]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Circumvent odd stmary font metrics (part of #9990).
[lyx.git] / src / insets / InsetBranch.cpp
index 2676d93338855498c7ae18d5f2ef114068537119..7d2d4d51cb36adb9529326219c0d75bbad96c9c4 100644 (file)
@@ -84,6 +84,8 @@ docstring InsetBranch::toolTip(BufferView const & bv, int, int) const
 
 docstring const InsetBranch::buttonLabel(BufferView const & bv) const
 {
+       static char_type const tick = 0x2714; // ✔ U+2714 HEAVY CHECK MARK
+       static char_type const cross = 0x2716; // ✖ U+2716 HEAVY MULTIPLICATION X
        docstring s = _("Branch: ") + params_.branch;
        Buffer const & realbuffer = *buffer().masterBuffer();
        BranchList const & branchlist = realbuffer.params().branchlist();
@@ -103,9 +105,9 @@ docstring const InsetBranch::buttonLabel(BufferView const & bv) const
        }
        bool const master_selected = isBranchSelected();
        bool const child_selected = isBranchSelected(true);
-       docstring symb = docstring(1, char_type(master_selected ? 0x2714 : 0x2716));
+       docstring symb = docstring(1, master_selected ? tick : cross);
        if (inchild && master_selected != child_selected)
-               symb += char_type(child_selected ? 0x2714 : 0x2716);
+               symb += child_selected ? tick : cross;
        if (decoration() == InsetLayout::CLASSIC)
                return symb + (isOpen(bv) ? s : getNewLabel(s));
        else
@@ -132,7 +134,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
                InsetBranchParams params;
                InsetBranch::string2params(to_utf8(cmd.argument()), params);
 
-               cur.recordUndoInset(ATOMIC_UNDO, this);
+               cur.recordUndoInset(this);
                params_.branch = params.branch;
                // what we really want here is a TOC update, but that means
                // a full buffer update
@@ -162,7 +164,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
                        // An option would be to check if the master is hidden.
                        // If it is, unhide.
                        if (!master)
-                               buffer().undo().recordUndoFullDocument(cur);
+                               buffer().undo().recordUndoBufferParams(cur);
                        else
                                // at least issue a warning for now (ugly, but better than dataloss).
                                frontend::Alert::warning(_("Branch state changes in master document"),
@@ -299,10 +301,11 @@ void InsetBranch::toString(odocstream & os) const
 }
 
 
-void InsetBranch::forToc(docstring & os, size_t maxlen) const
+void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
+                                                         bool const shorten) const
 {
        if (isBranchSelected())
-               InsetCollapsable::forToc(os, maxlen);
+               InsetCollapsable::forOutliner(os, maxlen, shorten);
 }
 
 
@@ -348,18 +351,23 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
 }
 
 
-void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
+                                                  UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
-
-       Toc & toc = buffer().tocBackend().toc("branch");
-       docstring str = params_.branch + ": ";
-       text().forToc(str, TOC_ENTRY_LENGTH);
-       toc.push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
+       
+       docstring tooltip;
+       text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
+       docstring str = params_.branch + ": " + tooltip;
+       tooltip = support::wrapParas(tooltip, 0, 60, 2);
+       
+       shared_ptr<Toc> toc = buffer().tocBackend().toc("branch");
+       toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
+       
        // Proceed with the rest of the inset.
        bool const doing_output = output_active && isBranchSelected();
-       InsetCollapsable::addToToc(cpit, doing_output);
+       InsetCollapsable::addToToc(cpit, doing_output, utype);
 }