summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Statusbar.h
blob: 0f6e5ad5d2c519bcc7306632766a1c06dfa2394a (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibGUI/Widget.h>

namespace GUI {

class Statusbar : public Widget {
    C_OBJECT(Statusbar)
public:
    virtual ~Statusbar() override;

    String text() const;
    String text(size_t index) const;
    void set_text(String);
    void set_text(size_t index, String);
    void set_override_text(String);
    void set_override_text(size_t index, String);

protected:
    explicit Statusbar(int label_count = 1);
    virtual void paint_event(PaintEvent&) override;
    virtual void resize_event(ResizeEvent&) override;

private:
    size_t label_count() const { return m_segments.size(); }
    void set_label_count(size_t label_count);
    NonnullRefPtr<Label> create_label();
    struct Segment {
        NonnullRefPtr<GUI::Label> label;
        String text;
        String override_text;
    };
    void update_label(size_t);
    Vector<Segment> m_segments;
    RefPtr<ResizeCorner> m_corner;
};

}