mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibGUI: Add a GAbstractButton base class for button widgets.
This patch moves GButton and GRadioButton to inherit from it. This allows them to share code for mouse event handling, etc.
This commit is contained in:
parent
abbcdba72e
commit
21c56477b0
18 changed files with 202 additions and 211 deletions
|
@ -1,32 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GAbstractButton.h>
|
||||
|
||||
class GRadioButton : public GWidget {
|
||||
class GRadioButton : public GAbstractButton {
|
||||
public:
|
||||
GRadioButton(const String& label, GWidget* parent);
|
||||
GRadioButton(const String& text, GWidget* parent);
|
||||
virtual ~GRadioButton() override;
|
||||
|
||||
void set_label(const String&);
|
||||
String label() const { return m_label; }
|
||||
virtual const char* class_name() const override { return "GRadioButton"; }
|
||||
|
||||
bool is_checked() const { return m_checked; }
|
||||
void set_checked(bool);
|
||||
virtual void click() override;
|
||||
|
||||
protected:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
|
||||
private:
|
||||
virtual bool is_radio_button() const final { return true; }
|
||||
|
||||
template<typename Callback> void for_each_in_group(Callback);
|
||||
static Size circle_size();
|
||||
|
||||
String m_label;
|
||||
bool m_checked { false };
|
||||
bool m_changing { false };
|
||||
bool m_tracking { false };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue