ui/winui/commandbar.cpp

branch
newapi
changeset 213
7e39db525fd9
parent 208
f632bc0589ab
child 226
4eef1d49f794
equal deleted inserted replaced
212:ad5c74af14c4 213:7e39db525fd9
34 #include "../common/object.h" 34 #include "../common/object.h"
35 #include "../common/context.h" 35 #include "../common/context.h"
36 36
37 #include "button.h" 37 #include "button.h"
38 #include "appmenu.h" 38 #include "appmenu.h"
39 #include "icons.h"
39 40
40 using namespace winrt; 41 using namespace winrt;
41 using namespace Microsoft::UI::Xaml; 42 using namespace Microsoft::UI::Xaml;
42 using namespace Microsoft::UI::Xaml::Controls; 43 using namespace Microsoft::UI::Xaml::Controls;
43 using namespace Microsoft::UI::Xaml::XamlTypeInfo; 44 using namespace Microsoft::UI::Xaml::XamlTypeInfo;
129 if (item->args.label) { 130 if (item->args.label) {
130 wchar_t* wlabel = str2wstr(item->args.label, nullptr); 131 wchar_t* wlabel = str2wstr(item->args.label, nullptr);
131 button.Label(wlabel); 132 button.Label(wlabel);
132 free(wlabel); 133 free(wlabel);
133 } 134 }
135 if(item->args.icon) {
136 button.Icon(ui_get_icon(item->args.icon));
137 }
134 138
135 // register callback 139 // register callback
136 if (item->args.onclick) { 140 if (item->args.onclick) {
137 ui_callback cbfunc = item->args.onclick; 141 ui_callback cbfunc = item->args.onclick;
138 void* cbdata = item->args.onclickdata; 142 void* cbdata = item->args.onclickdata;
155 if (item->args.label) { 159 if (item->args.label) {
156 wchar_t* wlabel = str2wstr(item->args.label, nullptr); 160 wchar_t* wlabel = str2wstr(item->args.label, nullptr);
157 button.Label(wlabel); 161 button.Label(wlabel);
158 free(wlabel); 162 free(wlabel);
159 } 163 }
164 if (item->args.icon) {
165 button.Icon(ui_get_icon(item->args.icon));
166 }
160 167
161 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, nullptr, item->args.varname, UI_VAR_INTEGER); 168 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, nullptr, item->args.varname, UI_VAR_INTEGER);
162 if (var) { 169 if (var) {
163 UIElement elm = button; 170 UIElement elm = button;
164 UiWidget* widget = new UiWidget(elm); 171 UiWidget* widget = new UiWidget(elm);
190 if (item->args.label) { 197 if (item->args.label) {
191 wchar_t* wlabel = str2wstr(item->args.label, nullptr); 198 wchar_t* wlabel = str2wstr(item->args.label, nullptr);
192 button.Label(wlabel); 199 button.Label(wlabel);
193 free(wlabel); 200 free(wlabel);
194 } 201 }
202 if (item->args.icon) {
203 button.Icon(ui_get_icon(item->args.icon));
204 }
195 205
196 MenuFlyoutItem mi = MenuFlyoutItem(); 206 MenuFlyoutItem mi = MenuFlyoutItem();
197 207
198 MenuFlyout flyout = ui_create_menu_flyout(obj, &item->menu); 208 MenuFlyout flyout = ui_create_menu_flyout(obj, &item->menu);
199 button.Flyout(flyout); 209 button.Flyout(flyout);

mercurial