mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
Improved layout of the Info Panel
Instead of relying on static pixel values for position and size of the widgets, the info panel now scales its widgets based on the selected system font size.
This commit is contained in:
committed by
Carlos R. Mafra
parent
1c8b680e3d
commit
b48b503eb1
60
src/dialog.c
60
src/dialog.c
@@ -1169,12 +1169,10 @@ static void destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
|
|||||||
|
|
||||||
void wShowInfoPanel(WScreen *scr)
|
void wShowInfoPanel(WScreen *scr)
|
||||||
{
|
{
|
||||||
const int win_width = 382;
|
|
||||||
const int win_height = 250;
|
|
||||||
InfoPanel *panel;
|
InfoPanel *panel;
|
||||||
WMPixmap *logo;
|
WMPixmap *logo;
|
||||||
WMFont *font;
|
WMFont *font;
|
||||||
char *name, *strbuf = NULL;
|
char *strbuf = NULL;
|
||||||
const char *separator;
|
const char *separator;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
Window parent;
|
Window parent;
|
||||||
@@ -1190,6 +1188,8 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
"TrueColor",
|
"TrueColor",
|
||||||
"DirectColor"
|
"DirectColor"
|
||||||
};
|
};
|
||||||
|
int fw, fh;
|
||||||
|
int pwidth, pheight;
|
||||||
|
|
||||||
if (infoPanel) {
|
if (infoPanel) {
|
||||||
if (infoPanel->scr == scr) {
|
if (infoPanel->scr == scr) {
|
||||||
@@ -1204,7 +1204,10 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
panel->scr = scr;
|
panel->scr = scr;
|
||||||
|
|
||||||
panel->win = WMCreateWindow(scr->wmscreen, "info");
|
panel->win = WMCreateWindow(scr->wmscreen, "info");
|
||||||
WMResizeWidget(panel->win, win_width, win_height);
|
WMGetScaleBaseFromSystemFont(scr->wmscreen, &fw, &fh);
|
||||||
|
pwidth = ScaleX(382);
|
||||||
|
pheight = ScaleY(250);
|
||||||
|
WMResizeWidget(panel->win, pwidth, pheight);
|
||||||
|
|
||||||
logo = WMCreateApplicationIconBlendedPixmap(scr->wmscreen, (RColor *) NULL);
|
logo = WMCreateApplicationIconBlendedPixmap(scr->wmscreen, (RColor *) NULL);
|
||||||
if (!logo) {
|
if (!logo) {
|
||||||
@@ -1212,20 +1215,23 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
}
|
}
|
||||||
if (logo) {
|
if (logo) {
|
||||||
panel->logoL = WMCreateLabel(panel->win);
|
panel->logoL = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->logoL, 64, 64);
|
WMResizeWidget(panel->logoL, ScaleX(64), ScaleY(64));
|
||||||
WMMoveWidget(panel->logoL, 30, 20);
|
WMMoveWidget(panel->logoL, ScaleX(30), ScaleY(20));
|
||||||
WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
|
WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
|
||||||
WMSetLabelImage(panel->logoL, logo);
|
WMSetLabelImage(panel->logoL, logo);
|
||||||
WMReleasePixmap(logo);
|
WMReleasePixmap(logo);
|
||||||
}
|
}
|
||||||
|
|
||||||
sepHeight = 3;
|
sepHeight = ScaleY(3);
|
||||||
panel->name1L = WMCreateLabel(panel->win);
|
panel->name1L = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->name1L, 240, 30 + 2);
|
WMResizeWidget(panel->name1L, ScaleX(240), ScaleY(30) + ScaleY(2));
|
||||||
WMMoveWidget(panel->name1L, 100, 30 - 2 - sepHeight);
|
WMMoveWidget(panel->name1L, ScaleX(100), ScaleY(30) - ScaleY(2) - sepHeight);
|
||||||
|
|
||||||
name = "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS" ":italic:pixelsize=28:antialias=true";
|
snprintf(buffer,
|
||||||
font = WMCreateFont(scr->wmscreen, name);
|
sizeof(buffer),
|
||||||
|
"Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS:italic:pixelsize=%d:antialias=true",
|
||||||
|
ScaleY(24));
|
||||||
|
font = WMCreateFont(scr->wmscreen, buffer);
|
||||||
strbuf = "Window Maker";
|
strbuf = "Window Maker";
|
||||||
if (font) {
|
if (font) {
|
||||||
width = WMWidthOfString(font, strbuf, strlen(strbuf));
|
width = WMWidthOfString(font, strbuf, strlen(strbuf));
|
||||||
@@ -1237,15 +1243,15 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
|
|
||||||
panel->lineF = WMCreateFrame(panel->win);
|
panel->lineF = WMCreateFrame(panel->win);
|
||||||
WMResizeWidget(panel->lineF, width, sepHeight);
|
WMResizeWidget(panel->lineF, width, sepHeight);
|
||||||
WMMoveWidget(panel->lineF, 100 + (240 - width) / 2, 60 - sepHeight);
|
WMMoveWidget(panel->lineF, ScaleX(100) + (ScaleX(240) - width) / 2, ScaleY(60) - sepHeight);
|
||||||
WMSetFrameRelief(panel->lineF, WRSimple);
|
WMSetFrameRelief(panel->lineF, WRSimple);
|
||||||
WMSetWidgetBackgroundColor(panel->lineF, scr->black);
|
WMSetWidgetBackgroundColor(panel->lineF, scr->black);
|
||||||
|
|
||||||
panel->name2L = WMCreateLabel(panel->win);
|
panel->name2L = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->name2L, 240, 24);
|
WMResizeWidget(panel->name2L, ScaleX(240), ScaleY(24));
|
||||||
WMMoveWidget(panel->name2L, 100, 60);
|
WMMoveWidget(panel->name2L, ScaleX(100), ScaleY(60));
|
||||||
name = "URW Gothic L,Nimbus Sans L:pixelsize=16:antialias=true";
|
snprintf(buffer, sizeof(buffer), "URW Gothic L,Nimbus Sans L:pixelsize=%d:antialias=true", ScaleY(16));
|
||||||
font = WMCreateFont(scr->wmscreen, name);
|
font = WMCreateFont(scr->wmscreen, buffer);
|
||||||
if (font) {
|
if (font) {
|
||||||
WMSetLabelFont(panel->name2L, font);
|
WMSetLabelFont(panel->name2L, font);
|
||||||
WMReleaseFont(font);
|
WMReleaseFont(font);
|
||||||
@@ -1256,18 +1262,18 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION);
|
snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION);
|
||||||
panel->versionL = WMCreateLabel(panel->win);
|
panel->versionL = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->versionL, 310, 16);
|
WMResizeWidget(panel->versionL, ScaleX(310), ScaleY(16));
|
||||||
WMMoveWidget(panel->versionL, 30, 95);
|
WMMoveWidget(panel->versionL, ScaleX(30), ScaleY(95));
|
||||||
WMSetLabelTextAlignment(panel->versionL, WARight);
|
WMSetLabelTextAlignment(panel->versionL, WARight);
|
||||||
WMSetLabelText(panel->versionL, buffer);
|
WMSetLabelText(panel->versionL, buffer);
|
||||||
WMSetLabelWraps(panel->versionL, False);
|
WMSetLabelWraps(panel->versionL, False);
|
||||||
|
|
||||||
panel->copyrL = WMCreateLabel(panel->win);
|
panel->copyrL = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->copyrL, 360, 60);
|
WMResizeWidget(panel->copyrL, ScaleX(360), ScaleY(60));
|
||||||
WMMoveWidget(panel->copyrL, 15, 190);
|
WMMoveWidget(panel->copyrL, ScaleX(15), ScaleY(190));
|
||||||
WMSetLabelTextAlignment(panel->copyrL, WALeft);
|
WMSetLabelTextAlignment(panel->copyrL, WALeft);
|
||||||
WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
|
WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
|
||||||
font = WMSystemFontOfSize(scr->wmscreen, 11);
|
font = WMSystemFontOfSize(scr->wmscreen, ScaleY(11));
|
||||||
if (font) {
|
if (font) {
|
||||||
WMSetLabelFont(panel->copyrL, font);
|
WMSetLabelFont(panel->copyrL, font);
|
||||||
WMReleaseFont(font);
|
WMReleaseFont(font);
|
||||||
@@ -1371,10 +1377,10 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
panel->infoL = WMCreateLabel(panel->win);
|
panel->infoL = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->infoL, 350, 80);
|
WMResizeWidget(panel->infoL, ScaleX(350), ScaleY(80));
|
||||||
WMMoveWidget(panel->infoL, 15, 115);
|
WMMoveWidget(panel->infoL, ScaleX(15), ScaleY(115));
|
||||||
WMSetLabelText(panel->infoL, strbuf);
|
WMSetLabelText(panel->infoL, strbuf);
|
||||||
font = WMSystemFontOfSize(scr->wmscreen, 11);
|
font = WMSystemFontOfSize(scr->wmscreen, ScaleY(11));
|
||||||
if (font) {
|
if (font) {
|
||||||
WMSetLabelFont(panel->infoL, font);
|
WMSetLabelFont(panel->infoL, font);
|
||||||
WMReleaseFont(font);
|
WMReleaseFont(font);
|
||||||
@@ -1385,14 +1391,14 @@ void wShowInfoPanel(WScreen *scr)
|
|||||||
WMRealizeWidget(panel->win);
|
WMRealizeWidget(panel->win);
|
||||||
WMMapSubwidgets(panel->win);
|
WMMapSubwidgets(panel->win);
|
||||||
|
|
||||||
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, win_width, win_height, 0, 0, 0);
|
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0);
|
||||||
|
|
||||||
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
|
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
|
||||||
|
|
||||||
WMMapWidget(panel->win);
|
WMMapWidget(panel->win);
|
||||||
|
|
||||||
center = getCenter(scr, win_width, win_height);
|
center = getCenter(scr, pwidth, pheight);
|
||||||
wwin = wManageInternalWindow(scr, parent, None, _("Info"), center.x, center.y, win_width, win_height);
|
wwin = wManageInternalWindow(scr, parent, None, _("Info"), center.x, center.y, pwidth, pheight);
|
||||||
|
|
||||||
WSETUFLAG(wwin, no_closable, 0);
|
WSETUFLAG(wwin, no_closable, 0);
|
||||||
WSETUFLAG(wwin, no_close_button, 0);
|
WSETUFLAG(wwin, no_close_button, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user