mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 06:20:28 +00:00
* first support of multiple BufferViews for macros. There are still problems that somehow the dimension caching is mixed among them.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22245 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
69d224eb65
commit
dc9081c208
@ -52,13 +52,13 @@ public:
|
|||||||
void metrics(MetricsInfo & mi, Dimension & dim) const {
|
void metrics(MetricsInfo & mi, Dimension & dim) const {
|
||||||
mathMacro_.macro()->unlock();
|
mathMacro_.macro()->unlock();
|
||||||
mathMacro_.cell(idx_).metrics(mi, dim);
|
mathMacro_.cell(idx_).metrics(mi, dim);
|
||||||
if (!mathMacro_.editing() && !def_.empty())
|
if (!mathMacro_.editing(mi.base.bv) && !def_.empty())
|
||||||
def_.metrics(mi, dim);
|
def_.metrics(mi, dim);
|
||||||
mathMacro_.macro()->lock();
|
mathMacro_.macro()->lock();
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const {
|
void draw(PainterInfo & pi, int x, int y) const {
|
||||||
if (mathMacro_.editing()) {
|
if (mathMacro_.editing(pi.base.bv)) {
|
||||||
// The only way a ArgumentProxy can appear is in a cell of the
|
// The only way a ArgumentProxy can appear is in a cell of the
|
||||||
// MathMacro. Moreover the cells are only drawn in the DISPLAY_FOLDED
|
// MathMacro. Moreover the cells are only drawn in the DISPLAY_FOLDED
|
||||||
// mode and then, in the case of "editing_ == true" the monochrome
|
// mode and then, in the case of "editing_ == true" the monochrome
|
||||||
@ -101,9 +101,8 @@ private:
|
|||||||
|
|
||||||
MathMacro::MathMacro(docstring const & name)
|
MathMacro::MathMacro(docstring const & name)
|
||||||
: InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
|
: InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
|
||||||
attachedArgsNum_(0), previousCurIdx_(-1),
|
attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
|
||||||
optionals_(0), nextFoldMode_(true),
|
macro_(0), needsUpdate_(false)
|
||||||
macro_(0), editing_(false), needsUpdate_(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
macro_->unlock();
|
macro_->unlock();
|
||||||
|
|
||||||
// calculate dimension with label while editing
|
// calculate dimension with label while editing
|
||||||
if (editing_) {
|
if (editing_[mi.base.bv]) {
|
||||||
FontInfo font = mi.base.font;
|
FontInfo font = mi.base.font;
|
||||||
augmentFont(font, from_ascii("lyxtex"));
|
augmentFont(font, from_ascii("lyxtex"));
|
||||||
Dimension namedim;
|
Dimension namedim;
|
||||||
@ -206,7 +205,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
|
|
||||||
int MathMacro::kerning() const {
|
int MathMacro::kerning() const {
|
||||||
if (displayMode_ == DISPLAY_NORMAL && !editing_)
|
if (displayMode_ == DISPLAY_NORMAL)
|
||||||
return expanded_.kerning();
|
return expanded_.kerning();
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -231,9 +230,10 @@ void MathMacro::updateRepresentation(Cursor const * bvCur)
|
|||||||
{
|
{
|
||||||
// index of child where the cursor is (or -1 if none is edited)
|
// index of child where the cursor is (or -1 if none is edited)
|
||||||
int curIdx = -1;
|
int curIdx = -1;
|
||||||
if (bvCur)
|
if (bvCur) {
|
||||||
curIdx = cursorIdx(*bvCur);
|
curIdx = cursorIdx(*bvCur);
|
||||||
previousCurIdx_ = curIdx;
|
previousCurIdx_[&bvCur->bv()] = curIdx;
|
||||||
|
}
|
||||||
|
|
||||||
// known macro?
|
// known macro?
|
||||||
if (macro_ == 0)
|
if (macro_ == 0)
|
||||||
@ -247,14 +247,17 @@ void MathMacro::updateRepresentation(Cursor const * bvCur)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// set edit mode to draw box around if needed
|
// set edit mode to draw box around if needed
|
||||||
bool prevEditing = editing_;
|
bool prevEditing = false;
|
||||||
editing_ = false;
|
bool editing = false;
|
||||||
if (bvCur)
|
if (bvCur) {
|
||||||
editing_ = editMode(*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?
|
// editMode changed and we have to switch default value and hole of optional?
|
||||||
if (optionals_ > 0 && nargs() > 0 &&
|
if (optionals_ > 0 && nargs() > 0 &&
|
||||||
prevEditing != editing_)
|
prevEditing != editing)
|
||||||
needsUpdate_ = true;
|
needsUpdate_ = true;
|
||||||
|
|
||||||
// macro changed?
|
// macro changed?
|
||||||
@ -310,7 +313,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
|
|||||||
for (size_t i = 0; i < nargs(); ++i)
|
for (size_t i = 0; i < nargs(); ++i)
|
||||||
cell(i).setXY(*pi.base.bv, x, y);
|
cell(i).setXY(*pi.base.bv, x, y);
|
||||||
|
|
||||||
if (editing_) {
|
if (editing_[pi.base.bv]) {
|
||||||
// draw header and rectangle around
|
// draw header and rectangle around
|
||||||
FontInfo font = pi.base.font;
|
FontInfo font = pi.base.font;
|
||||||
augmentFont(font, from_ascii("lyxtex"));
|
augmentFont(font, from_ascii("lyxtex"));
|
||||||
@ -334,13 +337,14 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
|
|||||||
expanded_.cell(0).draw(pi, expx, expy);
|
expanded_.cell(0).draw(pi, expx, expy);
|
||||||
|
|
||||||
// draw frame while editing
|
// draw frame while editing
|
||||||
if (editing_)
|
if (editing_[pi.base.bv])
|
||||||
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?
|
||||||
idx_type curIdx = cursorIdx(pi.base.bv->cursor());
|
idx_type curIdx = cursorIdx(pi.base.bv->cursor());
|
||||||
if (previousCurIdx_ != curIdx || editing_ != editMode(pi.base.bv->cursor()))
|
if (previousCurIdx_[pi.base.bv] != curIdx
|
||||||
|
|| editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))
|
||||||
pi.base.bv->cursor().updateFlags(Update::Force);
|
pi.base.bv->cursor().updateFlags(Update::Force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
#include "MacroTable.h"
|
#include "MacroTable.h"
|
||||||
#include "MathData.h"
|
#include "MathData.h"
|
||||||
|
|
||||||
namespace lyx {
|
#include <map>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
/// This class contains the data for a macro.
|
/// This class contains the data for a macro.
|
||||||
class MathMacro : public InsetMathNest {
|
class MathMacro : public InsetMathNest {
|
||||||
@ -98,7 +99,6 @@ public:
|
|||||||
///
|
///
|
||||||
bool extraBraces() const { return displayMode_ == DISPLAY_NORMAL && arity() > 0; }
|
bool extraBraces() const { return displayMode_ == DISPLAY_NORMAL && arity() > 0; }
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
docstring name() const;
|
docstring name() const;
|
||||||
///
|
///
|
||||||
@ -139,7 +139,7 @@ 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() { return editing_; }
|
bool editing(BufferView * bv) { return editing_[bv]; }
|
||||||
///
|
///
|
||||||
MacroData const * macro() { return macro_; }
|
MacroData const * macro() { return macro_; }
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ private:
|
|||||||
/// number of arguments that were really attached
|
/// number of arguments that were really attached
|
||||||
size_t attachedArgsNum_;
|
size_t attachedArgsNum_;
|
||||||
/// cursor position during last draw
|
/// cursor position during last draw
|
||||||
idx_type previousCurIdx_;
|
mutable std::map<BufferView const *, idx_type> previousCurIdx_;
|
||||||
/// optional argument attached? (only in DISPLAY_NORMAL mode)
|
/// optional argument attached? (only in DISPLAY_NORMAL mode)
|
||||||
size_t optionals_;
|
size_t optionals_;
|
||||||
/// fold mode to be set in next metrics call?
|
/// fold mode to be set in next metrics call?
|
||||||
@ -172,7 +172,7 @@ private:
|
|||||||
/// this might invalidate after metrics was called
|
/// this might invalidate after metrics was called
|
||||||
MacroData const * macro_;
|
MacroData const * macro_;
|
||||||
///
|
///
|
||||||
bool editing_;
|
mutable std::map<BufferView const *, bool> editing_;
|
||||||
///
|
///
|
||||||
std::string requires_;
|
std::string requires_;
|
||||||
/// update macro representation
|
/// update macro representation
|
||||||
|
Loading…
Reference in New Issue
Block a user