From 770907f90caad109dc57529843a3e9c21c25fcfc Mon Sep 17 00:00:00 2001 From: faissaloo Date: Sun, 16 Jun 2019 16:55:39 +0100 Subject: [PATCH] GWindow: Cleanup --- LibGUI/GWindow.cpp | 34 +++++++++++++++++----------------- LibGUI/GWindow.h | 4 +--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 9ef6ce4c90..0cc561c156 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -3,6 +3,7 @@ #include "GEventLoop.h" #include "GWidget.h" #include +#include #include #include #include @@ -350,27 +351,26 @@ void GWindow::event(CEvent& event) } void GWindow::paint_keybinds() { - if (m_keybind_mode) { - GPainter painter(*m_main_widget); + if (!m_keybind_mode) return; + GPainter painter(*m_main_widget); - for (auto& keypair: m_hashed_potential_keybind_widgets) { - auto widget = keypair.value; - bool could_be_keybind = true; - for (size_t i = 0; i < m_entered_keybind.length(); i++) { - if (keypair.key.characters()[i] != m_entered_keybind.characters()[i]) { - could_be_keybind = false; - } + for (auto& keypair: m_hashed_potential_keybind_widgets) { + auto widget = keypair.value; + bool could_be_keybind = true; + for (size_t i = 0; i < m_entered_keybind.length(); i++) { + if (keypair.key.characters()[i] != m_entered_keybind.characters()[i]) { + could_be_keybind = false; } + } - if (could_be_keybind) { - auto rect = Rect(widget->x()-5, widget->y()-5, 4+Font::default_font().width(keypair.key), 16); - auto highlight_rect = Rect(widget->x()-3, widget->y()-5, 0, 16); + if (could_be_keybind) { + auto rect = Rect(widget->x()-5, widget->y()-5, 4+Font::default_font().width(keypair.key), 16); + auto highlight_rect = Rect(widget->x()-3, widget->y()-5, 0, 16); - painter.fill_rect(rect, Color::LightGray); - painter.draw_rect(rect, Color::Black, false); - painter.draw_text(rect, keypair.key.characters(), TextAlignment::Center, Color::Black); - painter.draw_text(highlight_rect, m_entered_keybind.characters(), TextAlignment::CenterLeft, Color::MidGray); - } + painter.fill_rect(rect, Color::LightGray); + painter.draw_rect(rect, Color::Black, false); + painter.draw_text(rect, keypair.key.characters(), TextAlignment::Center, Color::Black); + painter.draw_text(highlight_rect, m_entered_keybind.characters(), TextAlignment::CenterLeft, Color::MidGray); } } } diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index 957a50ed93..aa09e6646a 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -2,14 +2,12 @@ #include #include -#include #include #include #include #include #include -class GPainter; class GWidget; class GWMEvent; @@ -168,6 +166,6 @@ private: bool m_show_titlebar { true }; bool m_keybind_mode { false }; String m_entered_keybind; - size_t m_max_keybind_length; + size_t m_max_keybind_length { 0 }; HashMap m_hashed_potential_keybind_widgets; };