The attached patch deals with most of the remaining issues with the Paragraph Settings dialog, after the long discussion about how to do it. I've redesigned the dialog itself in accord with some ideas of Edwin's, adapting also some suggestions of Helge's. A screenshot is attached. This separates out "Default" a bit, changes the label to "Default for Current Paragraph"---I think that makes it a little clearer to users what this does---and makes some space for adding "(Justifed)" without alignment issues.

Something even better, in the non-multi-paragraph case, might be to make it say "Default for Standard" or "Default for Itemize" or whatever. But I think doing this will involve rather more work, as the extant controller doesn't provide access to this.

There is one remaining issue, namely, that what the default is isn't indicated here, because I haven't had time to figure out how to determine if there is a multi-paragraph selection. And, fortunately, for me, I'm going on vacation for a week and a half on Thursday and am very unlikely to be able to do that before then. So I'm hoping someone else will finish that bit---Abdel, JMarc? The only thing that needs doing is to replace the silly:
   bool const isMultiParagraph = false;
in QParagraphDialog::checkAlignmentRadioButtons() with something sensible. The other needed code is already there.

Also, there are a couple "FIXME"s here that refer to the fact that LYX_ALIGN_LAYOUT isn't required to be a possible alignment. Obviously, it should be. The second patch I've attached makes this change---and another one, namely: Why should LYX_ALIGN_BLOCK be possible by default? No good reason, so far as I can see. With this, the two FIXMEs can be fixed (and I think a proper solution for some other bugs also comes into sight, but later). If anyone wants to sort this out, too, that'd be great.

I can commit all of this later tonight if someone tells me how to deal with the multi-paragraph bit. Or someone can fix that and commit it for me. I don't care. Either way.

Richard

--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

<<inline: snap14.png>>

Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp	(revision 18892)
+++ src/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: src/ParagraphParameters.cpp
===================================================================
--- src/ParagraphParameters.cpp	(revision 18892)
+++ src/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: src/Text2.cpp
===================================================================
--- src/Text2.cpp	(revision 18892)
+++ src/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: src/frontends/qt4/QParagraph.h
===================================================================
--- src/frontends/qt4/QParagraph.h	(revision 18892)
+++ src/frontends/qt4/QParagraph.h	(working copy)
@@ -44,8 +44,8 @@
 	QParagraph * form_;
 	typedef std::map<LyXAlignment, QRadioButton *> QPRadioMap;
 	QPRadioMap radioMap;
-//	typedef std::map<LyXAlignment, std::string> QPAlignmentLabels;
-//	QPAlignmentLabels labelMap;
+	typedef std::map<LyXAlignment, std::string> QPAlignmentLabels;
+	QPAlignmentLabels labelMap;
 	
 protected Q_SLOTS:
 	///
Index: src/frontends/qt4/QParagraph.cpp
===================================================================
--- src/frontends/qt4/QParagraph.cpp	(revision 18892)
+++ src/frontends/qt4/QParagraph.cpp	(working copy)
@@ -83,11 +83,12 @@
 	radioMap[LYX_ALIGN_RIGHT]  = alignRightRB;
 	radioMap[LYX_ALIGN_CENTER] = alignCenterRB;
 	
-/*	labelMap[LYX_ALIGN_LAYOUT] = "Default";
+	labelMap[LYX_ALIGN_LAYOUT] = "Default for Current Paragraph";
 	labelMap[LYX_ALIGN_BLOCK]  = "Justified";
 	labelMap[LYX_ALIGN_LEFT]   = "Left";
 	labelMap[LYX_ALIGN_RIGHT]  = "Right";
-	labelMap[LYX_ALIGN_CENTER] = "Center"; */
+	labelMap[LYX_ALIGN_CENTER] = "Center";
+
 }
 
 
@@ -113,30 +114,26 @@
 
 void QParagraphDialog::checkAlignmentRadioButtons() {
 	LyXAlignment const alignPossible = form_->controller().alignPossible();
-	//LyXAlignment const defaultAlignment = form_->controller().alignDefault();
+	LyXAlignment const defaultAlignment = form_->controller().alignDefault();
+	bool const isMultiParagraph = false; //FIXME
 	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));*/
+		string label = labelMap[align];
+		if (!isMultiParagraph && 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;
-	}
-
 	QPRadioMap::const_iterator it = radioMap.begin();
 	for (;it != radioMap.end(); ++it) {
 		if (align == it->first) {
Index: src/frontends/qt4/ui/ParagraphUi.ui
===================================================================
--- src/frontends/qt4/ui/ParagraphUi.ui	(revision 18892)
+++ src/frontends/qt4/ui/ParagraphUi.ui	(working copy)
@@ -8,8 +8,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>387</width>
-    <height>245</height>
+    <width>488</width>
+    <height>334</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -36,142 +36,20 @@
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item rowspan="4" row="0" column="0" >
-    <widget class="QGroupBox" name="aligmentGB" >
-     <property name="sizePolicy" >
-      <sizepolicy>
-       <hsizetype>3</hsizetype>
-       <vsizetype>5</vsizetype>
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="title" >
-      <string>Alignment</string>
-     </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>9</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item row="3" column="0" >
-       <widget class="QRadioButton" name="alignCenterRB" >
-        <property name="text" >
-         <string>&amp;Center</string>
-        </property>
-       </widget>
-      </item>
-      <item row="4" column="0" >
-       <widget class="QRadioButton" name="alignRightRB" >
-        <property name="text" >
-         <string>&amp;Right</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0" >
-       <widget class="QRadioButton" name="alignLeftRB" >
-        <property name="text" >
-         <string>&amp;Left</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0" >
-       <widget class="QRadioButton" name="alignJustRB" >
-        <property name="text" >
-         <string>&amp;Justified</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="0" >
-       <widget class="QRadioButton" name="alignDefaultRB" >
-        <property name="font" >
-         <font>
-          <italic>false</italic>
-         </font>
-        </property>
-        <property name="toolTip" >
-         <string>Use the default alignment for this paragraph, whatever it is.</string>
-        </property>
-        <property name="text" >
-         <string>Default</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="0" column="1" >
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <widget class="QLabel" name="linespacingL" >
-       <property name="text" >
-        <string>L&amp;ine spacing:</string>
-       </property>
-       <property name="buddy" >
-        <cstring>linespacing</cstring>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QComboBox" name="linespacing" >
-       <item>
-        <property name="text" >
-         <string>Default</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>Single</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>1.5</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>Double</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>Custom</string>
-        </property>
-       </item>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLineEdit" name="linespacingValue" >
-       <property name="enabled" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="2" column="1" >
+   <item row="4" column="0" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" >
       <size>
-       <width>249</width>
+       <width>20</width>
        <height>31</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="1" column="1" >
+   <item row="2" column="0" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
@@ -204,45 +82,7 @@
      </item>
     </layout>
    </item>
-   <item row="3" column="1" >
-    <widget class="QGroupBox" name="labelwidthGB" >
-     <property name="enabled" >
-      <bool>false</bool>
-     </property>
-     <property name="title" >
-      <string>Label Width</string>
-     </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>11</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item row="0" column="1" >
-       <widget class="QLineEdit" name="labelWidth" >
-        <property name="toolTip" >
-         <string>This text defines the width of the paragraph label</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="TextLabel2" >
-        <property name="toolTip" >
-         <string>This text defines the width of the paragraph label</string>
-        </property>
-        <property name="text" >
-         <string>&amp;Longest label</string>
-        </property>
-        <property name="buddy" >
-         <cstring>labelWidth</cstring>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="4" column="0" colspan="2" >
+   <item row="5" column="0" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
@@ -311,6 +151,174 @@
      </item>
     </layout>
    </item>
+   <item row="0" column="0" >
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="linespacingL" >
+       <property name="text" >
+        <string>L&amp;ine spacing:</string>
+       </property>
+       <property name="buddy" >
+        <cstring>linespacing</cstring>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="linespacing" >
+       <item>
+        <property name="text" >
+         <string>Default</string>
+        </property>
+       </item>
+       <item>
+        <property name="text" >
+         <string>Single</string>
+        </property>
+       </item>
+       <item>
+        <property name="text" >
+         <string>1.5</string>
+        </property>
+       </item>
+       <item>
+        <property name="text" >
+         <string>Double</string>
+        </property>
+       </item>
+       <item>
+        <property name="text" >
+         <string>Custom</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="linespacingValue" >
+       <property name="enabled" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QGroupBox" name="aligmentGB" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>3</hsizetype>
+       <vsizetype>5</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title" >
+      <string>Alignment</string>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="0" column="0" colspan="4" >
+       <widget class="QRadioButton" name="alignDefaultRB" >
+        <property name="font" >
+         <font>
+          <italic>false</italic>
+         </font>
+        </property>
+        <property name="toolTip" >
+         <string>Use the default alignment for this paragraph, whatever it is.</string>
+        </property>
+        <property name="text" >
+         <string>Default for Current Paragraph (Justified)</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3" >
+       <widget class="QRadioButton" name="alignRightRB" >
+        <property name="text" >
+         <string>&amp;Right</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" >
+       <widget class="QRadioButton" name="alignLeftRB" >
+        <property name="text" >
+         <string>&amp;Left</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2" >
+       <widget class="QRadioButton" name="alignCenterRB" >
+        <property name="text" >
+         <string>&amp;Center</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" >
+       <widget class="QRadioButton" name="alignJustRB" >
+        <property name="text" >
+         <string>&amp;Justified</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="3" column="0" >
+    <widget class="QGroupBox" name="labelwidthGB" >
+     <property name="enabled" >
+      <bool>false</bool>
+     </property>
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>5</hsizetype>
+       <vsizetype>1</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title" >
+      <string>Label Width</string>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="0" column="1" >
+       <widget class="QLineEdit" name="labelWidth" >
+        <property name="toolTip" >
+         <string>This text defines the width of the paragraph label</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="TextLabel2" >
+        <property name="toolTip" >
+         <string>This text defines the width of the paragraph label</string>
+        </property>
+        <property name="text" >
+         <string>&amp;Longest label</string>
+        </property>
+        <property name="buddy" >
+         <cstring>labelWidth</cstring>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
   </layout>
  </widget>
  <tabstops>
Index: src/Layout.h
===================================================================
--- src/Layout.h	(revision 18892)
+++ src/Layout.h	(working copy)
@@ -78,6 +78,13 @@
 }
 
 
+///
+inline
+LyXAlignment operator|(LyXAlignment la1, LyXAlignment la2) {
+	return static_cast<LyXAlignment>(static_cast<int>(la1) | static_cast<int>(la2));
+}
+
+
 /// The different LaTeX-Types
 enum LYX_LATEX_TYPES {
 	///
Index: src/Layout.cpp
===================================================================
--- src/Layout.cpp	(revision 18892)
+++ src/Layout.cpp	(working copy)
@@ -115,7 +115,7 @@
 	labelbottomsep = 0.0;
 	parsep = 0;
 	align = LYX_ALIGN_BLOCK;
-	alignpossible = LYX_ALIGN_BLOCK;
+	alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
 	labeltype = LABEL_NO_LABEL;
 	endlabeltype = END_LABEL_NO_LABEL;
 	// Should or should not. That is the question.
@@ -550,7 +550,7 @@
 	};
 
 	lexrc.pushTable(alignTags, AT_LAYOUT);
-	alignpossible = LYX_ALIGN_NONE;
+	alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
 	int lineno = lexrc.getLineNo();
 	do {
 		int le = lexrc.lex();

Reply via email to