add classic theme option to Makefile.pl

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@664 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-11 12:15:48 +00:00
parent 77f2ae8fd6
commit d95939b23c
5 changed files with 61 additions and 37 deletions

View File

@@ -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()

View File

@@ -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) {

View File

@@ -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");

View File

@@ -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);

View File

@@ -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;
}
}
}