ui/winui/button.cpp

changeset 76
641dcc79e0ef
parent 3
f154867f54dc
child 79
483d7342b439
--- a/ui/winui/button.cpp	Sun Nov 10 09:12:30 2024 +0100
+++ b/ui/winui/button.cpp	Sun Nov 10 15:30:46 2024 +0100
@@ -56,12 +56,17 @@
 		icon = NULL;
 	}
 
-	if (label && icon) {
+	IconElement icon_elm = { nullptr };
+	if (icon) {
+		icon_elm = ui_get_icon(icon);
+	}
+
+	if (label && icon_elm) {
 		StackPanel panel = StackPanel();
 		panel.Orientation(Orientation::Horizontal);
 		panel.Spacing(5);
 		
-		panel.Children().Append(ui_get_icon(icon));
+		panel.Children().Append(icon_elm);
 
 		wchar_t* wlabel = str2wstr(label, nullptr);
 		TextBlock label = TextBlock();
@@ -76,7 +81,7 @@
 		button.Content(box_value(wlabel));
 		free(wlabel);
 	}
-	else if (icon) {
+	else if (icon_elm) {
 		button.Content(ui_get_icon(icon));
 	}
 }
@@ -287,7 +292,7 @@
 		// get or create the group name
 		static int groupCount = 0;
 		winrt::hstring groupName;
-		if (radioButtons->size == 0) {
+		if (cxListSize(radioButtons) == 0) {
 			groupName = winrt::to_hstring(groupCount++);
 		} else {
 			UiWidget* firstButtonWidget = (UiWidget*)cxListAt(radioButtons, 0);

mercurial