For you dw people... I am working on getting ComplexButton to work (image inputs), and it would segfault when I'd close the bw. In FltkComplexButtonResource::createNewWidget, the button's child is a view. When the button is destroyed, since the button is a Group, its children get destroyed. Later on, the layout is being destroyed, and it deletes TopLevel. The toplevel widget destructor calls layout->removeWidget(), which tries to iterate through the views. To make the problem go away, I added: fltkcomplexbutton.hh: ~ComplexButton() {remove_all();} but I don't know any of this code well enough to know what _should_ be going on.
On Thu, Mar 20, 2008 at 03:12:15PM +0000, place wrote:
For you dw people... I am working on getting ComplexButton to work (image inputs),
Great!
and it would segfault when I'd close the bw.
In FltkComplexButtonResource::createNewWidget, the button's child is a view. When the button is destroyed, since the button is a Group, its children get destroyed. Later on, the layout is being destroyed, and it deletes TopLevel. The toplevel widget destructor calls layout->removeWidget(), which tries to iterate through the views.
Ok I'm just trying to understand the ComplexButton button stuff - rather good class name btw :-) Why is there a view as child of the button? What is this view supposed to display? Anyway, first I'd suggest: diff -r f1f343e2c024 dw/fltkui.cc --- a/dw/fltkui.cc Tue Mar 18 18:05:51 2008 +0100 +++ b/dw/fltkui.cc Wed Mar 26 16:57:13 2008 +0100 @@ -423,13 +423,15 @@ if (!relief) button->box(::fltk::FLAT_BOX); - button->begin (); lastFlatView = new FltkFlatView (allocation->x + reliefXThickness (), allocation->y + reliefYThickness (), allocation->width - 2 * reliefXThickness (), allocation->ascent + allocation->descent - 2 * reliefYThickness ()); + + button->add (lastFlatView); + if (layout) layout->attachView (lastFlatView); return button; because this begin () / end () stuff is rather ugly, especially if the matching end () is missing.
To make the problem go away, I added: fltkcomplexbutton.hh: ~ComplexButton() {remove_all();} but I don't know any of this code well enough to know what _should_ be going on.
Sounds reasonable, but I'd really like to understand that ComplexButton stuff first. Is there something in doc/ I did not see? How did you know it is supposed to be used for image inputs? Cheers, Johannes
Johannes wrote:
place wrote:
In FltkComplexButtonResource::createNewWidget, the button's child is a view. When the button is destroyed, since the button is a Group, its children get destroyed. Later on, the layout is being destroyed, and it deletes TopLevel. The toplevel widget destructor calls layout->removeWidget(), which tries to iterate through the views.
Ok I'm just trying to understand the ComplexButton button stuff - rather good class name btw :-) Why is there a view as child of the button? What is this view supposed to display?
I have no idea whether it's necessary. Maybe the layout in the button doesn't get shown otherwise?
Anyway, first I'd suggest:
diff -r f1f343e2c024 dw/fltkui.cc --- a/dw/fltkui.cc Tue Mar 18 18:05:51 2008 +0100 +++ b/dw/fltkui.cc Wed Mar 26 16:57:13 2008 +0100 @@ -423,13 +423,15 @@ if (!relief) button->box(::fltk::FLAT_BOX);
- button->begin (); lastFlatView = new FltkFlatView (allocation->x + reliefXThickness (), allocation->y + reliefYThickness (), allocation->width - 2 * reliefXThickness (), allocation->ascent + allocation->descent - 2 * reliefYThickness ()); + + button->add (lastFlatView); + if (layout) layout->attachView (lastFlatView); return button;
because this begin () / end () stuff is rather ugly, especially if the matching end () is missing.
Yes! At first, without the end(), I assumed the begin() was extraneous.
Sounds reasonable, but I'd really like to understand that ComplexButton stuff first. Is there something in doc/ I did not see? How did you know it is supposed to be used for image inputs?
In dw/ui.hh, it says * <tr><td>image <td>dw::core::ui::ComplexButtonResource * <td>dw::core::ui::ResourceFactory::createComplexButtonResource, * width a dw::Image inside and relief = false. PS I subscribed to the list under a new address, but my first msg is still awaiting moderator approval, so the old address lives on a bit longer...
On Wed, Mar 26, 2008 at 04:42:16PM +0000, place wrote:
Johannes wrote:
place wrote:
In FltkComplexButtonResource::createNewWidget, the button's child is a view. When the button is destroyed, since the button is a Group, its children get destroyed. Later on, the layout is being destroyed, and it deletes TopLevel. The toplevel widget destructor calls layout->removeWidget(), which tries to iterate through the views.
Ok I'm just trying to understand the ComplexButton button stuff - rather good class name btw :-) Why is there a view as child of the button? What is this view supposed to display?
I have no idea whether it's necessary. Maybe the layout in the button doesn't get shown otherwise?
Anyway, first I'd suggest:
diff -r f1f343e2c024 dw/fltkui.cc --- a/dw/fltkui.cc Tue Mar 18 18:05:51 2008 +0100 +++ b/dw/fltkui.cc Wed Mar 26 16:57:13 2008 +0100 @@ -423,13 +423,15 @@ if (!relief) button->box(::fltk::FLAT_BOX);
- button->begin (); lastFlatView = new FltkFlatView (allocation->x + reliefXThickness (), allocation->y + reliefYThickness (), allocation->width - 2 * reliefXThickness (), allocation->ascent + allocation->descent - 2 * reliefYThickness ()); + + button->add (lastFlatView); + if (layout) layout->attachView (lastFlatView); return button;
because this begin () / end () stuff is rather ugly, especially if the matching end () is missing.
Yes! At first, without the end(), I assumed the begin() was extraneous.
Sounds reasonable, but I'd really like to understand that ComplexButton stuff first. Is there something in doc/ I did not see? How did you know it is supposed to be used for image inputs?
In dw/ui.hh, it says
* <tr><td>image <td>dw::core::ui::ComplexButtonResource * <td>dw::core::ui::ResourceFactory::createComplexButtonResource, * width a dw::Image inside and relief = false.
Ahh, now I understand. layout is a new layout specific to the button. It is created in ComplexButton::init (). So the purpose of ComplexButton is to create buttons that can have arbitrary HTML rendered on them. I wonder if we really need to duplicate the button code from fltk for this. For now I think your fix is good. Perhaps we can make the whole stuff simpler in the future. Did you already manage to add an dw::Image to a ComplexButton? Cheers, Johannes
Johannes wrote:
Ahh, now I understand. layout is a new layout specific to the button. It is created in ComplexButton::init (). So the purpose of ComplexButton is to create buttons that can have arbitrary HTML rendered on them.
I wonder if we really need to duplicate the button code from fltk for this.
For now I think your fix is good. Perhaps we can make the whole stuff simpler in the future.
Did you already manage to add an dw::Image to a ComplexButton?
Yes. The two problems that remained were: Small images were only visible when the control panel was not visible. The recurring problem of dw's idea of offsets being different than that of fltk. And big images were usually (but not always -- some timing thing) offset inside their buttons by an amount that seemed to depend on the size of the alt text.
participants (2)
-
Johannes.Hofmann@gmx.de
-
place@gobigwest.com