mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibGUI: Tweak GUI::Label API a bit and add did_change_text() virtual
This commit is contained in:
parent
9fe310c470
commit
4e084793df
2 changed files with 10 additions and 7 deletions
|
@ -32,8 +32,8 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
Label::Label(const StringView& text)
|
Label::Label(String text)
|
||||||
: m_text(text)
|
: m_text(move(text))
|
||||||
{
|
{
|
||||||
set_frame_thickness(0);
|
set_frame_thickness(0);
|
||||||
set_frame_shadow(Gfx::FrameShadow::Plain);
|
set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||||
|
@ -66,14 +66,15 @@ void Label::set_icon(const Gfx::Bitmap* icon)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::set_text(const StringView& text)
|
void Label::set_text(String text)
|
||||||
{
|
{
|
||||||
if (text == m_text)
|
if (text == m_text)
|
||||||
return;
|
return;
|
||||||
m_text = text;
|
m_text = move(text);
|
||||||
if (m_autosize)
|
if (m_autosize)
|
||||||
size_to_fit();
|
size_to_fit();
|
||||||
update();
|
update();
|
||||||
|
did_change_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::paint_event(PaintEvent& event)
|
void Label::paint_event(PaintEvent& event)
|
||||||
|
|
|
@ -32,12 +32,13 @@
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class Label : public Frame {
|
class Label : public Frame {
|
||||||
C_OBJECT(Label)
|
C_OBJECT(Label);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Label() override;
|
virtual ~Label() override;
|
||||||
|
|
||||||
String text() const { return m_text; }
|
String text() const { return m_text; }
|
||||||
void set_text(const StringView&);
|
void set_text(String);
|
||||||
|
|
||||||
void set_icon(const Gfx::Bitmap*);
|
void set_icon(const Gfx::Bitmap*);
|
||||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||||
|
@ -53,9 +54,10 @@ public:
|
||||||
void set_autosize(bool);
|
void set_autosize(bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Label(const StringView& text = {});
|
explicit Label(String text = {});
|
||||||
|
|
||||||
virtual void paint_event(PaintEvent&) override;
|
virtual void paint_event(PaintEvent&) override;
|
||||||
|
virtual void did_change_text() { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void size_to_fit();
|
void size_to_fit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue