mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-02 14:01:10 +00:00
Redefine the speed-up "Wide" patch to draw proper boxes
in available space instead of line pairs. * rowpainter.C (paintPar): change background rectangle * insets/insettext.C (InsetText::draw): (InsetText::drawSelection): simplify rectangle drawing * insets/insettext.h: dump Tall() * insets/insetcollapsable.C (InsetCollapsable::metrics): subtract button from available space in case of inlined inset git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14161 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f032e0af1a
commit
4cb9cd44ec
@ -140,6 +140,9 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
InsetText::metrics(mi, textdim_);
|
InsetText::metrics(mi, textdim_);
|
||||||
openinlined_ = textdim_.wid + 2 * dim.wid <= mi.base.textwidth;
|
openinlined_ = textdim_.wid + 2 * dim.wid <= mi.base.textwidth;
|
||||||
if (openinlined_) {
|
if (openinlined_) {
|
||||||
|
// Correct for button width, and re-fit
|
||||||
|
mi.base.textwidth -= dim.wid;
|
||||||
|
InsetText::metrics(mi, textdim_);
|
||||||
dim.wid += textdim_.wid;
|
dim.wid += textdim_.wid;
|
||||||
dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des);
|
dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des);
|
||||||
dim.asc = textdim_.asc;
|
dim.asc = textdim_.asc;
|
||||||
|
@ -207,13 +207,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
|||||||
int const w = text_.width() + 2 * border_;
|
int const w = text_.width() + 2 * border_;
|
||||||
int const a = text_.ascent() + border_;
|
int const a = text_.ascent() + border_;
|
||||||
int const h = a + text_.descent() + border_;
|
int const h = a + text_.descent() + border_;
|
||||||
int const ww = pi.base.bv->workWidth();
|
pi.pain.rectangle(x, y - a, (Wide() ? text_.maxwidth_ : w), h,
|
||||||
if (w > ww - 40 || Wide()) {
|
frameColor());
|
||||||
pi.pain.line(0, y - a, ww, y - a, frameColor());
|
|
||||||
pi.pain.line(0, y - a + h, ww, y - a + h, frameColor());
|
|
||||||
} else {
|
|
||||||
pi.pain.rectangle(x, y - a, w, h, frameColor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,12 +218,7 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
|
|||||||
int const w = text_.width() + 2 * border_;
|
int const w = text_.width() + 2 * border_;
|
||||||
int const a = text_.ascent() + border_;
|
int const a = text_.ascent() + border_;
|
||||||
int const h = a + text_.descent() + border_;
|
int const h = a + text_.descent() + border_;
|
||||||
int const ww = pi.base.bv->workWidth();
|
pi.pain.fillRectangle(x, y - a, (Wide() ? text_.maxwidth_ : w), h,
|
||||||
if (Wide())
|
|
||||||
pi.pain.fillRectangle(0, y - a, ww, h,
|
|
||||||
backgroundColor());
|
|
||||||
else
|
|
||||||
pi.pain.fillRectangle(x, y - a, w, h,
|
|
||||||
backgroundColor());
|
backgroundColor());
|
||||||
text_.drawSelection(pi, x, y);
|
text_.drawSelection(pi, x, y);
|
||||||
}
|
}
|
||||||
@ -258,12 +248,6 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool const InsetText::Tall() const
|
|
||||||
{
|
|
||||||
return text_.ascent() + text_.descent() > 2 * defaultRowHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetText::forceParagraphsToDefault(LCursor & cur)
|
void InsetText::forceParagraphsToDefault(LCursor & cur)
|
||||||
{
|
{
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer().params();
|
||||||
|
@ -142,8 +142,6 @@ public:
|
|||||||
///
|
///
|
||||||
bool & Wide() const { return wide_inset_; }
|
bool & Wide() const { return wide_inset_; }
|
||||||
///
|
///
|
||||||
bool const Tall() const;
|
|
||||||
///
|
|
||||||
void forceParagraphsToDefault(LCursor & cur);
|
void forceParagraphsToDefault(LCursor & cur);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -819,8 +819,7 @@ void paintPar
|
|||||||
if (in) {
|
if (in) {
|
||||||
InsetText const * const t = in->asTextInset();
|
InsetText const * const t = in->asTextInset();
|
||||||
if (t)
|
if (t)
|
||||||
t->Wide() = in_inset_alone_on_row &&
|
t->Wide() = in_inset_alone_on_row;
|
||||||
t->Tall();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,8 +837,8 @@ void paintPar
|
|||||||
// (if paragraph background was not cleared)
|
// (if paragraph background was not cleared)
|
||||||
if (!repaintAll &&
|
if (!repaintAll &&
|
||||||
(!in_inset_alone_on_row || row_has_changed)) {
|
(!in_inset_alone_on_row || row_has_changed)) {
|
||||||
pi.pain.fillRectangle(( rowno ? 0 : x - 10 ), y - rit->ascent(),
|
pi.pain.fillRectangle(x, y - rit->ascent(),
|
||||||
pi.base.bv->workWidth(), rit->height(),
|
text.maxwidth_, rit->height(),
|
||||||
text.backgroundColor());
|
text.backgroundColor());
|
||||||
// If outer row has changed, force nested
|
// If outer row has changed, force nested
|
||||||
// insets to repaint completely
|
// insets to repaint completely
|
||||||
|
Loading…
Reference in New Issue
Block a user