Tue Jan 11 23:47:36 PST 2000 Michael Jennings <mej@eterm.org>

More fixes with menus and transparency.  After you build this version,
	check out the brand new "glass" theme at http://www.eterm.org/.  It
	looks sweet. :-)


SVN revision: 1905
This commit is contained in:
Michael Jennings 2000-01-12 07:49:02 +00:00
parent 48000815d7
commit 67e4e8d959
12 changed files with 111 additions and 58 deletions

View File

@ -3024,3 +3024,10 @@ Mon Jan 10 16:55:51 PST 2000 Michael Jennings <mej@eterm.org>
<keebler@sandwich.net>.
-------------------------------------------------------------------------------
Tue Jan 11 23:47:36 PST 2000 Michael Jennings <mej@eterm.org>
More fixes with menus and transparency. After you build this version,
check out the brand new "glass" theme at http://www.eterm.org/. It
looks sweet. :-)
-------------------------------------------------------------------------------

View File

@ -325,6 +325,7 @@
#undef IOTRACE
#undef HAVE_UTEMPTER
#undef PTY_GRP_NAME
#undef ENABLE_PROFILE
/* Leave that blank line there!! Autoheader needs it.

View File

@ -261,6 +261,16 @@ AC_ARG_WITH(pablo,
AC_MSG_RESULT(no)
fi, AC_MSG_RESULT(no)
)
AC_MSG_CHECKING(if profiling macros should be included)
AC_ARG_ENABLE(profile,
[ --enable-profile compile with code profiling macros enabled],
if test "$enableval" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_PROFILE)
else
AC_MSG_RESULT(no)
fi, AC_MSG_RESULT(no)
)
AC_MSG_CHECKING(for pixmap support)
AC_ARG_WITH(imlib,
[ --with-imlib[=DIR] compile with Imlib support (Imlib residing in DIR/lib) (default)],

View File

@ -140,6 +140,8 @@ extern unsigned int debug_level;
# define D_MALLOC(x) DPRINTF4(x)
# define DEBUG_ACTIONS 4
# define D_ACTIONS(x) DPRINTF4(x)
# define DEBUG_PROFILE 4
# define D_PROFILE(x) DPRINTF4(x)
# define DEBUG_X 5
@ -192,4 +194,6 @@ extern unsigned int debug_level;
} \
} while (0)
#include "profile.h"
#endif /* _DEBUG_H */

View File

@ -53,7 +53,6 @@
# define P_EVENT_TIME(type, start, stop) real_dprintf(type ": %ld microseconds\n", P_CMPTIMEVALS_USEC((start), (stop)))
#else
# define P_EVENT_TIME(type, start, stop) NOP
# define P_SETTIMEVAL(t) NOP
#endif
#define EVENT_DATA_ADD_HANDLER(data, type, handler) (data).handlers[(type)] = handler

View File

@ -69,11 +69,10 @@
# endif
/********************* Random development stuff ***************************/
/* #define PROFILE */
#ifdef PROFILE
/* #define PROFILE_SCREEN */
/* #define PROFILE_X_EVENTS */
/* #define COUNT_X_EVENTS */
#ifdef ENABLE_PROFILE
# define PROFILE_SCREEN
# define PROFILE_X_EVENTS
# define COUNT_X_EVENTS
#endif
#define OPTIMIZE_HACKS

View File

@ -766,7 +766,13 @@ menuitem_select(menu_t * menu)
XMoveWindow(Xdisplay, menu->swin, item->x, item->y);
XMapWindow(Xdisplay, menu->swin);
if (item->type == MENUITEM_SUBMENU) {
render_simage(images[image_submenu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_submenu, 0);
if (image_mode_is(image_submenu, MODE_AUTO)) {
enl_ipc_sync();
}
#if 0
paste_simage(images[image_submenu].selected, image_submenu, menu->swin, 0, 0, item->w - MENU_VGAP, item->h);
#endif
} else {
render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0);
if (image_mode_is(image_menu, MODE_AUTO)) {
@ -791,14 +797,6 @@ menuitem_deselect(menu_t * menu)
D_MENU(("menuitem_deselect(): Deselecting item \"%s\"\n", item->text));
item->state &= ~(MENU_STATE_IS_CURRENT);
XUnmapWindow(Xdisplay, menu->swin);
if (item->type == MENUITEM_SUBMENU) {
paste_simage(images[image_submenu].norm, image_submenu, menu->win, item->x, item->y, item->w - MENU_VGAP, item->h);
}
draw_string(menu->win, menu->gc, 2 * MENU_HGAP, item->y + item->h - MENU_VGAP, item->text, item->len);
if (item->rtext) {
draw_string(menu->win, menu->gc, item->x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->y + item->h - MENU_VGAP,
item->rtext, item->rlen);
}
}
void
@ -822,6 +820,20 @@ menu_display_submenu(menu_t * menu, menuitem_t * item)
menu->state |= MENU_STATE_IS_CURRENT;
}
void
menu_move(menu_t *menu, unsigned short x, unsigned short y) {
ASSERT(menu != NULL);
D_MENU(("menu_move(): Moving menu \"%s\" to %hu, %hu\n", menu->title, x, y));
menu->x = x;
menu->y = y;
XMoveWindow(Xdisplay, menu->win, menu->x, menu->y);
if (image_mode_is(image_menu, (MODE_TRANS | MODE_VIEWPORT))) {
menu_draw(menu);
}
}
void
menu_draw(menu_t * menu)
{
@ -870,29 +882,6 @@ menu_draw(menu_t * menu)
}
menu->w = width;
menu->h = height;
/* Size and render menu window */
XResizeWindow(Xdisplay, menu->win, menu->w, menu->h);
if (image_mode_is(image_menu, MODE_AUTO)) {
pixmap_t *pmap = images[image_menu].norm->pmap;
if (pmap->pixmap != None) {
XFreePixmap(Xdisplay, pmap->pixmap);
}
pmap->pixmap = XCreatePixmap(Xdisplay, menu->win, width, height, Xdepth);
paste_simage(images[image_menu].norm, image_menu, pmap->pixmap, 0, 0, width, height);
enl_ipc_sync();
} else {
render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, 0);
}
menu->bg = images[image_menu].norm->pmap->pixmap;
/* Size and render selected item window */
XResizeWindow(Xdisplay, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP);
render_simage(images[image_menu].selected, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP, image_menu, 0);
if (image_mode_is(image_menu, MODE_AUTO)) {
enl_ipc_sync();
}
}
/* If the menu will come up offscreen, move all the other menus out of the way. */
@ -918,17 +907,35 @@ menu_draw(menu_t * menu)
D_MENU((" -> Checking menu \"%s\" to see if it needs to be moved.\n", tmp->title));
if (tmp->state & MENU_STATE_IS_MAPPED) {
tmp->x += dx;
tmp->y += dy;
D_MENU((" -> Yes. New coordinates for this menu are %hu, %hu.\n", tmp->x, tmp->y));
XMoveWindow(Xdisplay, tmp->win, tmp->x, tmp->y);
menu_move(tmp, tmp->x + dx, tmp->y + dy);
}
}
}
XMoveWindow(Xdisplay, menu->win, menu->x, menu->y);
XMoveResizeWindow(Xdisplay, menu->win, menu->x, menu->y, menu->w, menu->h);
/* Draw menu background */
if (image_mode_is(image_menu, MODE_AUTO)) {
pixmap_t *pmap = images[image_menu].norm->pmap;
if (pmap->pixmap != None) {
XFreePixmap(Xdisplay, pmap->pixmap);
}
pmap->pixmap = XCreatePixmap(Xdisplay, menu->win, menu->w, menu->h, Xdepth);
paste_simage(images[image_menu].norm, image_menu, pmap->pixmap, 0, 0, menu->w, menu->h);
enl_ipc_sync();
} else {
render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, 0);
}
menu->bg = images[image_menu].norm->pmap->pixmap;
/* Size and render selected item window */
XResizeWindow(Xdisplay, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP);
render_simage(images[image_menu].selected, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP, image_menu, 0);
if (image_mode_is(image_menu, MODE_AUTO)) {
enl_ipc_sync();
}
XUnmapWindow(Xdisplay, menu->swin);
XMapWindow(Xdisplay, menu->win);
XRaiseWindow(Xdisplay, menu->win);
str_x = 2 * MENU_HGAP;
if (images[image_menu].selected->iml->pad) {

View File

@ -128,6 +128,7 @@ extern void menu_reset_submenus(menu_t *);
extern void menuitem_select(menu_t *);
extern void menuitem_deselect(menu_t *);
extern void menu_display_submenu(menu_t *, menuitem_t *);
extern void menu_move(menu_t *, unsigned short, unsigned short);
extern void menu_draw(menu_t *);
extern void menu_display(int, int, menu_t *);
extern void menu_action(menuitem_t *);

View File

@ -2394,6 +2394,10 @@ parse_image(char *buff)
print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image type defined", file_peek_path(), file_peek_line());
return;
}
if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined", file_peek_path(), file_peek_line());
return;
}
if (!filename) {
print_error("Parse error in file %s, line %lu: Missing filename", file_peek_path(), file_peek_line());
return;
@ -2407,6 +2411,10 @@ parse_image(char *buff)
print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image type defined", file_peek_path(), file_peek_line());
return;
}
if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined", file_peek_path(), file_peek_line());
return;
}
if (!geom) {
print_error("Parse error in file %s, line %lu: Missing geometry string", file_peek_path(), file_peek_line());
return;
@ -2423,6 +2431,10 @@ parse_image(char *buff)
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined", file_peek_path(), file_peek_line());
return;
}
if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined", file_peek_path(), file_peek_line());
return;
}
if (!color) {
print_error("Parse error in file %s, line %lu: Missing color name", file_peek_path(), file_peek_line());
return;
@ -2504,6 +2516,10 @@ parse_image(char *buff)
print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image type defined", file_peek_path(), file_peek_line());
return;
}
if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined", file_peek_path(), file_peek_line());
return;
}
if (NumWords(buff + 6) < 5) {
print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"bevel\"", file_peek_path(), file_peek_line());
return;
@ -2537,6 +2553,10 @@ parse_image(char *buff)
print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image type defined", file_peek_path(), file_peek_line());
return;
}
if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined", file_peek_path(), file_peek_line());
return;
}
if (NumWords(buff + 8) < 4) {
print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"padding\"", file_peek_path(), file_peek_line());
return;

View File

@ -572,9 +572,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
check_image_ipc(0);
if (image_mode_is(which, MODE_AUTO)) {
iclass = get_iclass_name(which);
if (images[which].current == images[which].selected) {
if (simg == images[which].selected) {
state = "hilited";
} else if (images[which].current == images[which].clicked) {
} else if (simg == images[which].clicked) {
state = "clicked";
} else {
state = "normal";
@ -1174,15 +1174,18 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
v = XGetPixel(ximg, x, y);
#define R() (((((v >> br) & mr) * rm) >> 8) & 0xff)
#define G() (((((v >> bg) & mg) * gm) >> 8) & 0xff)
#define B() (((((v << bb) & mb) * bm) >> 8) & 0xff)
v = ((R() & mr) << br) | ((G() & mg) << bg) | ((B() & mb) >> bb);
#undef R
#undef G
#undef B
XPutPixel(ximg, x, y, v);
register unsigned int rn, gn, bn;
v = XGetPixel(ximg, x, y);
rn = ((((v >> br) & mr) * rm) >> 8);
gn = ((((v >> bg) & mg) * gm) >> 8);
bn = ((((v << bb) & mb) * bm) >> 8);
if (!((rn & ~mr & 0xfff0) || (gn & ~mg & 0xfff0) || (bn & ~mb & 0xfff0))) {
v = ((rn & mr) << br) | ((gn & mg) << bg) | ((bn & mb) >> bb);
} else {
v = WhitePixel(Xdisplay, Xscreen);
}
XPutPixel(ximg, x, y, v);
}
}
}

View File

@ -13,8 +13,7 @@
/* NOTE: if PROFILE is not defined, all macros in this file will
* be set to (void)0 so they won't get compiled into binaries.
*/
#define PROFILE
# ifdef PROFILE
# ifdef ENABLE_PROFILE
/* Data structures */
@ -66,7 +65,7 @@ typedef struct {
P_CMPTIMEVALS_USEC(cnt.start, cnt.stop)); \
}
# else /* PROFILE */
# else /* ENABLE_PROFILE */
# define P_SETTIMEVAL(tv) ((void)0)
# define P_UPDATETOTAL(cnt) ((void)0)
@ -74,6 +73,6 @@ typedef struct {
# define P_CMPTIMEVALS_USEC(start, stop) ((void)0)
# define P_CALL(f, str) f
# endif /* PROFILE */
# endif /* ENABLE_PROFILE */
#endif /* _PROFILE_H */

View File

@ -436,6 +436,9 @@ Create_Windows(int argc, char *argv[])
XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]);
render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0);
if (image_mode_is(image_bg, MODE_AUTO)) {
enl_ipc_sync();
}
/* graphics context for the vt window */
{