2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-03-22 02:49:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Frame.h>
|
2019-03-22 02:49:14 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
class Progressbar : public Frame {
|
|
|
|
C_OBJECT(Progressbar)
|
2019-03-22 02:49:14 +01:00
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~Progressbar() override = default;
|
2019-03-22 02:49:14 +01:00
|
|
|
|
|
|
|
void set_range(int min, int max);
|
2019-04-19 01:05:59 +02:00
|
|
|
void set_min(int min) { set_range(min, max()); }
|
|
|
|
void set_max(int max) { set_range(min(), max); }
|
2019-03-22 02:49:14 +01:00
|
|
|
void set_value(int);
|
|
|
|
|
|
|
|
int value() const { return m_value; }
|
2019-04-12 15:17:53 +02:00
|
|
|
int min() const { return m_min; }
|
|
|
|
int max() const { return m_max; }
|
2019-03-22 02:49:14 +01:00
|
|
|
|
2021-03-07 17:39:01 -05:00
|
|
|
void set_orientation(Orientation value);
|
|
|
|
Orientation orientation() const { return m_orientation; }
|
|
|
|
|
2020-12-20 12:29:40 +01:00
|
|
|
String text() const { return m_text; }
|
|
|
|
void set_text(String text) { m_text = move(text); }
|
2019-03-25 04:25:25 +01:00
|
|
|
|
2019-06-07 17:13:23 +02:00
|
|
|
enum Format {
|
2019-05-28 11:53:16 +02:00
|
|
|
NoText,
|
|
|
|
Percentage,
|
|
|
|
ValueSlashMax
|
|
|
|
};
|
2019-03-25 04:25:25 +01:00
|
|
|
Format format() const { return m_format; }
|
|
|
|
void set_format(Format format) { m_format = format; }
|
|
|
|
|
2019-03-22 02:49:14 +01:00
|
|
|
protected:
|
2021-04-13 16:18:20 +02:00
|
|
|
Progressbar(Orientation = Orientation::Horizontal);
|
2019-09-21 16:31:12 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void paint_event(PaintEvent&) override;
|
2019-03-22 02:49:14 +01:00
|
|
|
|
|
|
|
private:
|
2019-03-25 04:25:25 +01:00
|
|
|
Format m_format { Percentage };
|
2019-03-22 02:49:14 +01:00
|
|
|
int m_min { 0 };
|
|
|
|
int m_max { 100 };
|
|
|
|
int m_value { 0 };
|
2020-12-20 12:29:40 +01:00
|
|
|
String m_text;
|
2021-03-07 17:39:01 -05:00
|
|
|
Orientation m_orientation { Orientation::Horizontal };
|
|
|
|
};
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
class VerticalProgressbar final : public Progressbar {
|
|
|
|
C_OBJECT(VerticalProgressbar);
|
2021-03-07 17:39:01 -05:00
|
|
|
|
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~VerticalProgressbar() override = default;
|
2021-03-07 17:39:01 -05:00
|
|
|
|
|
|
|
private:
|
2021-04-13 16:18:20 +02:00
|
|
|
VerticalProgressbar()
|
|
|
|
: Progressbar(Orientation::Vertical)
|
2021-03-07 17:39:01 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
class HorizontalProgressbar final : public Progressbar {
|
|
|
|
C_OBJECT(HorizontalProgressbar);
|
2021-03-07 17:39:01 -05:00
|
|
|
|
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~HorizontalProgressbar() override = default;
|
2021-03-07 17:39:01 -05:00
|
|
|
|
|
|
|
private:
|
2021-04-13 16:18:20 +02:00
|
|
|
HorizontalProgressbar()
|
|
|
|
: Progressbar(Orientation::Horizontal)
|
2021-03-07 17:39:01 -05:00
|
|
|
{
|
|
|
|
}
|
2019-03-22 02:49:14 +01:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
}
|