diff --git a/EasyUI/Components/Progress.as b/EasyUI/Components/Progress.as index 8157f76..db1b7b8 100644 --- a/EasyUI/Components/Progress.as +++ b/EasyUI/Components/Progress.as @@ -2,11 +2,34 @@ interface Progress : List { void SetPercentage(float percentage); float getPercentage(); + + void SetColor(SColor color); + SColor getColor(); + + void SetFillDirection(FillDirection direction); + FillDirection getFillDirection(); +} + +enum FillDirection +{ + Right, + Left, + Top, + Bottom } -class StandardHorizontalProgress : Progress, StandardList +class StandardProgress : Progress, StandardList { private float percentage = 0.0f; + private SColor color = color_white; + private FillDirection direction = FillDirection::Right; + + StandardProgress(EasyUI@ ui, SColor color = color_white) + { + super(ui); + + this.color = color; + } void SetPercentage(float percentage) { @@ -24,6 +47,34 @@ class StandardHorizontalProgress : Progress, StandardList return percentage; } + void SetColor(SColor color) + { + if (this.color == color) return; + + this.color = color; + + DispatchEvent(Event::Color); + } + + SColor getColor() + { + return color; + } + + void SetFillDirection(FillDirection direction) + { + if (this.direction == direction) return; + + this.direction = direction; + + DispatchEvent(Event::FillDirection); + } + + FillDirection getFillDirection() + { + return direction; + } + bool canClick() { return true; @@ -36,8 +87,33 @@ class StandardHorizontalProgress : Progress, StandardList Vec2f min = getTruePosition(); Vec2f max = min + getTrueBounds(); - GUI::DrawProgressBar(min, max, percentage); + GUI::DrawPane(min, max, SColor(0xffCCCCCC)); + + if (percentage > 0) + { + Vec2f bar_min = min; + Vec2f bar_max = max; + + switch (direction) + { + case FillDirection::Right: + bar_max.x = bar_min.x + Maths::Max((max.x - min.x) * percentage, 10.0f); + break; + case FillDirection::Left: + bar_min.x = bar_max.x - Maths::Max((max.x - min.x) * percentage, 10.0f); + break; + case FillDirection::Bottom: + bar_max.y = bar_min.y + Maths::Max((max.y - min.y) * percentage, 10.0f); + break; + case FillDirection::Top: + bar_min.y = bar_max.y - Maths::Max((max.y - min.y) * percentage, 10.0f); + break; + } + + GUI::DrawPane(bar_min, bar_max, color); + } StandardList::Render(); } } + diff --git a/EasyUI/Events/Events.as b/EasyUI/Events/Events.as index 3130647..a3b2f85 100644 --- a/EasyUI/Events/Events.as +++ b/EasyUI/Events/Events.as @@ -40,6 +40,7 @@ enum Event Spacing, CellWrap, FlowDirection, + FillDirection, ScrollIndex, // Interaction @@ -51,3 +52,4 @@ enum Event Scroll, } + diff --git a/README.md b/README.md index f37e2e8..5975159 100644 --- a/README.md +++ b/README.md @@ -130,10 +130,10 @@ parent inner bounds ────|──┃─>┃ ┌ ─ ─ ─ ─ ┐ | Category | Components | | ------------- | ------------------------------------------------------------------------------------------------------------------------------- | | Input | [StandardButton](#button) • [StandardVerticalSlider](#slider) • [StandardHorizontalSlider](#slider) • [StandardToggle](#toggle) | -| Informational | [StandardAvatar](#avatar) • [StandardIcon](#icon) • [StandardLabel](#label) • [StandardHorizontalProgress](#progress) | +| Informational | [StandardAvatar](#avatar) • [StandardIcon](#icon) • [StandardLabel](#label) • [StandardProgress](#progress) | | Container | [StandardList](#list) • [StandardPane](#pane) • [StandardStack](#stack) | -Planned: Dropdown, Minimap, Radio Button, Tile, Vertical Progress +Planned: Dropdown, Minimap, Radio Button, Tile ## Interfaces @@ -640,6 +640,34 @@ void SetPercentage(float percentage); float getPercentage(); ``` +#### Color + +The color of the progress. + +Default: white + +```angelscript +void SetColor(SColor color); +SColor getColor(); +``` + +#### Fill Direction + +The direction the progress will fill in. + +Default: FillDirection::Right + +```angelscript +void SetFillDirection(FillDirection direction); +FillDirection getFillDirection(); +``` + +Examples: + +- `FillDirection::Right` means the progress will flow from left to right. +- `FillDirection::Top` means the progress will flow from bottom to top. + + ### Slider A component that displays a slider whose handle can be dragged. @@ -677,3 +705,4 @@ void SetChecked(bool checked); bool isChecked(); ``` +