diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/chess/main.c | 2 | ||||
-rw-r--r-- | apps/view/Makefile | 7 | ||||
-rw-r--r-- | apps/view/main.c | 37 | ||||
-rw-r--r-- | apps/wm/main.c | 7 |
4 files changed, 49 insertions, 4 deletions
diff --git a/apps/chess/main.c b/apps/chess/main.c index a546e63..64911dc 100644 --- a/apps/chess/main.c +++ b/apps/chess/main.c @@ -64,7 +64,7 @@ static void load_image(struct piece *tile) enum gfx_filter filter = IS_COLOR(tile->piece, BLACK) ? GFX_FILTER_NONE : GFX_FILTER_INVERT; /* assert(gui_fill(win, tile->widget, GUI_LAYER_FG, 0) == EOK); */ - gui_load_image_filter(win, tile->widget, GUI_LAYER_FG, vec2(0, 0), vec2(TILE, TILE), filter, + gui_draw_image_filter(win, tile->widget, GUI_LAYER_FG, vec2(0, 0), vec2(TILE, TILE), filter, icon); } diff --git a/apps/view/Makefile b/apps/view/Makefile new file mode 100644 index 0000000..c4c6860 --- /dev/null +++ b/apps/view/Makefile @@ -0,0 +1,7 @@ +# MIT License, Copyright (c) 2021 Marvin Borner + +NAME = view +OBJS = main.o +LIBS = -lgui -lc + +include ../generic.mk diff --git a/apps/view/main.c b/apps/view/main.c new file mode 100644 index 0000000..20661a7 --- /dev/null +++ b/apps/view/main.c @@ -0,0 +1,37 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#include <def.h> +#include <libgui/gui.h> + +#define SCALING_FACTOR 0.1 + +static vec2 size = { 800, 800 }; +static const char *path; + +static void mousemove(struct gui_event_mouse *event) +{ + if (event->scroll) { + size = vec2_mul(size, event->scroll < 0 ? SCALING_FACTOR + 1 : 1 - SCALING_FACTOR); + gui_fill(event->win, event->widget, GUI_LAYER_FG, COLOR_WHITE); + gui_draw_image(event->win, event->widget, GUI_LAYER_FG, vec2(0, 0), size, path); + gui_redraw_widget(event->win, event->widget); + } +} + +int main(int argc, char *argv[]) +{ + UNUSED(argc); + UNUSED(argv); + + path = "/res/test.png"; + + u32 win = gui_new_custom_window(APPNAME, vec2(0, 0), size); + u32 canvas = gui_new_widget(win, GUI_MAIN, vec2(0, 0), size); + gui_fill(win, canvas, GUI_LAYER_BG, COLOR_WHITE); + gui_listen_widget(win, canvas, GUI_LISTEN_MOUSEMOVE, (u32)mousemove); + + gui_redraw_window(win); + gui_loop(); + + return 0; +} diff --git a/apps/wm/main.c b/apps/wm/main.c index 25478ff..771bd44 100644 --- a/apps/wm/main.c +++ b/apps/wm/main.c @@ -476,9 +476,10 @@ static void window_bar_draw(struct window *win, char name[64]) return; gfx_write(&win->ctx, vec2(BAR_MARGIN, BAR_MARGIN), FONT_24, COLOR_WHITE, name); - gfx_load_image_filter(&win->ctx, + gfx_draw_image_filter(&win->ctx, vec2(win->ctx.size.x - BAR_CLOSE_SIZE - BAR_MARGIN, BAR_MARGIN), - GFX_FILTER_INVERT, "/icons/close-" STRINGIFY(BAR_CLOSE_SIZE) ".png"); + vec2(BAR_CLOSE_SIZE, BAR_CLOSE_SIZE), GFX_FILTER_INVERT, + "/icons/close-" STRINGIFY(BAR_CLOSE_SIZE) ".png"); } /** @@ -751,7 +752,7 @@ int main(int argc, char **argv) assert(io_control(IO_BUS, IOCTL_BUS_REGISTER, "wm") == EOK); - assert(exec("paint", NULL) == EOK); + assert(exec("view", NULL) == EOK); u8 msg[1024] = { 0 }; struct event_keyboard event_keyboard = { 0 }; |