1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-06 13:54:12 +01:00

WPrefs update for ResizebarBack

This commit is contained in:
kojima
1999-04-12 04:54:50 +00:00
parent da91828129
commit ad6c5e0bd8
6 changed files with 166 additions and 36 deletions

1
TODO
View File

@@ -21,7 +21,6 @@ Need to do:
automatic best context guessing automatic best context guessing
- docklet to control AccessX (keyboard accessibility) functions - docklet to control AccessX (keyboard accessibility) functions
- rewrite all redundant stuff to use WINGs - rewrite all redundant stuff to use WINGs
- resizebartexture option
- add function to directly make a thumbnail of an image, using the - add function to directly make a thumbnail of an image, using the
functionality provided by the image libraries to load a minimal functionality provided by the image libraries to load a minimal
amount of data. amount of data.

View File

@@ -218,14 +218,16 @@ static char * hand_xpm[] = {
#define FTITLE (1<<0) #define FTITLE (1<<0)
#define UTITLE (1<<1) #define UTITLE (1<<1)
#define OTITLE (1<<2) #define OTITLE (1<<2)
#define MTITLE (1<<3) #define RESIZEBAR (1<<3)
#define MITEM (1<<4) #define MTITLE (1<<4)
#define ICON (1<<5) #define MITEM (1<<5)
#define BACK (1<<6) #define ICON (1<<6)
#define BACK (1<<7)
#define EVERYTHING 0xff #define EVERYTHING 0xff
#define RESIZEBAR_BEVEL -1
#define MENU_BEVEL -2
#define TEXPREV_WIDTH 40 #define TEXPREV_WIDTH 40
#define TEXPREV_HEIGHT 24 #define TEXPREV_HEIGHT 24
@@ -290,6 +292,70 @@ isPixmap(proplist_t prop)
} }
static void
drawResizebarBevel(RImage *img)
{
RColor light;
RColor dark;
RColor black;
int width = img->width;
int height = img->height;
int cwidth = 28;
black.alpha = 255;
black.red = black.green = black.blue = 0;
light.alpha = 0;
light.red = light.green = light.blue = 80;
dark.alpha = 0;
dark.red = dark.green = dark.blue = 40;
ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
height-1, &dark);
ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
height-1, &light);
RDrawLine(img, 0, height-1, width-1, height-1, &black);
RDrawLine(img, 0, 0, 0, height-1, &black);
RDrawLine(img, width-1, 0, width-1, height-1, &black);
}
static void
drawMenuBevel(RImage *img)
{
RColor light, dark, mid;
int i;
int iheight = img->height / 3;
light.alpha = 0;
light.red = light.green = light.blue = 80;
dark.alpha = 255;
dark.red = dark.green = dark.blue = 0;
mid.alpha = 0;
mid.red = mid.green = mid.blue = 40;
for (i = 1; i < 3; i++) {
ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
img->width-1, i*iheight-2, &mid);
RDrawLine(img, 0, i*iheight-1,
img->width-1, i*iheight-1, &dark);
ROperateLine(img, RAddOperation, 0, i*iheight,
img->width-1, i*iheight, &light);
}
}
static Pixmap static Pixmap
renderTexture(WMScreen *scr, proplist_t texture, int width, int height, renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
@@ -464,7 +530,13 @@ renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
dumpRImage(path, image); dumpRImage(path, image);
} }
if (border) { if (border < 0) {
if (border == RESIZEBAR_BEVEL) {
drawResizebarBevel(image);
} else if (border == MENU_BEVEL) {
drawMenuBevel(image);
}
} else if (border) {
RBevelImage(image, border); RBevelImage(image, border);
} }
@@ -475,6 +547,39 @@ renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
} }
static Pixmap
renderMenu(_Panel *panel, proplist_t texture, int width, int iheight)
{
WMScreen *scr = WMWidgetScreen(panel->win);
Display *dpy = WMScreenDisplay(scr);
Pixmap pix, tmp;
char *str;
GC gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
str = GetStringForKey("MenuStyle");
if (!str || strcasecmp(str, "normal")==0) {
int i;
tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
pix = XCreatePixmap(dpy, tmp, width, iheight*3,
WMScreenDepth(scr));
for (i = 0; i < 3; i++) {
XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight,
0, iheight*i);
}
XFreePixmap(dpy, tmp);
} else if (strcasecmp(str, "flat")==0) {
pix = renderTexture(scr, texture, width, iheight*3, NULL, RBEV_RAISED2);
} else {
pix = renderTexture(scr, texture, width, iheight*3, NULL, MENU_BEVEL);
}
XFreeGC(dpy, gc);
return pix;
}
static void static void
@@ -512,7 +617,7 @@ updatePreviewBox(_Panel *panel, int elements)
pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2); pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 10); XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 5);
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
@@ -522,7 +627,7 @@ updatePreviewBox(_Panel *panel, int elements)
pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2); pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 35); XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 30);
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
@@ -532,12 +637,22 @@ updatePreviewBox(_Panel *panel, int elements)
pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2); pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 60); XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 55);
XFreePixmap(dpy, pix);
}
if (elements & RESIZEBAR) {
item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
titem = (TextureListItem*)item->clientData;
pix = renderTexture(scr, titem->prop, 210, 9, NULL, RESIZEBAR_BEVEL);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 80);
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
if (elements & MTITLE) { if (elements & MTITLE) {
item = WMGetListItem(panel->texLs, panel->textureIndex[3]); item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
pix = renderTexture(scr, titem->prop, 100, 20, NULL, RBEV_RAISED2); pix = renderTexture(scr, titem->prop, 100, 20, NULL, RBEV_RAISED2);
@@ -547,14 +662,12 @@ updatePreviewBox(_Panel *panel, int elements)
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
if (elements & MITEM) { if (elements & MITEM) {
item = WMGetListItem(panel->texLs, panel->textureIndex[4]); item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
pix = renderTexture(scr, titem->prop, 100, 18, NULL, RBEV_RAISED2); pix = renderMenu(panel, titem->prop, 100, 18);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18, 30, 115); XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18*3, 30, 115);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18, 30, 115 + 18);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18, 30, 115 + 36);
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
@@ -564,13 +677,13 @@ updatePreviewBox(_Panel *panel, int elements)
} }
if (elements & ICON) { if (elements & ICON) {
item = WMGetListItem(panel->texLs, panel->textureIndex[5]); item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
pix = renderTexture(scr, titem->prop, 64, 64, NULL, pix = renderTexture(scr, titem->prop, 64, 64, NULL,
titem->ispixmap ? 0 : RBEV_RAISED3); titem->ispixmap ? 0 : RBEV_RAISED3);
XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 64, 64, 170, 90); XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 64, 64, 170, 95);
XFreePixmap(dpy, pix); XFreePixmap(dpy, pix);
} }
@@ -829,10 +942,11 @@ changePage(WMWidget *w, void *data)
char *str; char *str;
WMScreen *scr = WMWidgetScreen(w); WMScreen *scr = WMWidgetScreen(w);
RContext *rc = WMScreenRContext(scr); RContext *rc = WMScreenRContext(scr);
static WMPoint positions[6] = { static WMPoint positions[] = {
{5, 10}, {5, 5},
{5, 35}, {5, 30},
{5, 60}, {5, 55},
{5, 80},
{5, 95}, {5, 95},
{5, 130}, {5, 130},
{145, 110} {145, 110}
@@ -877,16 +991,17 @@ previewClick(XEvent *event, void *clientData)
{ {
_Panel *panel = (_Panel*)clientData; _Panel *panel = (_Panel*)clientData;
int i; int i;
static WMRect parts[6] = { static WMRect parts[] = {
{{30, 10},{210, 20}}, {{30, 5},{210, 20}},
{{30,35},{210,20}}, {{30,30},{210,20}},
{{30,60},{210,20}}, {{30,55},{210,20}},
{{30,80},{210,9}},
{{30,95},{100,20}}, {{30,95},{100,20}},
{{30,115},{100,60}}, {{30,115},{100,60}},
{{170,90},{64,64}} {{170,90},{64,64}}
}; };
for (i = 0; i < 6; i++) { for (i = 0; i < 7; i++) {
if (event->xbutton.x >= parts[i].pos.x if (event->xbutton.x >= parts[i].pos.x
&& event->xbutton.y >= parts[i].pos.y && event->xbutton.y >= parts[i].pos.y
&& event->xbutton.x < parts[i].pos.x + parts[i].size.width && event->xbutton.x < parts[i].pos.x + parts[i].size.width
@@ -1141,6 +1256,7 @@ createPanel(Panel *p)
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window")); WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows")); WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner")); WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus")); WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
WMAddPopUpButtonItem(panel->secP, _("Menu Items")); WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
WMAddPopUpButtonItem(panel->secP, _("Icon Background")); WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
@@ -1295,6 +1411,10 @@ showData(_Panel *panel)
"[Owner of Focused]", i); "[Owner of Focused]", i);
panel->textureIndex[i] = i++; panel->textureIndex[i] = i++;
setupTextureFor(panel->texLs, "ResizebarBack", "(solid, gray)",
"[Resizebar]", i);
panel->textureIndex[i] = i++;
setupTextureFor(panel->texLs, "MenuTitleBack", "(solid, black)", setupTextureFor(panel->texLs, "MenuTitleBack", "(solid, black)",
"[Menu Title]", i); "[Menu Title]", i);
panel->textureIndex[i] = i++; panel->textureIndex[i] = i++;
@@ -1336,14 +1456,18 @@ storeData(_Panel *panel)
item = WMGetListItem(panel->texLs, panel->textureIndex[3]); item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
SetObjectForKey(titem->prop, "MenuTitleBack"); SetObjectForKey(titem->prop, "ResizebarBack");
item = WMGetListItem(panel->texLs, panel->textureIndex[4]); item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
SetObjectForKey(titem->prop, "MenuTextBack"); SetObjectForKey(titem->prop, "MenuTitleBack");
item = WMGetListItem(panel->texLs, panel->textureIndex[5]); item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;
SetObjectForKey(titem->prop, "MenuTextBack");
item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
titem = (TextureListItem*)item->clientData;
SetObjectForKey(titem->prop, "IconBack"); SetObjectForKey(titem->prop, "IconBack");
} }
@@ -1361,7 +1485,7 @@ prepareForClose(_Panel *panel)
textureList = PLMakeArrayFromElements(NULL, NULL); textureList = PLMakeArrayFromElements(NULL, NULL);
/* store list of textures */ /* store list of textures */
for (i = 6; i < WMGetListNumberOfRows(panel->texLs); i++) { for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
item = WMGetListItem(panel->texLs, i); item = WMGetListItem(panel->texLs, i);
titem = (TextureListItem*)item->clientData; titem = (TextureListItem*)item->clientData;

View File

@@ -42,10 +42,12 @@
/****/ /****/
#define WVERSION "0.30" #define WVERSION "0.31"
#define WMVERSION "0.52.x" #define WMVERSION "0.52.x"
extern char *NOptionValueChanged;
typedef struct _Panel Panel; typedef struct _Panel Panel;
typedef struct { typedef struct {

View File

@@ -29,6 +29,9 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
char *NOptionValueChanged = "NOptionValueChanged";
extern void Initialize(WMScreen *scr); extern void Initialize(WMScreen *scr);
#define MAX_DEATHS 64 #define MAX_DEATHS 64

View File

@@ -1745,7 +1745,7 @@ wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, Bool control)
{ {
char buffer[128]; char buffer[128];
int sock; int sock;
#if 0
puts("CONNECTING"); puts("CONNECTING");
sock = connectKFM(scr); sock = connectKFM(scr);
if (sock < 0) if (sock < 0)
@@ -1758,6 +1758,7 @@ wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, Bool control)
writeSocket(sock, buffer); writeSocket(sock, buffer);
close(sock); close(sock);
#endif
} }

View File

@@ -155,7 +155,7 @@ getColor(proplist_t texture)
if (!dpy) { if (!dpy) {
if (sscanf(PLGetString(c1), "#%2x%2x%2x", &r1, &g1, &b1)==3 if (sscanf(PLGetString(c1), "#%2x%2x%2x", &r1, &g1, &b1)==3
&& sscanf(PLGetString(c2), "#%2x%2x%2x", &r2, &g2, &b2)==3) { && sscanf(PLGetString(c2), "#%2x%2x%2x", &r2, &g2, &b2)==3) {
sprintf(buffer, "#%2x%2x%2x", (r1+r2)/2, (g1+g2)/2, sprintf(buffer, "#%02x%02x%02x", (r1+r2)/2, (g1+g2)/2,
(b1+b2)/2); (b1+b2)/2);
value = PLMakeString(buffer); value = PLMakeString(buffer);
} else { } else {
@@ -170,9 +170,10 @@ getColor(proplist_t texture)
XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
PLGetString(c1), &color2); PLGetString(c1), &color2);
sprintf(buffer, "#%4x%4x%4x", (color1.red+color2.red)/2, sprintf(buffer, "#%02x%02x%02x",
(color1.green+color2.green)/2, (color1.red+color2.red)>>3,
(color1.blue+color2.blue)/2); (color1.green+color2.green)>>3,
(color1.blue+color2.blue)>>3);
value = PLMakeString(buffer); value = PLMakeString(buffer);
} }
} else if (strcasecmp(str, "mdgradient")==0 } else if (strcasecmp(str, "mdgradient")==0