Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Public Member Functions | Public Attributes | List of all members
ProgressBar Class Reference
Inheritance diagram for ProgressBar:
Inheritance graph
[legend]
Collaboration diagram for ProgressBar:
Collaboration graph
[legend]

Public Member Functions

void render (Element *parent)
 display the current state of the display More...
 
- Public Member Functions inherited from Element
virtual bool process (InputEvents *event)
 process any input that is received for this element More...
 
virtual void render (Element *parent)
 display the current state of the display More...
 
bool onTouchDown (InputEvents *event)
 
bool onTouchDrag (InputEvents *event)
 
bool onTouchUp (InputEvents *event)
 
void hide ()
 
void unhide ()
 
void renderBackground (bool fill=true)
 
void append (Element *element)
 
void remove (Element *element)
 
void removeAll (bool moveToTrash=false)
 
void position (int x, int y)
 position the element More...
 
void recalcPosition (Element *parent)
 
CST_Rect getBounds ()
 
CST_Renderer * getRenderer ()
 
void wipeAll (bool delSelf=false)
 
Elementchild (Element *child)
 
ElementsetPosition (int x, int y)
 
ElementsetAction (std::function< void()> func)
 
ElementcenterHorizontallyIn (Element *parent)
 
ElementcenterVerticallyIn (Element *parent)
 
ElementcenterIn (Element *parent)
 
ElementsetAbsolute (bool isAbs)
 
Elementconstrain (int flags, int padding=0)
 
Elementanimate (int durationIn, std::function< void(float)> onStep, std::function< void()> onFinish)
 
ElementmoveToFront ()
 
ElementsetTouchable (bool touchable)
 
void screenshot (std::string path)
 Take a screenshot of this element and its children, and save it to the given path. More...
 

Public Attributes

float percent = 0
 
int color
 
bool dimBg = false
 
int width = 0
 
- Public Attributes inherited from Element
std::function< void()> action = NULL
 the action to call (from binded callback) on touch or button selection https://stackoverflow.com/questions/14189440/c-class-member-callback-simple-examples More...
 
std::function< void(InputEvents *event)> actionWithEvents = NULL
 
std::vector< Element * > elements
 visible GUI child elements of this element More...
 
float scale = 1.0f
 
bool touchable = false
 whether or not this element can be touched (highlights bounds) More...
 
bool dragging = false
 whether or not this element is currently being dragged More...
 
bool needsRedraw = false
 whether or not this element needs the screen redrawn next time it's processed More...
 
int futureRedrawCounter = 0
 whether this element needs a redraw for the next X redraws (decreases each time) (0 is no redraws) More...
 
int lastMouseY = 0
 the last Y, X coordinate of the mouse (from a drag probably) More...
 
int lastMouseX = 0
 
bool hasBackground = false
 
rgb backgroundColor = {0, 0, 0}
 
bool isAbsolute = false
 
Elementparent = NULL
 the parent element (can sometimes be null if it isn't set) More...
 
bool hidden = false
 whether this element should skip rendering or not More...
 
bool isProtected = false
 
int elasticCounter = 0
 how much time is left in an elastic-type flick/scroll set by the last distance traveled in a scroll, and counts down every frame More...
 
int width = 0
 width and height of this element (must be manually set, isn't usually calculated (but is in some cases, like text or images)) More...
 
int height = 0
 
int x = 0
 
int y = 0
 
int xAbs = 0
 
int yAbs = 0
 
double angle = 0
 rotation angle in degrees More...
 
int xOff = 0
 
int yOff = 0
 
std::vector< Constraint * > constraints
 
std::vector< Animation * > animations
 
bool useColorMask = false
 whether or not to overlay a color mask on top of this element More...
 
CST_Color maskColor = {0,0,0,0}
 The color to overlay on top. More...
 

Additional Inherited Members

- Public Types inherited from Element
typedef Element super
 

Detailed Description

Definition at line 5 of file ProgressBar.hpp.

Constructor & Destructor Documentation

◆ ProgressBar()

ProgressBar::ProgressBar ( )

Definition at line 4 of file ProgressBar.cpp.

5{
6 // total width of full progress bar
7 this->width = 450;
8 this->height = 5; //HACKY: progress bars are 9 px tall and erroneously extend 4 px above their y-position (other elements use y-position as top, not center)
9 this->color = 0x56c1dfff;
10}

Member Function Documentation

◆ render()

void ProgressBar::render ( Element parent)
virtual

display the current state of the display

Reimplemented from Element.

Definition at line 12 of file ProgressBar.cpp.

13{
14 // if we're hidden, don't render
15 if (hidden) return;
16
17 if (this->percent < 0)
18 return;
19
20 auto renderer = getRenderer();
21
22 if (dimBg)
23 {
24 // draw a big dim layer around the entire window before drawing this progress bar
25 CST_Rect dim = { 0, 0, RootDisplay::screenWidth, RootDisplay::screenHeight };
26
27 CST_SetDrawBlend(renderer, true);
28 CST_SetDrawColorRGBA(renderer, 0x00, 0x00, 0x00, 0xbb);
29 CST_FillRect(renderer, &dim);
30 }
31
32 this->recalcPosition(parent);
33
34 int blue = this->color;
35 // int gray = 0x989898ff;
36
37 // draw full grayed out bar first
38 CST_Rect gray_rect;
39 gray_rect.x = this->xAbs;
40 gray_rect.y = this->yAbs - 4;
41 gray_rect.w = this->width;
42 gray_rect.h = 9;
43
44 CST_SetDrawColorRGBA(renderer, 0x98, 0x98, 0x98, 0xff); //gray2
45 CST_FillRect(renderer, &gray_rect);
46
47 // draw ending "circle"
48 CST_filledCircleRGBA(renderer, this->xAbs + this->width, this->yAbs, 4, 0x98, 0x98, 0x98, 0xff);
49
50 // draw left "circle" (rounded part of bar)
51 CST_filledCircleRGBA(renderer, this->xAbs, this->yAbs, 4, 0x56, 0xc1, 0xdf, 0xff);
52
53 // draw blue progress bar so far
54 CST_Rect blue_rect;
55 blue_rect.x = this->xAbs;
56 blue_rect.y = this->yAbs - 4;
57 blue_rect.w = this->width * this->percent;
58 blue_rect.h = 9;
59
60 CST_SetDrawColorRGBA(renderer, 0x56, 0xc1, 0xdf, 0xff); // blue2
61 CST_FillRect(renderer, &blue_rect);
62
63 // draw right "circle" (rounded part of bar, and ending)
64 CST_filledCircleRGBA(renderer, this->xAbs + width * this->percent, this->yAbs, 4, 0x56, 0xc1, 0xdf, 0xff);
65}
bool hidden
whether this element should skip rendering or not
Definition: Element.hpp:105
Element * parent
the parent element (can sometimes be null if it isn't set)
Definition: Element.hpp:102

References Element::hidden, and Element::parent.

Member Data Documentation

◆ color

int ProgressBar::color

Definition at line 12 of file ProgressBar.hpp.

◆ dimBg

bool ProgressBar::dimBg = false

Definition at line 13 of file ProgressBar.hpp.

◆ percent

float ProgressBar::percent = 0

Definition at line 10 of file ProgressBar.hpp.

◆ width

int ProgressBar::width = 0

Definition at line 15 of file ProgressBar.hpp.


The documentation for this class was generated from the following files: