Slight update...
Contrary to what I said in a previous message, completing the reworking
of the Paragraph Settings dialog isn't terribly difficult. Here's the
issue: In this dialog---both before the most recent patch and since it,
though there was some disagreement about this---we distinguish between
the Default alignment and, say, Justified, even if Justified happens to
be the Default for that paragraph. The reason to make this distinction
is that it is one thing to say, "Give this paragraph the default
alignment, whatever that is" and another to say, "Make this paragraph
fully justified, no matter what". The difference will only show up in
certain kinds of cases, such as when one is changing layouts, but it
seems to many of us, at least, that the difference should be respected,
and that the option of requiring a certain alignment, even if that is
currently the default, should be available.
The existing LyX code does not, however, respect the mentioned
difference, and the result is that the mentioned option isn't available,
in fact: If the default for a given paragraph is, as it happens,
Justified , then attempting to set the alignment to LYX_ALIGN_BLOCK will
fail: You'll actually get LYX_ALIGN_LAYOUT. The attached patch fixes
this. It's fairly simple: (i) In Text::setParagraph(), the code that
does what was just mentioned is removed; (ii) in
Paragraph::StartTeXParParams(), we ignore the alignment stuff if the
chosen alignment is the default for the paragraph; (iii) in
QParagraph::alignmentToRadioButtons(), we remove similarly offending
code; and (iv) in ParagraphParameters::params2string(), a similar sort
of change. I've also removed some commented-out code I accidentally left in
a previous patch.
This is safe, I think, and in the spirit of completing the previous UI
fix. Seeking two OKs.
Richard
Index: Text2.cpp
===================================================================
--- Text2.cpp (revision 18865)
+++ Text2.cpp (working copy)
@@ -649,16 +649,12 @@
params.spacing(spacing);
// does the layout allow the new alignment?
- Layout_ptr const & layout = par.layout();
-
- if (align == LYX_ALIGN_LAYOUT)
- align = layout->align;
- if (align & layout->alignpossible) {
- if (align == layout->align)
- params.align(LYX_ALIGN_LAYOUT);
- else
- params.align(align);
- }
+ //FIXME The reason we need the first check is because
+ //LYX_ALIGN_LAYOUT isn't required to be possible. It
+ //should be...and will be.
+ if ((align == LYX_ALIGN_LAYOUT) ||
+ (align & par.layout()->alignpossible))
+ params.align(align);
par.setLabelWidthString(labelwidthstring);
params.noindent(noindent);
}
Index: Paragraph.cpp
===================================================================
--- Paragraph.cpp (revision 18865)
+++ Paragraph.cpp (working copy)
@@ -1781,8 +1781,13 @@
os << "\\noindent ";
column += 10;
}
+
+ LyXAlignment const curAlign = params().align();
- switch (params().align()) {
+ if (curAlign == layout()->align)
+ return column;
+
+ switch (curAlign) {
case LYX_ALIGN_NONE:
case LYX_ALIGN_BLOCK:
case LYX_ALIGN_LAYOUT:
@@ -1798,7 +1803,7 @@
break;
}
- switch (params().align()) {
+ switch (curAlign) {
case LYX_ALIGN_NONE:
case LYX_ALIGN_BLOCK:
case LYX_ALIGN_LAYOUT:
Index: ParagraphParameters.cpp
===================================================================
--- ParagraphParameters.cpp (revision 18865)
+++ ParagraphParameters.cpp (working copy)
@@ -279,14 +279,11 @@
// This needs to be done separately
params.labelWidthString(par.getLabelWidthString());
- // Alignment
- Layout_ptr const & layout = par.layout();
- if (params.align() == LYX_ALIGN_LAYOUT)
- params.align(layout->align);
-
ostringstream os;
params.write(os);
+ Layout_ptr const & layout = par.layout();
+
// Is alignment possible
os << "\\alignpossible " << layout->alignpossible << '\n';
Index: frontends/qt4/QParagraph.cpp
===================================================================
--- frontends/qt4/QParagraph.cpp (revision 18865)
+++ frontends/qt4/QParagraph.cpp (working copy)
@@ -83,11 +83,6 @@
radioMap[LYX_ALIGN_RIGHT] = alignRightRB;
radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
-/* labelMap[LYX_ALIGN_LAYOUT] = "Default";
- labelMap[LYX_ALIGN_BLOCK] = "Justified";
- labelMap[LYX_ALIGN_LEFT] = "Left";
- labelMap[LYX_ALIGN_RIGHT] = "Right";
- labelMap[LYX_ALIGN_CENTER] = "Center"; */
}
@@ -113,30 +108,21 @@
void QParagraphDialog::checkAlignmentRadioButtons() {
LyXAlignment const alignPossible = form_->controller().alignPossible();
- //LyXAlignment const defaultAlignment = form_->controller().alignDefault();
QPRadioMap::iterator it = radioMap.begin();
for (; it != radioMap.end(); ++it) {
LyXAlignment const align = it->first;
+ //FIXME The reason we need the second check is because
+ //LYX_ALIGN_LAYOUT isn't required to be possible. It
+ //should be...and will be.
it->second->setEnabled((align & alignPossible) ||
(align == LYX_ALIGN_LAYOUT));
-/* string label = labelMap[align];
- if (align == LYX_ALIGN_LAYOUT)
- label += "()" + labelMap[defaultAlignment] + ")";
- it->second->setText(qt_(label));*/
}
}
void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align)
{
- LyXAlignment const defaultAlignment = form_->controller().alignDefault();
- if (align == LYX_ALIGN_LAYOUT || align == defaultAlignment) {
- alignDefaultRB->blockSignals(true);
- alignDefaultRB->setChecked(true);
- alignDefaultRB->blockSignals(false);
- return;
- }
-
+lyxerr << align << std::endl;
QPRadioMap::const_iterator it = radioMap.begin();
for (;it != radioMap.end(); ++it) {
if (align == it->first) {