Vertical progress bar added.
This commit is contained in:
parent
d2b90bd83e
commit
85f0e5be56
3 changed files with 52 additions and 9 deletions
|
|
@ -307,6 +307,7 @@ typedef struct WidgetT {
|
|||
struct {
|
||||
int32_t value;
|
||||
int32_t maxValue;
|
||||
bool vertical;
|
||||
} progressBar;
|
||||
|
||||
struct {
|
||||
|
|
@ -541,6 +542,7 @@ void wgtComboBoxSetSelected(WidgetT *w, int32_t idx);
|
|||
// ============================================================
|
||||
|
||||
WidgetT *wgtProgressBar(WidgetT *parent);
|
||||
WidgetT *wgtProgressBarV(WidgetT *parent);
|
||||
void wgtProgressBarSetValue(WidgetT *w, int32_t value);
|
||||
int32_t wgtProgressBarGetValue(const WidgetT *w);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,24 @@ WidgetT *wgtProgressBar(WidgetT *parent) {
|
|||
if (w) {
|
||||
w->as.progressBar.value = 0;
|
||||
w->as.progressBar.maxValue = 100;
|
||||
w->as.progressBar.vertical = false;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
// wgtProgressBarV
|
||||
// ============================================================
|
||||
|
||||
WidgetT *wgtProgressBarV(WidgetT *parent) {
|
||||
WidgetT *w = widgetAlloc(parent, WidgetProgressBarE);
|
||||
|
||||
if (w) {
|
||||
w->as.progressBar.value = 0;
|
||||
w->as.progressBar.maxValue = 100;
|
||||
w->as.progressBar.vertical = true;
|
||||
}
|
||||
|
||||
return w;
|
||||
|
|
@ -58,9 +76,14 @@ void wgtProgressBarSetValue(WidgetT *w, int32_t value) {
|
|||
// ============================================================
|
||||
|
||||
void widgetProgressBarCalcMinSize(WidgetT *w, const BitmapFontT *font) {
|
||||
if (w->as.progressBar.vertical) {
|
||||
w->calcMinW = font->charHeight + 4;
|
||||
w->calcMinH = font->charWidth * 12;
|
||||
} else {
|
||||
w->calcMinW = font->charWidth * 12;
|
||||
w->calcMinH = font->charHeight + 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
|
|
@ -89,6 +112,18 @@ void widgetProgressBarPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const
|
|||
|
||||
int32_t innerW = w->w - 4;
|
||||
int32_t innerH = w->h - 4;
|
||||
|
||||
if (w->as.progressBar.vertical) {
|
||||
int32_t fillH = (innerH * w->as.progressBar.value) / maxVal;
|
||||
|
||||
if (fillH > innerH) {
|
||||
fillH = innerH;
|
||||
}
|
||||
|
||||
if (fillH > 0) {
|
||||
rectFill(d, ops, w->x + 2, w->y + 2 + innerH - fillH, innerW, fillH, fg);
|
||||
}
|
||||
} else {
|
||||
int32_t fillW = (innerW * w->as.progressBar.value) / maxVal;
|
||||
|
||||
if (fillW > innerW) {
|
||||
|
|
@ -99,3 +134,4 @@ void widgetProgressBarPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const
|
|||
rectFill(d, ops, w->x + 2, w->y + 2, fillW, innerH, fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -502,9 +502,14 @@ static void setupControlsWindow(AppContextT *ctx) {
|
|||
wgtHSeparator(page1);
|
||||
|
||||
wgtLabel(page1, "&Progress:");
|
||||
WidgetT *pb = wgtProgressBar(page1);
|
||||
WidgetT *pbRow = wgtHBox(page1);
|
||||
WidgetT *pb = wgtProgressBar(pbRow);
|
||||
pb->weight = 100;
|
||||
wgtProgressBarSetValue(pb, 65);
|
||||
wgtSetTooltip(pb, "Task progress: 65%");
|
||||
WidgetT *pbV = wgtProgressBarV(pbRow);
|
||||
wgtProgressBarSetValue(pbV, 75);
|
||||
wgtSetTooltip(pbV, "Vertical progress: 75%");
|
||||
|
||||
wgtLabel(page1, "&Volume:");
|
||||
WidgetT *slider = wgtSlider(page1, 0, 100);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue