Hello,
the attached patch changes behavior of rotate-tabular and rotate-cell toolbar buttons such that they
toggle the rotation. Therefore a toggle feature is added to the tabular features. Moreover after the
patch the state of the set-rotate-cell and toggle-rotate-cell buttons is on only if all selected
cells in the table are rotated. If not all selected cells are rotated then the toggle button rotates
all selected cells.
The toggle-icons are now copied from the set-icons. Maybe they should be changed a little bit (arrow
in both directions?).
Objections?
José, can it go in?
Bernhard
Index: lib/images/tabular-feature_toggle-rotate-cell.xpm
===================================================================
--- lib/images/tabular-feature_toggle-rotate-cell.xpm (revision 0)
+++ lib/images/tabular-feature_toggle-rotate-cell.xpm (revision 0)
@@ -0,0 +1,46 @@
+/* XPM */
+static char *tabular_feature_set_rotate_cell_[] = {
+/* columns rows colors chars-per-pixel */
+"22 22 18 1",
+" c black",
+". c gray4",
+"X c #131313131313",
+"o c #1B1B1B1B1B1B",
+"O c gray14",
+"+ c #343434343434",
+"@ c gray23",
+"# c #414141414141",
+"$ c #484848484848",
+"% c gray32",
+"& c #5D5D5D5D5D5D",
+"* c #626262626262",
+"= c #6D6D6D6D6D6D",
+"- c gray48",
+"; c #838383838383",
+": c gray58",
+"> c gray100",
+", c None",
+/* pixels */
+",,,,,,,,,,, ,,,,,,,,,,",
+",,,,,,,,,,X.,,,,,,,,,,",
+",,,,,,,,,o;. ,,,,,,,,",
+",,,,,,,,X:=.+&@ ,,,,,,",
+",,,,,,,.:*o =* ,,,,,",
+",,,,,,,> *# X& ,,,,",
+",,,,,,,,, *o Xoo# >,,",
+",,,,,,,,,, . >*O+o.=>,",
+",,,,,,,,,,>.,,>,@*.@>,",
+",,,,,,,,,,,,,,,>*=o.,,",
+",,,,,,, ,,> @ ,,",
+",,,,,,, >>>>> ,,, * ,,",
+",,,,,,, >>>>> ,,, -O>,",
+",,,,,,, >>>>> ,,> *@>,",
+",,,,,,, >>>>> ,>* .,>,",
+",,,,,,, ,> =%>,,",
+",,,,,,,,,,,,,,, = >,,,",
+",,,,,,,,,,,,>,.$ ,,,,,",
+",,,,,,,,,,,>&Xo ,,,,,,",
+",,,,,,,,, X$->,,,,,,",
+",,,,,,,,,,,,,>>,,,,,,,",
+",,,,,,,,,,,,,,,,,,,,,,"
+};
Index: lib/images/tabular-feature_toggle-rotate-tabular.xpm
===================================================================
--- lib/images/tabular-feature_toggle-rotate-tabular.xpm (revision 0)
+++ lib/images/tabular-feature_toggle-rotate-tabular.xpm (revision 0)
@@ -0,0 +1,46 @@
+/* XPM */
+static char *tabular_feature_set_rotate_tabular_[] = {
+/* columns rows colors chars-per-pixel */
+"22 22 18 1",
+" c black",
+". c gray4",
+"X c #131313131313",
+"o c #1B1B1B1B1B1B",
+"O c gray14",
+"+ c #343434343434",
+"@ c gray23",
+"# c #414141414141",
+"$ c #484848484848",
+"% c gray32",
+"& c #5D5D5D5D5D5D",
+"* c #626262626262",
+"= c #6D6D6D6D6D6D",
+"- c gray48",
+"; c #838383838383",
+": c gray58",
+"> c gray100",
+", c None",
+/* pixels */
+",,,,,,,,,,, ,,,,,,,,,,",
+",,,,,,,,,,X.,,,,,,,,,,",
+",,,,,,,,,o;. ,,,,,,,,",
+",,, X:=.+&@ ,,,",
+",,, >>>.:*o =* > ,,,",
+",,, >>>> *# X& ,,,",
+",,, *o Xoo# >,,",
+",,, >>>> > . >*O+o.=>,",
+",,, >>>> >>.> >>@*.@>,",
+",,, >*=o.,,",
+",,, >>>> >>>> >>> @ ,,",
+",,, >>>> >>>> >>> * ,,",
+",,, -O>,",
+",,, >>>> >>>> >>> *@>,",
+",,, >>>> >>>> >>* .,>,",
+",,, > =%>,,",
+",,, >>>> >>>> > = >,,,",
+",,, >>>> >>>> .$ > ,,,",
+",,, >&Xo ,,,",
+",,,,,,,,, X$->,,,,,,",
+",,,,,,,,,,,,,>>,,,,,,,",
+",,,,,,,,,,,,,,,,,,,,,,"
+};
Index: lib/ui/stdtoolbars.inc
===================================================================
--- lib/ui/stdtoolbars.inc (revision 18243)
+++ lib/ui/stdtoolbars.inc (working copy)
@@ -128,8 +128,8 @@
Item "Align middle" "tabular-feature valign-middle"
Item "Align bottom" "tabular-feature valign-bottom"
Separator
- Item "Rotate cell" "tabular-feature set-rotate-cell"
- Item "Rotate table" "tabular-feature set-rotate-tabular"
+ Item "Rotate cell" "tabular-feature toggle-rotate-cell"
+ Item "Rotate table" "tabular-feature toggle-rotate-tabular"
Item "Set multi-column" "tabular-feature multicolumn"
End
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (revision 18244)
+++ src/insets/InsetTabular.cpp (working copy)
@@ -151,8 +151,10 @@
{ Tabular::SET_MPWIDTH, "set-mpwidth" },
{ Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
{ Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
+ { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular" },
{ Tabular::SET_ROTATE_CELL, "set-rotate-cell" },
{ Tabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
+ { Tabular::TOGGLE_ROTATE_CELL, "toggle-rotate-cell" },
{ Tabular::SET_USEBOX, "set-usebox" },
{ Tabular::SET_LTHEAD, "set-lthead" },
{ Tabular::UNSET_LTHEAD, "unset-lthead" },
@@ -3542,11 +3544,12 @@
row_type sel_row_start = 0;
row_type sel_row_end = 0;
- col_type dummy;
+ col_type sel_col_start = 0;
+ col_type sel_col_end = 0;
Tabular::ltType dummyltt;
bool flag = true;
- getSelection(cur, sel_row_start, sel_row_end, dummy, dummy);
+ getSelection(cur, sel_row_start, sel_row_end, sel_col_start,
sel_col_end);
switch (action) {
case Tabular::SET_PWIDTH:
@@ -3647,6 +3650,7 @@
status.setOnOff(!tabular.isLongTabular());
break;
+ case Tabular::TOGGLE_ROTATE_TABULAR:
case Tabular::SET_ROTATE_TABULAR:
status.setOnOff(tabular.getRotateTabular());
break;
@@ -3655,12 +3659,39 @@
status.setOnOff(!tabular.getRotateTabular());
break;
+ case Tabular::TOGGLE_ROTATE_CELL:
case Tabular::SET_ROTATE_CELL:
- status.setOnOff(tabular.getRotateCell(cur.idx()));
+ {
+ bool oneNotRotated = false;
+
+ row_type i = sel_row_start;
+ while (!oneNotRotated && i <= sel_row_end) {
+ col_type j = sel_col_start;
+ while (!oneNotRotated && j <= sel_col_end) {
+ oneNotRotated =
!tabular.getRotateCell(tabular.getCellNumber(i, j));
+ ++j;
+ }
+ ++i;
+ }
+ status.setOnOff(!oneNotRotated);
+ }
break;
case Tabular::UNSET_ROTATE_CELL:
- status.setOnOff(!tabular.getRotateCell(cur.idx()));
+ {
+ bool oneRotated = false;
+
+ row_type i = sel_row_start;
+ while (!oneRotated && i <= sel_row_end) {
+ col_type j = sel_col_start;
+ while (!oneRotated && j <= sel_col_end) {
+ oneRotated =
tabular.getRotateCell(tabular.getCellNumber(i, j));
+ ++j;
+ }
+ ++i;
+ }
+ status.setOnOff(!oneRotated);
+ }
break;
case Tabular::SET_USEBOX:
@@ -4339,6 +4370,10 @@
tabular.setRotateTabular(false);
break;
+ case Tabular::TOGGLE_ROTATE_TABULAR:
+ tabular.setRotateTabular(!tabular.getRotateTabular());
+ break;
+
case Tabular::SET_ROTATE_CELL:
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
for (col_type j = sel_col_start; j <= sel_col_end; ++j)
@@ -4353,6 +4388,26 @@
tabular.getCellNumber(i, j), false);
break;
+ case Tabular::TOGGLE_ROTATE_CELL:
+ {
+ bool oneNotRotated = false;
+
+ row_type i = sel_row_start;
+ while (!oneNotRotated && i <= sel_row_end) {
+ col_type j = sel_col_start;
+ while (!oneNotRotated && j <= sel_col_end) {
+ oneNotRotated =
!tabular.getRotateCell(tabular.getCellNumber(i, j));
+ ++j;
+ }
+ ++i;
+ }
+ for (row_type i = sel_row_start; i <= sel_row_end; ++i)
+ for (col_type j = sel_col_start; j <= sel_col_end; ++j)
+ tabular.setRotateCell(
+ tabular.getCellNumber(i, j),
oneNotRotated);
+ }
+ break;
+
case Tabular::SET_USEBOX: {
Tabular::BoxType val = Tabular::BoxType(convert<int>(value));
if (val == tabular.getUsebox(cur.idx()))
Index: src/insets/InsetTabular.h
===================================================================
--- src/insets/InsetTabular.h (revision 18244)
+++ src/insets/InsetTabular.h (working copy)
@@ -144,10 +144,14 @@
///
UNSET_ROTATE_TABULAR,
///
+ TOGGLE_ROTATE_TABULAR,
+ ///
SET_ROTATE_CELL,
///
UNSET_ROTATE_CELL,
///
+ TOGGLE_ROTATE_CELL,
+ ///
SET_USEBOX,
///
SET_LTHEAD,