Mercurial > molko
changeset 508:7f7602bae0bd
examples: minor touches
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 03 Mar 2023 19:45:00 +0100 |
parents | d49a05e7a5b5 |
children | a11cd7ea3a37 |
files | CMakeLists.txt examples/example-action/example-action.c examples/example-animation/example-animation.c examples/example-audio/example-audio.c examples/example-battle/example-battle.c examples/example-cursor/example-cursor.c examples/example-drawable/example-drawable.c examples/example-font/example-font.c examples/example-message/example-message.c examples/example-notify/example-notify.c examples/example-sprite/example-sprite.c examples/example-trace/example-trace.c libmlk-core/mlk/core/action-stack.c libmlk-core/mlk/core/drawable-stack.c libmlk-ui/mlk/ui/gridmenu.c |
diffstat | 15 files changed, 26 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Thu Mar 02 21:36:43 2023 +0100 +++ b/CMakeLists.txt Fri Mar 03 19:45:00 2023 +0100 @@ -27,7 +27,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-deprecated-declarations -Wno-unknown-pragmas -pedantic ${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-deprecated-declarations -Wno-unknown-pragmas ${CMAKE_C_FLAGS}") if (CMAKE_C_COMPILER_ID MATCHES "GNU") set(CMAKE_C_FLAGS "-Wno-format-truncation ${CMAKE_C_FLAGS}")
--- a/examples/example-action/example-action.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-action/example-action.c Fri Mar 03 19:45:00 2023 +0100 @@ -70,7 +70,6 @@ * Just a label to explain to the user what to do. */ static struct mlk_label label = { - .flags = MLK_LABEL_FLAGS_SHADOW, .text = "Select your destiny." }; @@ -322,7 +321,7 @@ { (void)st; - mlk_painter_set_color(0x4f8fbaff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&label); mlk_action_stack_draw(&chests_stack);
--- a/examples/example-animation/example-animation.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-animation/example-animation.c Fri Mar 03 19:45:00 2023 +0100 @@ -97,7 +97,7 @@ cellw = mlk_registry_sprites[MLK_REGISTRY_TEXTURE_NUMBERS].cellw; cellh = mlk_registry_sprites[MLK_REGISTRY_TEXTURE_NUMBERS].cellh; - mlk_painter_set_color(0x4f8fbaff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&label);
--- a/examples/example-audio/example-audio.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-audio/example-audio.c Fri Mar 03 19:45:00 2023 +0100 @@ -29,7 +29,6 @@ #include <mlk/core/window.h> #include <mlk/ui/label.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/example/example.h> @@ -42,15 +41,13 @@ static struct mlk_label label_music = { .text = "Music: <Space> play, <p> pause, <r> resume, <q> stop, <l> loop.", .x = 10, - .y = 10, - .flags = MLK_LABEL_FLAGS_SHADOW + .y = 10 }; static struct mlk_label label_sound = { .text = "Sound: click anywhere to pop a sound.", .x = 10, - .y = 30, - .flags = MLK_LABEL_FLAGS_SHADOW + .y = 30 }; static void @@ -117,7 +114,7 @@ { (void)st; - mlk_painter_set_color(0x006554ff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&label_music); mlk_label_draw(&label_sound);
--- a/examples/example-battle/example-battle.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-battle/example-battle.c Fri Mar 03 19:45:00 2023 +0100 @@ -37,7 +37,6 @@ #include <mlk/ui/align.h> #include <mlk/ui/label.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/rpg/battle-bar-default.h> @@ -254,11 +253,10 @@ static const struct mlk_label info = { .text = "Press <Space> to start a battle.", .x = 10, - .y = 10, - .flags = MLK_LABEL_FLAGS_SHADOW + .y = 10 }; - mlk_painter_set_color(0x4f8fbaff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&info); mlk_painter_present();
--- a/examples/example-cursor/example-cursor.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-cursor/example-cursor.c Fri Mar 03 19:45:00 2023 +0100 @@ -42,8 +42,7 @@ static struct mlk_label help = { .x = 10, .y = 10, - .text = help_text, - .flags = MLK_LABEL_FLAGS_SHADOW + .text = help_text }; static void @@ -106,7 +105,7 @@ { (void)st; - mlk_painter_set_color(0xebede9ff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&help); mlk_painter_present();
--- a/examples/example-drawable/example-drawable.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-drawable/example-drawable.c Fri Mar 03 19:45:00 2023 +0100 @@ -38,7 +38,6 @@ #include <mlk/core/window.h> #include <mlk/ui/label.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/example/example.h> @@ -47,8 +46,7 @@ static struct mlk_label help = { .x = 10, .y = 10, - .text = "Keys: <Esc> to reset. Click anywhere to spawn a drawable.", - .flags = MLK_LABEL_FLAGS_SHADOW + .text = "Keys: <Esc> to reset. Click anywhere to spawn a drawable." }; static struct mlk_state *states[1]; @@ -159,7 +157,7 @@ { (void)st; - mlk_painter_set_color(0xebede9ff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&help); mlk_drawable_stack_draw(&stack);
--- a/examples/example-font/example-font.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-font/example-font.c Fri Mar 03 19:45:00 2023 +0100 @@ -29,7 +29,6 @@ #include <mlk/core/util.h> #include <mlk/core/window.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/example/example.h> @@ -101,11 +100,11 @@ { (void)st; - struct mlk_font *font = mlk_theme.fonts[MLK_THEME_FONT_INTERFACE]; + struct mlk_font *font = mlk_ui_fonts[MLK_UI_FONT_INTERFACE]; struct mlk_texture tex; int err; - mlk_painter_set_color(0xffffffff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); if ((err = mlk_font_render(font, &tex, "Example of text. Use <Left>/<Right> to change color and <Space> to toggle antialiasing.", colors[ci])) < 0)
--- a/examples/example-message/example-message.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-message/example-message.c Fri Mar 03 19:45:00 2023 +0100 @@ -29,7 +29,6 @@ #include <mlk/core/window.h> #include <mlk/ui/frame.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/rpg/message.h> @@ -76,7 +75,7 @@ static void draw(struct mlk_state *st) { - mlk_painter_set_color(0xffffffff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); message_draw(st->data); mlk_painter_present();
--- a/examples/example-notify/example-notify.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-notify/example-notify.c Fri Mar 03 19:45:00 2023 +0100 @@ -39,8 +39,7 @@ static struct mlk_label help = { .text = "Keys: <Space> to generate a notification.", .x = 10, - .y = 10, - .flags = MLK_LABEL_FLAGS_SHADOW + .y = 10 }; static struct mlk_texture *icon; static struct mlk_state *states[1]; @@ -87,7 +86,7 @@ { (void)st; - mlk_painter_set_color(0xffffffff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_label_draw(&help); mlk_notify_draw();
--- a/examples/example-sprite/example-sprite.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-sprite/example-sprite.c Fri Mar 03 19:45:00 2023 +0100 @@ -51,8 +51,7 @@ static struct mlk_label help = { .x = 10, .y = 10, - .text = msg, - .flags = MLK_LABEL_FLAGS_SHADOW + .text = msg }; static void @@ -117,7 +116,7 @@ int x, y; - mlk_painter_set_color(0xebede9ff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_align(MLK_ALIGN_CENTER, &x, &y, sprite->cellw, sprite->cellh, 0, 0, mlk_window.w, mlk_window.h); mlk_sprite_draw(sprite, row, column, x, y);
--- a/examples/example-trace/example-trace.c Thu Mar 02 21:36:43 2023 +0100 +++ b/examples/example-trace/example-trace.c Fri Mar 03 19:45:00 2023 +0100 @@ -28,7 +28,6 @@ #include <mlk/core/trace.h> #include <mlk/core/util.h> -#include <mlk/ui/theme.h> #include <mlk/ui/ui.h> #include <mlk/example/example.h> @@ -87,7 +86,7 @@ { (void)st; - mlk_painter_set_color(0x4f8fbaff); + mlk_painter_set_color(MLK_EXAMPLE_BG); mlk_painter_clear(); mlk_trace_hud_draw(); mlk_painter_present();
--- a/libmlk-core/mlk/core/action-stack.c Thu Mar 02 21:36:43 2023 +0100 +++ b/libmlk-core/mlk/core/action-stack.c Fri Mar 03 19:45:00 2023 +0100 @@ -143,5 +143,6 @@ } } - memset(st, 0, sizeof (*st)); + for (size_t i = 0; i < st->actionsz; ++i) + st->actions[i] = NULL; }
--- a/libmlk-core/mlk/core/drawable-stack.c Thu Mar 02 21:36:43 2023 +0100 +++ b/libmlk-core/mlk/core/drawable-stack.c Fri Mar 03 19:45:00 2023 +0100 @@ -118,5 +118,6 @@ } } - memset(st, 0, sizeof (*st)); + for (size_t i = 0; i < st->objectsz; ++i) + st->objects[i] = NULL; }
--- a/libmlk-ui/mlk/ui/gridmenu.c Thu Mar 02 21:36:43 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.c Fri Mar 03 19:45:00 2023 +0100 @@ -178,6 +178,8 @@ static void draw(struct mlk_gridmenu_delegate *delegate, const struct mlk_gridmenu *menu) { + (void)delegate; + size_t pagesz, pagenr, item, c = 0, r = 0; const struct mlk_gridmenu_style *style; struct mlk_texture tex;