From d6c1ac3ecf01c771b22913601ea4c3638763cb1c Mon Sep 17 00:00:00 2001 From: Tim Taenny Date: Thu, 31 Jan 2019 17:34:29 +0100 Subject: [PATCH] Added icon feature option to WPrefs: Enforce icon margin The current findBestIcon function usually selects an icon image that almost completely fills up the (default) 64x64 pixels of an icon. As Dan noted in the function, the icon images should use only 75% of the available space, which would result in room for the miniwindow title and better overall aesthetics. This feature option provides for enabling such an automatic "icon shrinking" functionality. Note: This commit only introduces the new option, not the actual image shrinking. --- WPrefs.app/Icons.c | 13 ++++++++++++- src/WindowMaker.h | 1 + src/defaults.c | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/WPrefs.app/Icons.c b/WPrefs.app/Icons.c index f0ad10b5..0f067aaa 100644 --- a/WPrefs.app/Icons.c +++ b/WPrefs.app/Icons.c @@ -79,6 +79,7 @@ typedef struct _Panel { WMButton *arrB; WMButton *omnB; WMButton *sclB; + WMButton *marginB; struct { WMFrame *frame; @@ -173,6 +174,7 @@ static void showData(_Panel * panel) WMSetButtonSelected(panel->arrB, GetBoolForKey("AutoArrangeIcons")); WMSetButtonSelected(panel->omnB, GetBoolForKey("StickyIcons")); WMSetButtonSelected(panel->sclB, GetBoolForKey("SingleClickLaunch")); + WMSetButtonSelected(panel->marginB, GetBoolForKey("EnforceIconMargin")); str = GetStringForKey("IconPosition"); if (str != NULL) { @@ -387,7 +389,7 @@ static void createPanel(Panel * p) WMResizeWidget(panel->optF, 215, 148); WMMoveWidget(panel->optF, 292, 72); /* WMSetFrameTitle(panel->optF, _("Icon Display")); */ - starty = 8 + 27; /* the last term centers the checkboxes within the panel; subtract 13 for a new option */ + starty = 8 + 14; /* the last term centers the checkboxes within the panel; subtract 13 for a new option */ panel->arrB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->arrB, 198, 26); @@ -413,6 +415,14 @@ static void createPanel(Panel * p) WMSetBalloonTextForView(_("Launch applications and restore windows with a single click."), WMWidgetView(panel->sclB)); + panel->marginB = WMCreateSwitchButton(panel->optF); + WMResizeWidget(panel->marginB, 198, 26); + WMMoveWidget(panel->marginB, 12, starty); + starty += 26; + WMSetButtonText(panel->marginB, _("Enforce icon margin")); + + WMSetBalloonTextForView(_("Make sure that the icon image does not protrude into the icon frame."), WMWidgetView(panel->marginB)); + WMMapSubwidgets(panel->optF); WMRealizeWidget(panel->box); @@ -428,6 +438,7 @@ static void storeData(_Panel * panel) SetBoolForKey(WMGetButtonSelected(panel->arrB), "AutoArrangeIcons"); SetBoolForKey(WMGetButtonSelected(panel->omnB), "StickyIcons"); SetBoolForKey(WMGetButtonSelected(panel->sclB), "SingleClickLaunch"); + SetBoolForKey(WMGetButtonSelected(panel->marginB), "EnforceIconMargin"); SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel->sizeP) * 8 + 24, "IconSize"); diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 90f1d2b3..fb046a2a 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -376,6 +376,7 @@ extern struct WPreferences { char disable_root_mouse; /* disable button events in root window */ char auto_focus; /* focus window when it's mapped */ char *icon_back_file; /* background image for icons */ + char enforce_icon_margin; /* auto-shrink icon images */ WCoord *root_menu_pos; /* initial position of the root menu*/ WCoord *app_menu_pos; diff --git a/src/defaults.c b/src/defaults.c index 23a0cff9..682f6599 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -363,6 +363,8 @@ WDefaultEntry optionList[] = { &wPreferences.icon_yard, getEnum, setIconPosition, NULL, NULL}, {"IconificationStyle", "Zoom", seIconificationStyles, &wPreferences.iconification_style, getEnum, NULL, NULL, NULL}, + {"EnforceIconMargin", "NO", NULL, + &wPreferences.enforce_icon_margin, getBool, NULL, NULL, NULL}, {"DisableWSMouseActions", "NO", NULL, &wPreferences.disable_root_mouse, getBool, NULL, NULL, NULL}, {"MouseLeftButtonAction", "SelectWindows", seMouseButtonActions,