mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-31 19:12:32 +01:00
WPrefs: grouped items related to the texture 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. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
2925e54bc1
commit
18d77de91c
@@ -294,17 +294,46 @@ static char *sampleColors[] = {
|
|||||||
static const struct {
|
static const struct {
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *default_value;
|
const char *default_value;
|
||||||
const char *label;
|
const char *texture_label; /* text used when displaying the list of textures */
|
||||||
|
WMRect preview; /* The rectangle where the corresponding object is displayed */
|
||||||
|
WMPoint hand; /* The coordinate where the hand is drawn when pointing this item */
|
||||||
|
const char *popup_label; /* text used for the popup button with the list of editable items */
|
||||||
} textureOptions[] = {
|
} textureOptions[] = {
|
||||||
{ "FTitleBack", "(solid, black)", N_("[Focused]") },
|
|
||||||
{ "UTitleBack", "(solid, gray)", N_("[Unfocused]") },
|
#define PFOCUSED 0
|
||||||
{ "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]") },
|
{ "FTitleBack", "(solid, black)", N_("[Focused]"),
|
||||||
{ "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
|
{ { 30, 10 }, { 190, 20 } }, { 5, 10 }, N_("Titlebar of Focused Window") },
|
||||||
{ "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
|
|
||||||
{ "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
|
#define PUNFOCUSED 1
|
||||||
{ "IconBack", "(solid, gray)", N_("[Icon]") },
|
{ "UTitleBack", "(solid, gray)", N_("[Unfocused]"),
|
||||||
{ "WorkspaceBack", "(solid, black)", N_("[Background]") }
|
{ { 30, 40 }, { 190, 20 } }, { 5, 40 }, N_("Titlebar of Unfocused Windows") },
|
||||||
|
|
||||||
|
#define POWNER 2
|
||||||
|
{ "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]"),
|
||||||
|
{ { 30, 70 }, { 190, 20 } }, { 5, 70 }, N_("Titlebar of Focused Window's Owner") },
|
||||||
|
|
||||||
|
#define PRESIZEBAR 3
|
||||||
|
{ "ResizebarBack", "(solid, gray)", N_("[Resizebar]"),
|
||||||
|
{ { 30, 100 }, { 190, 9 } }, { 5, 100 }, N_("Window Resizebar") },
|
||||||
|
|
||||||
|
#define PMTITLE 4
|
||||||
|
{ "MenuTitleBack", "(solid, black)", N_("[Menu Title]"),
|
||||||
|
{ { 30, 120 }, { 90, 20 } }, { 5, 120 }, N_("Titlebar of Menus") },
|
||||||
|
|
||||||
|
#define PMITEM 5
|
||||||
|
{ "MenuTextBack", "(solid, gray)", N_("[Menu Item]"),
|
||||||
|
{ { 30, 140 }, { 90, 20 * 4 } }, { 5, 160 }, N_("Menu Items") },
|
||||||
|
|
||||||
|
#define PICON 6
|
||||||
|
{ "IconBack", "(solid, gray)", N_("[Icon]"),
|
||||||
|
{ { 155, 130 }, { 64, 64 } }, { 130, 150 }, N_("Icon Background") },
|
||||||
|
|
||||||
|
#define PBACKGROUND 7
|
||||||
|
{ "WorkspaceBack", "(solid, black)", N_("[Background]"),
|
||||||
|
{ { -1, -1}, { 0, 0 } }, { -22, -21 }, N_("Workspace Background") }
|
||||||
};
|
};
|
||||||
|
#define EVERYTHING 0xff
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RESIZEBAR_BEVEL = -1,
|
RESIZEBAR_BEVEL = -1,
|
||||||
@@ -393,26 +422,6 @@ static const struct {
|
|||||||
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } }
|
{ { 155, 130 }, { 64, 64 } }, { 130, 132 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static WMRect previewPositions[] = {
|
|
||||||
#define PFOCUSED 0
|
|
||||||
{{30, 10}, {190, 20}},
|
|
||||||
#define PUNFOCUSED 1
|
|
||||||
{{30, 40}, {190, 20}},
|
|
||||||
#define POWNER 2
|
|
||||||
{{30, 70}, {190, 20}},
|
|
||||||
#define PRESIZEBAR 3
|
|
||||||
{{30, 100}, {190, 9}},
|
|
||||||
#define PMTITLE 4
|
|
||||||
{{30, 120}, {90, 20}},
|
|
||||||
#define PMITEM 5
|
|
||||||
{{30, 140}, {90, 20 * 4}},
|
|
||||||
#define PICON 6
|
|
||||||
{{155, 130}, {64, 64}}
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PBACKGROUND 7
|
|
||||||
#define EVERYTHING 0xff
|
|
||||||
|
|
||||||
|
|
||||||
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
||||||
{
|
{
|
||||||
@@ -762,15 +771,16 @@ static void renderPreview(_Panel * panel, GC gc, int part, int relief)
|
|||||||
titem = (TextureListItem *) item->clientData;
|
titem = (TextureListItem *) item->clientData;
|
||||||
|
|
||||||
pix = renderTexture(scr, titem->prop,
|
pix = renderTexture(scr, titem->prop,
|
||||||
previewPositions[part].size.width, previewPositions[part].size.height, NULL, relief);
|
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||||
|
NULL, relief);
|
||||||
|
|
||||||
XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
|
XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
|
||||||
previewPositions[part].size.width,
|
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||||
previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
|
textureOptions[part].preview.pos.x, textureOptions[part].preview.pos.y);
|
||||||
|
|
||||||
XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
|
XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
|
||||||
previewPositions[part].size.width,
|
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||||
previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
|
textureOptions[part].preview.pos.x, textureOptions[part].preview.pos.y);
|
||||||
|
|
||||||
XFreePixmap(WMScreenDisplay(scr), pix);
|
XFreePixmap(WMScreenDisplay(scr), pix);
|
||||||
}
|
}
|
||||||
@@ -842,17 +852,16 @@ static void updatePreviewBox(_Panel * panel, int elements)
|
|||||||
titem = (TextureListItem *) item->clientData;
|
titem = (TextureListItem *) item->clientData;
|
||||||
|
|
||||||
pix = renderMenu(panel, titem->prop,
|
pix = renderMenu(panel, titem->prop,
|
||||||
previewPositions[PMITEM].size.width, previewPositions[PMITEM].size.height / 4);
|
textureOptions[PMITEM].preview.size.width,
|
||||||
|
textureOptions[PMITEM].preview.size.height / 4);
|
||||||
|
|
||||||
XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
|
XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
|
||||||
previewPositions[PMITEM].size.width,
|
textureOptions[PMITEM].preview.size.width, textureOptions[PMITEM].preview.size.height,
|
||||||
previewPositions[PMITEM].size.height,
|
textureOptions[PMITEM].preview.pos.x, textureOptions[PMITEM].preview.pos.y);
|
||||||
previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
|
|
||||||
|
|
||||||
XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
|
XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
|
||||||
previewPositions[PMITEM].size.width,
|
textureOptions[PMITEM].preview.size.width, textureOptions[PMITEM].preview.size.height,
|
||||||
previewPositions[PMITEM].size.height,
|
textureOptions[PMITEM].preview.pos.x, textureOptions[PMITEM].preview.pos.y);
|
||||||
previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
|
|
||||||
|
|
||||||
XFreePixmap(dpy, pix);
|
XFreePixmap(dpy, pix);
|
||||||
|
|
||||||
@@ -1094,15 +1103,6 @@ static void changePage(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, 100},
|
|
||||||
{5, 120},
|
|
||||||
{5, 160},
|
|
||||||
{130, 150}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (w) {
|
if (w) {
|
||||||
section = WMGetPopUpButtonSelectedItem(panel->secP);
|
section = WMGetPopUpButtonSelectedItem(panel->secP);
|
||||||
@@ -1116,14 +1116,12 @@ static void changePage(WMWidget * w, void *data)
|
|||||||
|
|
||||||
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->oldsection].x,
|
textureOptions[panel->oldsection].hand.x, textureOptions[panel->oldsection].hand.y, 22, 22,
|
||||||
positions[panel->oldsection].y, 22, 22 ,
|
textureOptions[panel->oldsection].hand.x, textureOptions[panel->oldsection].hand.y);
|
||||||
positions[panel->oldsection].x,
|
|
||||||
positions[panel->oldsection].y);
|
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w) {
|
||||||
panel->oldsection = section;
|
panel->oldsection = section;
|
||||||
WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
|
WMDrawPixmap(panel->hand, panel->preview, textureOptions[section].hand.x, textureOptions[section].hand.y);
|
||||||
}
|
}
|
||||||
WMRedisplayWidget(panel->prevL);
|
WMRedisplayWidget(panel->prevL);
|
||||||
}
|
}
|
||||||
@@ -1135,12 +1133,11 @@ static void previewClick(XEvent * event, void *clientData)
|
|||||||
|
|
||||||
switch (panel->oldTabItem) {
|
switch (panel->oldTabItem) {
|
||||||
case 0:
|
case 0:
|
||||||
for (i = 0; i < wlengthof(previewPositions); i++) {
|
for (i = 0; i < wlengthof(textureOptions); i++) {
|
||||||
if (event->xbutton.x >= previewPositions[i].pos.x
|
if (event->xbutton.x >= textureOptions[i].preview.pos.x &&
|
||||||
&& event->xbutton.y >= previewPositions[i].pos.y
|
event->xbutton.y >= textureOptions[i].preview.pos.y &&
|
||||||
&& event->xbutton.x < previewPositions[i].pos.x
|
event->xbutton.x < textureOptions[i].preview.pos.x + textureOptions[i].preview.size.width &&
|
||||||
+ previewPositions[i].size.width
|
event->xbutton.y < textureOptions[i].preview.pos.y + textureOptions[i].preview.size.height) {
|
||||||
&& event->xbutton.y < previewPositions[i].pos.y + previewPositions[i].size.height) {
|
|
||||||
|
|
||||||
WMSetPopUpButtonSelectedItem(panel->secP, i);
|
WMSetPopUpButtonSelectedItem(panel->secP, i);
|
||||||
changePage(panel->secP, panel);
|
changePage(panel->secP, panel);
|
||||||
@@ -1857,14 +1854,9 @@ static void createPanel(Panel * p)
|
|||||||
panel->secP = WMCreatePopUpButton(panel->texF);
|
panel->secP = WMCreatePopUpButton(panel->texF);
|
||||||
WMResizeWidget(panel->secP, 228, 20);
|
WMResizeWidget(panel->secP, 228, 20);
|
||||||
WMMoveWidget(panel->secP, 7, 7);
|
WMMoveWidget(panel->secP, 7, 7);
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
|
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
|
for (i = 0; i < wlengthof(textureOptions); i++)
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
|
WMAddPopUpButtonItem(panel->secP, _(textureOptions[i].popup_label));
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
|
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
|
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
|
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
|
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Workspace Background"));
|
|
||||||
|
|
||||||
WMSetPopUpButtonSelectedItem(panel->secP, 0);
|
WMSetPopUpButtonSelectedItem(panel->secP, 0);
|
||||||
WMSetPopUpButtonAction(panel->secP, changePage, panel);
|
WMSetPopUpButtonAction(panel->secP, changePage, panel);
|
||||||
@@ -2135,7 +2127,7 @@ static void showData(_Panel * panel)
|
|||||||
|
|
||||||
for (i = 0; i < wlengthof(textureOptions); i++) {
|
for (i = 0; i < wlengthof(textureOptions); i++) {
|
||||||
setupTextureFor(panel->texLs, textureOptions[i].key,
|
setupTextureFor(panel->texLs, textureOptions[i].key,
|
||||||
textureOptions[i].default_value, _(textureOptions[i].label), i);
|
textureOptions[i].default_value, _(textureOptions[i].texture_label), i);
|
||||||
panel->textureIndex[i] = i;
|
panel->textureIndex[i] = i;
|
||||||
}
|
}
|
||||||
updatePreviewBox(panel, EVERYTHING);
|
updatePreviewBox(panel, EVERYTHING);
|
||||||
|
|||||||
Reference in New Issue
Block a user