1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibGUI: Add a GRadioButton widget.

Radio buttons are automagically exclusive with other radio button children
of the same parent. :^)
This commit is contained in:
Andreas Kling 2019-05-23 22:37:21 +02:00
parent 00075b1c8a
commit 36d8b9e89b
8 changed files with 157 additions and 0 deletions

32
LibGUI/GRadioButton.h Normal file
View file

@ -0,0 +1,32 @@
#pragma once
#include <LibGUI/GWidget.h>
class GRadioButton : public GWidget {
public:
GRadioButton(const String& label, GWidget* parent);
virtual ~GRadioButton() override;
void set_label(const String&);
String label() const { return m_label; }
bool is_checked() const { return m_checked; }
void set_checked(bool);
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 };
};