mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +01:00
WPrefs: grouped items related to the color selection in a single place
Having all these information spread in different places makes it error prone when wanting to add/remove/change something in the list are there are many unrelated places to keep in sync. By merging everything in a single struct array it is a lot easier to maintain this list. Took the opportunity to properly document a little hack which is used to avoid complex handling for a special case. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
2c9e500b88
commit
2925e54bc1
@@ -343,22 +343,54 @@ enum {
|
|||||||
static const struct {
|
static const struct {
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *default_value;
|
const char *default_value;
|
||||||
|
const char *label;
|
||||||
|
WMRect preview; /* The rectangle where the corresponding object is displayed */
|
||||||
|
WMPoint hand; /* The coordinate where the hand is drawn when pointing this item */
|
||||||
} colorOptions[] = {
|
} colorOptions[] = {
|
||||||
{ "FTitleColor", "white" },
|
/* Related to Window titles */
|
||||||
{ "UTitleColor", "black" },
|
{ "FTitleColor", "white", N_("Focused Window Title"),
|
||||||
{ "PTitleColor", "white" },
|
{ { 30, 10 }, { 190, 20 } }, { 5, 10 } },
|
||||||
{ "MenuTitleColor", "white" },
|
{ "UTitleColor", "black", N_("Unfocused Window Title"),
|
||||||
{ "MenuTextColor", "black" },
|
{ { 30, 40 }, { 190, 20 } }, { 5, 40 } },
|
||||||
{ "MenuDisabledColor", "#616161" },
|
{ "PTitleColor", "white", N_("Owner of Focused Window Title"),
|
||||||
{ "HighlightColor", "white" },
|
{ { 30, 70 }, { 190, 20 } }, { 5, 70 } },
|
||||||
{ "HighlightTextColor", "black" },
|
|
||||||
{ "FrameFocusedBorderColor", "black" },
|
/* Related to Menus */
|
||||||
{ "FrameBorderColor", "black" },
|
{ "MenuTitleColor", "white", N_("Menu Title") ,
|
||||||
{ "FrameSelectedBorderColor", "white" },
|
{ { 30, 120 }, { 90, 20 } }, { 5, 120 } },
|
||||||
{ "IconTitleColor", "white" },
|
{ "MenuTextColor", "black", N_("Menu Item Text") ,
|
||||||
{ "IconTitleBack", "black" },
|
{ { 30, 140 }, { 90, 20 } }, { 5, 140 } },
|
||||||
{ "ClipTitleColor", "black" },
|
{ "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
|
||||||
{ "CClipTitleColor", "#454045" }
|
{ { 30, 160 }, { 90, 20 } }, { 5, 160 } },
|
||||||
|
{ "HighlightColor", "white", N_("Menu Highlight Color") ,
|
||||||
|
{ { 30, 180 }, { 90, 20 } }, { 5, 180 } },
|
||||||
|
{ "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
|
||||||
|
{ { 30, 200 }, { 90, 20 } }, { 5, 180 } },
|
||||||
|
/*
|
||||||
|
* yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
|
||||||
|
* at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
|
||||||
|
* for the MenuTextColor selection as user would expect
|
||||||
|
*
|
||||||
|
* Note that the entries are reffered by their index for performance
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Related to Window's border */
|
||||||
|
{ "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
{ "FrameBorderColor", "black", N_("Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
{ "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
|
||||||
|
{ { 0, 0 }, { 0, 0 } }, { -22, -21 } },
|
||||||
|
|
||||||
|
/* Related to Icons and Clip */
|
||||||
|
{ "IconTitleColor", "white", N_("Miniwindow Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "IconTitleBack", "black", N_("Miniwindow Title Back") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "ClipTitleColor", "black", N_("Clip Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } },
|
||||||
|
{ "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static WMRect previewPositions[] = {
|
static WMRect previewPositions[] = {
|
||||||
@@ -381,23 +413,6 @@ static WMRect previewPositions[] = {
|
|||||||
#define PBACKGROUND 7
|
#define PBACKGROUND 7
|
||||||
#define EVERYTHING 0xff
|
#define EVERYTHING 0xff
|
||||||
|
|
||||||
static WMRect previewColorPositions[] = {
|
|
||||||
{{30, 10}, {190, 20}},
|
|
||||||
{{30, 40}, {190, 20}},
|
|
||||||
{{30, 70}, {190, 20}},
|
|
||||||
{{30, 120}, {90, 20}},
|
|
||||||
{{30, 140}, {90, 20}},
|
|
||||||
{{30, 160}, {90, 20}},
|
|
||||||
{{30, 180}, {90, 20}},
|
|
||||||
{{30, 200}, {90, 20}},
|
|
||||||
{{0, 0}, {0, 0}},
|
|
||||||
{{0, 0}, {0, 0}},
|
|
||||||
{{0, 0}, {0, 0}},
|
|
||||||
{{155, 130}, {64, 64}},
|
|
||||||
{{155, 130}, {64, 64}},
|
|
||||||
{{155, 130}, {64, 64}},
|
|
||||||
{{155, 130}, {64, 64}}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
||||||
{
|
{
|
||||||
@@ -1135,14 +1150,17 @@ static void previewClick(XEvent * event, void *clientData)
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
|
for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
|
||||||
if (event->xbutton.x >= previewColorPositions[i].pos.x
|
if (event->xbutton.x >= colorOptions[i].preview.pos.x &&
|
||||||
&& event->xbutton.y >= previewColorPositions[i].pos.y
|
event->xbutton.y >= colorOptions[i].preview.pos.y &&
|
||||||
&& event->xbutton.x < previewColorPositions[i].pos.x
|
event->xbutton.x < colorOptions[i].preview.pos.x + colorOptions[i].preview.size.width &&
|
||||||
+ previewColorPositions[i].size.width
|
event->xbutton.y < colorOptions[i].preview.pos.y + colorOptions[i].preview.size.height) {
|
||||||
&& event->xbutton.y < previewColorPositions[i].pos.y
|
|
||||||
+ previewColorPositions[i].size.height) {
|
|
||||||
|
|
||||||
/* yuck kluge */
|
/*
|
||||||
|
* yuck kluge: the entry #7 is HighlightTextColor which does not have actually a
|
||||||
|
* display area, but are reused to make the last "Normal Item" menu entry actually
|
||||||
|
* pick the same color item as the other similar item displayed, which corresponds
|
||||||
|
* to MenuTextColor
|
||||||
|
*/
|
||||||
if (i == 7)
|
if (i == 7)
|
||||||
i = 4;
|
i = 4;
|
||||||
|
|
||||||
@@ -1369,40 +1387,24 @@ static void changeColorPage(WMWidget * w, void *data)
|
|||||||
int section;
|
int section;
|
||||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||||
RContext *rc = WMScreenRContext(scr);
|
RContext *rc = WMScreenRContext(scr);
|
||||||
static WMPoint positions[] = {
|
|
||||||
{5, 10},
|
|
||||||
{5, 40},
|
|
||||||
{5, 70},
|
|
||||||
{5, 120},
|
|
||||||
{5, 140},
|
|
||||||
{5, 160},
|
|
||||||
{5, 180},
|
|
||||||
{5, 180},
|
|
||||||
{-22, -21},
|
|
||||||
{-22, -21},
|
|
||||||
{-22, -21},
|
|
||||||
{130, 132},
|
|
||||||
{130, 132},
|
|
||||||
{130, 132},
|
|
||||||
{130, 132}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (panel->preview) {
|
if (panel->preview) {
|
||||||
GC gc;
|
GC gc;
|
||||||
|
|
||||||
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||||
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
||||||
positions[panel->oldcsection].x,
|
colorOptions[panel->oldcsection].hand.x,
|
||||||
positions[panel->oldcsection].y, 22, 22 ,
|
colorOptions[panel->oldcsection].hand.y, 22, 22 ,
|
||||||
positions[panel->oldcsection].x,
|
colorOptions[panel->oldcsection].hand.x,
|
||||||
positions[panel->oldcsection].y);
|
colorOptions[panel->oldcsection].hand.y);
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w) {
|
||||||
section = WMGetPopUpButtonSelectedItem(panel->colP);
|
section = WMGetPopUpButtonSelectedItem(panel->colP);
|
||||||
|
|
||||||
panel->oldcsection = section;
|
panel->oldcsection = section;
|
||||||
if (panel->preview)
|
if (panel->preview)
|
||||||
WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
|
WMDrawPixmap(panel->hand, panel->preview,
|
||||||
|
colorOptions[section].hand.x, colorOptions[section].hand.y);
|
||||||
|
|
||||||
if (section >= ICONT_COL)
|
if (section >= ICONT_COL)
|
||||||
updateColorPreviewBox(panel, 1 << section);
|
updateColorPreviewBox(panel, 1 << section);
|
||||||
@@ -1945,21 +1947,9 @@ static void createPanel(Panel * p)
|
|||||||
panel->colP = WMCreatePopUpButton(panel->colF);
|
panel->colP = WMCreatePopUpButton(panel->colF);
|
||||||
WMResizeWidget(panel->colP, 228, 20);
|
WMResizeWidget(panel->colP, 228, 20);
|
||||||
WMMoveWidget(panel->colP, 7, 7);
|
WMMoveWidget(panel->colP, 7, 7);
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
|
for (i = 0; i < wlengthof(colorOptions); i++)
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
|
WMAddPopUpButtonItem(panel->colP, _(colorOptions[i].label));
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Focused Window Border Color"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Window Border Color"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Selected Window Border Color"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
|
|
||||||
WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
|
|
||||||
|
|
||||||
WMSetPopUpButtonSelectedItem(panel->colP, 0);
|
WMSetPopUpButtonSelectedItem(panel->colP, 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user