mousetrap v0.2.0
|
menu model, used to specifc behavior of menu bars and popover menus More...
#include <menu_model.hpp>
Public Types | |
enum | SectionFormat { NORMAL , HORIZONTAL_BUTTONS , HORIZONTAL_BUTTONS_LEFT_TO_RIGHT , HORIZONTAL_BUTTONS_RIGHT_TO_LEFT , CIRCULAR_BUTTONS , INLINE_BUTTONS } |
formatting for sectsion More... | |
Public Member Functions | |
MenuModel () | |
construct as emtpy | |
MenuModel (detail::MenuModelInternal *) | |
construct from internal | |
~MenuModel () | |
destruct | |
NativeObject | get_internal () const override |
expose internal | |
void | add_action (const std::string &label, const Action &action) |
add an action to the model, if the action is stateful, the menu item will contain a check box | |
void | add_widget (const Widget &widget) |
add widget to menu, note that widgets can only be display when they are part of a section or submenu, not if they are in the toplevel sectino | |
void | add_section (const std::string &label, const MenuModel &menu_model, SectionFormat format=NORMAL) |
add a section to a menu. A section is visible in the same scope as the outer menu, it has a title and present its child labels according to the given mousetrap::SectionFormat | |
void | add_submenu (const std::string &label, const MenuModel &menu_model) |
add submenu to a menu. A submenut will appear as a single menu item, when clicked, the menu will open another popup to display the menu items contained in the submenu | |
void | add_icon (const Icon &, const Action &) |
add menu item that is a button with an icon and no label | |
operator NativeObject () const override | |
expose a GObject \for_internal_use_only | |
operator GMenuModel * () const | |
expose as GMenuModel | |
Public Member Functions inherited from mousetrap::SignalEmitter | |
void | set_signal_blocked (const std::string &signal_id, bool b) |
block a signal by id \for_internal_use_only | |
bool | get_signal_blocked (const std::string &signal_id) const |
get whether a signal is currently blocked | |
std::vector< std::string > | get_all_signal_names () |
get list of possible signal ids \for_internal_use_only | |
template<typename Function_t > | |
void | connect_signal (const std::string &signal_id, Function_t *function, void *data=nullptr) |
connect static function to signal, does not work with lambdas \for_internal_use_only | |
void | disconnect_signal (const std::string &signal_id) |
disconnect signal, it may not be invoked until reconnected, if signal is not registered, does nothing. For internal use only | |
virtual | operator NativeObject () const =0 |
expose as NativeObject, this is the GLib instance that signals are emitted on \for_internal_use_only | |
virtual NativeObject | get_internal () const |
expose internally managed object, \for_internal_use_only | |
Public Member Functions inherited from mousetrap::has_signal_items_changed< MenuModel > | |
void | connect_signal_items_changed (Function_t f, Data_t data) |
connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function | |
void | connect_signal_items_changed (Function_t f) |
connect handler, will be invoked when signal is emitted | |
void | set_signal_items_changed_blocked (bool b) |
bool | get_signal_items_changed_blocked () const |
void | emit_signal_items_changed (int32_t position, int32_t n_removed, int32_t n_added) |
invoke signal handler manually | |
void | disconnect_signal_items_changed () |
Protected Member Functions | |
std::map< std::string, GtkWidget * > | get_widgets () const |
get list of registered widgets \for_internal_use_only | |
Protected Member Functions inherited from mousetrap::SignalEmitter | |
SignalEmitter () | |
ctor | |
~SignalEmitter () | |
destructor | |
Protected Member Functions inherited from mousetrap::has_signal_items_changed< MenuModel > | |
has_signal_items_changed (MenuModel *instance) | |
Friends | |
class | MenuBar |
class | PopoverMenu |
Additional Inherited Members | |
Static Public Attributes inherited from mousetrap::has_signal_items_changed< MenuModel > | |
static const char * | signal_id |
glib ID | |
menu model, used to specifc behavior of menu bars and popover menus
signal id | signature | emitted when... |
---|---|---|
items_changed | (MenuModel&, int32_t position, int32_t n_removed, int32_t n_added, (Data_t)) -> void | An item was added or removed from a MenuModel |
formatting for sectsion
void mousetrap::MenuModel::add_action | ( | const std::string & | label, |
const Action & | action | ||
) |
add an action to the model, if the action is stateful, the menu item will contain a check box
label | label to be used |
action | action that triggers when the label is activated |
References mousetrap::Action::get_id(), mousetrap::Action::get_is_stateful(), and mousetrap::Action::get_state().
add menu item that is a button with an icon and no label
icon | icon |
action | acton to trigger |
References mousetrap::Action::get_id().
void mousetrap::MenuModel::add_section | ( | const std::string & | label, |
const MenuModel & | menu_model, | ||
SectionFormat | format = NORMAL |
||
) |
add a section to a menu. A section is visible in the same scope as the outer menu, it has a title and present its child labels according to the given mousetrap::SectionFormat
label | label for the section, appears at the start of the section, similar to a heading |
menu_model | model to use for populating the section items |
format | section format to use |
References CIRCULAR_BUTTONS, HORIZONTAL_BUTTONS, HORIZONTAL_BUTTONS_LEFT_TO_RIGHT, HORIZONTAL_BUTTONS_RIGHT_TO_LEFT, and INLINE_BUTTONS.
void mousetrap::MenuModel::add_submenu | ( | const std::string & | label, |
const MenuModel & | menu_model | ||
) |
add submenu to a menu. A submenut will appear as a single menu item, when clicked, the menu will open another popup to display the menu items contained in the submenu
label | label for the submenu |
menu_model | model to use for populating the submenu items |
References mousetrap::log::critical().
void mousetrap::MenuModel::add_widget | ( | const Widget & | widget | ) |
add widget to menu, note that widgets can only be display when they are part of a section or submenu, not if they are in the toplevel sectino
widget |
|
overridevirtual |
expose internal
Reimplemented from mousetrap::SignalEmitter.
Referenced by mousetrap::MenuBar::MenuBar(), and mousetrap::PopoverMenu::PopoverMenu().
|
protected |
get list of registered widgets \for_internal_use_only
|
overridevirtual |
expose a GObject \for_internal_use_only
Implements mousetrap::SignalEmitter.