ui/winui/label.cpp

branch
newapi
changeset 221
a82d9beaa94a
parent 220
e377456302df
child 231
e160bb392148
equal deleted inserted replaced
220:e377456302df 221:a82d9beaa94a
151 UiWidget* widget = (UiWidget*)d->obj; 151 UiWidget* widget = (UiWidget*)d->obj;
152 ProgressBar progressbar = widget->uielement.as<ProgressBar>(); 152 ProgressBar progressbar = widget->uielement.as<ProgressBar>();
153 d->value = newvalue; 153 d->value = newvalue;
154 progressbar.Value(newvalue); 154 progressbar.Value(newvalue);
155 } 155 }
156
157 UIWIDGET ui_progressspinner_create(UiObject* obj, UiProgressbarSpinnerArgs args) {
158 UiObject* current = uic_current_obj(obj);
159
160 // create textbox and toolkit wrapper
161 ProgressRing spinner = ProgressRing();
162 spinner.IsActive(false);
163
164 UIElement elm = spinner;
165 UiWidget* widget = new UiWidget(elm);
166 ui_context_add_widget_destructor(current->ctx, widget);
167
168 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_DOUBLE);
169 if (var) {
170 UiInteger* value = (UiInteger*)var->value;
171 value->obj = widget;
172 value->get = ui_progressspinner_get;
173 value->set = ui_progressspinner_set;
174
175 // listener for notifying observers
176 // TODO:
177 }
178
179 // add button to current container
180 UI_APPLY_LAYOUT1(current, args);
181
182 current->container->Add(spinner, false);
183
184 return widget;
185 }
186
187 int64_t ui_progressspinner_get(UiInteger * i) {
188 UiWidget* widget = (UiWidget*)i->obj;
189 ProgressRing spinner = widget->uielement.as<ProgressRing>();
190 i->value = spinner.IsActive();
191 return i->value;
192 }
193
194 void ui_progressspinner_set(UiInteger * i, int64_t newvalue) {
195 UiWidget* widget = (UiWidget*)i->obj;
196 ProgressRing spinner = widget->uielement.as<ProgressRing>();
197 i->value = newvalue != 0 ? 1 : 0;
198 spinner.IsActive(i->value);
199 }

mercurial