LibGUI: Use ControlBoxButtons in SpinBox and ComboBox
Converts the buttons of these widgets into ControlBoxButtons.
This commit is contained in:
parent
bf59cd7ca5
commit
c90fe7ce93
Notes:
sideshowbarker
2024-07-19 04:42:22 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/c90fe7ce935 Pull-request: https://github.com/SerenityOS/serenity/pull/2839
4 changed files with 12 additions and 11 deletions
Libraries/LibGUI
|
@ -24,8 +24,8 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/ComboBox.h>
|
||||
#include <LibGUI/ControlBoxButton.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/ListView.h>
|
||||
#include <LibGUI/Model.h>
|
||||
|
@ -89,9 +89,8 @@ ComboBox::ComboBox()
|
|||
m_open_button->click();
|
||||
};
|
||||
|
||||
m_open_button = add<Button>();
|
||||
m_open_button = add<ControlBoxButton>(ControlBoxButton::DownArrow);
|
||||
m_open_button->set_focusable(false);
|
||||
m_open_button->set_text("\xE2\xAC\x87"); // DOWNWARDS BLACK ARROW
|
||||
m_open_button->on_click = [this](auto) {
|
||||
if (m_list_window->is_visible())
|
||||
close();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
namespace GUI {
|
||||
|
||||
class ComboBoxEditor;
|
||||
class ControlBoxButton;
|
||||
|
||||
class ComboBox : public Widget {
|
||||
C_OBJECT(ComboBox)
|
||||
|
@ -65,7 +66,7 @@ protected:
|
|||
|
||||
private:
|
||||
RefPtr<ComboBoxEditor> m_editor;
|
||||
RefPtr<Button> m_open_button;
|
||||
RefPtr<ControlBoxButton> m_open_button;
|
||||
RefPtr<Window> m_list_window;
|
||||
RefPtr<ListView> m_list_view;
|
||||
bool m_only_allow_values_from_model { false };
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/ControlBoxButton.h>
|
||||
#include <LibGUI/SpinBox.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
|
||||
|
@ -41,14 +41,13 @@ SpinBox::SpinBox()
|
|||
else
|
||||
m_editor->set_text(String::number(m_value));
|
||||
};
|
||||
m_increment_button = add<Button>();
|
||||
|
||||
m_increment_button = add<ControlBoxButton>(ControlBoxButton::UpArrow);
|
||||
m_increment_button->set_focusable(false);
|
||||
m_increment_button->set_text("\xE2\xAC\x86"); // UPWARDS BLACK ARROW
|
||||
m_increment_button->on_click = [this](auto) { set_value(m_value + 1); };
|
||||
m_increment_button->set_auto_repeat_interval(150);
|
||||
m_decrement_button = add<Button>();
|
||||
m_decrement_button = add<ControlBoxButton>(ControlBoxButton::DownArrow);
|
||||
m_decrement_button->set_focusable(false);
|
||||
m_decrement_button->set_text("\xE2\xAC\x87"); // DOWNWARDS BLACK ARROW
|
||||
m_decrement_button->on_click = [this](auto) { set_value(m_value - 1); };
|
||||
m_decrement_button->set_auto_repeat_interval(150);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
class ControlBoxButton;
|
||||
|
||||
class SpinBox : public Widget {
|
||||
C_OBJECT(SpinBox)
|
||||
public:
|
||||
|
@ -55,8 +57,8 @@ protected:
|
|||
|
||||
private:
|
||||
RefPtr<TextEditor> m_editor;
|
||||
RefPtr<Button> m_increment_button;
|
||||
RefPtr<Button> m_decrement_button;
|
||||
RefPtr<ControlBoxButton> m_increment_button;
|
||||
RefPtr<ControlBoxButton> m_decrement_button;
|
||||
|
||||
int m_min { 0 };
|
||||
int m_max { 100 };
|
||||
|
|
Loading…
Add table
Reference in a new issue