Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Widget::PopoverMenu Class Referencefinal

A replacement for GTK3ʼs Gtk::Menu, as removed in GTK4. More...

#include <popover-menu.h>

Inheritance diagram for Inkscape::UI::Widget::PopoverMenu:

Public Member Functions

 PopoverMenu (Gtk::PositionType position, bool has_arrow=false)
 Create popover with CSS classes .menu & .popover-menu, positioned as requested.
 
void attach (Gtk::Widget &child, int left_attach, int right_attach, int top_attach, int bottom_attach)
 Add child at pos as per Gtk::Menu::attach()
 
void append (Gtk::Widget &child)
 Add new row containing child, at start/top.
 
void prepend (Gtk::Widget &child)
 Add new row containing child, at end/bottom.
 
void remove (Gtk::Widget &child)
 Remove added child.
 
void remove_all ()
 Remove all items.
 
void append_section_label (Glib::ustring const &markup)
 Append label, w/ markup & the .dim-label style class.
 
void append_separator ()
 Append a horizontal separator.
 
bool activate (Glib::ustring const &search)
 Find and active from string.
 
void popup_at (Gtk::Widget &widget, int x_offset=0, int y_offset=0)
 Replace Gtk::Menu::popup_at_pointer.
 
void popup_at_center (Gtk::Widget &widget)
 As popup_at() but point to center of widget.
 
std::vector< Gtk::Widget * > const & get_items ()
 Get the list of menu items (children of our grid) Take copy, not reference, if you iterate & change items!
 
void get_children () const =delete
 This would give not the items, rather an internal Grid. Use get_items().
 
void get_children ()=delete
 This would give not the items, rather an internal Grid. Use get_items().
 

Private Member Functions

void check_child_invariants ()
 
void set_scrolled_window_size ()
 
void unset_items_focus_hover (Gtk::Widget *except_active)
 

Private Attributes

Gtk::ScrolledWindow & _scrolled_window
 
PopoverMenuGrid & _grid
 
std::vector< Gtk::Widget * > _items
 
Gtk::Label * _active_search = nullptr
 

Friends

class PopoverMenuItem
 
class CompletionPopup
 

Detailed Description

A replacement for GTK3ʼs Gtk::Menu, as removed in GTK4.

Aim is to be a minimal but mostly “drop-in” replacement for Menus, including grid and activation functionality.

Definition at line 41 of file popover-menu.h.

Constructor & Destructor Documentation

◆ PopoverMenu()

Inkscape::UI::Widget::PopoverMenu::PopoverMenu ( Gtk::PositionType  position,
bool  has_arrow = false 
)

Create popover with CSS classes .menu & .popover-menu, positioned as requested.

Definition at line 47 of file popover-menu.cpp.

References _grid, _scrolled_window, check_child_invariants(), set_scrolled_window_size(), and unset_items_focus_hover().

Member Function Documentation

◆ activate()

bool Inkscape::UI::Widget::PopoverMenu::activate ( Glib::ustring const &  search)

◆ append()

void Inkscape::UI::Widget::PopoverMenu::append ( Gtk::Widget &  child)

Add new row containing child, at start/top.

Definition at line 90 of file popover-menu.cpp.

References _grid, _items, check_child_invariants(), and item.

Referenced by append_section_label(), and append_separator().

◆ append_section_label()

void Inkscape::UI::Widget::PopoverMenu::append_section_label ( Glib::ustring const &  markup)

Append label, w/ markup & the .dim-label style class.

Definition at line 116 of file popover-menu.cpp.

References append(), item, and label.

◆ append_separator()

void Inkscape::UI::Widget::PopoverMenu::append_separator ( )

Append a horizontal separator.

Definition at line 126 of file popover-menu.cpp.

References append().

◆ attach()

void Inkscape::UI::Widget::PopoverMenu::attach ( Gtk::Widget &  child,
int  left_attach,
int  right_attach,
int  top_attach,
int  bottom_attach 
)

Add child at pos as per Gtk::Menu::attach()

Definition at line 78 of file popover-menu.cpp.

References _grid, _items, check_child_invariants(), Inkscape::UI::Widget::height, item, and width.

Referenced by Inkscape::UI::Dialog::DialogNotebook::build_docking_menu().

◆ check_child_invariants()

void Inkscape::UI::Widget::PopoverMenu::check_child_invariants ( )
private

Definition at line 147 of file popover-menu.cpp.

References _grid, _scrolled_window, and Inkscape::UI::is_descendant_of().

Referenced by append(), attach(), PopoverMenu(), and prepend().

◆ get_children() [1/2]

void Inkscape::UI::Widget::PopoverMenu::get_children ( ) const
delete

This would give not the items, rather an internal Grid. Use get_items().

◆ get_children() [2/2]

void Inkscape::UI::Widget::PopoverMenu::get_children ( )
delete

This would give not the items, rather an internal Grid. Use get_items().

◆ get_items()

std::vector< Gtk::Widget * > const & Inkscape::UI::Widget::PopoverMenu::get_items ( )

Get the list of menu items (children of our grid) Take copy, not reference, if you iterate & change items!

Definition at line 142 of file popover-menu.cpp.

References _items.

◆ popup_at()

void Inkscape::UI::Widget::PopoverMenu::popup_at ( Gtk::Widget &  widget,
int  x_offset = 0,
int  y_offset = 0 
)

Replace Gtk::Menu::popup_at_pointer.

If x or y offsets != 0, :pointing-to is set to {x,y,1,1} widget must be the parent passed to self constructor or a descendant.

Definition at line 131 of file popover-menu.cpp.

References Inkscape::UI::popup_at().

◆ popup_at_center()

void Inkscape::UI::Widget::PopoverMenu::popup_at_center ( Gtk::Widget &  widget)

As popup_at() but point to center of widget.

Definition at line 137 of file popover-menu.cpp.

References Inkscape::UI::popup_at_center().

◆ prepend()

void Inkscape::UI::Widget::PopoverMenu::prepend ( Gtk::Widget &  child)

Add new row containing child, at end/bottom.

Definition at line 98 of file popover-menu.cpp.

References _grid, _items, check_child_invariants(), and item.

◆ remove()

void Inkscape::UI::Widget::PopoverMenu::remove ( Gtk::Widget &  child)

Remove added child.

Definition at line 106 of file popover-menu.cpp.

References _grid, _items, and item.

◆ remove_all()

void Inkscape::UI::Widget::PopoverMenu::remove_all ( )

Remove all items.

Definition at line 222 of file popover-menu.cpp.

References _grid, _items, and item.

Referenced by Inkscape::UI::Dialog::LivePathEffectEditor::add_lpes().

◆ set_scrolled_window_size()

void Inkscape::UI::Widget::PopoverMenu::set_scrolled_window_size ( )
private

Definition at line 155 of file popover-menu.cpp.

References _scrolled_window.

Referenced by PopoverMenu().

◆ unset_items_focus_hover()

void Inkscape::UI::Widget::PopoverMenu::unset_items_focus_hover ( Gtk::Widget *  except_active)
private

Definition at line 213 of file popover-menu.cpp.

References _items, and item.

Referenced by Inkscape::UI::Widget::CompletionPopup::onPopoverKeyPressed(), and PopoverMenu().

Friends And Related Symbol Documentation

◆ CompletionPopup

friend class CompletionPopup
friend

Definition at line 94 of file popover-menu.h.

◆ PopoverMenuItem

friend class PopoverMenuItem
friend

Definition at line 93 of file popover-menu.h.

Member Data Documentation

◆ _active_search

Gtk::Label* Inkscape::UI::Widget::PopoverMenu::_active_search = nullptr
private

Definition at line 88 of file popover-menu.h.

Referenced by activate().

◆ _grid

PopoverMenuGrid& Inkscape::UI::Widget::PopoverMenu::_grid
private

◆ _items

std::vector<Gtk::Widget *> Inkscape::UI::Widget::PopoverMenu::_items
private

◆ _scrolled_window

Gtk::ScrolledWindow& Inkscape::UI::Widget::PopoverMenu::_scrolled_window
private

Definition at line 85 of file popover-menu.h.

Referenced by check_child_invariants(), PopoverMenu(), and set_scrolled_window_size().


The documentation for this class was generated from the following files: