Skip to content

Commit

Permalink
Partial grid margin support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Oct 13, 2023
1 parent 59393f4 commit 85d64f9
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 72 deletions.
2 changes: 2 additions & 0 deletions FL/Fl_Grid.H
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public:
// set individual margins

virtual void margin(int left, int top = -1, int right = -1, int bottom = -1);
int margin() const { return margin_left_; }
int margin(int *left, int *top, int *right, int *bottom) const;

// set default row and column gaps for all rows and columns, respectively

Expand Down
51 changes: 48 additions & 3 deletions fluid/Fl_Widget_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2214,9 +2214,10 @@ void value_cb(Fl_Value_Input* i, void* v) {

void values_group_cb(Fl_Group* g, void* v) {
if (v == LOAD) {
if (current_widget->is_a(Fl_Type::ID_Flex)) {
g->hide();
} else if (current_widget->is_a(Fl_Type::ID_Window)) {
if ( current_widget->is_a(Fl_Type::ID_Flex)
|| current_widget->is_a(Fl_Type::ID_Grid)
|| current_widget->is_a(Fl_Type::ID_Window))
{
g->hide();
} else {
g->show();
Expand All @@ -2236,6 +2237,17 @@ void flex_margin_group_cb(Fl_Group* g, void* v) {
}
}

void grid_margin_group_cb(Fl_Group* g, void* v) {
if (v == LOAD) {
if (current_widget->is_a(Fl_Type::ID_Grid)) {
g->show();
} else {
g->hide();
}
propagate_load(g, v);
}
}

void size_range_group_cb(Fl_Group* g, void* v) {
if (v == LOAD) {
if (current_widget->is_a(Fl_Type::ID_Window)) {
Expand Down Expand Up @@ -2474,6 +2486,39 @@ void flex_fixed_cb(Fl_Check_Button* i, void* v) {
}
}


void grid_margin_left_cb(Fl_Value_Input* i, void* v) {
if (v == LOAD) {
if (current_widget->is_a(Fl_Type::ID_Flex)) {
int v; ((Fl_Flex*)current_widget->o)->margin(&v, NULL, NULL, NULL);
i->value(v);
}
} else {
int mod = 0;
int v_old, v = (int)i->value();
for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
if (o->selected && o->is_a(Fl_Type::ID_Flex)) {
int v_old; ((Fl_Flex*)((Fl_Widget_Type*)o)->o)->margin(&v_old, NULL, NULL, NULL);
if (v!=v_old) {
((Fl_Flex*)((Fl_Widget_Type*)o)->o)->margin(&v, NULL, NULL, NULL);
((Fl_Flex*)((Fl_Widget_Type*)o)->o)->layout();
mod = 1;
}
}
}
if (mod) set_modflag(1);
}
}
void grid_margin_right_cb(Fl_Value_Input* i, void* v) {
}
void grid_margin_top_cb(Fl_Value_Input* i, void* v) {
}
void grid_margin_bottom_cb(Fl_Value_Input* i, void* v) {
}
void grid_margin_hgap_cb(Fl_Value_Input* i, void* v) {
}
void grid_margin_vgap_cb(Fl_Value_Input* i, void* v) {
}
////////////////////////////////////////////////////////////////

// subtypes:
Expand Down
111 changes: 75 additions & 36 deletions fluid/widget_panel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -248,42 +248,6 @@ mat");
o->labelsize(11);
o->callback((Fl_Callback*)align_cb, (void*)((fl_intptr_t)FL_ALIGN_WRAP));
} // Fl_Button* o
{ Fl_Button* o = new Fl_Button(278, 115, 20, 20, "@-1<-");
o->tooltip("Left-align the label.");
o->type(1);
o->selection_color(FL_INACTIVE_COLOR);
o->labelsize(11);
o->labelcolor(FL_INACTIVE_COLOR);
o->callback((Fl_Callback*)align_cb, (void*)((fl_intptr_t)FL_ALIGN_LEFT));
o->hide();
} // Fl_Button* o
{ Fl_Button* o = new Fl_Button(303, 115, 20, 20, "@-1->");
o->tooltip("Right-align the label.");
o->type(1);
o->selection_color(FL_INACTIVE_COLOR);
o->labelsize(11);
o->labelcolor(FL_INACTIVE_COLOR);
o->callback((Fl_Callback*)align_cb, (void*)((fl_intptr_t)FL_ALIGN_RIGHT));
o->hide();
} // Fl_Button* o
{ Fl_Button* o = new Fl_Button(328, 115, 20, 20, "@-18");
o->tooltip("Top-align the label.");
o->type(1);
o->selection_color(FL_INACTIVE_COLOR);
o->labelsize(11);
o->labelcolor(FL_INACTIVE_COLOR);
o->callback((Fl_Callback*)align_cb, (void*)((fl_intptr_t)FL_ALIGN_TOP));
o->hide();
} // Fl_Button* o
{ Fl_Button* o = new Fl_Button(353, 115, 20, 20, "@-12");
o->tooltip("Bottom-align the label.");
o->type(1);
o->selection_color(FL_INACTIVE_COLOR);
o->labelsize(11);
o->labelcolor(FL_INACTIVE_COLOR);
o->callback((Fl_Callback*)align_cb, (void*)((fl_intptr_t)FL_ALIGN_BOTTOM));
o->hide();
} // Fl_Button* o
{ Fl_Choice* o = new Fl_Choice(172, 115, 110, 20);
o->down_box(FL_BORDER_BOX);
o->labelsize(11);
Expand Down Expand Up @@ -423,6 +387,7 @@ sized to fit the container.");
o->labelsize(11);
o->callback((Fl_Callback*)values_group_cb);
o->align(Fl_Align(FL_ALIGN_LEFT));
o->hide();
{ Fl_Value_Input* o = new Fl_Value_Input(95, 185, 55, 20, "Size:");
o->tooltip("The size of the slider.");
o->labelsize(11);
Expand Down Expand Up @@ -473,34 +438,44 @@ sized to fit the container.");
{ Fl_Value_Input* o = new Fl_Value_Input(95, 185, 55, 20, "Left:");
o->tooltip("Left margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)flex_margin_left_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(155, 185, 55, 20, "Top:");
o->tooltip("Top margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)flex_margin_top_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(215, 185, 55, 20, "Right:");
o->tooltip("Right margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)flex_margin_right_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(275, 185, 55, 20, "Bottom:");
o->tooltip("Bottom margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)flex_margin_bottom_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(335, 185, 55, 20, "Gap:");
o->tooltip("Gap between children.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)flex_margin_gap_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
Expand All @@ -510,6 +485,70 @@ sized to fit the container.");
} // Fl_Box* o
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(95, 185, 300, 20, "Margins:");
o->labelfont(1);
o->labelsize(11);
o->callback((Fl_Callback*)grid_margin_group_cb);
o->align(Fl_Align(FL_ALIGN_LEFT));
{ Fl_Value_Input* o = new Fl_Value_Input(95, 185, 45, 20, "Left:");
o->tooltip("Left margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_left_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(144, 185, 45, 20, "Top:");
o->tooltip("Top margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_top_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(193, 185, 45, 20, "Right:");
o->tooltip("Right margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_right_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(242, 185, 45, 20, "Bottom:");
o->tooltip("Bottom margin in group.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_bottom_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(291, 185, 45, 20, "Hor.Gap:");
o->tooltip("Gap between children.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_hgap_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Value_Input* o = new Fl_Value_Input(340, 185, 45, 20, "Vert.Gap:");
o->tooltip("Gap between children.");
o->labelsize(11);
o->maximum(1000);
o->step(1);
o->textsize(11);
o->callback((Fl_Callback*)grid_margin_vgap_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
} // Fl_Value_Input* o
{ Fl_Box* o = new Fl_Box(395, 185, 0, 20);
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(95, 185, 300, 20, "Size Range:");
o->labelfont(1);
o->labelsize(11);
Expand Down
81 changes: 48 additions & 33 deletions fluid/widget_panel.fl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Function {make_widget_panel()} {
} {
Fl_Group {} {
label GUI
callback propagate_load open selected
callback propagate_load open
xywh {10 30 400 330} labelsize 11 when 0 resizable
} {
Fl_Group {} {
Expand Down Expand Up @@ -90,7 +90,7 @@ or compressed in the original file format} xywh {364 65 20 20} type Toggle
}
Fl_Group {} {
label {Inactive:}
callback propagate_load open
callback propagate_load open selected
xywh {95 90 309 20} labelfont 1 labelsize 11 align 4
} {
Fl_Input {} {
Expand Down Expand Up @@ -118,7 +118,7 @@ or compressed in the original file format} xywh {364 90 20 20} type Toggle
}
Fl_Group {} {
label {Alignment:}
callback propagate_load
callback propagate_load open
xywh {95 115 310 20} labelfont 1 labelsize 11 align 4
} {
Fl_Button {} {
Expand All @@ -133,30 +133,6 @@ or compressed in the original file format} xywh {364 90 20 20} type Toggle
callback align_cb
tooltip {Wrap the label text.} xywh {130 115 38 20} type Toggle selection_color 8 labelsize 11
}
Fl_Button {} {
label {@-1<-}
user_data {(fl_intptr_t)FL_ALIGN_LEFT}
callback align_cb
tooltip {Left-align the label.} xywh {278 115 20 20} type Toggle selection_color 8 labelsize 11 labelcolor 8 hide
}
Fl_Button {} {
label {@-1->}
user_data {(fl_intptr_t)FL_ALIGN_RIGHT}
callback align_cb
tooltip {Right-align the label.} xywh {303 115 20 20} type Toggle selection_color 8 labelsize 11 labelcolor 8 hide
}
Fl_Button {} {
label {@-18}
user_data {(fl_intptr_t)FL_ALIGN_TOP}
callback align_cb
tooltip {Top-align the label.} xywh {328 115 20 20} type Toggle selection_color 8 labelsize 11 labelcolor 8 hide
}
Fl_Button {} {
label {@-12}
user_data {(fl_intptr_t)FL_ALIGN_BOTTOM}
callback align_cb
tooltip {Bottom-align the label.} xywh {353 115 20 20} type Toggle selection_color 8 labelsize 11 labelcolor 8 hide
}
Fl_Choice {} {
callback align_text_image_cb open
xywh {172 115 110 20} down_box BORDER_BOX labelsize 11 textsize 11
Expand Down Expand Up @@ -363,7 +339,7 @@ h, ph, sh, ch, and i} xywh {275 150 55 20} labelsize 11 align 5 textsize 11
Fl_Group {} {
label {Values:}
callback values_group_cb open
xywh {95 185 300 20} labelfont 1 labelsize 11 align 4
xywh {95 185 300 20} labelfont 1 labelsize 11 align 4 hide
} {
Fl_Value_Input {} {
label {Size:}
Expand Down Expand Up @@ -402,27 +378,66 @@ h, ph, sh, ch, and i} xywh {275 150 55 20} labelsize 11 align 5 textsize 11
Fl_Value_Input {} {
label {Left:}
callback flex_margin_left_cb
tooltip {Left margin in group.} xywh {95 185 55 20} labelsize 11 align 5 textsize 11
tooltip {Left margin in group.} xywh {95 185 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Top:}
callback flex_margin_top_cb
tooltip {Top margin in group.} xywh {155 185 55 20} labelsize 11 align 5 textsize 11
tooltip {Top margin in group.} xywh {155 185 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Right:}
callback flex_margin_right_cb
tooltip {Right margin in group.} xywh {215 185 55 20} labelsize 11 align 5 textsize 11
tooltip {Right margin in group.} xywh {215 185 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Bottom:}
callback flex_margin_bottom_cb
tooltip {Bottom margin in group.} xywh {275 185 55 20} labelsize 11 align 5 textsize 11
tooltip {Bottom margin in group.} xywh {275 185 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Gap:}
callback flex_margin_gap_cb
tooltip {Gap between children.} xywh {335 185 55 20} labelsize 11 align 5 textsize 11
tooltip {Gap between children.} xywh {335 185 55 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Box {} {
xywh {395 185 0 20} resizable
}
}
Fl_Group {} {
label {Margins:}
callback grid_margin_group_cb open
xywh {95 185 300 20} labelfont 1 labelsize 11 align 4
} {
Fl_Value_Input {} {
label {Left:}
callback grid_margin_left_cb
tooltip {Left margin in group.} xywh {95 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Top:}
callback grid_margin_top_cb
tooltip {Top margin in group.} xywh {144 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Right:}
callback grid_margin_right_cb
tooltip {Right margin in group.} xywh {193 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Bottom:}
callback grid_margin_bottom_cb
tooltip {Bottom margin in group.} xywh {242 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Hor.Gap:}
callback grid_margin_hgap_cb
tooltip {Gap between children.} xywh {291 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Value_Input {} {
label {Vert.Gap:}
callback grid_margin_vgap_cb
tooltip {Gap between children.} xywh {340 185 45 20} labelsize 11 align 5 maximum 1000 step 1 textsize 11
}
Fl_Box {} {
xywh {395 185 0 20} resizable
Expand Down
Loading

0 comments on commit 85d64f9

Please sign in to comment.