Change LabelType Top_Environment to LabelType Above, and LabelType

Centered_Top_Environment to LabelType Centered.
This commit is contained in:
Richard Heck 2013-02-09 11:13:01 -05:00
parent 57d8b059e0
commit 32b0e8cbdb
7 changed files with 52 additions and 46 deletions

View File

@ -4443,8 +4443,8 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
par.params().labelString(docstring());
break;
case LABEL_TOP_ENVIRONMENT:
case LABEL_CENTERED_TOP_ENVIRONMENT:
case LABEL_ABOVE:
case LABEL_CENTERED:
case LABEL_STATIC: {
docstring const & lcounter = layout.counter;
if (!lcounter.empty()) {

View File

@ -684,8 +684,8 @@ void Layout::readLabelType(Lexer & lex)
enum {
LA_NO_LABEL = 1,
LA_MANUAL,
LA_TOP_ENVIRONMENT,
LA_CENTERED_TOP_ENVIRONMENT,
LA_ABOVE,
LA_CENTERED,
LA_STATIC,
LA_SENSITIVE,
LA_ENUMERATE,
@ -695,15 +695,15 @@ void Layout::readLabelType(Lexer & lex)
LexerKeyword labelTypeTags[] = {
{ "bibliography", LA_BIBLIO },
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
{ "enumerate", LA_ENUMERATE },
{ "itemize", LA_ITEMIZE },
{ "manual", LA_MANUAL },
{ "no_label", LA_NO_LABEL },
{ "sensitive", LA_SENSITIVE },
{ "static", LA_STATIC },
{ "top_environment", LA_TOP_ENVIRONMENT }
{ "above", LA_ABOVE },
{ "bibliography", LA_BIBLIO },
{ "centered", LA_CENTERED },
{ "enumerate", LA_ENUMERATE },
{ "itemize", LA_ITEMIZE },
{ "manual", LA_MANUAL },
{ "no_label", LA_NO_LABEL },
{ "sensitive", LA_SENSITIVE },
{ "static", LA_STATIC }
};
PushPopHelper pph(lex, labelTypeTags);
@ -721,11 +721,11 @@ void Layout::readLabelType(Lexer & lex)
case LA_MANUAL:
labeltype = LABEL_MANUAL;
break;
case LA_TOP_ENVIRONMENT:
labeltype = LABEL_TOP_ENVIRONMENT;
case LA_ABOVE:
labeltype = LABEL_ABOVE;
break;
case LA_CENTERED_TOP_ENVIRONMENT:
labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
case LA_CENTERED:
labeltype = LABEL_CENTERED;
break;
case LA_STATIC:
labeltype = LABEL_STATIC;
@ -1035,8 +1035,8 @@ string const & Layout::htmlitemattr() const
string const & Layout::htmllabeltag() const
{
if (htmllabeltag_.empty()) {
if (labeltype != LABEL_TOP_ENVIRONMENT &&
labeltype != LABEL_CENTERED_TOP_ENVIRONMENT)
if (labeltype != LABEL_ABOVE &&
labeltype != LABEL_CENTERED)
htmllabeltag_ = "span";
else
htmllabeltag_ = "div";
@ -1161,7 +1161,7 @@ void Layout::makeDefaultCSS() const
// label font
if (labelfont != font)
labelCSS = labelfont.asCSS() + from_ascii("\n");
if (labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
if (labeltype == LABEL_CENTERED)
labelCSS += from_ascii("text-align: center;\n");
if (!labelCSS.empty())

View File

@ -180,6 +180,24 @@ public:
|| latextype == LATEX_ITEM_ENVIRONMENT
|| latextype == LATEX_LIST_ENVIRONMENT;
}
/// Is this the kind of layout in which adjacent paragraphs
/// are handled as one group?
bool isParagraphGroup() const {
return latextype == LATEX_ENVIRONMENT
|| latextype == LATEX_BIB_ENVIRONMENT;
}
///
bool labelIsInline() const {
return labeltype == LABEL_STATIC
|| labeltype == LABEL_SENSITIVE
|| labeltype == LABEL_ENUMERATE
|| labeltype == LABEL_ITEMIZE;
}
bool labelIsAbove() const {
return labeltype == LABEL_ABOVE
|| labeltype == LABEL_CENTERED
|| labeltype == LABEL_BIBLIO;
}
///
bool operator==(Layout const &) const;

View File

@ -113,11 +113,9 @@ enum LabelType {
///
LABEL_BIBLIO,
///
LABEL_TOP_ENVIRONMENT,
LABEL_ABOVE,
///
LABEL_CENTERED_TOP_ENVIRONMENT,
// the flushright labels following now must start with LABEL_STATIC
LABEL_CENTERED,
///
LABEL_STATIC,
///

View File

@ -1112,10 +1112,8 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
}
// special code for the top label
if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_BIBLIO
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& text_->isFirstInSequence(pit)
if (layout.labelIsAbove()
&& (!layout.isParagraphGroup() || text_->isFirstInSequence(pit))
&& !par.labelString().empty())
{
labeladdon = int(
@ -1981,10 +1979,7 @@ int TextMetrics::leftMargin(int max_width,
&& layout.latextype == LATEX_ENVIRONMENT
&& !text_->isFirstInSequence(pit))) {
l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
} else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
&& layout.labeltype != LABEL_BIBLIO
&& layout.labeltype !=
LABEL_CENTERED_TOP_ENVIRONMENT) {
} else if (!layout.labelIsAbove()) {
l_margin += labelfont_metrics.signedWidth(layout.labelindent);
l_margin += labelfont_metrics.width(layout.labelsep);
l_margin += labelfont_metrics.width(par.labelString());
@ -2026,8 +2021,8 @@ int TextMetrics::leftMargin(int max_width,
// set the correct parindent
if (pos == 0
&& (layout.labeltype == LABEL_NO_LABEL
|| layout.labeltype == LABEL_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_ABOVE
|| layout.labeltype == LABEL_CENTERED
|| (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT
&& !text_->isFirstInSequence(pit)))

View File

@ -930,6 +930,7 @@ void makeCommand(Buffer const & buf,
// Label around sectioning number:
// FIXME Probably need to account for LABEL_MANUAL
// FIXME Probably also need now to account for labels ABOVE and CENTERED.
if (style.labeltype != LABEL_NO_LABEL) {
openLabelTag(xs, style);
xs << pbegin->params().labelString();

View File

@ -586,20 +586,14 @@ void RowPainter::paintFirst()
}
}
bool const is_seq = text_.isFirstInSequence(pit_);
bool const is_first =
text_.isFirstInSequence(pit_) || !layout.isParagraphGroup();
//lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
if (layout.labeltype >= LABEL_STATIC
&& (layout.labeltype != LABEL_STATIC
|| layout.latextype != LATEX_ENVIRONMENT
|| is_seq)) {
if (layout.labelIsInline()
&& (layout.labeltype != LABEL_STATIC || is_first)) {
paintLabel();
} else if (is_seq
&& (layout.labeltype == LABEL_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_BIBLIO
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
// the labels at the top of an environment.
// More or less for bibliography
} else if (is_first && layout.labelIsAbove()) {
paintTopLevelLabel();
}
}
@ -683,7 +677,7 @@ void RowPainter::paintTopLevelLabel()
+ (layout.labelbottomsep * defaultRowHeight()));
double x = x_;
if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
if (layout.labeltype == LABEL_CENTERED) {
if (is_rtl)
x = leftMargin();
x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;