From d95939b23c21be2e3d2ad7c0610c832fd0dc4c73 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Tue, 11 Nov 2025 12:15:48 +0000 Subject: [PATCH] add classic theme option to Makefile.pl git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@664 b9cfdab3-6d41-4d17-bbe4-086880011989 --- CMakeLists.txt | 6 ++-- Makefile.pl | 10 +++--- pl/rules.pl | 3 ++ src/core.c | 2 +- src/widget/submenu.c | 77 +++++++++++++++++++++++++++----------------- 5 files changed, 61 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9711c93..9e27a58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") else() option(BUILD_VULKAN "Compile Vulkan widget or not" ON) endif() -option(CLASSIC "Use classic theme" OFF) +option(CLASSIC_THEME "Use classic theme" OFF) option(BUILD_EXAMPLES "Build examples" OFF) option(USE_STB_IMAGE "Use stb_image" ON) option(USE_STB_TRUETYPE "Use stb_truetype" OFF) @@ -100,11 +100,11 @@ target_include_directories( include ) -if(CLASSIC) +if(CLASSIC_THEME) target_compile_definitions( Mw PRIVATE - MW_CLASSIC_THEME + USE_CLASSIC_THEME ) endif() diff --git a/Makefile.pl b/Makefile.pl index a97dcfe..359b41e 100755 --- a/Makefile.pl +++ b/Makefile.pl @@ -33,6 +33,7 @@ our $cross = 0; require("./pl/utils.pl"); +param_set("classic-theme", 0); param_set("stb-image", 1); param_set("stb-truetype", 0); param_set("freetype2", 1); @@ -42,6 +43,7 @@ param_set("vulkan", 0); param_set("vulkan-string-helper", 1); my %features = ( + "classic-theme" => "use classic theme", "stb-image" => "use stb_image instead of libjpeg/libpng", "stb-truetype" => "use stb_truetype", "freetype2" => "use FreeType2", @@ -51,10 +53,10 @@ my %features = ( "vulkan-string-helper" => "use Vulkan string helper" ); my @features_keys = ( - "1stb-image", "1stb-truetype", - "1freetype2", "1opengl", - "2xrender", "1vulkan", - "2vulkan-string-helper" + "1classic-theme", "1stb-image", + "1stb-truetype", "1freetype2", + "1opengl", "2xrender", + "1vulkan", "2vulkan-string-helper" ); foreach my $l (@ARGV) { diff --git a/pl/rules.pl b/pl/rules.pl index 93191ad..8ad6659 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -3,6 +3,9 @@ new_object("src/*.c"); my $gl_libs = ""; +if (param_get("classic-theme")) { + add_cflags("-DUSE_CLASSIC_THEME"); +} if ($backend eq "x11") { add_cflags("-DUSE_X11"); new_object("src/backend/x11.c"); diff --git a/src/core.c b/src/core.c index aa2499a..d261537 100644 --- a/src/core.c +++ b/src/core.c @@ -500,7 +500,7 @@ static void set_boldfont(MwWidget handle) { void MwSetDefault(MwWidget handle) { MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask); -#ifdef MW_CLASSIC_THEME +#ifdef USE_CLASSIC_THEME inherit_integer(handle, MwNmodernLook, 0); #else inherit_integer(handle, MwNmodernLook, 1); diff --git a/src/widget/submenu.c b/src/widget/submenu.c index 305fad3..cd94268 100644 --- a/src/widget/submenu.c +++ b/src/widget/submenu.c @@ -47,33 +47,48 @@ static void draw(MwWidget handle) { p.y = 3; for(i = 0; i < arrlen(menu->sub); i++) { - int tw = MwTextWidth(handle, menu->sub[i]->name); - int th = MwTextHeight(handle, menu->sub[i]->name); + if(strcmp(menu->sub[i]->name, "----") == 0) { + MwRect rc; - if(menu->sub[i]->wsub != NULL) { - r.x = 0; - r.y = p.y - 3; - r.width = tw + 15 + 5 * 2; - r.height = th + 3 * 2; - MwDrawWidgetBack(handle, &r, base, 0, MwTRUE); + p.y += 1; + + rc.x = MwDefaultBorderWidth(handle) * 2; + rc.y = p.y; + rc.width = r.width - (rc.x * 2); + rc.height = MwDefaultBorderWidth(handle) * 2; + + MwDrawFrame(handle, &rc, base, 1); + + p.y += MwDefaultBorderWidth(handle) * 2 + 1; + } else { + int tw = MwTextWidth(handle, menu->sub[i]->name); + int th = MwTextHeight(handle, menu->sub[i]->name); + + if(menu->sub[i]->wsub != NULL) { + r.x = 0; + r.y = p.y - 3; + r.width = tw + 15 + 5 * 2; + r.height = th + 3 * 2; + MwDrawWidgetBack(handle, &r, base, 0, MwTRUE); + } + + p.x = 5 + tw / 2; + + p.y += th / 2; + MwDrawText(handle, &p, menu->sub[i]->name, 1, MwALIGNMENT_CENTER, text); + + if(arrlen(menu->sub[i]->sub) > 0) { + MwRect tr; + + tr.x = p.x + tw / 2 + 5; + tr.y = p.y - th / 2 + 2; + tr.width = tr.height = 11; + + MwDrawTriangle(handle, &tr, base, menu->sub[i]->wsub != NULL ? 1 : 0, MwEAST); + } + + p.y += th / 2 + 3; } - - p.x = 5 + tw / 2; - - p.y += th / 2; - MwDrawText(handle, &p, menu->sub[i]->name, 1, MwALIGNMENT_CENTER, text); - - if(arrlen(menu->sub[i]->sub) > 0) { - MwRect tr; - - tr.x = p.x + tw / 2 + 5; - tr.y = p.y - th / 2 + 2; - tr.width = tr.height = 11; - - MwDrawTriangle(handle, &tr, base, menu->sub[i]->wsub != NULL ? 1 : 0, MwEAST); - } - - p.y += th / 2 + 3; } } @@ -170,10 +185,14 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { MwLLShow(handle->lowlevel, 1); for(i = 0; i < arrlen(menu->sub); i++) { - int tw = MwTextWidth(handle, menu->sub[i]->name); - h += MwTextHeight(handle, menu->sub[i]->name) + 3; - if(tw > w) { - w = tw; + if(strcmp(menu->sub[i]->name, "----") == 0) { + h += MwDefaultBorderWidth(handle) * 2 + 2; + } else { + int tw = MwTextWidth(handle, menu->sub[i]->name); + h += MwTextHeight(handle, menu->sub[i]->name) + 3; + if(tw > w) { + w = tw; + } } }