diff -r 527a66c0afb2 -r e377456302df ui/winui/label.cpp --- a/ui/winui/label.cpp Tue Oct 17 21:00:48 2023 +0200 +++ b/ui/winui/label.cpp Tue Oct 17 21:50:48 2023 +0200 @@ -70,7 +70,7 @@ // TODO: } - // add button to current container + // add label to current container UI_APPLY_LAYOUT1(current, args); current->container->Add(label, false); @@ -102,3 +102,54 @@ TextBox box = widget->uielement.as(); box.Text(ui_string_set(str, newvalue)); } + + +// -------------------- progressbar ------------------------- + +UIWIDGET ui_progressbar_create(UiObject* obj, UiProgressbarArgs args) { + UiObject* current = uic_current_obj(obj); + + // create textbox and toolkit wrapper + ProgressBar progressbar = ProgressBar(); + progressbar.Minimum(args.min); + progressbar.Maximum(args.max == 0 ? 100 : args.max); + if (args.width > 0) { + progressbar.Width(args.width); + } + + UIElement elm = progressbar; + UiWidget* widget = new UiWidget(elm); + ui_context_add_widget_destructor(current->ctx, widget); + + UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_DOUBLE); + if (var) { + UiDouble* value = (UiDouble*)var->value; + value->obj = widget; + value->get = ui_progressbar_get; + value->set = ui_progressbar_set; + + // listener for notifying observers + // TODO: + } + + // add button to current container + UI_APPLY_LAYOUT1(current, args); + + current->container->Add(progressbar, false); + + return widget; +} + +double ui_progressbar_get(UiDouble * d) { + UiWidget* widget = (UiWidget*)d->obj; + ProgressBar progressbar = widget->uielement.as(); + d->value = progressbar.Value(); + return d->value; +} + +void ui_progressbar_set(UiDouble * d, double newvalue) { + UiWidget* widget = (UiWidget*)d->obj; + ProgressBar progressbar = widget->uielement.as(); + d->value = newvalue; + progressbar.Value(newvalue); +}