Project

General

Profile

Actions

Feature #1849

closed

WMenu API proporsal

Added by Dmitriy Igrishin almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
04/17/2013
Due date:
% Done:

0%

Estimated time:

Description

Hey,

How about making following WMenu's function members virtual:

addItem(WMenuItem*),

removeItem(WMenuItem*),

addMenu (const std::string &iconPath, const WString &text, WMenu *menu),

setInternalPathEnabled,

internalPathEnabled,

setInternalBasePath,

internalBasePath ?

It can be useful when specializing WMenu to non-trivial internal path

changes handling (for example, with global handler).

Note, that overriding WMenu::internalPathChanged is insufficient for

such purposes.

Actions #1

Updated by Koen Deforche almost 11 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche

Hey Dmitriy,

Good idea to open up some of these methods.

I can see the benefit for addItem() and removeItem(), but what's the use case for internal path related methods? What's an example of a non-trivial internal path handler and why is the virtual internalPathChanged() insufficient?

Regards,

koen

Actions #2

Updated by Dmitriy Igrishin almost 11 years ago

Hey Koen,

Currently, calling setInternalPathEnabled() results in that all WMenu

items participates in the internal path changes. By overriding

setInternalPathEnabled() this behaviour can be overriden as the user see fit.

The first use case that comes to my mind --- the menu item for calling a submenu.

But we discussed this use case in the mailing list in april (see

"WMenu behaviour proporsal." thread) and decided to add virtual bool WMenuItem::hasInternalPath().

Example of overriding setInternalPathEnabled() may looks like this:

void Menu::setInternalBasePath(const std::string& base_path)

{

if (internal_base_path_ == base_path)

return;

internal_base_path_ = terminate(base_path, '/');

for (auto i : items_)

activate(i~~first, i~~>second);

}

void Menu::activate(Menuitem* mi, Ipc_handler& h)

{

const auto path = internal_base_path();

if (!path.empty()) {

mi~~setLink(WLink(WLink::InternalPath, path + mi~~>subpath()));

h = Ipc_handler(path, [=]() { mi->select(); });

}

}

Please, check the "WMenu behaviour proporsal." thread in the mailing list for completeness.

Actions #3

Updated by Koen Deforche over 10 years ago

  • Status changed from Feedback to InProgress
Actions #4

Updated by Koen Deforche over 10 years ago

  • Status changed from InProgress to Resolved
Actions #5

Updated by Koen Deforche over 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF