mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
Improved layout of the Input Panels
Instead of relying on static pixel values for position and size of the widgets, the input panels now scale their widgets based on the selected system font size.
This commit is contained in:
committed by
Carlos R. Mafra
parent
26bb94a8e7
commit
f9236c8d20
@@ -357,6 +357,7 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
||||
{
|
||||
WMInputPanel *panel;
|
||||
int x, dw = 0, aw = 0, w;
|
||||
int fw, fh;
|
||||
|
||||
panel = wmalloc(sizeof(WMInputPanel));
|
||||
|
||||
@@ -366,16 +367,17 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
||||
panel->win = WMCreateWindowWithStyle(scrPtr, "inputPanel", WMTitledWindowMask);
|
||||
WMSetWindowTitle(panel->win, "");
|
||||
|
||||
WMResizeWidget(panel->win, 320, 160);
|
||||
WMGetScaleBaseFromSystemFont(scrPtr, &fw, &fh);
|
||||
WMResizeWidget(panel->win, ScaleX(320), ScaleY(160));
|
||||
|
||||
if (title) {
|
||||
WMFont *largeFont;
|
||||
|
||||
largeFont = WMBoldSystemFontOfSize(scrPtr, 24);
|
||||
largeFont = WMBoldSystemFontOfSize(scrPtr, ScaleY(24));
|
||||
|
||||
panel->tLbl = WMCreateLabel(panel->win);
|
||||
WMMoveWidget(panel->tLbl, 20, 16);
|
||||
WMResizeWidget(panel->tLbl, 320 - 40, WMFontHeight(largeFont) + 4);
|
||||
WMMoveWidget(panel->tLbl, ScaleX(20), ScaleY(16));
|
||||
WMResizeWidget(panel->tLbl, ScaleX(320) - 2 * ScaleX(20), WMFontHeight(largeFont) + ScaleY(4));
|
||||
WMSetLabelText(panel->tLbl, title);
|
||||
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
||||
WMSetLabelFont(panel->tLbl, largeFont);
|
||||
@@ -385,15 +387,15 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
||||
|
||||
if (msg) {
|
||||
panel->mLbl = WMCreateLabel(panel->win);
|
||||
WMMoveWidget(panel->mLbl, 20, 50);
|
||||
WMResizeWidget(panel->mLbl, 320 - 40, WMFontHeight(scrPtr->normalFont) * 2);
|
||||
WMMoveWidget(panel->mLbl, ScaleX(20), ScaleY(50));
|
||||
WMResizeWidget(panel->mLbl, ScaleX(320) - 2 * ScaleX(20), WMFontHeight(scrPtr->normalFont) * 2);
|
||||
WMSetLabelText(panel->mLbl, msg);
|
||||
WMSetLabelTextAlignment(panel->mLbl, WALeft);
|
||||
}
|
||||
|
||||
panel->text = WMCreateTextField(panel->win);
|
||||
WMMoveWidget(panel->text, 20, 85);
|
||||
WMResizeWidget(panel->text, 320 - 40, WMWidgetHeight(panel->text));
|
||||
WMMoveWidget(panel->text, ScaleX(20), ScaleY(85));
|
||||
WMResizeWidget(panel->text, ScaleX(320) - 2 * ScaleX(20), ScaleY(20));
|
||||
WMSetTextFieldText(panel->text, defaultText);
|
||||
|
||||
WMAddNotificationObserver(endedEditingObserver, panel, WMTextDidEndEditingNotification, panel->text);
|
||||
@@ -409,29 +411,29 @@ WMInputPanel *WMCreateInputPanel(WMScreen * scrPtr, WMWindow * owner, const char
|
||||
if (aw > w)
|
||||
w = aw;
|
||||
|
||||
w += 30;
|
||||
x = 310;
|
||||
w += ScaleX(30);
|
||||
x = ScaleX(310);
|
||||
|
||||
if (okButton) {
|
||||
x -= w + 10;
|
||||
x -= w + ScaleX(10);
|
||||
|
||||
panel->defBtn = WMCreateCustomButton(panel->win, WBBPushInMask
|
||||
| WBBPushChangeMask | WBBPushLightMask);
|
||||
WMSetButtonAction(panel->defBtn, inputBoxOnClick, panel);
|
||||
WMMoveWidget(panel->defBtn, x, 124);
|
||||
WMResizeWidget(panel->defBtn, w, 24);
|
||||
WMMoveWidget(panel->defBtn, x, ScaleY(124));
|
||||
WMResizeWidget(panel->defBtn, w, ScaleY(24));
|
||||
WMSetButtonText(panel->defBtn, okButton);
|
||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||
}
|
||||
if (cancelButton) {
|
||||
x -= w + 10;
|
||||
x -= w + ScaleX(10);
|
||||
|
||||
panel->altBtn = WMCreateCommandButton(panel->win);
|
||||
WMSetButtonAction(panel->altBtn, inputBoxOnClick, panel);
|
||||
WMMoveWidget(panel->altBtn, x, 124);
|
||||
WMResizeWidget(panel->altBtn, w, 24);
|
||||
WMMoveWidget(panel->altBtn, x, ScaleY(124));
|
||||
WMResizeWidget(panel->altBtn, w, ScaleY(24));
|
||||
WMSetButtonText(panel->altBtn, cancelButton);
|
||||
}
|
||||
|
||||
|
||||
18
src/dialog.c
18
src/dialog.c
@@ -428,6 +428,7 @@ int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, c
|
||||
WMPoint center;
|
||||
WMInputPanelWithHistory *p;
|
||||
char *filename;
|
||||
int pwidth, pheight;
|
||||
|
||||
filename = HistoryFileName(name);
|
||||
p = wmalloc(sizeof(WMInputPanelWithHistory));
|
||||
@@ -440,14 +441,16 @@ int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, c
|
||||
p->variants = NULL;
|
||||
p->varpos = 0;
|
||||
WMCreateEventHandler(WMWidgetView(p->panel->text), KeyPressMask, handleHistoryKeyPress, p);
|
||||
pwidth = WMWidgetWidth(p->panel->win);
|
||||
pheight = WMWidgetHeight(p->panel->win);
|
||||
|
||||
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
|
||||
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0);
|
||||
XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);
|
||||
|
||||
XReparentWindow(dpy, WMWidgetXID(p->panel->win), parent, 0, 0);
|
||||
|
||||
center = getCenter(scr, 320, 160);
|
||||
wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, 320, 160);
|
||||
center = getCenter(scr, pwidth, pheight);
|
||||
wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight);
|
||||
|
||||
wwin->client_leader = WMWidgetXID(p->panel->win);
|
||||
|
||||
@@ -491,16 +494,19 @@ int wInputDialog(WScreen *scr, const char *title, const char *message, char **te
|
||||
WMInputPanel *panel;
|
||||
char *result;
|
||||
WMPoint center;
|
||||
int pwidth, pheight;
|
||||
|
||||
panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text, _("OK"), _("Cancel"));
|
||||
pwidth = WMWidgetWidth(panel->win);
|
||||
pheight = WMWidgetHeight(panel->win);
|
||||
|
||||
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
|
||||
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0);
|
||||
XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);
|
||||
|
||||
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
|
||||
|
||||
center = getCenter(scr, 320, 160);
|
||||
wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, 320, 160);
|
||||
center = getCenter(scr, pwidth, pheight);
|
||||
wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight);
|
||||
|
||||
wwin->client_leader = WMWidgetXID(panel->win);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user