FillBar.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_DC_FILL_BAR_INCLUDED
34 #define H_DC_FILL_BAR_INCLUDED
35 
36 #include <Dynacoe/Entity.h>
37 #include <Dynacoe/Color.h>
38 #include <Dynacoe/Components/Object2D.h>
39 #include <Dynacoe/Components/Shape2D.h>
40 
41 
42 namespace Dynacoe {
43 
48 class FillBar : public Entity {
49  public:
50 
53  enum class FillDirection {
54  Up,
55  Left,
56  Down,
57  Right
58  };
59 
63  enum class FillTransition {
64  Instant,
65  EaseSlow,
66  EaseFast,
67  LinearSlow,
68  LinearFast
69  };
70 
71 
72 
73  FillBar();
74 
77  void SetDims(int w, int h);
78 
81  void SetBorder(int px);
82 
86 
90 
91 
92 
95  void SetColorFill(const Color & c);
96 
99  void SetColorEmpty(const Color & c);
100 
103  void SetColorBorder(const Color & c);
104 
109  void SetFill(float f);
110 
111 
112 
113 
114 
115 
116 
117  void Run();
118 
119 
120 
121  private:
122 
123 
124  Entity * empty;
125  Entity * full;
126 
127  Entity * borderUp;
128  Entity * borderDown;
129  Entity * borderLeft;
130  Entity * borderRight;
131 
132  float fraction;
133  float realFraction;
134 
135  int border;
136  int width;
137  int height;
138 
139  FillDirection fill;
140  FillTransition transition;
141 };
142 }
143 
144 #endif
void SetBorder(int px)
Sets the number of pixels to make the border.
A standard object representing an RGBA color.
Definition: Color.h:47
Fill from the bottom to the top.
Basic interactive object.
Definition: Entity.h:62
FillDirection
Sets the fill direction of the bar.
Definition: FillBar.h:53
Fill from the left to the right. This is the default.
Will linearly fill the bar at a moderate rate.
void SetColorBorder(const Color &c)
Sets the color of the fill border.
Fill from the right to the left.
Always shows exactly the fill amount.
Definition: AssetID.h:37
void SetDims(int w, int h)
Sets the dimensions of the bar.
Simple visual Entity representing a fraction of something.
Definition: FillBar.h:48
void SetColorEmpty(const Color &c)
Sets the background color for the empty portion of the bar.
void SetColorFill(const Color &c)
Sets the color of the filling visual.
Will linearly fill the bar at a slow rate.
void SetFill(float f)
Sets the fill fraction amount.
void SetFillDirection(FillDirection f)
Sets the fill direction.
Will quickly ease the bar to match the fill. This is the default.
void SetFillTransition(FillTransition f)
Sets the fill transition.
Will slowly ease the bar to match the fill.
FillTransition
Sets how the bar will show the fraction of fill when it changes.
Definition: FillBar.h:63
Fill from the top to the bottom.