1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-27 12:45:55 +01:00

Added ScaleX and ScaleY macros to WINGs

To reduce code duplication the ScaleX and ScaleY macros have been
moved to WUtil.h. Along with the function WMGetScaleBaseFromSystemFont
these macros can be used in all panels to scale the widgets based on
the current system font size instead of giving fixed pixel sizes which
messes up the panels if a larger system font is selected in WPrefs.

Use the macros in the following way:

    instead of   WMResizeWidget(widget, 128, 64);
                 WMMoveWidget(widget, 32, 32);

    use          int fw, fh;
                 WMGetScaleBaseFromSystemFont(scr->wmscreen, &fw, &fh);
                 WMResizeWidget(widget, ScaleX(128), ScaleY(64));
                 WMMoveWidget(widget, ScaleX(32), ScaleY(32));
This commit is contained in:
Tim Taenny
2019-06-12 22:06:25 +02:00
committed by Carlos R. Mafra
parent 8f29bdc690
commit b185d46286
4 changed files with 66 additions and 54 deletions

View File

@@ -237,6 +237,16 @@ char *WMGetFontName(WMFont * font)
return font->name;
}
void WMGetScaleBaseFromSystemFont(WMScreen *scrPtr, int *alphabetWidth, int *fontHeight)
{
WMFont *font;
font = WMDefaultSystemFont(scrPtr);
*alphabetWidth = WMWidthOfString(font, "abcdefghijklmnopqrstuvwxyz", 26);
*fontHeight = WMFontHeight(font);
WMReleaseFont(font);
}
WMFont *WMDefaultSystemFont(WMScreen * scrPtr)
{
return WMRetainFont(scrPtr->normalFont);