Commit acd8ccb0 authored by bzt's avatar bzt

Displaying and zooming glyphs

parent 72a99ba0
This diff is collapsed.
......@@ -60,7 +60,7 @@ endif
endif
OBJS = $(SRCS:.c=.o) logofont.o font.o
OBJS = $(SRCS:.c=.o) logofont.o font.o uninames.o
all: configure $(OBJS) $(TARGET)
......@@ -78,6 +78,9 @@ font.o: $(FONT)
@$(LD) -r -b binary -o font.o font
@rm font
uninames.o: unicode.h unicode.dat
@$(LD) -r -b binary -o uninames.o unicode.dat
%: %.c ../ssfn.h
$(CC) $(CFLAGS) $< -c $@
......
/*
* sfnedit/color.c
*
* Copyright (C) 2019 bzt (bztsrc@gitlab)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @brief Color picker (View and Controller)
*
*/
#include <stdlib.h>
#include <stdio.h>
#include "file.h"
#include "ui.h"
void view_coords(ui_win_t *win);
int selcolor = 0, hue = 0, sat = 0, val = 0, incolorsel = 0;
/**
* Color conversion RGB to HSV
*/
void rgb2hsv(uint32_t c)
{
int r = (int)(((uint8_t*)&c)[2]), g = (int)(((uint8_t*)&c)[1]), b = (int)(((uint8_t*)&c)[0]), m, d;
m = r < g? r : g; if(b < m) m = b;
val = r > g? r : g; if(b > val) val = b;
d = val - m;
if(!val) { sat = hue = 0; return; }
sat = d * 255 / val;
if(!sat) { hue = 0; return; }
if(r == val) hue = 43*(g - b) / d;
else if(g == val) hue = 85 + 43*(b - r) / d;
else hue = 171 + 43*(r - g) / d;
if(hue < 0) hue += 256;
}
/**
* Color conversion HSV to RGB
*/
uint32_t hsv2rgb(int a, int h, int s, int v)
{
int i, f, p, q, t;
uint32_t c = (a & 255) << 24;
if(!s) { ((uint8_t*)&c)[2] = ((uint8_t*)&c)[1] = ((uint8_t*)&c)[0] = v; }
else {
if(h >= 255) i = 0; else i = h / 43;
f = (h - i * 43) * 6;
p = (v * (255 - s) + 127) >> 8;
q = (v * (255 - ((s * f + 127) >> 8)) + 127) >> 8;
t = (v * (255 - ((s * (255 - f) + 127) >> 8)) + 127) >> 8;
switch(i) {
case 0: ((uint8_t*)&c)[2] = v; ((uint8_t*)&c)[1] = t; ((uint8_t*)&c)[0] = p; break;
case 1: ((uint8_t*)&c)[2] = q; ((uint8_t*)&c)[1] = v; ((uint8_t*)&c)[0] = p; break;
case 2: ((uint8_t*)&c)[2] = p; ((uint8_t*)&c)[1] = v; ((uint8_t*)&c)[0] = t; break;
case 3: ((uint8_t*)&c)[2] = p; ((uint8_t*)&c)[1] = q; ((uint8_t*)&c)[0] = v; break;
case 4: ((uint8_t*)&c)[2] = t; ((uint8_t*)&c)[1] = p; ((uint8_t*)&c)[0] = v; break;
default: ((uint8_t*)&c)[2] = v; ((uint8_t*)&c)[1] = p; ((uint8_t*)&c)[0] = q; break;
}
}
return c;
}
/**
* View for color picker
*/
void view_color(ui_win_t *win, uint32_t *c)
{
char tmp[4];
int i, j, p, w = (win->w - 52) / 30;
uint32_t h;
uint8_t *d, *a = (uint8_t*)&theme[THEME_INACT], *b = (uint8_t*)&theme[THEME_INPBG], *C = (uint8_t*)c;
if(w < 5) w = 5;
if(selcolor == -1) {
if(!*c) selcolor = 240;
else for(selcolor=0; selcolor < 240 && cmap[selcolor] != *c; selcolor++);
}
for(j = 0; j < 8; j++)
for(i = 0; i < 30; i++) {
ui_box(win, 52 + i*w, j*w + 26, w, w, theme[selcolor == j*30+i ? THEME_INPUT : THEME_INPBG]);
ui_argb(win, 52 + i*w+1, j*w + 26+1, w-2, w-2, cmap[j*30+i]);
}
ui_box(win, 52, 8*w + 26, w, w, theme[selcolor == 240 ? THEME_INPUT : THEME_INPBG]);
ui_argb(win, 53, 8*w + 27, w-2, w-2, 0);
ssfn_x = 52; ssfn_y = (9*w + 26) + 8;
if(selcolor >= 240) {
ui_box(win, ssfn_x, ssfn_y - 8, 256+32+17+17+40, 260, ssfn_bg);
} else {
ssfn_fg = theme[THEME_FG];
ui_text(win, "A ", ssfn_bg, ssfn_bg);
sprintf(tmp, "%02X", ((uint8_t*)c)[3]);
ui_scale(win, tmp, 16, 0);
ssfn_x = 52; ssfn_y += 24;
ssfn_fg = theme[THEME_FG];
ui_text(win, "R ", ssfn_bg, ssfn_bg);
sprintf(tmp, "%02X", ((uint8_t*)c)[2]);
ui_scale(win, tmp, 16, 0);
ssfn_x = 52; ssfn_y += 24;
ssfn_fg = theme[THEME_FG];
ui_text(win, "G ", ssfn_bg, ssfn_bg);
sprintf(tmp, "%02X", ((uint8_t*)c)[1]);
ui_scale(win, tmp, 16, 0);
ssfn_x = 52; ssfn_y += 24;
ssfn_fg = theme[THEME_FG];
ui_text(win, "B ", ssfn_bg, ssfn_bg);
sprintf(tmp, "%02X", ((uint8_t*)c)[0]);
ui_scale(win, tmp, 16, 0);
ssfn_y = (9*w + 26) + 2; ssfn_x += 8;
ui_box(win, ssfn_x - 4, ssfn_y - 2, 4, 260, ssfn_bg);
ui_box(win, ssfn_x +17+256+17, ssfn_y - 2, 4, 260, ssfn_bg);
for(p = ssfn_y * win->p + ssfn_x, j=0;j<256 && (int)ssfn_y + j < win->h;j++, p += win->p) {
if(((uint8_t*)c)[3] == 255-j && (int)ssfn_x < win->w && (int)ssfn_y + j + 2< win->h ) {
win->data[p - 4] = theme[THEME_INPUT];
win->data[p - 3] = theme[THEME_INPUT];
win->data[p - 2] = theme[THEME_INPUT];
win->data[p - 3 - win->p] = theme[THEME_INPUT];
win->data[p - 3 + win->p] = theme[THEME_INPUT];
win->data[p - 4 - 2*win->p] = theme[THEME_INPUT];
win->data[p - 4 - win->p] = theme[THEME_INPUT];
win->data[p - 4 + win->p] = theme[THEME_INPUT];
win->data[p - 4 + 2*win->p] = theme[THEME_INPUT];
for(i=0;i<15 && (int)ssfn_x + i < win->w;i++)
win->data[p+i] = theme[THEME_INPUT];
} else
for(i=0;i<15 && (int)ssfn_x + i < win->w;i++) {
d = (j & 8) ^ (i & 8) ? a : b;
((uint8_t*)&win->data[p+i])[0] = (d[0]*j + (256 - j)*C[0])>>8;
((uint8_t*)&win->data[p+i])[1] = (d[1]*j + (256 - j)*C[1])>>8;
((uint8_t*)&win->data[p+i])[2] = (d[2]*j + (256 - j)*C[2])>>8;
}
}
rgb2hsv(*c);
for(p = ssfn_y * win->p + ssfn_x + 16, j=0;j<256 && (int)ssfn_y + j < win->h;j++, p += win->p)
for(i=0;i<256 && (int)ssfn_x + 16 + i < win->w;i++)
win->data[p + i] = sat == i || 255-j == val ? theme[i<96 && j<96 ?THEME_INPBG:THEME_INPUT] :
hsv2rgb(255, hue,i,255-j);
for(p = ssfn_y * win->p + ssfn_x + 17+256, j=0;j<255 && (int)ssfn_y + j < win->h;j++, p += win->p) {
h = hsv2rgb(255, j, 255, 255);
if(hue == j && (int)ssfn_x + 19 < win->w && (int)ssfn_y + j + 2< win->h ) {
h = theme[THEME_INPUT];
win->data[p + 19] = h;
win->data[p + 18] = h;
win->data[p + 17] = h;
win->data[p + 18 - win->p] = h;
win->data[p + 18 + win->p] = h;
win->data[p + 19 - 2*win->p] = h;
win->data[p + 19 - win->p] = h;
win->data[p + 19 + win->p] = h;
win->data[p + 19 + 2*win->p] = h;
}
for(i=0;i<15 && (int)ssfn_x + 17+256 + i < win->w;i++)
win->data[p + i] = h;
}
}
}
/**
* Controller for color picker
*/
int ctrl_color(ui_win_t *win, ui_event_t *evt, uint32_t *c)
{
int w = (win->w - 52) / 30;
uint8_t *a;
switch(evt->type) {
case E_MOUSEMOVE:
if(incolorsel && selcolor < 240 && evt->y >= 30 + w*9 && evt->y < 30 + 256 + w*9) {
a = (uint8_t*)&cmap[selcolor];
if(evt->x > 117 && evt->x < 136) {
a[3] = 255 - (evt->y - w*9 - 30);
} else
if(evt->x >= 136 && evt->x < 392) {
if(!cmap[selcolor]) a[3] = 255;
sat = evt->x - 136;
val = 255 - (evt->y - w*9 - 30);
cmap[selcolor] = hsv2rgb(a[3], hue, sat, val);
} else
if(evt->x >= 392 && evt->x < 412) {
if(!cmap[selcolor]) a[3] = 255;
hue = evt->y - w*9 - 30;
if(hue >= 255) hue = 0;
cmap[selcolor] = hsv2rgb(a[3], hue, sat, val);
}
*c = cmap[selcolor];
view_color(win, c);
view_coords(win);
ui_flushwin(win, 0, 0, win->w, win->h);
}
break;
case E_BTNPRESS:
if(evt->x > 52 && evt->y > 26) {
if(evt->y < 26 + w * 9) {
selcolor = (evt->y - 26) / w * 30 + (evt->x - 52) / w;
if(selcolor > 239) { *c = 0; selcolor = 240; }
else *c = cmap[selcolor];
}
if(selcolor < 240 && evt->y >= 30 + w*9 && evt->y < 30 + 256 + w*9) {
a = (uint8_t*)&cmap[selcolor];
if(evt->x > 69 && evt->x < 88) {
if(evt->y >= 36 + w*9 && evt->y < 36 + 18 + w*9 && a[3] > 0) a[3]--;
if(evt->y >= 60 + w*9 && evt->y < 60 + 18 + w*9 && a[2] > 0) a[2]--;
if(evt->y >= 84 + w*9 && evt->y < 84 + 18 + w*9 && a[1] > 0) a[1]--;
if(evt->y >= 108 + w*9 && evt->y < 108 + 18 + w*9 && a[0] > 0) a[0]--;
} else
if(evt->x > 88 && evt->x < 112) {
if(evt->y >= 36 + w*9 && evt->y < 36 + 18 + w*9 && a[3] < 255) a[3]++;
if(evt->y >= 60 + w*9 && evt->y < 60 + 18 + w*9 && a[2] < 255) a[2]++;
if(evt->y >= 84 + w*9 && evt->y < 84 + 18 + w*9 && a[1] < 255) a[1]++;
if(evt->y >= 108 + w*9 && evt->y < 108 + 18 + w*9 && a[0] < 255) a[0]++;
} else {
incolorsel = 1;
if(evt->x > 117 && evt->x < 136) {
a[3] = 255 - (evt->y - w*9 - 30);
} else
if(evt->x >= 136 && evt->x < 392) {
if(!cmap[selcolor]) a[3] = 255;
sat = evt->x - 136;
val = 255 - (evt->y - w*9 - 30);
cmap[selcolor] = hsv2rgb(a[3], hue, sat, val);
} else
if(evt->x >= 392 && evt->x < 412) {
if(!cmap[selcolor]) a[3] = 255;
hue = evt->y - w*9 - 30;
if(hue >= 255) hue = 0;
cmap[selcolor] = hsv2rgb(a[3], hue, sat, val);
}
*c = cmap[selcolor];
}
}
view_color(win, c);
view_coords(win);
ui_flushwin(win, 0, 0, win->w, win->h);
}
break;
case E_BTNRELEASE:
incolorsel = 0;
break;
}
return 0;
}
/*
* sfnedit/edit.c
*
* Copyright (C) 2019 bzt (bztsrc@gitlab)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @brief Glyph edit tab (View and Controller)
*
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ui.h"
#include "lang.h"
#include "util.h"
#include "file.h"
#include "render.h"
#include "unicode.h"
extern int op, np, selcolor, clickx, clicky;
int overmenu=0, showgrid=0, mousex=0, mousey=0, inmove=0, prevx = 0, prevy = 0;
int zooms[] = { 16,24,32,40,48,56,64,80,96,128,160,192,224,256,320,384,448,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192 };
uint32_t penfg=0, penbg=0;
/**
* Display coordinates on left bottom corner
*/
void view_coords(ui_win_t *win)
{
char coord[8];
int i;
ssfn_fg = theme[THEME_TABU];
ssfn_bg = theme[THEME_BG];
sprintf(coord, "%4d", mousex);
ssfn_x = 2; ssfn_y = win->h - 34;
ui_text(win, coord, ssfn_bg, ssfn_bg);
sprintf(coord, "%4d", mousey);
ssfn_x = 2; ssfn_y = win->h - 18;
ui_text(win, coord, ssfn_bg, ssfn_bg);
if(!penfg) {
for(i=239; i>0 && !cmap[i]; i--);
penfg = cmap[i];
}
ui_box(win, 2, win->h - 50, 34, 1, ssfn_bg);
ui_argb(win, 2, win->h - 49, 15, 15, penfg);
ui_box(win, 17, win->h - 49, 2, 15, ssfn_bg);
ui_argb(win, 19, win->h - 49, 15, 15, penbg);
}
/**
* Display the toolbar
*/
void view_tools(ui_win_t *win)
{
int i, y;
for(i=0, y=24; i < (win->menu >= 6 && win->menu < 9? 9 : 7) && y < win->h; i++, y += 36)
ui_box(win, 2, y, 32, 32, theme[i==win->menu ? THEME_TABU : THEME_BGLOGO]);
ui_icon(win, tool_icons, 2, 22, 320-(win->menu >= 6 && win->menu < 9? 0 : 36+36));
}
/**
* Display the layers
*/
void view_layers(ui_win_t *win)
{
int i, y;
uint32_t fg;
for(i=win->fscroll, y=276; i < chars[win->chr].len + 1 && y < win->h - 50; i++, y += 33) {
fg = theme[i == win->frag? THEME_INPUT : THEME_INACT];
ui_box(win, 2, y, 32, 1, theme[THEME_BG]);
ui_box(win, 2, y+1, 32, 32, theme[i == chars[win->chr].len ? THEME_BG : (i == win->frag? THEME_INPBG : THEME_TABBG)]);
if(i < chars[win->chr].len)
switch(frags[chars[win->chr].frags[i]].type) {
case SSFN_FRAG_BITMAP:
render_bitmap(&frags[chars[win->chr].frags[i]], win->data, win->w, win->h, win->p, 0, 0, 2, y+1, 32, 32, fg);
break;
case SSFN_FRAG_PIXMAP:
render_pixmap(&frags[chars[win->chr].frags[i]], win->data, win->w, win->h, win->p, 0, 0, 2, y+1, 32, 32,
theme[THEME_TABBG]);
break;
case SSFN_FRAG_CONTOUR:
op = i == win->frag? 0 : 2; np = 0;
render_contour(&frags[chars[win->chr].frags[i]], win->data, win->w, win->h, win->p, 0, 0, 2, y+1, 32, 32,
fg, theme[THEME_TABBG]);
render_raster();
break;
}
}
view_coords(win);
}
/**
* Display the main edit area
*/
void view_editarea(ui_win_t *win)
{
int i, j, s, p, q, w, h, a, b, c, d;
switch(win->menu) {
case 3:
i = ui_textwidth(lang[AREYOUSURE], 64);
ssfn_x = 40 + ((win->w - 40 - i) >> 1); ssfn_y = (win->h - 80) >> 1;
ssfn_fg = theme[THEME_FG]; ssfn_bg = theme[THEME_BG];
ui_text(win, lang[AREYOUSURE], ssfn_bg, ssfn_bg);
ssfn_x = 40; ssfn_y = (win->h) >> 1;
i = (win->w - 80) >> 1;
ui_button(win, lang[NO], i, 3, 0);
ssfn_x += 16;
ui_button(win, lang[YES], i, 3, 3);
break;
case 9:
case 10:
view_color(win, win->menu == 9 ? &penfg : &penbg);
break;
default:
w = win->w - 52; h = win->h - 32;
if(!win->bg) {
win->bg = (uint32_t*)malloc(w*h*sizeof(uint32_t));
if(!win->bg) error("view_editarea", ERR_MEM);
s = (win->zoom + (8 << font->quality)) / (16 << font->quality);
q = win->zoom >> 1;
a = win->zoom-win->zx;
b = win->zoom-win->zy;
if(showgrid && s > 2) {
c = win->zx-(q%s);
d = win->zy-(q%s);
for(j=p=0;j<h;j++)
for(i=0;i<w;i++,p++)
win->bg[p] = theme[i < -win->zx || j < -win->zy || i >= a || j >= b ? THEME_BG :
((!((i+c)%s) || !((j+d)%s))? THEME_TABBG : THEME_INPBG)];
} else {
c = q-win->zx;
d = q-win->zy;
for(j=p=0;j<h;j++)
for(i=0;i<w;i++,p++)
win->bg[p] = theme[i < -win->zx || j < -win->zy || i >= a || j >= b ? THEME_BG :
(i == c || j == d ? THEME_TABBG : THEME_INPBG)];
}
}
for(i=0; i < chars[win->chr].len; i++) {
switch(frags[chars[win->chr].frags[i]].type) {
case SSFN_FRAG_BITMAP:
render_bitmap(&frags[chars[win->chr].frags[i]], win->bg, w, h, w, win->zx, win->zy,
0, 0, win->zoom, win->zoom, theme[i == win->frag ? THEME_INPUT : THEME_INACT]);
break;
case SSFN_FRAG_PIXMAP:
render_pixmap(&frags[chars[win->chr].frags[i]], win->bg, w, h, w, win->zx, win->zy,
0, 0, win->zoom, win->zoom, theme[THEME_BG]);
break;
case SSFN_FRAG_CONTOUR:
op = 0; np = 0;
render_contour(&frags[chars[win->chr].frags[i]], win->bg, w, h, w, win->zx, win->zy,
0, 0, win->zoom, win->zoom, theme[i == win->frag ? THEME_INPUT : THEME_INACT], theme[THEME_TABBG]);
break;
}
}
for(j=0,p=32*win->p; j < h && 32 + j < win->h; j++, p += win->p)
for(i=0;i<w && 52+i < win->w;i++)
win->data[p + 52 + i] = win->bg[j*w+i];
}
}
void view_zoomin(ui_win_t *win, int x, int y)
{
int i;
if(win->zoom < zooms[(int)(sizeof(zooms)/sizeof(zooms[0]))-1]) {
for(i=0;i<(int)(sizeof(zooms)/sizeof(zooms[0])) && win->zoom != zooms[i];i++);
i = zooms[i+1];
win->zx = ((win->zx + x) * i + (win->zoom >> 1)) / win->zoom - x;
win->zy = ((win->zy + y) * i + (win->zoom >> 1)) / win->zoom - y;
win->zoom = i;
mousex = ((win->zx + x) * (16 << font->quality) + (i >> 1)) / i;
mousey = ((win->zy + y) * (16 << font->quality) + (i >> 1)) / i;
if(win->bg) free(win->bg);
win->bg = NULL;
ui_resizewin(win, win->w, win->h);
}
}
void view_zoomout(ui_win_t *win, int x, int y)
{
int i;
if(win->zoom > zooms[0]) {
for(i=1;i<(int)(sizeof(zooms)/sizeof(zooms[0])) && win->zoom != zooms[i];i++);
i = zooms[i-1];
win->zx = ((win->zx + x) * i + (win->zoom >> 1)) / win->zoom - x;
win->zy = ((win->zy + y) * i + (win->zoom >> 1)) / win->zoom - y;
win->zoom = i;
mousex = ((win->zx + x) * (16 << font->quality) + (i >> 1)) / i;
mousey = ((win->zy + y) * (16 << font->quality) + (i >> 1)) / i;
if(win->bg) free(win->bg);
win->bg = NULL;
ui_resizewin(win, win->w, win->h);
}
}
/**
* View for edit tab
*/
void view_edit(ui_win_t *win)
{
view_layers(win);
view_tools(win);
view_editarea(win);
}
/**
* Controller for edit tab
*/
int ctrl_edit(ui_win_t *win, ui_event_t *evt)
{
switch(evt->type) {
case E_KEY:
switch(evt->x) {
case 'g':
showgrid ^= 1;
if(win->bg) free(win->bg);
win->bg = NULL;
break;
default: break;
}
return 1;
case E_MOUSEMOVE:
if(!overmenu && win->menu != 3 && win->menu < 9 && evt->y > 32 && evt->x > 52) {
ui_cursorwin(win, inmove ? CURSOR_MOVE : CURSOR_CROSS);
if(inmove) {
win->zx = clickx - evt->x + prevx;
win->zy = clicky - evt->y + prevy;
if(win->bg) free(win->bg);
win->bg = NULL;
return 1;
}
mousex = ((evt->x - 52 + win->zx) * (16 << font->quality) + (win->zoom >> 1)) / win->zoom;
mousey = ((evt->y - 32 + win->zy) * (16 << font->quality) + (win->zoom >> 1)) / win->zoom;
view_coords(win);
ui_flushwin(win, 0, win->h - 34, 36, 32);
} else {
mousex = mousey = 0;
if(evt->y > 26 && evt->x > 52 && win->menu > 8) ctrl_color(win, evt, win->menu == 9 ? &penfg : &penbg);
else {
ui_cursorwin(win, CURSOR_PTR);
view_coords(win);
if(evt->x < 36 && win->menu < 9) {
if(overmenu) win->menu = (evt->y - 24) / 36;
if(win->menu > 8) win->menu = 5;