From 85e37b01b213d67e4057cb2312b94cb55741392f Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sat, 22 Dec 2007 14:39:47 +0000 Subject: [PATCH] * simplify editing logic of math macros by making it purely dynamic git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22260 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/MathMacro.cpp | 19 ++++--------------- src/mathed/MathMacro.h | 2 -- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 9468bc10a9..8741dfc705 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -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())) diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h index 54ca2de8c6..c5faebc9bf 100644 --- a/src/mathed/MathMacro.h +++ b/src/mathed/MathMacro.h @@ -139,8 +139,6 @@ protected: /// including the optional ones (even if it can be empty here) void attachArguments(std::vector const & args, size_t arity, int optionals); /// - bool editing(BufferView * bv) { return editing_[bv]; } - /// MacroData const * macro() { return macro_; } private: -- 2.39.2