Re: [fltk/fltk] Fluid: enhancement for widget_class for extra option: reposition-and-rescale (PR #481)
Etorth
Aug 13, 2022
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:
with above test.fl, it's using the Relative option to the customized widget class Test_widget_class, and can be compiled by the fluidwithout 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"voidTest_widget_class::cb_b_1_i(Fl_Button*, void*) {
printf("b_1 clicked\n");
}
voidTest_widget_class::cb_b_1(Fl_Button* o, void* v) {
((Test_widget_class*)(o->parent()))->cb_b_1_i(o,v);
}
voidTest_widget_class::cb_b_2_i(Fl_Button*, void*) {
printf("b_2 clicked\n");
}
voidTest_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, constchar *L) :
Fl_Group(0, 0, W, H, L)
{
this->box(FL_UP_BOX);
{ Fl_Button* o = newFl_Button(0, 0, 105, 35, "b_1");
o->callback((Fl_Callback*)cb_b_1);
} // Fl_Button* o
{ Fl_Button* o = newFl_Button(425, 0, 105, 35, "b_2");
o->callback((Fl_Callback*)cb_b_2);
} // Fl_Button* oposition(X, Y);
end();
resizable(this);
resize(X, Y, W, H); // <-------------------------------- tried 1, to resize here
}
Fl_Double_Window *m_window=(Fl_Double_Window *)0;
intmain() {
{ m_window = newFl_Double_Window(565, 202, "FLTK-Test_widget_class");
{ Test_widget_class* o = newTest_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();
returnFl::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>
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.