/* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace GUI { class Statusbar : public Widget { C_OBJECT(Statusbar) public: virtual ~Statusbar() override = default; DeprecatedString text(size_t index = 0) const; void set_text(DeprecatedString); void set_text(size_t index, DeprecatedString); void set_override_text(DeprecatedString); class Segment final : public Button { C_OBJECT(Segment) friend class Statusbar; public: enum class Mode { Proportional, Fixed, Auto, }; void set_clickable(bool b) { m_clickable = b; } bool is_clickable() { return m_clickable; } void set_mode(Mode mode) { m_mode = mode; } Mode mode() const { return m_mode; } protected: virtual void paint_event(PaintEvent& event) override; virtual void mousedown_event(MouseEvent& event) override; virtual void mouseup_event(MouseEvent& event) override; private: Segment(); void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } void set_restored_width(int width) { m_restored_width = width; } int restored_width() const { return m_restored_width; } DeprecatedString const& override_text() const { return m_override_text; } DeprecatedString const& restored_text() const { return m_restored_text; } DeprecatedString m_override_text; DeprecatedString m_restored_text; bool m_clickable { false }; int m_restored_width { 0 }; int m_thickness { 1 }; Mode m_mode { Mode::Proportional }; Gfx::FrameShape m_shape { Gfx::FrameShape::Panel }; }; Segment& segment(size_t index) { return m_segments.at(index); } protected: explicit Statusbar(int segment_count = 1); virtual void paint_event(PaintEvent&) override; virtual void resize_event(ResizeEvent&) override; private: void set_segment_count(size_t); size_t segment_count() const { return m_segments.size(); } void update_segment(size_t); NonnullRefPtr create_segment(); virtual void child_event(Core::ChildEvent&) override; Vector> m_segments; RefPtr m_corner; }; }