mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibGUI: Extend mimic pressed across keyboard shortcuts for buttons
Primary motivation for this was to get a visual indication in the browser for Ctrl-R refresh. This extends what ForLoveOfCats had done for calculator button shortcuts across all buttons with shortcuts. When an action is triggered without an activator each associated button will be set as mimic pressed.
This commit is contained in:
parent
7af87e8e6b
commit
554709fec6
Notes:
sideshowbarker
2024-07-17 14:34:17 +09:00
Author: https://github.com/robryanx Commit: https://github.com/SerenityOS/serenity/commit/554709fec6 Pull-request: https://github.com/SerenityOS/serenity/pull/13455
|
@ -131,6 +131,12 @@ void Action::activate(Core::Object* activator)
|
|||
}
|
||||
}
|
||||
|
||||
if (activator == nullptr) {
|
||||
for_each_toolbar_button([](auto& button) {
|
||||
button.set_mimic_pressed(true);
|
||||
});
|
||||
}
|
||||
|
||||
on_activation(*this);
|
||||
m_activator = nullptr;
|
||||
}
|
||||
|
|
|
@ -224,8 +224,23 @@ void Button::set_default(bool default_button)
|
|||
|
||||
void Button::set_mimic_pressed(bool mimic_pressed)
|
||||
{
|
||||
m_mimic_pressed = mimic_pressed;
|
||||
update();
|
||||
if (!is_being_pressed()) {
|
||||
m_mimic_pressed = mimic_pressed;
|
||||
|
||||
stop_timer();
|
||||
start_timer(80, Core::TimerShouldFireWhenNotVisible::Yes);
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void Button::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
if (is_mimic_pressed()) {
|
||||
m_mimic_pressed = false;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ protected:
|
|||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<GUI::Menu> m_menu;
|
||||
Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal };
|
||||
|
|
Loading…
Reference in a new issue