Author Topic: Tidy main context menu  (Read 18545 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Tidy main context menu
« Reply #15 on: September 04, 2012, 03:50:39 pm »
At start up, the framework and each plugin should "register" the menu commands/popup/toolbar items it offers with a unique ID.
Exactly what I meant. Just that the menu's ID is automatically given by the wxMenu item, which is unique in itself. So IMHO there is no need to provide more information than the menu.
« Last Edit: September 04, 2012, 03:52:52 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Tidy main context menu
« Reply #16 on: September 04, 2012, 04:15:52 pm »
At start up, the framework and each plugin should "register" the menu commands/popup/toolbar items it offers with a unique ID.
Exactly what I meant. Just that the menu's ID is automatically given by the wxMenu item, which is unique in itself. So IMHO there is no need to provide more information than the menu.

You need persistent IDs for keybinder (which is why keybinder currently uses the menu label) and to let the user control whether certain items will or will not display. wxIDs like Menu ID's are dynamic, so this is a problem. (Even bigger problem for popup items).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Tidy main context menu
« Reply #17 on: September 04, 2012, 04:56:12 pm »
You need persistent IDs for keybinder (which is why keybinder currently uses the menu label)
The label, maybe in combination with the parent item, is just fine - including for popup menus IMHO. I do it similar in another project of mine.

How would you do persistent ID's otherwise? (Maybe I misunderstood "persistent" - you don't mean globally unique ID's that don't change through sessions, do you?!)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Tidy main context menu
« Reply #18 on: September 04, 2012, 08:47:23 pm »
You need persistent IDs for keybinder (which is why keybinder currently uses the menu label)
The label, maybe in combination with the parent item, is just fine - including for popup menus IMHO. I do it similar in another project of mine.

But it doesn't work for menus that dynamically update their label: e.g. "Find declaration of: 'NULL'"

The simplest thing to do would be to assign a unique XRCID (or equivalently "name" member) to every menu/toolbar/popup item. This would nicely tie in nicely to the wxWidgets event system. This would make it easy to find items in, say, a menu by using wxWindow::FindWindowByName, wxWindow::GetName etc.

EDIT: Turns out this isn't so simple -- I forgot MenuItem's aren't derived from wxWindow...

It might also be possible to have the SDK supply unique names using wxWindow::SetName, but would have to be careful not to break XRC based UI.
« Last Edit: September 04, 2012, 08:59:23 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Tidy main context menu
« Reply #19 on: September 04, 2012, 09:05:11 pm »
How would you do persistent ID's otherwise? (Maybe I misunderstood "persistent" - you don't mean globally unique ID's that don't change through sessions, do you?!)

So what would be so bad about this? To do this stuff we want to do, we need some mapping between a unique ID (that lets us store persistent information about the menu/popup/toolbar items such as keybindings and hidden state) and their run-time id's. We defacto do this right now using the label, but why not just take it a step further and use a unique ID?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Tidy main context menu
« Reply #20 on: September 04, 2012, 10:37:33 pm »
So what would be so bad about this?
I am not saying its bad, I just want to understand your idea.

So - there are many ways, some are:
  • use menu addresses as ID's, not provided by the plugins
  • use menu labels (including parent labels) for ID's, not provided by the plugins
  • use an ID provided by a plugin (might interfere with another)
  • use some kind of global UUID
...for all these cases I am not sure how easy it would be to store e.g. the settings for these ID's so you can manipulate menus across C::B session. The overall goal would be to allow the user to modify the menu items (s)he want to see, any maybe even the order. You brought in dynamic menu labels (like for spell checking) which is something I did not even consider.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Tidy main context menu
« Reply #21 on: September 04, 2012, 11:18:08 pm »
We have lots of them, example: watches, data breakpoints, various find .... of...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Tidy main context menu
« Reply #22 on: September 04, 2012, 11:30:34 pm »
  • use an ID provided by a plugin (might interfere with another)
could use the plugin ID as a prefix: e.g. "codesnippets/AddSnippet"

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Tidy main context menu
« Reply #23 on: September 05, 2012, 01:31:39 am »
Just to let people know, I agree that this registering system is better than the current system, however, I do not yet have any very good ideas of how to create it (nor really quite enough willpower :)).  I am still working on reorganizing the menu using the current system, and will hopefully come up with something a bit more efficient (for use until such a time as someone implements menu registration).

(If anyone here has decided to work on menu registration now, please tell me so I do not waste time with writing code that will immediately become obsolete.)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Tidy main context menu
« Reply #24 on: September 05, 2012, 02:14:25 am »
(If anyone here has decided to work on menu registration now, please tell me so I do not waste time with writing code that will immediately become obsolete.)
Don't waste time if you don't write a menu registration system. If dmoore hasn't implemented such system until I get some free time, I'll do it, as I have some ideas :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Tidy main context menu
« Reply #25 on: September 05, 2012, 03:00:38 am »
(If anyone here has decided to work on menu registration now, please tell me so I do not waste time with writing code that will immediately become obsolete.)
Don't waste time if you don't write a menu registration system. If dmoore hasn't implemented such system until I get some free time, I'll do it, as I have some ideas :)

I don't have any immediate plans, but maybe in a few weeks (say 3) if noone else has started I will take a look. I'll be happy to test others code. It will take a bit of planning and is a reasonably big job because of all the plugins that will need to be refactored.