mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
* 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
This commit is contained in:
parent
9ac321f28f
commit
85e37b01b2
@ -163,6 +163,9 @@ bool MathMacro::editMode(Cursor const & cur) const {
|
|||||||
|
|
||||||
void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) 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
|
// calculate new metrics according to display mode
|
||||||
if (displayMode_ == DISPLAY_INIT || displayMode_ == DISPLAY_INTERACTIVE_INIT) {
|
if (displayMode_ == DISPLAY_INIT || displayMode_ == DISPLAY_INTERACTIVE_INIT) {
|
||||||
mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim);
|
mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim);
|
||||||
@ -246,20 +249,6 @@ void MathMacro::updateRepresentation(Cursor const * bvCur)
|
|||||||
if (displayMode_ != DISPLAY_NORMAL)
|
if (displayMode_ != DISPLAY_NORMAL)
|
||||||
return;
|
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?
|
// macro changed?
|
||||||
if (needsUpdate_) {
|
if (needsUpdate_) {
|
||||||
needsUpdate_ = false;
|
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);
|
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());
|
idx_type curIdx = cursorIdx(pi.base.bv->cursor());
|
||||||
if (previousCurIdx_[pi.base.bv] != curIdx
|
if (previousCurIdx_[pi.base.bv] != curIdx
|
||||||
|| editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))
|
|| editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))
|
||||||
|
@ -139,8 +139,6 @@ protected:
|
|||||||
/// including the optional ones (even if it can be empty here)
|
/// including the optional ones (even if it can be empty here)
|
||||||
void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
|
void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
|
||||||
///
|
///
|
||||||
bool editing(BufferView * bv) { return editing_[bv]; }
|
|
||||||
///
|
|
||||||
MacroData const * macro() { return macro_; }
|
MacroData const * macro() { return macro_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user