mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
Revert "Use new display() values to remove some inset hardcoding."
This is a work in progress that committed by mistake.
This reverts commit b28ec44476
.
This commit is contained in:
parent
23dbacb636
commit
ad29b0067f
@ -557,13 +557,19 @@ LyXAlignment TextMetrics::getAlign(Paragraph const & par, Row const & row) const
|
|||||||
|
|
||||||
// Display-style insets should always be on a centered row
|
// Display-style insets should always be on a centered row
|
||||||
if (Inset const * inset = par.getInset(row.pos())) {
|
if (Inset const * inset = par.getInset(row.pos())) {
|
||||||
if (inset->display() & Inset::Display) {
|
switch (inset->display()) {
|
||||||
if (inset->display() & Inset::AlignLeft)
|
case Inset::AlignLeft:
|
||||||
align = LYX_ALIGN_BLOCK;
|
align = LYX_ALIGN_BLOCK;
|
||||||
else if (inset->display() & Inset::AlignRight)
|
break;
|
||||||
align = LYX_ALIGN_RIGHT;
|
case Inset::AlignCenter:
|
||||||
else
|
align = LYX_ALIGN_CENTER;
|
||||||
align = LYX_ALIGN_CENTER;
|
break;
|
||||||
|
case Inset::Inline:
|
||||||
|
// unchanged (use align)
|
||||||
|
break;
|
||||||
|
case Inset::AlignRight:
|
||||||
|
align = LYX_ALIGN_RIGHT;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,12 +920,15 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle some situations that abruptly terminate the row
|
// Handle some situations that abruptly terminate the row
|
||||||
// - Before an inset with BreakBefore
|
// - A newline inset
|
||||||
// - After an inset with BreakAfter
|
// - Before a display inset
|
||||||
Inset const * prevInset = !row.empty() ? row.back().inset : 0;
|
// - After a display inset
|
||||||
Inset const * nextInset = (i + 1 < end) ? par.getInset(i + 1) : 0;
|
Inset const * inset = 0;
|
||||||
if ((nextInset && nextInset->display() & Inset::BreakBefore)
|
if (par.isNewline(i) || par.isEnvSeparator(i)
|
||||||
|| (prevInset && prevInset->display() & Inset::BreakAfter)) {
|
|| (i + 1 < end && (inset = par.getInset(i + 1))
|
||||||
|
&& inset->display())
|
||||||
|
|| (!row.empty() && row.back().inset
|
||||||
|
&& row.back().inset->display())) {
|
||||||
row.flushed(true);
|
row.flushed(true);
|
||||||
need_new_row = par.isNewline(i);
|
need_new_row = par.isNewline(i);
|
||||||
++i;
|
++i;
|
||||||
@ -1744,7 +1753,7 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
|
|||||||
// display style insets are always centered, omit indentation
|
// display style insets are always centered, omit indentation
|
||||||
&& !(!par.empty()
|
&& !(!par.empty()
|
||||||
&& par.isInset(pos)
|
&& par.isInset(pos)
|
||||||
&& par.getInset(pos)->display() & Inset::Display)
|
&& par.getInset(pos)->display())
|
||||||
&& (!(tclass.isDefaultLayout(par.layout())
|
&& (!(tclass.isDefaultLayout(par.layout())
|
||||||
|| tclass.isPlainLayout(par.layout()))
|
|| tclass.isPlainLayout(par.layout()))
|
||||||
|| buffer.params().paragraph_separation
|
|| buffer.params().paragraph_separation
|
||||||
|
@ -467,26 +467,14 @@ public:
|
|||||||
/// does this inset try to use all available space (like \\hfill does)?
|
/// does this inset try to use all available space (like \\hfill does)?
|
||||||
virtual bool isHfill() const { return false; }
|
virtual bool isHfill() const { return false; }
|
||||||
|
|
||||||
// Describe how the inset should be typeset
|
|
||||||
enum DisplayType {
|
enum DisplayType {
|
||||||
Inline = 0,
|
Inline = 0,
|
||||||
// break row before this inset
|
AlignLeft,
|
||||||
BreakBefore = 1,
|
AlignCenter,
|
||||||
// break row after this inset
|
AlignRight
|
||||||
BreakAfter = 2,
|
|
||||||
// optionally break row after this inset (not used yet)
|
|
||||||
CanBreakAfter = 4,
|
|
||||||
// specify an alignment (left, right) for a display inset (default is center)
|
|
||||||
AlignLeft = 8,
|
|
||||||
AlignRight = 16,
|
|
||||||
// do not allow cursor to go at the end of the row before
|
|
||||||
// a display inset (not used yet)
|
|
||||||
NoBoundary = 32,
|
|
||||||
// A display inset breaks row at both ends
|
|
||||||
Display = BreakBefore | BreakAfter
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// How should this inset be typeset?
|
/// should we have a non-filled line before this inset?
|
||||||
virtual DisplayType display() const { return Inline; }
|
virtual DisplayType display() const { return Inline; }
|
||||||
/// indentation before this inset (only needed for displayed hull insets with fleqn option)
|
/// indentation before this inset (only needed for displayed hull insets with fleqn option)
|
||||||
virtual int indent(BufferView const &) const { return 0; }
|
virtual int indent(BufferView const &) const { return 0; }
|
||||||
@ -646,21 +634,6 @@ protected:
|
|||||||
Buffer * buffer_;
|
Buffer * buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Inset::DisplayType operator|(Inset::DisplayType const d1,
|
|
||||||
Inset::DisplayType const d2)
|
|
||||||
{
|
|
||||||
return static_cast<Inset::DisplayType>(int(d1) | int(d2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Inset::DisplayType operator&(Inset::DisplayType const d1,
|
|
||||||
Inset::DisplayType const d2)
|
|
||||||
{
|
|
||||||
return static_cast<Inset::DisplayType>(int(d1) & int(d2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return BIBTEX_CODE; }
|
InsetCode lyxCode() const { return BIBTEX_CODE; }
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
void latex(otexstream &, OutputParams const &) const;
|
void latex(otexstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
|
@ -111,6 +111,8 @@ public:
|
|||||||
///
|
///
|
||||||
void metrics(MetricsInfo &, Dimension &) const;
|
void metrics(MetricsInfo &, Dimension &) const;
|
||||||
///
|
///
|
||||||
|
DisplayType display() const { return Inline; }
|
||||||
|
///
|
||||||
ColorCode backgroundColor(PainterInfo const &) const;
|
ColorCode backgroundColor(PainterInfo const &) const;
|
||||||
///
|
///
|
||||||
LyXAlignment contentAlignment() const;
|
LyXAlignment contentAlignment() const;
|
||||||
|
@ -38,7 +38,7 @@ private:
|
|||||||
///
|
///
|
||||||
void write(std::ostream & os) const;
|
void write(std::ostream & os) const;
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
bool neverIndent() const { return true; }
|
bool neverIndent() const { return true; }
|
||||||
///
|
///
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return FLOAT_LIST_CODE; }
|
InsetCode lyxCode() const { return FLOAT_LIST_CODE; }
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
void write(std::ostream &) const;
|
void write(std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -1159,7 +1159,7 @@ string InsetInclude::contextMenuName() const
|
|||||||
|
|
||||||
Inset::DisplayType InsetInclude::display() const
|
Inset::DisplayType InsetInclude::display() const
|
||||||
{
|
{
|
||||||
return type(params()) == INPUT ? Inline : Display;
|
return type(params()) == INPUT ? Inline : AlignCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
///
|
///
|
||||||
bool hasSettings() const;
|
bool hasSettings() const;
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name Static public methods obligated for InsetCommand derived classes
|
/// \name Static public methods obligated for InsetCommand derived classes
|
||||||
|
@ -68,7 +68,7 @@ InsetListings::~InsetListings()
|
|||||||
|
|
||||||
Inset::DisplayType InsetListings::display() const
|
Inset::DisplayType InsetListings::display() const
|
||||||
{
|
{
|
||||||
return params().isInline() || params().isFloat() ? Inline : Display | AlignLeft;
|
return params().isInline() || params().isFloat() ? Inline : AlignLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +47,6 @@ public:
|
|||||||
InsetNewline(InsetNewlineParams par) : Inset(0)
|
InsetNewline(InsetNewlineParams par) : Inset(0)
|
||||||
{ params_.kind = par.kind; }
|
{ params_.kind = par.kind; }
|
||||||
///
|
///
|
||||||
DisplayType display() const { return BreakAfter | NoBoundary; }
|
|
||||||
///
|
|
||||||
static void string2params(std::string const &, InsetNewlineParams &);
|
static void string2params(std::string const &, InsetNewlineParams &);
|
||||||
///
|
///
|
||||||
static std::string params2string(InsetNewlineParams const &);
|
static std::string params2string(InsetNewlineParams const &);
|
||||||
|
@ -76,7 +76,7 @@ private:
|
|||||||
///
|
///
|
||||||
void write(std::ostream & os) const;
|
void write(std::ostream & os) const;
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
docstring insetLabel() const;
|
docstring insetLabel() const;
|
||||||
///
|
///
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
///
|
///
|
||||||
bool hasSettings() const { return true; }
|
bool hasSettings() const { return true; }
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
void latex(otexstream &, OutputParams const &) const;
|
void latex(otexstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
|
@ -116,6 +116,12 @@ docstring InsetNote::layoutName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Inset::DisplayType InsetNote::display() const
|
||||||
|
{
|
||||||
|
return Inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetNote::write(ostream & os) const
|
void InsetNote::write(ostream & os) const
|
||||||
{
|
{
|
||||||
params_.write(os);
|
params_.write(os);
|
||||||
|
@ -61,6 +61,8 @@ private:
|
|||||||
InsetCode lyxCode() const { return NOTE_CODE; }
|
InsetCode lyxCode() const { return NOTE_CODE; }
|
||||||
///
|
///
|
||||||
docstring layoutName() const;
|
docstring layoutName() const;
|
||||||
|
///
|
||||||
|
DisplayType display() const;
|
||||||
/** returns false if, when outputing LaTeX, font changes should
|
/** returns false if, when outputing LaTeX, font changes should
|
||||||
be closed before generating this inset. This is needed for
|
be closed before generating this inset. This is needed for
|
||||||
insets that may contain several paragraphs */
|
insets that may contain several paragraphs */
|
||||||
|
@ -49,12 +49,14 @@ public:
|
|||||||
docstring toolTip(BufferView const &, int, int) const
|
docstring toolTip(BufferView const &, int, int) const
|
||||||
{ return tooltip_; }
|
{ return tooltip_; }
|
||||||
///
|
///
|
||||||
docstring getTOCString() const;
|
docstring getTOCString() const;
|
||||||
///
|
///
|
||||||
bool hasSettings() const { return true; }
|
bool hasSettings() const { return true; }
|
||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return REF_CODE; }
|
InsetCode lyxCode() const { return REF_CODE; }
|
||||||
///
|
///
|
||||||
|
DisplayType display() const { return Inline; }
|
||||||
|
///
|
||||||
void latex(otexstream &, OutputParams const &) const;
|
void latex(otexstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
int plaintext(odocstringstream & ods, OutputParams const & op,
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
||||||
|
@ -151,6 +151,12 @@ docstring InsetScript::layoutName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Inset::DisplayType InsetScript::display() const
|
||||||
|
{
|
||||||
|
return Inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
int const shift = params_.shift(mi.base.font);
|
int const shift = params_.shift(mi.base.font);
|
||||||
|
@ -67,6 +67,8 @@ public:
|
|||||||
///
|
///
|
||||||
docstring layoutName() const;
|
docstring layoutName() const;
|
||||||
///
|
///
|
||||||
|
DisplayType display() const;
|
||||||
|
///
|
||||||
void metrics(MetricsInfo &, Dimension &) const;
|
void metrics(MetricsInfo &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
|
@ -64,8 +64,6 @@ public:
|
|||||||
// remove warning
|
// remove warning
|
||||||
return docstring();
|
return docstring();
|
||||||
}
|
}
|
||||||
///
|
|
||||||
DisplayType display() const { return BreakAfter | NoBoundary; }
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
InsetSeparatorParams params() const { return params_; }
|
InsetSeparatorParams params() const { return params_; }
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
///
|
///
|
||||||
docstring layoutName() const;
|
docstring layoutName() const;
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
virtual void validate(LaTeXFeatures &) const;
|
virtual void validate(LaTeXFeatures &) const;
|
||||||
///
|
///
|
||||||
|
@ -5396,13 +5396,13 @@ Inset::DisplayType InsetTabular::display() const
|
|||||||
if (tabular.is_long_tabular) {
|
if (tabular.is_long_tabular) {
|
||||||
switch (tabular.longtabular_alignment) {
|
switch (tabular.longtabular_alignment) {
|
||||||
case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
|
case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
|
||||||
return Display | AlignLeft;
|
return AlignLeft;
|
||||||
case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
|
case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
|
||||||
return Display;
|
return AlignCenter;
|
||||||
case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
|
case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
|
||||||
return Display | AlignRight;
|
return AlignRight;
|
||||||
default:
|
default:
|
||||||
return Display;
|
return AlignCenter;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return Inline;
|
return Inline;
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
///
|
///
|
||||||
void write(std::ostream & os) const;
|
void write(std::ostream & os) const;
|
||||||
///
|
///
|
||||||
DisplayType display() const { return Display; }
|
DisplayType display() const { return AlignCenter; }
|
||||||
///
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
|
@ -540,7 +540,7 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
// insert a gap in front of the formula
|
// insert a gap in front of the formula
|
||||||
// value was hardcoded to 1 pixel
|
// value was hardcoded to 1 pixel
|
||||||
dim.wid += mi.base.bv->zoomedPixels(1) ;
|
dim.wid += mi.base.bv->zoomedPixels(1) ;
|
||||||
if (display() != Inline) {
|
if (display()) {
|
||||||
dim.asc += display_margin;
|
dim.asc += display_margin;
|
||||||
dim.des += display_margin;
|
dim.des += display_margin;
|
||||||
}
|
}
|
||||||
@ -549,13 +549,13 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Changer dummy1 = mi.base.changeFontSet(standardFont());
|
Changer dummy1 = mi.base.changeFontSet(standardFont());
|
||||||
Changer dummy2 = mi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
|
Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY
|
||||||
: LM_ST_TEXT);
|
: LM_ST_TEXT);
|
||||||
|
|
||||||
// let the cells adjust themselves
|
// let the cells adjust themselves
|
||||||
InsetMathGrid::metrics(mi, dim);
|
InsetMathGrid::metrics(mi, dim);
|
||||||
|
|
||||||
if (display() != Inline) {
|
if (display()) {
|
||||||
dim.asc += display_margin;
|
dim.asc += display_margin;
|
||||||
dim.des += display_margin;
|
dim.des += display_margin;
|
||||||
}
|
}
|
||||||
@ -653,7 +653,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
|||||||
Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
|
Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
|
||||||
: Changer();
|
: Changer();
|
||||||
Changer dummy1 = pi.base.changeFontSet(standardFont());
|
Changer dummy1 = pi.base.changeFontSet(standardFont());
|
||||||
Changer dummy2 = pi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
|
Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY
|
||||||
: LM_ST_TEXT);
|
: LM_ST_TEXT);
|
||||||
|
|
||||||
int xmath = x;
|
int xmath = x;
|
||||||
@ -695,7 +695,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
if (display() != Inline) {
|
if (display()) {
|
||||||
InsetMathGrid::metricsT(mi, dim);
|
InsetMathGrid::metricsT(mi, dim);
|
||||||
} else {
|
} else {
|
||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
@ -711,7 +711,7 @@ void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
|||||||
|
|
||||||
void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
|
void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
|
||||||
{
|
{
|
||||||
if (display() != Inline) {
|
if (display()) {
|
||||||
InsetMathGrid::drawT(pain, x, y);
|
InsetMathGrid::drawT(pain, x, y);
|
||||||
} else {
|
} else {
|
||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
@ -1022,12 +1022,12 @@ Inset::DisplayType InsetMathHull::display() const
|
|||||||
case hullMultline:
|
case hullMultline:
|
||||||
case hullGather:
|
case hullGather:
|
||||||
if (buffer().params().is_math_indent)
|
if (buffer().params().is_math_indent)
|
||||||
return Display | AlignLeft;
|
return AlignLeft;
|
||||||
else
|
else
|
||||||
return Display;
|
return AlignCenter;
|
||||||
}
|
}
|
||||||
// avoid warning
|
// avoid warning
|
||||||
return Display;
|
return AlignCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2324,7 +2324,7 @@ int InsetMathHull::plaintext(odocstringstream & os,
|
|||||||
OutputParams const & op, size_t max_length) const
|
OutputParams const & op, size_t max_length) const
|
||||||
{
|
{
|
||||||
// Try enabling this now that there is a flag as requested at #2275.
|
// Try enabling this now that there is a flag as requested at #2275.
|
||||||
if (buffer().isExporting() && display() != Inline) {
|
if (buffer().isExporting() && display()) {
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
TextMetricsInfo mi;
|
TextMetricsInfo mi;
|
||||||
metricsT(mi, dim);
|
metricsT(mi, dim);
|
||||||
|
Loading…
Reference in New Issue
Block a user