# Plutonium framework API: Plutonium/include/pu/ui/elm/elm_ProgressBar.hpp Source File

elm_ProgressBar.hpp
Go to the documentation of this file.
/*
Plutonium library
@file ProgressBar.hpp
@brief A ProgressBar is an Element which represents a progress (a percentage) by filling a bar.
@author XorTroll
@copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
*/
#pragma once
#include <pu/ui/elm/elm_Element.hpp>
namespace pu::ui::elm {
class ProgressBar : public Element {
public:
static constexpr Color DefaultProgressColor = { 139, 195, 74, 255 };
static constexpr Color DefaultBackgroundColor = { 140, 140, 140, 255 };
private:
i32 x;
i32 y;
i32 w;
i32 h;
double val;
double max_val;
Color progress_clr;
Color bg_clr;
public:
ProgressBar(const i32 x, const i32 y, const i32 width, const i32 height, const double max_val) : Element(), x(x), y(y), w(width), h(height), val(0), max_val(max_val), progress_clr(DefaultProgressColor), bg_clr(DefaultBackgroundColor) {}
PU_SMART_CTOR(ProgressBar)
inline i32 GetX() override {
return this->x;
}
inline void SetX(const i32 x) {
this->x = x;
}
inline i32 GetY() override {
return this->y;
}
inline void SetY(const i32 y) {
this->y = y;
}
inline i32 GetWidth() override {
return this->w;
}
inline void SetWidth(const i32 width) {
this->w = width;
}
inline i32 GetHeight() override {
return this->h;
}
inline void SetHeight(const i32 height) {
this->h = height;
}
inline Color GetProgressColor() {
return this->progress_clr;
}
inline void SetProgressColor(const Color progress_clr) {
this->progress_clr = progress_clr;
}
inline Color GetBackgroundColor() {
return this->bg_clr;
}
inline void SetBackgroundColor(const Color bg_clr) {
this->bg_clr = bg_clr;
}
inline double GetProgress() {
return this->val;
}
void SetProgress(const double progress);
inline void IncrementProgress(const double extra_progress) {
this->SetProgress(this->val + extra_progress);
}
inline void DecrementProgress(const double extra_progress) {
this->SetProgress(this->val - extra_progress);
}
inline void SetMaxProgress(const double max_progress) {
this->max_val = max_progress;
}
inline double GetMaxProgress() {
return this->max_val;
}
inline void FillProgress() {
this->SetProgress(this->max_val);
}
inline void ClearProgress() {
this->SetProgress(0);
}
inline bool IsCompleted() {
return this->val == this->max_val;
}
void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override;
void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override {}
};
}
pu::ui::elm::Element
Definition: elm_Element.hpp:37
pu::ui::elm::ProgressBar
Definition: elm_ProgressBar.hpp:19
pu::ui::elm::ProgressBar::GetMaxProgress
double GetMaxProgress()
Definition: elm_ProgressBar.hpp:104
pu::ui::elm::ProgressBar::OnRender
void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override
pu::ui::elm::ProgressBar::GetX
i32 GetX() override
Definition: elm_ProgressBar.hpp:38
pu::ui::elm::ProgressBar::GetWidth
i32 GetWidth() override
Definition: elm_ProgressBar.hpp:54
pu::ui::elm::ProgressBar::SetHeight
void SetHeight(const i32 height)
Definition: elm_ProgressBar.hpp:66
pu::ui::elm::ProgressBar::SetMaxProgress
void SetMaxProgress(const double max_progress)
Definition: elm_ProgressBar.hpp:100
pu::ui::elm::ProgressBar::OnInput
void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override
Definition: elm_ProgressBar.hpp:121
pu::ui::elm::ProgressBar::ClearProgress
void ClearProgress()
Definition: elm_ProgressBar.hpp:112
pu::ui::elm::ProgressBar::SetProgressColor
void SetProgressColor(const Color progress_clr)
Definition: elm_ProgressBar.hpp:74
pu::ui::elm::ProgressBar::SetProgress
void SetProgress(const double progress)
pu::ui::elm::ProgressBar::GetProgressColor
Color GetProgressColor()
Definition: elm_ProgressBar.hpp:70
pu::ui::elm::ProgressBar::ProgressBar
ProgressBar(const i32 x, const i32 y, const i32 width, const i32 height, const double max_val)
Definition: elm_ProgressBar.hpp:35
pu::ui::elm::ProgressBar::SetBackgroundColor
void SetBackgroundColor(const Color bg_clr)
Definition: elm_ProgressBar.hpp:82
pu::ui::elm::ProgressBar::IncrementProgress
void IncrementProgress(const double extra_progress)
Definition: elm_ProgressBar.hpp:92
pu::ui::elm::ProgressBar::IsCompleted
bool IsCompleted()
Definition: elm_ProgressBar.hpp:116
pu::ui::elm::ProgressBar::DecrementProgress
void DecrementProgress(const double extra_progress)
Definition: elm_ProgressBar.hpp:96
pu::ui::elm::ProgressBar::GetBackgroundColor
Color GetBackgroundColor()
Definition: elm_ProgressBar.hpp:78
pu::ui::elm::ProgressBar::DefaultProgressColor
static constexpr Color DefaultProgressColor
Definition: elm_ProgressBar.hpp:21
pu::ui::elm::ProgressBar::FillProgress
void FillProgress()
Definition: elm_ProgressBar.hpp:108
pu::ui::elm::ProgressBar::DefaultBackgroundColor
static constexpr Color DefaultBackgroundColor
Definition: elm_ProgressBar.hpp:22
pu::ui::elm::ProgressBar::SetY
void SetY(const i32 y)
Definition: elm_ProgressBar.hpp:50
pu::ui::elm::ProgressBar::SetX
void SetX(const i32 x)
Definition: elm_ProgressBar.hpp:42
pu::ui::elm::ProgressBar::GetProgress
double GetProgress()
Definition: elm_ProgressBar.hpp:86
pu::ui::elm::ProgressBar::GetY
i32 GetY() override
Definition: elm_ProgressBar.hpp:46
pu::ui::elm::ProgressBar::SetWidth
void SetWidth(const i32 width)
Definition: elm_ProgressBar.hpp:58
pu::ui::elm::ProgressBar::GetHeight
i32 GetHeight() override
Definition: elm_ProgressBar.hpp:62
elm_Element.hpp
pu::ui::elm
Definition: elm_Button.hpp:18
pu::i32
s32 i32
Definition: pu_Include.hpp:28
PU_SMART_CTOR
#define PU_SMART_CTOR(type)
Definition: pu_Include.hpp:19
pu::ui::Color
Definition: ui_Types.hpp:44
pu::ui::TouchPoint
Definition: ui_Types.hpp:62