|
|
Thanks for response, hope this "feature" to be accepted in some way if not a bug in other person's view.
following test.fl should be sufficient to demonstrate the purpose of this PR:
# data file for the Fltk User Interface Designer (fluid)
version 1.0400
header_name {.h}
code_name {.cxx}
widget_class Test_widget_class {open
xywh {695 274 529 35} box UP_BOX resizable visible position_relative
} {
Fl_Button {} {
label b_1
callback {printf("b_1 clicked\\n");}
xywh {0 0 105 35}
}
Fl_Button {} {
label b_2
callback {printf("b_2 clicked\\n");}
xywh {425 0 105 35}
}
}
Function {main()} {open return_type int
} {
Fl_Window m_window {open
xywh {680 247 565 202} type Double resizable visible
} {
Fl_Box {} {
label Test_widget_class
xywh {10 25 325 55} box UP_FRAME resizable
class Test_widget_class
}
}
code {m_window->show();
return Fl::run();} {}
}
with above test.fl , it's using the Relative option to the customized widget class Test_widget_class , and can be compiled by the fluid without my PR, and generates following GUI:
You can see the x and y offset get aligned to the placeholder of Test_widget_class , however the size w and h doesn't, which make the b_2 can not be clicked.
Now with the same test.fl , but change the Relative to Relative & Rescale as following, you need my patch to change current Fl_Light_Button to a Fl_Choice :
Now generate the code and build/run the GUI, you can see the widget class Test_widget_class get auto-rescaled when put into the placeholder:
PS:
I did try to call Fl_Group::resize(X, Y, W, H) as following in the generated test.cxx code, either in the constructor of the customized widget class, or after the widget instance creation, but neither worked.
// generated by Fast Light User Interface Designer (fluid) version 1.0400
#include "test.h"
void Test_widget_class::cb_b_1_i(Fl_Button*, void*) {
printf("b_1 clicked\n");
}
void Test_widget_class::cb_b_1(Fl_Button* o, void* v) {
((Test_widget_class*)(o->parent()))->cb_b_1_i(o,v);
}
void Test_widget_class::cb_b_2_i(Fl_Button*, void*) {
printf("b_2 clicked\n");
}
void Test_widget_class::cb_b_2(Fl_Button* o, void* v) {
((Test_widget_class*)(o->parent()))->cb_b_2_i(o,v);
}
Test_widget_class::Test_widget_class(int X, int Y, int W, int H, const char *L) :
Fl_Group(0, 0, W, H, L)
{
this->box(FL_UP_BOX);
{ Fl_Button* o = new Fl_Button(0, 0, 105, 35, "b_1");
o->callback((Fl_Callback*)cb_b_1);
} // Fl_Button* o
{ Fl_Button* o = new Fl_Button(425, 0, 105, 35, "b_2");
o->callback((Fl_Callback*)cb_b_2);
} // Fl_Button* o
position(X, Y);
end();
resizable(this);
resize(X, Y, W, H); // <-------------------------------- tried 1, to resize here
}
Fl_Double_Window *m_window=(Fl_Double_Window *)0;
int main() {
{ m_window = new Fl_Double_Window(565, 202, "FLTK-Test_widget_class");
{ Test_widget_class* o = new Test_widget_class(10, 25, 325, 55, "Test_widget_class");
o->box(FL_UP_FRAME);
o->color(FL_BACKGROUND_COLOR);
o->selection_color(FL_BACKGROUND_COLOR);
o->labeltype(FL_NORMAL_LABEL);
o->labelfont(0);
o->labelsize(14);
o->labelcolor(FL_FOREGROUND_COLOR);
o->align(Fl_Align(FL_ALIGN_CENTER));
o->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(o);
o->resize(o->x(), o->y(), o->w(), o->h()); // <------------------------------ tried 2: to resize here
} // Test_widget_class* o
m_window->end();
} // Fl_Double_Window* m_window
m_window->show();
return Fl::run();
}
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/pull/481/c1214219738@github.com>
[ Direct Link to Message ] | |
|
| |