diff options
| -rw-r--r-- | fluid/Fl_Grid_Type.cxx | 23 | ||||
| -rw-r--r-- | fluid/widget_panel.cxx | 45 | ||||
| -rw-r--r-- | fluid/widget_panel.fl | 50 | ||||
| -rw-r--r-- | fluid/widget_panel.h | 2 | ||||
| -rw-r--r-- | src/Fl_Grid.cxx | 2 |
5 files changed, 77 insertions, 45 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx index 1ec831c7c..383785778 100644 --- a/fluid/Fl_Grid_Type.cxx +++ b/fluid/Fl_Grid_Type.cxx @@ -470,7 +470,10 @@ void Fl_Grid_Type::insert_child(Fl_Widget *child) { // a red button "replace". If clicked, user gets the option to delete // the old widget, or just remove the cell, or cancel. // TODO: move cells by using the arrow keys? -// TODO: move cells via drag'n'drop +// TODO: move cells via drag'n'drop -> int Fl_Window_Type::handle(int event) +// TODO: handling of children that are themselves Groups. As it is, the children +// are not moved correctly if a parent group repositions or resizes groups. +// The same is true for Fl_Flex. // TODO: better grid overlay? // TODO: grid_child_cb should move all selected cells, not just the current_selected. // TODO: buttons to add and delete rows and columns in the widget dialog @@ -527,13 +530,19 @@ void grid_child_cb(Fluid_Coord_Input* i, void* v, int what) { if (old_v != v) { switch (what & 0x00ff) { case 8: if (v>=0 && v2>=0) move_cell(g, current_widget->o, v, v2); - if (freeze_row_col) i->value(v); break; + if (freeze_row_col) i->value(v); + break; case 9: if (v>=0 && v2>=0) move_cell(g, current_widget->o, v2, v); - if (freeze_row_col) i->value(v); break; - case 10: if (cell && cell->row()+v<=g->rows()) cell->rowspan(v); break; - case 11: if (cell && cell->col()+v<=g->cols()) cell->colspan(v); break; - case 12: if (cell) cell->minimum_size(v, v2); break; - case 13: if (cell) cell->minimum_size(v2, v); break; + if (freeze_row_col) i->value(v); + break; + case 10: if (cell && cell->row()+v<=g->rows()) cell->rowspan(v); + break; + case 11: if (cell && cell->col()+v<=g->cols()) cell->colspan(v); + break; + case 12: if (cell) cell->minimum_size(v, v2); + break; + case 13: if (cell) cell->minimum_size(v2, v); + break; } if (!cell && new_cell) new_cell->minimum_size(20, 20); diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx index 8b3130c10..2d35b1362 100644 --- a/fluid/widget_panel.cxx +++ b/fluid/widget_panel.cxx @@ -29,19 +29,24 @@ Fl_Double_Window* make_window() { w = o; (void)w; { Fl_Grid* o = new Fl_Grid(25, 25, 262, 160); o->labelsize(11); - o->layout(3, 3); - o->margin(10, 8, 11, 12); - static const int rowgaps[] = { 3, -1, -1 }; - o->row_gap(rowgaps, 3); - static const int colwidths[] = { 0, 100, 0 }; - o->col_width(colwidths, 3); - static const int colweights[] = { 50, 40, 50 }; - o->col_weight(colweights, 3); - static const int colgaps[] = { 1, 3, -1 }; - o->col_gap(colgaps, 3); - { Fl_Button* o = new Fl_Button(85, 75, 139, 59, "Button"); + o->layout(4, 4); + o->margin(10, 10, 16, 12); + static const int colwidths[] = { 0, 100, 0, 0 }; + o->col_width(colwidths, 4); + static const int colweights[] = { 50, 40, 50, 50 }; + o->col_weight(colweights, 4); + { Fl_Button* o = new Fl_Button(70, 63, 129, 50, "Button"); o->labelsize(11); } // Fl_Button* o + { Fl_Group* o = new Fl_Group(224, 115, 40, 45); + o->box(FL_BORDER_BOX); + o->color((Fl_Color)11); + o->labelsize(11); + { Fl_Button* o = new Fl_Button(234, 120, 24, 20, "Button"); + o->labelsize(11); + } // Fl_Button* o + o->end(); + } // Fl_Group* o Fl_Grid::Cell *cell = NULL; cell = o->widget(o->child(0), 1, 1, 1, 1, 48); if (cell) cell->minimum_size(20, 20); @@ -333,15 +338,15 @@ static void cb_Bottom(Fl_Value_Input* o, void* v) { static void cb_Row(Fl_Value_Input* o, void* v) { Fl_Grid *grid = Fl_Grid_Type::selected(); if (!grid) return; - int m = 0; if (v == LOAD) { - grid->gap(&m, NULL); + int m = 0; + grid->gap(&m, NULL); o->value(m); } else { int m = (int)o->value(), old_m; grid->gap(&old_m, NULL); if (m != old_m) { - grid->gap(m, -1); + grid->gap(m, m2); grid->need_layout(true); set_modflag(1); } @@ -351,15 +356,15 @@ static void cb_Row(Fl_Value_Input* o, void* v) { static void cb_Col(Fl_Value_Input* o, void* v) { Fl_Grid *grid = Fl_Grid_Type::selected(); if (!grid) return; - int m = 0; if (v == LOAD) { + int m = 0; grid->gap(NULL, &m); o->value(m); } else { int m = (int)o->value(), old_m; grid->gap(NULL, &old_m); if (m != old_m) { - grid->gap(-1, m); + grid->gap(m2, m); grid->need_layout(true); set_modflag(1); } @@ -417,6 +422,7 @@ static void cb_Height(Fluid_Coord_Input* o, void* v) { o->value(grid->row_height(r)); } else { int h = o->value(), old_h = grid->row_height(r); + if (h < 0) h = 0; if (h != old_h) { grid->row_height(r, h); grid->need_layout(true); @@ -433,6 +439,7 @@ static void cb_Weight(Fluid_Coord_Input* o, void* v) { o->value(grid->row_weight(r)); } else { int h = o->value(), old_h = grid->row_weight(r); + if (h < 0) h = 0; if (h != old_h) { grid->row_weight(r, h); grid->need_layout(true); @@ -449,6 +456,7 @@ static void cb_Gap(Fluid_Coord_Input* o, void* v) { o->value(grid->row_gap(r)); } else { int h = o->value(), old_h = grid->row_gap(r); + if (h < -1) h = -1; if (h != old_h) { grid->row_gap(r, h); grid->need_layout(true); @@ -497,6 +505,7 @@ static void cb_Width(Fluid_Coord_Input* o, void* v) { o->value(grid->col_width(c)); } else { int h = o->value(), old_h = grid->col_width(c); + if (h < 0) h = 0; if (h != old_h) { grid->col_width(c, h); grid->need_layout(true); @@ -513,6 +522,7 @@ static void cb_Weight1(Fluid_Coord_Input* o, void* v) { o->value(grid->col_weight(c)); } else { int h = o->value(), old_h = grid->col_weight(c); + if (h < 0) h = 0; if (h != old_h) { grid->col_weight(c, h); grid->need_layout(true); @@ -529,6 +539,7 @@ static void cb_Gap1(Fluid_Coord_Input* o, void* v) { o->value(grid->col_gap(c)); } else { int h = o->value(), old_h = grid->col_gap(c); + if (h < -1) h = -1; if (h != old_h) { grid->col_gap(c, h); grid->need_layout(true); @@ -564,6 +575,7 @@ Fl_Double_Window* make_widget_panel() { o->labelsize(11); o->callback((Fl_Callback*)propagate_load); o->when(FL_WHEN_NEVER); + o->hide(); { Fl_Group* o = new Fl_Group(95, 40, 309, 20, "Label:"); o->labelfont(1); o->labelsize(11); @@ -1638,7 +1650,6 @@ access the Widget pointer and \'v\' to access the user value."); { widget_tab_grid = new Fl_Group(10, 30, 400, 330, "Grid"); widget_tab_grid->labelsize(11); widget_tab_grid->callback((Fl_Callback*)propagate_load); - widget_tab_grid->hide(); { Fl_Group* o = new Fl_Group(95, 60, 315, 20, "Grid Layout:"); o->labelfont(1); o->labelsize(11); diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl index 648a8a1b8..dede14fa1 100644 --- a/fluid/widget_panel.fl +++ b/fluid/widget_panel.fl @@ -50,19 +50,25 @@ Function {make_window()} {open } { Fl_Grid {} {open xywh {25 25 262 160} labelsize 11 - dimensions {3 3} margin {10 8 11 12} - rowgaps { 3 -1 -1 } - colwidths { 0 100 0 } - colweights { 50 40 50 } - colgaps { 1 3 -1 } + dimensions {4 4} margin {10 10 16 12} + colwidths { 0 100 0 0 } + colweights { 50 40 50 50 } } { Fl_Button {} { label Button - xywh {85 75 139 59} labelsize 11 + xywh {70 63 129 50} labelsize 11 parent_properties { location {1 1} } } + Fl_Group {} {open + xywh {224 115 40 45} box BORDER_BOX color 11 labelsize 11 + } { + Fl_Button {} { + label Button + xywh {234 120 24 20} labelsize 11 + } + } } } } @@ -82,8 +88,8 @@ Function {make_widget_panel()} { } { Fl_Group {} { label GUI - callback propagate_load selected - xywh {10 30 400 330} labelsize 11 when 0 resizable + callback propagate_load + xywh {10 30 400 330} labelsize 11 when 0 hide resizable } { Fl_Group {} { label {Label:} @@ -1069,7 +1075,7 @@ wCallback->do_callback(wCallback, v);} open Fl_Group widget_tab_grid { label Grid callback propagate_load open - xywh {10 30 400 330} labelsize 11 hide + xywh {10 30 400 330} labelsize 11 } { Fl_Group {} { label {Grid Layout:} @@ -1201,7 +1207,7 @@ if (v == LOAD) { grid->need_layout(true); set_modflag(1); } -}} +}} selected tooltip {Left margin in group.} xywh {95 100 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11 } Fl_Value_Input {} { @@ -1274,15 +1280,15 @@ if (v == LOAD) { label {Row:} callback {Fl_Grid *grid = Fl_Grid_Type::selected(); if (!grid) return; -int m = 0; if (v == LOAD) { - grid->gap(&m, NULL); + int m = 0; + grid->gap(&m, NULL); o->value(m); } else { - int m = o->value(), old_m; - grid->gap(&old_m, NULL); + int m = o->value(), old_m, m2; + grid->gap(&old_m, &m2); if (m != old_m) { - grid->gap(m, -1); + grid->gap(m, m2); grid->need_layout(true); set_modflag(1); } @@ -1293,15 +1299,15 @@ if (v == LOAD) { label {Col:} callback {Fl_Grid *grid = Fl_Grid_Type::selected(); if (!grid) return; -int m = 0; if (v == LOAD) { + int m = 0; grid->gap(NULL, &m); o->value(m); } else { - int m = o->value(), old_m; - grid->gap(NULL, &old_m); + int m = o->value(), old_m, m2; + grid->gap(&m2, &old_m); if (m != old_m) { - grid->gap(-1, m); + grid->gap(m2, m); grid->need_layout(true); set_modflag(1); } @@ -1380,6 +1386,7 @@ if (v == LOAD) { o->value(grid->row_height(r)); } else { int h = o->value(), old_h = grid->row_height(r); + if (h < 0) h = 0; if (h != old_h) { grid->row_height(r, h); grid->need_layout(true); @@ -1398,6 +1405,7 @@ if (v == LOAD) { o->value(grid->row_weight(r)); } else { int h = o->value(), old_h = grid->row_weight(r); + if (h < 0) h = 0; if (h != old_h) { grid->row_weight(r, h); grid->need_layout(true); @@ -1416,6 +1424,7 @@ if (v == LOAD) { o->value(grid->row_gap(r)); } else { int h = o->value(), old_h = grid->row_gap(r); + if (h < -1) h = -1; if (h != old_h) { grid->row_gap(r, h); grid->need_layout(true); @@ -1490,6 +1499,7 @@ if (v == LOAD) { o->value(grid->col_width(c)); } else { int h = o->value(), old_h = grid->col_width(c); + if (h < 0) h = 0; if (h != old_h) { grid->col_width(c, h); grid->need_layout(true); @@ -1508,6 +1518,7 @@ if (v == LOAD) { o->value(grid->col_weight(c)); } else { int h = o->value(), old_h = grid->col_weight(c); + if (h < 0) h = 0; if (h != old_h) { grid->col_weight(c, h); grid->need_layout(true); @@ -1526,6 +1537,7 @@ if (v == LOAD) { o->value(grid->col_gap(c)); } else { int h = o->value(), old_h = grid->col_gap(c); + if (h < -1) h = -1; if (h != old_h) { grid->col_gap(c, h); grid->need_layout(true); diff --git a/fluid/widget_panel.h b/fluid/widget_panel.h index 47809985d..1a4021a9b 100644 --- a/fluid/widget_panel.h +++ b/fluid/widget_panel.h @@ -23,10 +23,10 @@ #include <FL/Fl_Double_Window.H> #include <FL/Fl_Grid.H> #include <FL/Fl_Button.H> +#include <FL/Fl_Group.H> Fl_Double_Window* make_window(); #include <FL/Fl_Tabs.H> extern Fl_Tabs *widget_tabs; -#include <FL/Fl_Group.H> extern void propagate_load(Fl_Group*, void*); #include <FL/Fl_Input.H> extern void label_cb(Fl_Input*, void*); diff --git a/src/Fl_Grid.cxx b/src/Fl_Grid.cxx index ac4f9f224..9910bb069 100644 --- a/src/Fl_Grid.cxx +++ b/src/Fl_Grid.cxx @@ -276,7 +276,7 @@ void Fl_Grid::draw_grid() { for (int c = 0; c < cols_ - 1; c++) { - int gap = Cols_[c].gap_ >= 0 ? Cols_[c].gap_ : gap_row_; + int gap = Cols_[c].gap_ >= 0 ? Cols_[c].gap_ : gap_col_; x0 += Cols_[c].w_; if (gap == 0) { fl_yxline(x0, y0, y1); |
