STR #985: This is a medium size change in the way that FLUID manages widget label sizes. I moved the 'preset' functionality from the 'widget size' menu into the grid setting window. The menu now only changes selected widgets while the setting panel modifies newly created widgets. Settings are stored in the preferences.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4561 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
fcb8f9e056
commit
576fd78bde
@ -35,6 +35,7 @@
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Menu_Item.H>
|
||||
#include <FL/Fl_Round_Button.H>
|
||||
#include "Fl_Widget_Type.h"
|
||||
#include "undo.h"
|
||||
#include <math.h>
|
||||
@ -115,6 +116,15 @@ void grid_cb(Fl_Input *i, long v) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set default widget sizes...
|
||||
void default_widget_size_cb(Fl_Round_Button *b, long size) {
|
||||
// Update the "normal" text size of new widgets...
|
||||
b->setonly();
|
||||
Fl_Widget_Type::default_size = size;
|
||||
fluid_prefs.set("widget_size", size);
|
||||
}
|
||||
|
||||
|
||||
void i18n_type_cb(Fl_Choice *c, void *) {
|
||||
undo_checkpoint();
|
||||
|
||||
@ -210,6 +220,13 @@ void show_grid_cb(Fl_Widget *, void *) {
|
||||
sprintf(buf,"%d",gridy); vertical_input->value(buf);
|
||||
sprintf(buf,"%d",snap); snap_input->value(buf);
|
||||
guides_toggle->value(show_guides);
|
||||
int s = Fl_Widget_Type::default_size;
|
||||
if (s<=8) def_widget_size[0]->setonly();
|
||||
else if (s<=11) def_widget_size[1]->setonly();
|
||||
else if (s<=14) def_widget_size[2]->setonly();
|
||||
else if (s<=18) def_widget_size[3]->setonly();
|
||||
else if (s<=24) def_widget_size[4]->setonly();
|
||||
else if (s<=32) def_widget_size[5]->setonly();
|
||||
grid_window->hotspot(grid_window);
|
||||
grid_window->show();
|
||||
}
|
||||
|
@ -508,14 +508,11 @@ void align_widget_cb(Fl_Widget*, long how)
|
||||
}
|
||||
|
||||
|
||||
// Set default widget sizes...
|
||||
// Set sizes of selected widgets...
|
||||
void widget_size_cb(Fl_Widget *, long size) {
|
||||
// Update the "normal" text size of new widgets...
|
||||
Fl_Widget_Type::default_size = size;
|
||||
|
||||
// Update any selected widgets...
|
||||
int changed = 0;
|
||||
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
||||
for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
|
||||
if (o->selected && o->is_widget()) {
|
||||
if (!changed) {
|
||||
changed = 1;
|
||||
@ -531,7 +528,10 @@ void widget_size_cb(Fl_Widget *, long size) {
|
||||
((Fl_Widget_Type *)o)->textstuff(2, f, s, c);
|
||||
|
||||
w->redraw();
|
||||
// since this may be a major change, the whole window should be redrawn
|
||||
if (w->window()) w->window()->redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,6 +274,7 @@ Fl_Double_Window* make_settings_window() {
|
||||
recent_spinner->maximum(10);
|
||||
recent_spinner->value(c);
|
||||
}
|
||||
o->set_non_modal();
|
||||
o->end();
|
||||
}
|
||||
return w;
|
||||
@ -391,43 +392,110 @@ static void cb_Close2(Fl_Button*, void*) {
|
||||
grid_window->hide();
|
||||
}
|
||||
|
||||
Fl_Double_Window* make_grid_window() {
|
||||
Fl_Round_Button *def_widget_size[6]={(Fl_Round_Button *)0};
|
||||
|
||||
Fl_Double_Window* make_layout_window() {
|
||||
Fl_Double_Window* w;
|
||||
{ Fl_Double_Window* o = grid_window = new Fl_Double_Window(145, 185, "Grid");
|
||||
{ Fl_Double_Window* o = grid_window = new Fl_Double_Window(275, 240, "Layout Settings");
|
||||
w = o;
|
||||
{ Fl_Input* o = horizontal_input = new Fl_Input(88, 10, 47, 25, "Horizontal:");
|
||||
{ Fl_Input* o = horizontal_input = new Fl_Input(106, 10, 50, 25, "x");
|
||||
o->tooltip("Horizontal grid spacing.");
|
||||
o->type(2);
|
||||
o->box(FL_THIN_DOWN_BOX);
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)grid_cb, (void*)(1));
|
||||
o->align(FL_ALIGN_RIGHT);
|
||||
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
|
||||
}
|
||||
{ Fl_Input* o = vertical_input = new Fl_Input(88, 45, 47, 25, "Vertical:");
|
||||
{ Fl_Input* o = vertical_input = new Fl_Input(166, 10, 50, 25, "pixels");
|
||||
o->tooltip("Vertical grid spacing.");
|
||||
o->type(2);
|
||||
o->box(FL_THIN_DOWN_BOX);
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)grid_cb, (void*)(2));
|
||||
o->align(FL_ALIGN_RIGHT);
|
||||
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
|
||||
}
|
||||
{ Fl_Input* o = snap_input = new Fl_Input(88, 80, 47, 25, "Snap:");
|
||||
{ Fl_Input* o = snap_input = new Fl_Input(106, 45, 50, 25, "pixel snap");
|
||||
o->tooltip("Snap to grid within this many pixels.");
|
||||
o->type(2);
|
||||
o->box(FL_THIN_DOWN_BOX);
|
||||
o->labelfont(1);
|
||||
o->callback((Fl_Callback*)grid_cb, (void*)(3));
|
||||
o->align(FL_ALIGN_RIGHT);
|
||||
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
|
||||
}
|
||||
{ Fl_Check_Button* o = guides_toggle = new Fl_Check_Button(27, 115, 108, 25, "Show Guides");
|
||||
{ Fl_Check_Button* o = guides_toggle = new Fl_Check_Button(106, 80, 110, 25, "Show Guides");
|
||||
o->tooltip("Show distance and alignment guides in overlay");
|
||||
o->down_box(FL_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)guides_cb, (void*)(4));
|
||||
}
|
||||
{ Fl_Button* o = new Fl_Button(76, 150, 59, 25, "Close");
|
||||
{ Fl_Button* o = new Fl_Button(205, 205, 60, 25, "Close");
|
||||
o->tooltip("Close this dialog.");
|
||||
o->callback((Fl_Callback*)cb_Close2);
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(26, 10, 70, 25, "Grid:");
|
||||
o->labelfont(1);
|
||||
o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(-1, 115, 97, 25, "Widget Size:");
|
||||
o->labelfont(1);
|
||||
o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Group* o = new Fl_Group(105, 115, 170, 75);
|
||||
{ Fl_Round_Button* o = def_widget_size[0] = new Fl_Round_Button(105, 115, 70, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(8));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(120, 115, 50, 25, "tiny");
|
||||
o->labelsize(8);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Round_Button* o = def_widget_size[1] = new Fl_Round_Button(180, 115, 70, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(11));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(195, 115, 50, 25, "small");
|
||||
o->labelsize(11);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Round_Button* o = def_widget_size[2] = new Fl_Round_Button(105, 140, 70, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(14));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(120, 140, 50, 25, "normal");
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Round_Button* o = def_widget_size[3] = new Fl_Round_Button(180, 140, 90, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(18));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(195, 140, 68, 25, "medium");
|
||||
o->labelsize(18);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Round_Button* o = def_widget_size[4] = new Fl_Round_Button(105, 165, 75, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(24));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(120, 165, 64, 25, "large");
|
||||
o->labelsize(24);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
{ Fl_Round_Button* o = def_widget_size[5] = new Fl_Round_Button(180, 165, 95, 25);
|
||||
o->type(102);
|
||||
o->down_box(FL_ROUND_DOWN_BOX);
|
||||
o->callback((Fl_Callback*)default_widget_size_cb, (void*)(32));
|
||||
}
|
||||
{ Fl_Box* o = new Fl_Box(195, 165, 76, 25, "huge");
|
||||
o->labelsize(32);
|
||||
o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
o->set_non_modal();
|
||||
o->end();
|
||||
}
|
||||
return w;
|
||||
|
@ -53,7 +53,7 @@ Function {make_project_window()} {open
|
||||
callback {project_window->hide();}
|
||||
tooltip {Close this dialog.} xywh {293 156 42 20} labelsize 11
|
||||
}
|
||||
Fl_Tabs {} {open selected
|
||||
Fl_Tabs {} {open
|
||||
xywh {10 10 325 138} selection_color 4 labelsize 11
|
||||
} {
|
||||
Fl_Group {} {
|
||||
@ -144,8 +144,8 @@ decl {void scheme_cb(Fl_Choice *, void *);} {public
|
||||
Function {make_settings_window()} {open
|
||||
} {
|
||||
Fl_Window settings_window {
|
||||
label {GUI Settings} open
|
||||
xywh {326 145 340 225} type Double visible
|
||||
label {GUI Settings}
|
||||
xywh {326 145 340 225} type Double non_modal visible
|
||||
} {
|
||||
Fl_Choice scheme_choice {
|
||||
label {Scheme:}
|
||||
@ -158,15 +158,15 @@ Function {make_settings_window()} {open
|
||||
} {
|
||||
MenuItem {} {
|
||||
label Default
|
||||
xywh {0 0 35 25}
|
||||
xywh {0 0 35 25} labelsize 14
|
||||
}
|
||||
MenuItem {} {
|
||||
label None
|
||||
xywh {0 0 35 25}
|
||||
xywh {0 0 35 25} labelsize 14
|
||||
}
|
||||
MenuItem {} {
|
||||
label Plastic
|
||||
xywh {0 0 35 25}
|
||||
xywh {0 0 35 25} labelsize 14
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
@ -235,7 +235,7 @@ Function {make_shell_window()} {open
|
||||
} {
|
||||
Fl_Window shell_window {
|
||||
label {Shell Command}
|
||||
xywh {588 153 365 125} type Double hide
|
||||
xywh {682 167 365 125} type Double visible
|
||||
} {
|
||||
Fl_Input shell_command_input {
|
||||
label {Command:}
|
||||
@ -297,43 +297,109 @@ Function {make_shell_window()} {open
|
||||
}
|
||||
}
|
||||
|
||||
Function {make_grid_window()} {open
|
||||
Function {make_layout_window()} {open
|
||||
} {
|
||||
Fl_Window grid_window {
|
||||
label Grid
|
||||
xywh {803 141 145 185} type Double hide
|
||||
label {Layout Settings}
|
||||
xywh {676 337 275 240} type Double non_modal visible
|
||||
} {
|
||||
Fl_Input horizontal_input {
|
||||
label {Horizontal:}
|
||||
label x
|
||||
user_data 1 user_data_type long
|
||||
callback grid_cb
|
||||
tooltip {Horizontal grid spacing.} xywh {88 10 47 25} type Int box THIN_DOWN_BOX labelfont 1
|
||||
tooltip {Horizontal grid spacing.} xywh {106 10 50 25} type Int box THIN_DOWN_BOX align 8
|
||||
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
|
||||
}
|
||||
Fl_Input vertical_input {
|
||||
label {Vertical:}
|
||||
label pixels
|
||||
user_data 2 user_data_type long
|
||||
callback grid_cb
|
||||
tooltip {Vertical grid spacing.} xywh {88 45 47 25} type Int box THIN_DOWN_BOX labelfont 1
|
||||
tooltip {Vertical grid spacing.} xywh {166 10 50 25} type Int box THIN_DOWN_BOX align 8
|
||||
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
|
||||
}
|
||||
Fl_Input snap_input {
|
||||
label {Snap:}
|
||||
label {pixel snap}
|
||||
user_data 3 user_data_type long
|
||||
callback grid_cb
|
||||
tooltip {Snap to grid within this many pixels.} xywh {88 80 47 25} type Int box THIN_DOWN_BOX labelfont 1
|
||||
tooltip {Snap to grid within this many pixels.} xywh {106 45 50 25} type Int box THIN_DOWN_BOX align 8
|
||||
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
|
||||
}
|
||||
Fl_Check_Button guides_toggle {
|
||||
label {Show Guides}
|
||||
user_data 4 user_data_type long
|
||||
callback guides_cb
|
||||
tooltip {Show distance and alignment guides in overlay} xywh {27 115 108 25} down_box DOWN_BOX
|
||||
tooltip {Show distance and alignment guides in overlay} xywh {106 80 110 25} down_box DOWN_BOX
|
||||
}
|
||||
Fl_Button {} {
|
||||
label Close
|
||||
callback {grid_window->hide();}
|
||||
tooltip {Close this dialog.} xywh {76 150 59 25}
|
||||
tooltip {Close this dialog.} xywh {205 205 60 25}
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {Grid:}
|
||||
xywh {26 10 70 25} labelfont 1 align 24
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {Widget Size:}
|
||||
xywh {-1 115 97 25} labelfont 1 align 24
|
||||
}
|
||||
Fl_Group {} {open
|
||||
xywh {105 115 170 75}
|
||||
} {
|
||||
Fl_Round_Button {def_widget_size[0]} {
|
||||
user_data 8 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {105 115 70 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label tiny
|
||||
xywh {120 115 50 25} labelsize 8 align 20
|
||||
}
|
||||
Fl_Round_Button {def_widget_size[1]} {
|
||||
user_data 11 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {180 115 70 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label small
|
||||
xywh {195 115 50 25} labelsize 11 align 20
|
||||
}
|
||||
Fl_Round_Button {def_widget_size[2]} {
|
||||
user_data 14 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {105 140 70 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label normal
|
||||
xywh {120 140 50 25} align 20
|
||||
}
|
||||
Fl_Round_Button {def_widget_size[3]} {
|
||||
user_data 18 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {180 140 90 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label medium
|
||||
xywh {195 140 68 25} labelsize 18 align 20
|
||||
}
|
||||
Fl_Round_Button {def_widget_size[4]} {
|
||||
user_data 24 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {105 165 75 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label large
|
||||
xywh {120 165 64 25} labelsize 24 align 20
|
||||
}
|
||||
Fl_Round_Button {def_widget_size[5]} {
|
||||
user_data 32 user_data_type long
|
||||
callback default_widget_size_cb selected
|
||||
xywh {180 165 95 25} type Radio down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
label huge
|
||||
xywh {195 165 76 25} labelsize 32 align 20
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,10 @@ extern Fl_Input *vertical_input;
|
||||
extern Fl_Input *snap_input;
|
||||
extern void guides_cb(Fl_Check_Button*, long);
|
||||
extern Fl_Check_Button *guides_toggle;
|
||||
Fl_Double_Window* make_grid_window();
|
||||
#include <FL/Fl_Round_Button.H>
|
||||
extern void default_widget_size_cb(Fl_Round_Button*, long);
|
||||
extern Fl_Round_Button *def_widget_size[6];
|
||||
Fl_Double_Window* make_layout_window();
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -1623,12 +1623,15 @@ Fl_Menu_Item Main_Menu[] = {
|
||||
{"&Horizontal",0,(Fl_Callback *)align_widget_cb,(void*)40},
|
||||
{"&Vertical",0,(Fl_Callback *)align_widget_cb,(void*)41},
|
||||
{0},
|
||||
{"&Set Widget Size",0,0,0,FL_SUBMENU|FL_MENU_DIVIDER},
|
||||
{"&Tiny",FL_ALT+'1',(Fl_Callback *)widget_size_cb,(void*)8,FL_MENU_RADIO,FL_NORMAL_LABEL,FL_HELVETICA,8},
|
||||
{"&Small",FL_ALT+'2',(Fl_Callback *)widget_size_cb,(void*)11,FL_MENU_RADIO,FL_NORMAL_LABEL,FL_HELVETICA,11},
|
||||
{"&Normal",FL_ALT+'3',(Fl_Callback *)widget_size_cb,(void*)14,FL_MENU_RADIO|FL_MENU_VALUE},
|
||||
{"Set &Widget Size",0,0,0,FL_SUBMENU|FL_MENU_DIVIDER},
|
||||
{"&Tiny",FL_ALT+'1',(Fl_Callback *)widget_size_cb,(void*)8,0,FL_NORMAL_LABEL,FL_HELVETICA,8},
|
||||
{"&Small",FL_ALT+'2',(Fl_Callback *)widget_size_cb,(void*)11,0,FL_NORMAL_LABEL,FL_HELVETICA,11},
|
||||
{"&Normal",FL_ALT+'3',(Fl_Callback *)widget_size_cb,(void*)14,0,FL_NORMAL_LABEL,FL_HELVETICA,14},
|
||||
{"&Medium",FL_ALT+'4',(Fl_Callback *)widget_size_cb,(void*)18,0,FL_NORMAL_LABEL,FL_HELVETICA,18},
|
||||
{"&Large",FL_ALT+'5',(Fl_Callback *)widget_size_cb,(void*)24,0,FL_NORMAL_LABEL,FL_HELVETICA,24},
|
||||
{"&Huge",FL_ALT+'6',(Fl_Callback *)widget_size_cb,(void*)32,0,FL_NORMAL_LABEL,FL_HELVETICA,32},
|
||||
{0},
|
||||
{"&Grid...",FL_CTRL+'g',show_grid_cb},
|
||||
{"&Grid and Size Settings...",FL_CTRL+'g',show_grid_cb},
|
||||
{0},
|
||||
{"&Shell",0,0,0,FL_SUBMENU},
|
||||
{"Execute &Command...",FL_ALT+'x',(Fl_Callback *)show_shell_window},
|
||||
@ -1690,10 +1693,11 @@ void make_main_window() {
|
||||
fluid_prefs.get("gridx", gridx, 5);
|
||||
fluid_prefs.get("gridy", gridy, 5);
|
||||
fluid_prefs.get("show_guides", show_guides, 0);
|
||||
fluid_prefs.get("widget_size", Fl_Widget_Type::default_size, 14);
|
||||
|
||||
load_history();
|
||||
|
||||
make_grid_window();
|
||||
make_layout_window();
|
||||
make_settings_window();
|
||||
make_shell_window();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user