]> git.lyx.org Git - lyx.git/commitdiff
* simplify editing logic of math macros by making it purely dynamic
authorStefan Schimanski <sts@lyx.org>
Sat, 22 Dec 2007 14:39:47 +0000 (14:39 +0000)
committerStefan Schimanski <sts@lyx.org>
Sat, 22 Dec 2007 14:39:47 +0000 (14:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22260 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/MathMacro.cpp
src/mathed/MathMacro.h

index 9468bc10a933f73e07913ae3569d119947efbc83..8741dfc705658875bbb8235791cbb272d4052c55 100644 (file)
@@ -163,6 +163,9 @@ bool MathMacro::editMode(Cursor const & cur) const {
 
 void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+       // set edit mode for which we will have calculated metrics
+       editing_[mi.base.bv] = editMode(mi.base.bv->cursor());
+
        // calculate new metrics according to display mode
        if (displayMode_ == DISPLAY_INIT || displayMode_ == DISPLAY_INTERACTIVE_INIT) {
                mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim);
@@ -246,20 +249,6 @@ void MathMacro::updateRepresentation(Cursor const * bvCur)
        if (displayMode_ != DISPLAY_NORMAL)
                return;
 
-       // set edit mode to draw box around if needed
-       bool prevEditing = false;
-       bool editing = false;
-       if (bvCur) {
-               prevEditing = editing_[&bvCur->bv()];
-               editing = editMode(*bvCur);
-               editing_[&bvCur->bv()] = editing;
-       }
-       
-       // editMode changed and we have to switch default value and hole of optional?
-       if (optionals_ > 0 && nargs() > 0 && 
-           prevEditing != editing)
-               needsUpdate_ = true;
-       
        // macro changed?
        if (needsUpdate_) {
                needsUpdate_ = false;
@@ -341,7 +330,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                        pi.pain.rectangle(x, y - dim.asc, dim.wid, dim.height(), Color_mathmacroframe);
        }
 
-       // another argument selected?
+       // another argument selected or edit mode changed?
        idx_type curIdx = cursorIdx(pi.base.bv->cursor());
        if (previousCurIdx_[pi.base.bv] != curIdx 
                        || editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))
index 54ca2de8c634b706418ed733c3436153a90cf551..c5faebc9bf163372531fb755647bb0fe33c1f68f 100644 (file)
@@ -139,8 +139,6 @@ protected:
        /// including the optional ones (even if it can be empty here)
        void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
        ///
-       bool editing(BufferView * bv) { return editing_[bv]; }
-       ///
        MacroData const * macro() { return macro_; }
 
 private: