mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibGUI+WindowServer: Add menu minimum width support
This commit is contained in:
parent
adc845e0cb
commit
350affe406
8 changed files with 56 additions and 10 deletions
|
@ -38,11 +38,12 @@ u32 find_ampersand_shortcut_character(StringView string)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Menu::Menu(ConnectionFromClient* client, int menu_id, String name)
|
||||
Menu::Menu(ConnectionFromClient* client, int menu_id, String name, int minimum_width)
|
||||
: Core::EventReceiver(client)
|
||||
, m_client(client)
|
||||
, m_menu_id(menu_id)
|
||||
, m_name(move(name))
|
||||
, m_minimum_width(minimum_width)
|
||||
{
|
||||
m_alt_shortcut_character = find_ampersand_shortcut_character(m_name);
|
||||
}
|
||||
|
@ -90,7 +91,7 @@ int Menu::content_width() const
|
|||
if (widest_shortcut)
|
||||
widest_item += padding_between_text_and_shortcut() + widest_shortcut;
|
||||
|
||||
return max(widest_item, rect_in_window_menubar().width()) + horizontal_padding() + frame_thickness() * 2;
|
||||
return max(m_minimum_width, max(widest_item, rect_in_window_menubar().width()) + horizontal_padding() + frame_thickness() * 2);
|
||||
}
|
||||
|
||||
int Menu::item_height() const
|
||||
|
@ -770,6 +771,11 @@ void Menu::set_name(String name)
|
|||
m_name = move(name);
|
||||
}
|
||||
|
||||
void Menu::set_minimum_width(int minimum_width)
|
||||
{
|
||||
m_minimum_width = minimum_width;
|
||||
}
|
||||
|
||||
bool Menu::is_open() const
|
||||
{
|
||||
return MenuManager::the().is_open(*this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue