ui/winui/button.cpp

branch
newapi
changeset 374
eae5d6623fd3
parent 373
2eede3d98aba
equal deleted inserted replaced
373:2eede3d98aba 374:eae5d6623fd3
54 } 54 }
55 else if (type == UI_LABEL_TEXT) { 55 else if (type == UI_LABEL_TEXT) {
56 icon = NULL; 56 icon = NULL;
57 } 57 }
58 58
59 if (label && icon) { 59 IconElement icon_elm = { nullptr };
60 if (icon) {
61 icon_elm = ui_get_icon(icon);
62 }
63
64 if (label && icon_elm) {
60 StackPanel panel = StackPanel(); 65 StackPanel panel = StackPanel();
61 panel.Orientation(Orientation::Horizontal); 66 panel.Orientation(Orientation::Horizontal);
62 panel.Spacing(5); 67 panel.Spacing(5);
63 68
64 panel.Children().Append(ui_get_icon(icon)); 69 panel.Children().Append(icon_elm);
65 70
66 wchar_t* wlabel = str2wstr(label, nullptr); 71 wchar_t* wlabel = str2wstr(label, nullptr);
67 TextBlock label = TextBlock(); 72 TextBlock label = TextBlock();
68 label.Text(wlabel); 73 label.Text(wlabel);
69 panel.Children().Append(label); 74 panel.Children().Append(label);
74 else if (label) { 79 else if (label) {
75 wchar_t* wlabel = str2wstr(label, nullptr); 80 wchar_t* wlabel = str2wstr(label, nullptr);
76 button.Content(box_value(wlabel)); 81 button.Content(box_value(wlabel));
77 free(wlabel); 82 free(wlabel);
78 } 83 }
79 else if (icon) { 84 else if (icon_elm) {
80 button.Content(ui_get_icon(icon)); 85 button.Content(ui_get_icon(icon));
81 } 86 }
82 } 87 }
83 88
84 89

mercurial