On 06/17/16 04:21, Manolo wrote:
> > What /is/ the most compatible way to set/clear menu item checkboxes
> across Fl_Menu_Bar and Fl_Sys_Menu_Bar?
>
> The recommended way is, starting from a menu item :
>
> int index = smenubar->find_index(item);
> // to set:
> smenubar->mode(index, smenubar->mode(index) | FL_MENU_VALUE);
> // to clear:
> smenubar->mode(index, smenubar->mode(index) & ~FL_MENU_VALUE);
Great! Will add some docs to that effect.
That's the fix I ended up using.. I'd never used mode() before,
or even noticed it in the API.
> I'm guessing 'rank' means "index"?
> If so, I suggest we change the docs (and code) to refer to 'index'
> for consistency,
>
> Yes, please.
Will do..
> > Is there maybe a way we can have an apply() or sync() method
> in Fl_Sys_Menu_Bar (or some such named method) that can apply any changes
> made to the menu()[] array so that they're reflected in the GUI?
> This would make it easier than having to retool apps from using the item techniques.
>
> This method exists: Fl_Sys_Menu_Bar::update()
> but, unfortunately it is protected.
> I think we should make it public in 1.4. It can't be done in 1.3.4 because it would break the ABI.
If a few others sign off on this idea of making it public,
maybe I can add some ABI guards to 1.3.4 so it can be accessed optionally.
And maybe you can add it as public to the 1.4 branch?
(I haven't been keeping an eye on the 1.4 branch, but if you don't have time,
I can check it out and make the mod)
> With this, one could write:
>
> item->set(); (or item->clear();)
> smenubar->update();
Right, that sounds useful, as I'm thinking that could be really useful
for old code that directly manipulates the items..
> With 1.3.x it is possible (but ugly) to fool the protection:
>
> class fool: public Fl_Sys_Menu_Bar {
> public:
> void update() {Fl_Sys_Menu_Bar::update();}
> };
>
> ((fool*)smenubar)->update();
Ah, interesting technique to force a method from protected -> public.
I kind of had the reverse problem during debugging; for me the mode()
technique wasn't working, until I realized I was passing the sys menubar
around as an Fl_Menu_Bar pointer instead, and was getting the wrong mode() method..!
> > It might not be a bad idea to put some warnings in the Fl_Menu_Item methods
> about which calls aren't compatible with Fl_Sys_Menu_Bar, or maybe \see also
> references to Fl_Sys_Menu_Bar with the above recommended doc warnings.
>
> My vision would be to first set the update() method public, and then to explain in
> class Fl_Sys_Menu_Bar that all operations applied to menu items should be followed by
> a call to the update() menu method to be visible in the interface.
Right, sounds reasonable.
I can add mention of this to the existing caveats for Fl_Sys_Menu_Bar.
Going to wait for one of the other devs to weigh in on all the above
before I make any changes; often Ian/Albrecht/Matt/etc come up with some
interesting insights..