use grids instead of nested boxes for input config dialog. (still lags, needs optimization)

adjust things to make those dialogs sexier.
This commit is contained in:
StapleButter 2017-10-05 01:03:22 +02:00
parent 9d3f13b689
commit 5d5311c53c
2 changed files with 10 additions and 13 deletions

View File

@ -303,27 +303,24 @@ void Open()
{ {
uiBox* in_ctrl = uiNewHorizontalBox(); uiBox* in_ctrl = uiNewHorizontalBox();
uiBoxAppend(top, uiControl(in_ctrl), 0); uiBoxAppend(top, uiControl(in_ctrl), 0);
uiBoxSetPadded(in_ctrl, 1);
uiGroup* g_key = uiNewGroup("Keyboard"); uiGroup* g_key = uiNewGroup("Keyboard");
uiBoxAppend(in_ctrl, uiControl(g_key), 1); uiBoxAppend(in_ctrl, uiControl(g_key), 1);
uiBox* b_key = uiNewVerticalBox(); uiGrid* b_key = uiNewGrid();
uiGroupSetChild(g_key, uiControl(b_key)); uiGroupSetChild(g_key, uiControl(b_key));
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
int j = keyorder[i]; int j = keyorder[i];
uiBox* box = uiNewHorizontalBox();
uiBoxAppend(b_key, uiControl(box), 0);
uiLabel* label = uiNewLabel(keylabels[j]); uiLabel* label = uiNewLabel(keylabels[j]);
uiBoxAppend(box, uiControl(label), 1); uiGridAppend(b_key, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
char* keyname = uiKeyName(Config::KeyMapping[j]); char* keyname = uiKeyName(Config::KeyMapping[j]);
uiButton* btn = uiNewButton(keyname); uiButton* btn = uiNewButton(keyname);
uiBoxAppend(box, uiControl(btn), 1); uiGridAppend(b_key, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
uiButtonOnClicked(btn, OnKeyStartConfig, &keyorder[i]); uiButtonOnClicked(btn, OnKeyStartConfig, &keyorder[i]);
uiFreeText(keyname); uiFreeText(keyname);
@ -331,24 +328,21 @@ void Open()
uiGroup* g_joy = uiNewGroup("Joystick"); uiGroup* g_joy = uiNewGroup("Joystick");
uiBoxAppend(in_ctrl, uiControl(g_joy), 1); uiBoxAppend(in_ctrl, uiControl(g_joy), 1);
uiBox* b_joy = uiNewVerticalBox(); uiGrid* b_joy = uiNewGrid();
uiGroupSetChild(g_joy, uiControl(b_joy)); uiGroupSetChild(g_joy, uiControl(b_joy));
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
int j = keyorder[i]; int j = keyorder[i];
uiBox* box = uiNewHorizontalBox();
uiBoxAppend(b_joy, uiControl(box), 0);
uiLabel* label = uiNewLabel(keylabels[j]); uiLabel* label = uiNewLabel(keylabels[j]);
uiBoxAppend(box, uiControl(label), 1); uiGridAppend(b_joy, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
char keyname[16]; char keyname[16];
JoyMappingName(Config::JoyMapping[j], keyname); JoyMappingName(Config::JoyMapping[j], keyname);
uiButton* btn = uiNewButton(keyname); uiButton* btn = uiNewButton(keyname);
uiBoxAppend(box, uiControl(btn), 1); uiGridAppend(b_joy, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
uiButtonOnClicked(btn, OnJoyStartConfig, &keyorder[i]); uiButtonOnClicked(btn, OnJoyStartConfig, &keyorder[i]);
} }
} }

View File

@ -32,6 +32,7 @@ uiWindowsControlAllDefaultsExceptDestroy(uiButton)
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define buttonHeight 14 #define buttonHeight 14
#define buttonMinWidth 64
static void uiButtonMinimumSize(uiWindowsControl *c, int *width, int *height) static void uiButtonMinimumSize(uiWindowsControl *c, int *width, int *height)
{ {
@ -45,6 +46,7 @@ static void uiButtonMinimumSize(uiWindowsControl *c, int *width, int *height)
size.cy = 0; size.cy = 0;
if (SendMessageW(b->hwnd, BCM_GETIDEALSIZE, 0, (LPARAM) (&size)) != FALSE) { if (SendMessageW(b->hwnd, BCM_GETIDEALSIZE, 0, (LPARAM) (&size)) != FALSE) {
*width = size.cx; *width = size.cx;
if (*width < buttonMinWidth) *width = buttonMinWidth;
*height = size.cy; *height = size.cy;
return; return;
} }
@ -53,6 +55,7 @@ static void uiButtonMinimumSize(uiWindowsControl *c, int *width, int *height)
// Microsoft says to use a fixed width for all buttons; this isn't good enough // Microsoft says to use a fixed width for all buttons; this isn't good enough
// use the text width instead, with some edge padding // use the text width instead, with some edge padding
*width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE)); *width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
if (*width < buttonMinWidth) *width = buttonMinWidth;
y = buttonHeight; y = buttonHeight;
uiWindowsGetSizing(b->hwnd, &sizing); uiWindowsGetSizing(b->hwnd, &sizing);
uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y); uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y);