mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-06 09:29:44 +00:00
draw button
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@32 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -13,7 +13,7 @@ static void draw(MilskoWidget handle) {
|
||||
r.width = MilskoGetInteger(handle, MilskoNwidth);
|
||||
r.height = MilskoGetInteger(handle, MilskoNheight);
|
||||
|
||||
MilskoDrawFrame(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)), 0);
|
||||
MilskoDrawFrame(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)), handle->pressed);
|
||||
|
||||
MilskoDrawRect(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)));
|
||||
}
|
||||
|
||||
19
src/core.c
19
src/core.c
@@ -3,11 +3,23 @@
|
||||
|
||||
#include "stb_ds.h"
|
||||
|
||||
static void llhandler(MilskoLL handle) {
|
||||
static void lldrawhandler(MilskoLL handle) {
|
||||
MilskoWidget h = (MilskoWidget)handle->user;
|
||||
MilskoDispatch(h, draw);
|
||||
}
|
||||
|
||||
static void lluphandler(MilskoLL handle) {
|
||||
MilskoWidget h = (MilskoWidget)handle->user;
|
||||
h->pressed = 0;
|
||||
|
||||
MilskoDispatch(h, click);
|
||||
}
|
||||
|
||||
static void lldownhandler(MilskoLL handle) {
|
||||
MilskoWidget h = (MilskoWidget)handle->user;
|
||||
h->pressed = 1;
|
||||
}
|
||||
|
||||
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||
MilskoWidget h = malloc(sizeof(*h));
|
||||
|
||||
@@ -18,9 +30,12 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
||||
h->children = NULL;
|
||||
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
||||
h->class = class;
|
||||
h->pressed = 0;
|
||||
|
||||
h->lowlevel->user = h;
|
||||
h->lowlevel->callback->draw = llhandler;
|
||||
h->lowlevel->callback->draw = lldrawhandler;
|
||||
h->lowlevel->callback->up = lluphandler;
|
||||
h->lowlevel->callback->down = lldownhandler;
|
||||
|
||||
if(parent != NULL) arrput(parent->children, h);
|
||||
|
||||
|
||||
10
src/x11.c
10
src/x11.c
@@ -110,6 +110,16 @@ void MilskoLLNextEvent(MilskoLL handle) {
|
||||
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
||||
if(ev.type == Expose) {
|
||||
MilskoLLDispatch(handle, draw);
|
||||
} else if(ev.type == ButtonPress) {
|
||||
if(ev.xbutton.button == Button1) {
|
||||
MilskoLLDispatch(handle, down);
|
||||
MilskoLLDispatch(handle, draw);
|
||||
}
|
||||
} else if(ev.type == ButtonRelease) {
|
||||
if(ev.xbutton.button == Button1) {
|
||||
MilskoLLDispatch(handle, up);
|
||||
MilskoLLDispatch(handle, draw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user