Added the first implementation of "live mode" to Fluid. This is incomplete and mostly untested, but it seems to be a great help to figure out the darned wonderful resize behavior. I apologize for typos, no time to compile on Linux. Please feed back.
More details in the developers mailing list. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4407 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
9ac6934696
commit
8461a157e4
@ -219,6 +219,49 @@ void Fl_Group_Type::move_child(Fl_Type* cc, Fl_Type* before) {
|
||||
o->redraw();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// live mode support
|
||||
|
||||
Fl_Widget *Fl_Group_Type::enter_live_mode(int top) {
|
||||
Fl_Group *grp = new Fl_Group(o->x(), o->y(), o->w(), o->h());
|
||||
live_widget = grp;
|
||||
if (live_widget) {
|
||||
copy_properties();
|
||||
Fl_Type *n;
|
||||
for (n = next; n && n->level > level; n = n->next) {
|
||||
if (n->level == level+1)
|
||||
n->enter_live_mode();
|
||||
}
|
||||
grp->end();
|
||||
}
|
||||
return live_widget;
|
||||
}
|
||||
|
||||
Fl_Widget *Fl_Tabs_Type::enter_live_mode(int top) {
|
||||
Fl_Tabs *grp = new Fl_Tabs(o->x(), o->y(), o->w(), o->h());
|
||||
live_widget = grp;
|
||||
if (live_widget) {
|
||||
copy_properties();
|
||||
Fl_Type *n;
|
||||
for (n = next; n && n->level > level; n = n->next) {
|
||||
if (n->level == level+1)
|
||||
n->enter_live_mode();
|
||||
}
|
||||
grp->end();
|
||||
}
|
||||
return live_widget;
|
||||
}
|
||||
|
||||
void Fl_Group_Type::leave_live_mode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* copy all properties from the edit widget to the live widget
|
||||
*/
|
||||
void Fl_Group_Type::copy_properties() {
|
||||
Fl_Widget_Type::copy_properties();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// some other group subclasses that fluid does not treat specially:
|
||||
|
||||
|
||||
@ -827,6 +827,28 @@ void Fl_Type::read_property(const char *c) {
|
||||
|
||||
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
|
||||
|
||||
/**
|
||||
* Build widgets and dataset needed in live mode.
|
||||
* \return a widget pointer that the live mode initiator can 'show()'
|
||||
* \see leave_live_mode()
|
||||
*/
|
||||
Fl_Widget *Fl_Type::enter_live_mode(int top) {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release all resources created when enetring live mode.
|
||||
* \see enter_live_mode()
|
||||
*/
|
||||
void Fl_Type::leave_live_mode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy all needed properties for this tye into the live object.
|
||||
*/
|
||||
void Fl_Type::copy_properties() {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
||||
@ -115,6 +115,11 @@ public:
|
||||
virtual void write_code1(); // code and .h before children
|
||||
virtual void write_code2(); // code and .h after children
|
||||
|
||||
// live mode
|
||||
virtual Fl_Widget *enter_live_mode(int top=0); // build wdgets needed for live mode
|
||||
virtual void leave_live_mode(); // free allocated resources
|
||||
virtual void copy_properties(); // copy properties from this type into a potetial live object
|
||||
|
||||
// get message number for I18N
|
||||
int msgnum();
|
||||
|
||||
@ -284,6 +289,7 @@ protected:
|
||||
void write_block_close();
|
||||
void write_code2();
|
||||
void write_color(const char*, Fl_Color);
|
||||
Fl_Widget *live_widget;
|
||||
|
||||
public:
|
||||
static int default_size;
|
||||
@ -326,6 +332,10 @@ public:
|
||||
virtual void read_property(const char *);
|
||||
virtual int read_fdesign(const char*, const char*);
|
||||
|
||||
virtual Fl_Widget *enter_live_mode(int top=0);
|
||||
virtual void leave_live_mode();
|
||||
virtual void copy_properties();
|
||||
|
||||
virtual void ideal_size(int &w, int &h);
|
||||
virtual void ideal_spacing(int &x, int &y);
|
||||
|
||||
@ -373,6 +383,10 @@ public:
|
||||
int is_parent() const {return 1;}
|
||||
int is_group() const {return 1;}
|
||||
int pixmapID() { return 6; }
|
||||
|
||||
virtual Fl_Widget *enter_live_mode(int top=0);
|
||||
virtual void leave_live_mode();
|
||||
virtual void copy_properties();
|
||||
};
|
||||
|
||||
extern const char pack_type_name[];
|
||||
@ -384,6 +398,7 @@ public:
|
||||
virtual const char *type_name() {return pack_type_name;}
|
||||
Fl_Widget_Type *_make() {return new Fl_Pack_Type();}
|
||||
int pixmapID() { return 22; }
|
||||
void copy_properties();
|
||||
};
|
||||
|
||||
extern const char tabs_type_name[];
|
||||
@ -403,6 +418,7 @@ public:
|
||||
void add_child(Fl_Type*, Fl_Type*);
|
||||
void remove_child(Fl_Type*);
|
||||
int pixmapID() { return 13; }
|
||||
Fl_Widget *enter_live_mode(int top=0);
|
||||
};
|
||||
|
||||
extern const char scroll_type_name[];
|
||||
@ -488,6 +504,10 @@ public:
|
||||
int is_parent() const {return 1;}
|
||||
int is_group() const {return 1;}
|
||||
int is_window() const {return 1;}
|
||||
|
||||
Fl_Widget *enter_live_mode(int top=0);
|
||||
void leave_live_mode();
|
||||
void copy_properties();
|
||||
};
|
||||
|
||||
class Fl_Widget_Class_Type : private Fl_Window_Type {
|
||||
|
||||
@ -1357,12 +1357,12 @@ void step_cb(Fl_Value_Input* i, void* v) {
|
||||
double n = i->value();
|
||||
for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
|
||||
if (o->selected && o->is_widget()) {
|
||||
Fl_Widget_Type* q = (Fl_Widget_Type*)o;
|
||||
if (q->is_valuator()) {
|
||||
((Fl_Valuator*)(q->o))->step(n);
|
||||
q->o->redraw();
|
||||
mod = 1;
|
||||
}
|
||||
Fl_Widget_Type* q = (Fl_Widget_Type*)o;
|
||||
if (q->is_valuator()) {
|
||||
((Fl_Valuator*)(q->o))->step(n);
|
||||
q->o->redraw();
|
||||
mod = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mod) set_modflag(1);
|
||||
@ -1424,12 +1424,12 @@ void subtype_cb(Fl_Choice* i, void* v) {
|
||||
Fl_Menu_Item* m = current_widget->subtypes();
|
||||
for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
|
||||
if (o->selected && o->is_widget()) {
|
||||
Fl_Widget_Type* q = (Fl_Widget_Type*)o;
|
||||
if (q->subtypes()==m) {
|
||||
q->o->type(n);
|
||||
q->redraw();
|
||||
mod = 1;
|
||||
}
|
||||
Fl_Widget_Type* q = (Fl_Widget_Type*)o;
|
||||
if (q->subtypes()==m) {
|
||||
q->o->type(n);
|
||||
q->redraw();
|
||||
mod = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mod) set_modflag(1);
|
||||
@ -1483,6 +1483,59 @@ void overlay_cb(Fl_Button*o,void *v) {
|
||||
toggle_overlays(o,v);
|
||||
}
|
||||
|
||||
void leave_live_mode_cb(Fl_Widget*, void*);
|
||||
|
||||
void live_mode_cb(Fl_Button*o,void *v) {
|
||||
/// \todo live mode should end gracefully when the application quits
|
||||
/// or when the user closes the live widget
|
||||
static Fl_Type *live_type = 0L;
|
||||
static Fl_Widget *live_widget = 0L;
|
||||
static Fl_Window *live_window = 0L;
|
||||
// if 'o' is 0, we must quit live mode
|
||||
if (!o) {
|
||||
o = wLiveMode;
|
||||
o->value(0);
|
||||
}
|
||||
if (o->value()) {
|
||||
if (numselected == 1) {
|
||||
live_widget = current_widget->enter_live_mode(1);
|
||||
if (live_widget) {
|
||||
live_type = current_widget;
|
||||
Fl_Group::current(0);
|
||||
int w = live_widget->w();
|
||||
int h = live_widget->h();
|
||||
live_window = new Fl_Window(w+20, h+55, "Fluid Live Mode Widget");
|
||||
live_window->box(FL_FLAT_BOX);
|
||||
live_window->color(FL_GREEN);
|
||||
Fl_Group *rsz = new Fl_Group(0, h+20, 130, 35);
|
||||
rsz->box(FL_NO_BOX);
|
||||
Fl_Box *rsz_dummy = new Fl_Box(110, h+20, 1, 25);
|
||||
rsz_dummy->box(FL_NO_BOX);
|
||||
rsz->resizable(rsz_dummy);
|
||||
Fl_Button *btn = new Fl_Button(10, h+20, 100, 25, "Exit Live Mode");
|
||||
btn->labelsize(12);
|
||||
btn->callback(leave_live_mode_cb);
|
||||
live_widget->position(10, 10);
|
||||
live_window->add(live_widget);
|
||||
live_window->resizable(live_widget);
|
||||
live_window->set_modal(); // block all other UI
|
||||
live_window->callback(leave_live_mode_cb);
|
||||
live_window->show();
|
||||
} else o->value(0);
|
||||
} else o->value(0);
|
||||
} else {
|
||||
if (live_type)
|
||||
live_type->leave_live_mode();
|
||||
if (live_window) {
|
||||
live_window->hide();
|
||||
Fl::delete_widget(live_window);
|
||||
}
|
||||
live_type = 0L;
|
||||
live_widget = 0L;
|
||||
live_window = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
// update the panel according to current widget set:
|
||||
static void load_panel() {
|
||||
if (!the_panel) return;
|
||||
@ -2238,6 +2291,87 @@ int Fl_Widget_Type::read_fdesign(const char* propname, const char* value) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void leave_live_mode_cb(Fl_Widget*, void*) {
|
||||
live_mode_cb(0, 0);
|
||||
}
|
||||
|
||||
Fl_Widget *Fl_Widget_Type::enter_live_mode(int top) {
|
||||
live_widget = widget(o->x(), o->y(), o->w(), o->h());
|
||||
if (live_widget)
|
||||
copy_properties();
|
||||
return live_widget;
|
||||
}
|
||||
|
||||
void Fl_Widget_Type::leave_live_mode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* copy all properties from the edit widget to the live widget
|
||||
*/
|
||||
void Fl_Widget_Type::copy_properties() {
|
||||
if (!live_widget)
|
||||
return;
|
||||
|
||||
Fl_Widget *w = live_widget;
|
||||
w->label(o->label());
|
||||
w->tooltip(o->tooltip());
|
||||
w->type(o->type());
|
||||
w->box(o->box());
|
||||
/* move this into the derived _type classes
|
||||
if (is_button()) {
|
||||
Fl_Button* d = (Fl_Button*)live_widget, *s = (Fl_Button*)o;
|
||||
d->down_box(s->down_box());
|
||||
d->shortcut(s->shortcut());
|
||||
d->value(s->value());
|
||||
} else if (!strcmp(type_name(), "Fl_Input_Choice")) {
|
||||
Fl_Input_Choice* d = (Fl_Input_Choice*)live_widget, *s = (Fl_Input_Choice*)o;
|
||||
d->down_box(s->down_box());
|
||||
} else if (is_menu_button()) {
|
||||
Fl_Menu_* d = (Fl_Menu_*)live_widget, *s = (Fl_Menu_*)o;
|
||||
d->down_box(s->down_box());
|
||||
}
|
||||
*/
|
||||
w->color(o->color());
|
||||
w->selection_color(o->selection_color());
|
||||
w->labeltype(o->labeltype());
|
||||
w->labelfont(o->labelfont());
|
||||
w->labelsize(o->labelsize());
|
||||
w->labelcolor(o->labelcolor());
|
||||
w->align(o->align());
|
||||
/* move this into the derived _type classes
|
||||
if (is_valuator()) {
|
||||
Fl_Valuator* d = (Fl_Valuator*)live_widget, *s = (Fl_Valuator*)o;
|
||||
d->minimum(s->minimum());
|
||||
d->maximum(s->maximum());
|
||||
d->step(s->step());
|
||||
d->value(s->value());
|
||||
//if (is_valuator()==2) {
|
||||
// double x = ((Fl_Slider*)v)->slider_size();
|
||||
// double y = ((Fl_Slider*)f)->slider_size();
|
||||
// if (x != y) write_string("slider_size %g", x);
|
||||
//}
|
||||
}
|
||||
/* move this into the derived _type classes
|
||||
{Fl_Font ff; int fs; Fl_Color fc; if (textstuff(4,ff,fs,fc)) {
|
||||
Fl_Font f; int s; Fl_Color c; textstuff(0,f,s,c);
|
||||
if (f != ff) write_string("textfont %d", f);
|
||||
if (s != fs) write_string("textsize %d", s);
|
||||
if (c != fc) write_string("textcolor %d", c);
|
||||
}}*/
|
||||
/// hmmm: if (!o->visible()) write_string("hide");
|
||||
if (!o->active())
|
||||
w->deactivate();
|
||||
if (resizable() && w->parent())
|
||||
w->parent()->resizable(o);
|
||||
}
|
||||
|
||||
void Fl_Pack_Type::copy_properties()
|
||||
{
|
||||
Fl_Group_Type::copy_properties();
|
||||
Fl_Pack *d = (Fl_Pack*)live_widget, *s =(Fl_Pack*)o;
|
||||
d->spacing(s->spacing());
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
||||
@ -1388,6 +1388,35 @@ void Fl_Widget_Class_Type::write_code2() {
|
||||
write_c("}\n");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// live mode support
|
||||
|
||||
Fl_Widget *Fl_Window_Type::enter_live_mode(int top) {
|
||||
Fl_Window *win = new Fl_Window(o->x(), o->y(), o->w(), o->h());
|
||||
live_widget = win;
|
||||
if (live_widget) {
|
||||
copy_properties();
|
||||
Fl_Type *n;
|
||||
for (n = next; n && n->level > level; n = n->next) {
|
||||
if (n->level == level+1)
|
||||
n->enter_live_mode();
|
||||
}
|
||||
win->end();
|
||||
}
|
||||
return live_widget;
|
||||
}
|
||||
|
||||
void Fl_Window_Type::leave_live_mode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* copy all properties from the edit widget to the live widget
|
||||
*/
|
||||
void Fl_Window_Type::copy_properties() {
|
||||
Fl_Widget_Type::copy_properties();
|
||||
/// \todo copy resizing constraints over
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
||||
@ -43,18 +43,20 @@ Fl_Value_Input *widget_h_input=(Fl_Value_Input *)0;
|
||||
|
||||
Fl_Input *v_input[4]={(Fl_Input *)0};
|
||||
|
||||
Fl_Button *wLiveMode=(Fl_Button *)0;
|
||||
|
||||
Fl_Double_Window* make_widget_panel() {
|
||||
Fl_Double_Window* w;
|
||||
{ Fl_Double_Window* o = new Fl_Double_Window(410, 355);
|
||||
w = o;
|
||||
o->labelsize(11);
|
||||
w->hotspot(o);
|
||||
{ Fl_Tabs* o = new Fl_Tabs(5, 5, 400, 310);
|
||||
{ Fl_Tabs* o = new Fl_Tabs(3, 5, 402, 310);
|
||||
o->selection_color((Fl_Color)4);
|
||||
o->labelsize(11);
|
||||
o->callback((Fl_Callback*)cb_);
|
||||
o->when(FL_WHEN_NEVER);
|
||||
{ Fl_Group* o = new Fl_Group(5, 25, 400, 290, "GUI");
|
||||
{ Fl_Group* o = new Fl_Group(3, 25, 402, 290, "GUI");
|
||||
o->labelsize(11);
|
||||
o->callback((Fl_Callback*)propagate_load);
|
||||
o->when(FL_WHEN_NEVER);
|
||||
@ -385,7 +387,7 @@ Fl_Double_Window* make_widget_panel() {
|
||||
o->end();
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
{ Fl_Group* o = new Fl_Group(5, 25, 400, 290, "Style");
|
||||
{ Fl_Group* o = new Fl_Group(3, 25, 402, 290, "Style");
|
||||
o->labelsize(11);
|
||||
o->callback((Fl_Callback*)propagate_load);
|
||||
o->when(FL_WHEN_NEVER);
|
||||
@ -655,7 +657,7 @@ Fl_Double_Window* make_widget_panel() {
|
||||
o->end();
|
||||
Fl_Group::current()->resizable(o);
|
||||
}
|
||||
{ Fl_Group* o = new Fl_Group(8, 321, 391, 19);
|
||||
{ Fl_Group* o = new Fl_Group(8, 321, 391, 24);
|
||||
o->labelsize(11);
|
||||
{ Fl_Box* o = new Fl_Box(8, 325, 20, 20);
|
||||
o->labelsize(11);
|
||||
@ -667,7 +669,7 @@ Fl_Double_Window* make_widget_panel() {
|
||||
o->labelcolor((Fl_Color)1);
|
||||
o->callback((Fl_Callback*)overlay_cb);
|
||||
}
|
||||
{ Fl_Button* o = new Fl_Button(159, 325, 80, 20, "Revert");
|
||||
{ Fl_Button* o = new Fl_Button(80, 325, 80, 20, "Revert");
|
||||
o->labelsize(11);
|
||||
o->callback((Fl_Callback*)revert_cb);
|
||||
o->hide();
|
||||
@ -681,6 +683,13 @@ Fl_Double_Window* make_widget_panel() {
|
||||
o->callback((Fl_Callback*)cancel_cb);
|
||||
o->hide();
|
||||
}
|
||||
{ Fl_Button* o = wLiveMode = new Fl_Button(145, 325, 84, 20, "LIve &Mode");
|
||||
o->tooltip("Hide the widget overlay box.");
|
||||
o->type(1);
|
||||
o->labelsize(11);
|
||||
o->labelcolor(FL_FOREGROUND_COLOR);
|
||||
o->callback((Fl_Callback*)live_mode_cb);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
o->size_range(o->w(), o->h());
|
||||
|
||||
@ -28,7 +28,7 @@ comment {//
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
} {selected in_source in_header
|
||||
} {in_source in_header
|
||||
}
|
||||
|
||||
Function {make_widget_panel()} {open
|
||||
@ -39,12 +39,12 @@ Function {make_widget_panel()} {open
|
||||
} {
|
||||
Fl_Tabs {} {
|
||||
callback {propagate_load((Fl_Group *)o,v);} open
|
||||
xywh {5 5 400 310} selection_color 4 labelsize 11 when 0 resizable
|
||||
xywh {3 5 402 310} selection_color 4 labelsize 11 when 0 resizable
|
||||
} {
|
||||
Fl_Group {} {
|
||||
label GUI
|
||||
callback propagate_load
|
||||
xywh {5 25 400 290} labelsize 11 when 0 resizable
|
||||
xywh {3 25 402 290} labelsize 11 when 0 resizable
|
||||
} {
|
||||
Fl_Group {} {
|
||||
callback propagate_load
|
||||
@ -290,7 +290,7 @@ Function {make_widget_panel()} {open
|
||||
Fl_Group {} {
|
||||
label Style
|
||||
callback propagate_load
|
||||
xywh {5 25 400 290} labelsize 11 when 0 hide
|
||||
xywh {3 25 402 290} labelsize 11 when 0 hide
|
||||
} {
|
||||
Fl_Group {} {
|
||||
callback propagate_load
|
||||
@ -489,8 +489,8 @@ Function {make_widget_panel()} {open
|
||||
}
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
xywh {8 321 391 19} labelsize 11
|
||||
Fl_Group {} {selected
|
||||
xywh {8 321 391 24} labelsize 11
|
||||
} {
|
||||
Fl_Box {} {
|
||||
xywh {8 325 20 20} labelsize 11 resizable
|
||||
@ -503,7 +503,7 @@ Function {make_widget_panel()} {open
|
||||
Fl_Button {} {
|
||||
label Revert
|
||||
callback revert_cb
|
||||
xywh {159 325 80 20} labelsize 11 hide
|
||||
xywh {80 325 80 20} labelsize 11 hide
|
||||
}
|
||||
Fl_Return_Button {} {
|
||||
label Close
|
||||
@ -515,6 +515,11 @@ Function {make_widget_panel()} {open
|
||||
callback cancel_cb
|
||||
xywh {329 325 70 20} labelsize 11 hide
|
||||
}
|
||||
Fl_Button wLiveMode {
|
||||
label {LIve &Mode}
|
||||
callback live_mode_cb
|
||||
tooltip {Hide the widget overlay box.} xywh {145 325 84 20} type Toggle labelsize 11 labelcolor 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,6 +102,8 @@ extern void revert_cb(Fl_Button*, void*);
|
||||
#include <FL/Fl_Return_Button.H>
|
||||
extern void ok_cb(Fl_Return_Button*, void*);
|
||||
extern void cancel_cb(Fl_Button*, void*);
|
||||
extern void live_mode_cb(Fl_Button*, void*);
|
||||
extern Fl_Button *wLiveMode;
|
||||
Fl_Double_Window* make_widget_panel();
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user