summaryrefslogtreecommitdiff
path: root/Widgets/Button.h
blob: cdbc522ecfcf8adf365e57f08467e6bac7908a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include "Widget.h"
#include <AK/AKString.h>
#include <AK/Function.h>

class Button final : public Widget {
public:
    explicit Button(Widget* parent);
    virtual ~Button() override;

    String caption() const { return m_caption; }
    void setCaption(String&&);

    Function<void(Button&)> onClick;

private:
    virtual void paintEvent(PaintEvent&) override;
    virtual void mouseDownEvent(MouseEvent&) override;
    virtual void mouseUpEvent(MouseEvent&) override;

    virtual const char* class_name() const override { return "Button"; }

    String m_caption;
    bool m_beingPressed { false };
};