Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions EasyUI/Components/Progress.as
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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();
}
}

2 changes: 2 additions & 0 deletions EasyUI/Events/Events.as
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum Event
Spacing,
CellWrap,
FlowDirection,
FillDirection,
ScrollIndex,

// Interaction
Expand All @@ -51,3 +52,4 @@ enum Event
Scroll,
}


33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -677,3 +705,4 @@ void SetChecked(bool checked);
bool isChecked();
```