ladybird/Userland/Libraries/LibGUI/Statusbar.h
thankyouverycool f7e034d4b2 LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle
Previously, Frames could set both these properties along with a
thickness to confusing effect: Most shapes of the same shadowing only
differentiated at a thickness >= 2, and some not at all. This led
to a lot of creative but ultimately superfluous choices in the code.

Instead let's streamline our options, automate thickness, and get
the right look without so much guesswork.

Plain shadowing has been consolidated into a single Plain style,
and 0 thickness can be had by setting style to NoFrame.
2023-04-30 05:49:46 +02:00

85 lines
2.4 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Button.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Widget.h>
#include <LibGfx/Palette.h>
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_style(Gfx::FrameStyle style) { m_style = style; }
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 };
Mode m_mode { Mode::Proportional };
Gfx::FrameStyle m_style { Gfx::FrameStyle::SunkenPanel };
};
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<Segment> create_segment();
virtual void child_event(Core::ChildEvent&) override;
Vector<NonnullRefPtr<Segment>> m_segments;
RefPtr<ResizeCorner> m_corner;
};
}