mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Get rid of use_preview_ in various insets
This concerns InsetPreview, InsetIPA and InsetMathHull. Caching such a value is bad when opening the same buffer in two views. In this case, it is not necessary to remember use_preview_ at all, actually. Also remove private member dim_ which is not used and remove some trailing whitespace. Fixes bugs #9085 abd #9957.
This commit is contained in:
parent
a3b19c60a7
commit
2804011957
@ -36,7 +36,7 @@ namespace lyx {
|
|||||||
|
|
||||||
InsetIPA::InsetIPA(Buffer * buf)
|
InsetIPA::InsetIPA(Buffer * buf)
|
||||||
: InsetText(buf),
|
: InsetText(buf),
|
||||||
preview_(new RenderPreview(this)), use_preview_(true)
|
preview_(new RenderPreview(this))
|
||||||
{
|
{
|
||||||
setDrawFrame(true);
|
setDrawFrame(true);
|
||||||
setFrameColor(Color_insetframe);
|
setFrameColor(Color_insetframe);
|
||||||
@ -150,9 +150,7 @@ void InsetIPA::reloadPreview(DocIterator const & pos) const
|
|||||||
|
|
||||||
void InsetIPA::draw(PainterInfo & pi, int x, int y) const
|
void InsetIPA::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
use_preview_ = previewState(pi.base.bv);
|
if (previewState(pi.base.bv)) {
|
||||||
|
|
||||||
if (use_preview_) {
|
|
||||||
preview_->draw(pi, x + TEXT_TO_INSET_OFFSET, y);
|
preview_->draw(pi, x + TEXT_TO_INSET_OFFSET, y);
|
||||||
setPosCache(pi, x, y);
|
setPosCache(pi, x, y);
|
||||||
return;
|
return;
|
||||||
@ -170,7 +168,7 @@ void InsetIPA::edit(Cursor & cur, bool front, EntryDirection entry_from)
|
|||||||
|
|
||||||
Inset * InsetIPA::editXY(Cursor & cur, int x, int y)
|
Inset * InsetIPA::editXY(Cursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
if (use_preview_) {
|
if (previewState(&cur.bv())) {
|
||||||
edit(cur, true, ENTRY_DIRECTION_IGNORE);
|
edit(cur, true, ENTRY_DIRECTION_IGNORE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -191,7 +189,6 @@ void InsetIPA::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
dim.asc += TEXT_TO_INSET_OFFSET;
|
dim.asc += TEXT_TO_INSET_OFFSET;
|
||||||
dim.des += TEXT_TO_INSET_OFFSET;
|
dim.des += TEXT_TO_INSET_OFFSET;
|
||||||
dim.wid += TEXT_TO_INSET_OFFSET;
|
dim.wid += TEXT_TO_INSET_OFFSET;
|
||||||
dim_ = dim;
|
|
||||||
dim.wid += TEXT_TO_INSET_OFFSET;
|
dim.wid += TEXT_TO_INSET_OFFSET;
|
||||||
// insert a one pixel gap
|
// insert a one pixel gap
|
||||||
dim.wid += 1;
|
dim.wid += 1;
|
||||||
|
@ -94,12 +94,6 @@ protected:
|
|||||||
|
|
||||||
///
|
///
|
||||||
boost::scoped_ptr<RenderPreview> preview_;
|
boost::scoped_ptr<RenderPreview> preview_;
|
||||||
///
|
|
||||||
mutable bool use_preview_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
mutable Dimension dim_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,16 +34,15 @@ using namespace std;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
InsetPreview::InsetPreview(Buffer * buf)
|
InsetPreview::InsetPreview(Buffer * buf)
|
||||||
: InsetText(buf),
|
: InsetText(buf), preview_(new RenderPreview(this))
|
||||||
preview_(new RenderPreview(this)), use_preview_(true)
|
|
||||||
{
|
{
|
||||||
setDrawFrame(true);
|
setDrawFrame(true);
|
||||||
setFrameColor(Color_previewframe);
|
setFrameColor(Color_previewframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetPreview::~InsetPreview()
|
InsetPreview::~InsetPreview()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetPreview::preparePreview(DocIterator const & pos) const
|
void InsetPreview::preparePreview(DocIterator const & pos) const
|
||||||
{
|
{
|
||||||
TexRow texrow;
|
TexRow texrow;
|
||||||
odocstringstream str;
|
odocstringstream str;
|
||||||
@ -137,15 +136,12 @@ void InsetPreview::reloadPreview(DocIterator const & pos) const
|
|||||||
|
|
||||||
void InsetPreview::draw(PainterInfo & pi, int x, int y) const
|
void InsetPreview::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
use_preview_ = previewState(pi.base.bv);
|
if (previewState(pi.base.bv)) {
|
||||||
|
|
||||||
if (use_preview_) {
|
|
||||||
// one pixel gap in front
|
// one pixel gap in front
|
||||||
preview_->draw(pi, x + 1 + TEXT_TO_INSET_OFFSET, y);
|
preview_->draw(pi, x + 1 + TEXT_TO_INSET_OFFSET, y);
|
||||||
setPosCache(pi, x, y);
|
setPosCache(pi, x, y);
|
||||||
return;
|
} else
|
||||||
}
|
InsetText::draw(pi, x, y);
|
||||||
InsetText::draw(pi, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,7 +154,7 @@ void InsetPreview::edit(Cursor & cur, bool front, EntryDirection entry_from)
|
|||||||
|
|
||||||
Inset * InsetPreview::editXY(Cursor & cur, int x, int y)
|
Inset * InsetPreview::editXY(Cursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
if (use_preview_) {
|
if (previewState(&cur.bv())) {
|
||||||
edit(cur, true, ENTRY_DIRECTION_IGNORE);
|
edit(cur, true, ENTRY_DIRECTION_IGNORE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -172,14 +168,13 @@ void InsetPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
if (previewState(mi.base.bv)) {
|
if (previewState(mi.base.bv)) {
|
||||||
preview_->metrics(mi, dim);
|
preview_->metrics(mi, dim);
|
||||||
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
||||||
|
|
||||||
dim.wid = max(dim.wid, 4);
|
dim.wid = max(dim.wid, 4);
|
||||||
dim.asc = max(dim.asc, 4);
|
dim.asc = max(dim.asc, 4);
|
||||||
|
|
||||||
dim.asc += TEXT_TO_INSET_OFFSET;
|
dim.asc += TEXT_TO_INSET_OFFSET;
|
||||||
dim.des += TEXT_TO_INSET_OFFSET;
|
dim.des += TEXT_TO_INSET_OFFSET;
|
||||||
dim.wid += TEXT_TO_INSET_OFFSET;
|
dim.wid += TEXT_TO_INSET_OFFSET;
|
||||||
dim_ = dim;
|
|
||||||
dim.wid += TEXT_TO_INSET_OFFSET;
|
dim.wid += TEXT_TO_INSET_OFFSET;
|
||||||
// insert a one pixel gap
|
// insert a one pixel gap
|
||||||
dim.wid += 1;
|
dim.wid += 1;
|
||||||
|
@ -81,12 +81,7 @@ protected:
|
|||||||
|
|
||||||
///
|
///
|
||||||
boost::scoped_ptr<RenderPreview> preview_;
|
boost::scoped_ptr<RenderPreview> preview_;
|
||||||
///
|
|
||||||
mutable bool use_preview_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
mutable Dimension dim_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ static InsetLabel * dummy_pointer = 0;
|
|||||||
InsetMathHull::InsetMathHull(Buffer * buf)
|
InsetMathHull::InsetMathHull(Buffer * buf)
|
||||||
: InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NUMBER),
|
: InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NUMBER),
|
||||||
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
|
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
|
||||||
preview_(new RenderPreview(this)), use_preview_(false)
|
preview_(new RenderPreview(this))
|
||||||
{
|
{
|
||||||
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
|
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
|
||||||
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
|
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
|
||||||
@ -173,7 +173,7 @@ InsetMathHull::InsetMathHull(Buffer * buf)
|
|||||||
InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
|
InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
|
||||||
: InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, NUMBER),
|
: InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, NUMBER),
|
||||||
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
|
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
|
||||||
preview_(new RenderPreview(this)), use_preview_(false)
|
preview_(new RenderPreview(this))
|
||||||
{
|
{
|
||||||
buffer_ = buf;
|
buffer_ = buf;
|
||||||
initMath();
|
initMath();
|
||||||
@ -316,7 +316,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
|
|||||||
|
|
||||||
Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
|
Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
if (use_preview_) {
|
if (previewState(&cur.bv())) {
|
||||||
edit(cur, true);
|
edit(cur, true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -526,7 +526,6 @@ void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
|
|||||||
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
BufferView const * const bv = pi.base.bv;
|
BufferView const * const bv = pi.base.bv;
|
||||||
use_preview_ = previewState(bv);
|
|
||||||
|
|
||||||
if (type_ == hullRegexp) {
|
if (type_ == hullRegexp) {
|
||||||
Dimension const dim = dimension(*bv);
|
Dimension const dim = dimension(*bv);
|
||||||
@ -534,7 +533,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
|||||||
dim.width() - 2, dim.height() - 2, Color_regexpframe);
|
dim.width() - 2, dim.height() - 2, Color_regexpframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_preview_) {
|
if (previewState(bv)) {
|
||||||
Dimension const dim = dimension(*bv);
|
Dimension const dim = dimension(*bv);
|
||||||
if (previewTooSmall(dim)) {
|
if (previewTooSmall(dim)) {
|
||||||
// we have an extra frame
|
// we have an extra frame
|
||||||
|
@ -256,8 +256,6 @@ private:
|
|||||||
///
|
///
|
||||||
boost::scoped_ptr<RenderPreview> preview_;
|
boost::scoped_ptr<RenderPreview> preview_;
|
||||||
///
|
///
|
||||||
mutable bool use_preview_;
|
|
||||||
///
|
|
||||||
DocIterator docit_;
|
DocIterator docit_;
|
||||||
///
|
///
|
||||||
typedef std::map<docstring, int> CounterMap;
|
typedef std::map<docstring, int> CounterMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user