add waozi icons
No files matched your search
@@ -0,0 +1,50 @@
|
||||
*.sym
|
||||
*.tar.gz
|
||||
*.zip
|
||||
*~
|
||||
*.love
|
||||
.raylib*
|
||||
.claude/
|
||||
.local/
|
||||
.codex/
|
||||
.agents/
|
||||
.cache/
|
||||
*.wasm
|
||||
build/
|
||||
node_modules
|
||||
*.nix-defexpr
|
||||
*.npm
|
||||
*.nix-profile
|
||||
.claude.json
|
||||
.bash_history
|
||||
|
||||
|
||||
*.exe
|
||||
*_x86_64
|
||||
*.xdp*
|
||||
main
|
||||
|
||||
.direnv/
|
||||
.node-repl-history
|
||||
result
|
||||
result-*
|
||||
|
||||
.idea/
|
||||
*.iml
|
||||
.gradle/
|
||||
local.properties
|
||||
Captures/
|
||||
.externalNativeBuild/
|
||||
.cxx/
|
||||
|
||||
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
*.bak
|
||||
*.swp
|
||||
|
||||
local.properties
|
||||
*.o
|
||||
*.9
|
||||
*.8
|
||||
*.a
|
||||
@@ -0,0 +1,6 @@
|
||||
[submodule "vendor/raylib"]
|
||||
path = vendor/raylib
|
||||
url = https://github.com/raysan5/raylib.git
|
||||
[submodule "vendor/rini"]
|
||||
path = vendor/rini
|
||||
url = https://github.com/raysan5/rini.git
|
||||
@@ -1,12 +1,12 @@
|
||||
CC = gcc
|
||||
WINDRES = windres
|
||||
|
||||
SRC = src/main.c src/app.c src/ui.c src/theme_meta.c ../liblotus/src/theme.c
|
||||
SRC = src/main.c src/app.c src/ui.c src/theme_meta.c src/theme.c
|
||||
INBE_DIR = libinbe
|
||||
INBE_A = $(INBE_DIR)/libinbe.a
|
||||
|
||||
RAYLIB_DIR = ../vendor/raylib/src
|
||||
RAYLIB_BUILD_DIR = ../vendor/raylib/build/sdl
|
||||
RAYLIB_DIR = vendor/raylib/src
|
||||
RAYLIB_BUILD_DIR = vendor/raylib/build/sdl
|
||||
RAYLIB_A = $(RAYLIB_BUILD_DIR)/libraylib.a
|
||||
|
||||
ANDROID_DIR = droid
|
||||
@@ -79,7 +79,7 @@ WEB_RAYLIB_OBJS = \
|
||||
$(WEB_RAYLIB_BUILD_DIR)/raudio.o
|
||||
WEB_CFLAGS = -Wall -Wextra -std=gnu99 -Os -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -D_DEFAULT_SOURCE -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1
|
||||
WEB_SHELL = src/web_shell.html
|
||||
WEB_LDFLAGS = -sUSE_GLFW=3 -sASYNCIFY -sALLOW_MEMORY_GROWTH=1 --shell-file $(WEB_SHELL) --preload-file [email protected] --preload-file [email protected] --preload-file themes/sky.ini@themes/sky.ini --preload-file themes/sky_dark.ini@themes/sky_dark.ini --preload-file themes/ocean.ini@themes/ocean.ini --preload-file themes/ocean_dark.ini@themes/ocean_dark.ini --preload-file themes/forest.ini@themes/forest.ini --preload-file themes/forest_dark.ini@themes/forest_dark.ini --preload-file themes/sunset.ini@themes/sunset.ini --preload-file themes/sunset_dark.ini@themes/sunset_dark.ini --preload-file themes/lavender.ini@themes/lavender.ini --preload-file themes/lavender_dark.ini@themes/lavender_dark.ini --preload-file themes/cherry.ini@themes/cherry.ini --preload-file themes/cherry_dark.ini@themes/cherry_dark.ini --preload-file ../icons/gear.png@icons/gear.png --preload-file ../icons/x.png@icons/x.png --preload-file ../icons/manual.png@icons/manual.png --preload-file ../icons/return.png@icons/return.png --preload-file ../icons/backward.png@icons/backward.png --preload-file ../icons/forward.png@icons/forward.png --preload-file ../icons/play.png@icons/play.png --preload-file ../icons/pause.png@icons/pause.png --preload-file ../icons/stat.png@icons/stat.png --preload-file ../icons/home.png@icons/home.png --preload-file ../icons/trash.png@icons/trash.png --preload-file ../icons/telegram.png@icons/telegram.png --preload-file ../icons/globe.png@icons/globe.png --preload-file ../icons/stripe.png@icons/stripe.png --preload-file ../icons/monero.png@icons/monero.png --preload-file assets/angel.jpg@assets/angel.jpg --preload-file assets/begin.jpg@assets/begin.jpg --preload-file assets/sounds/breath-in.ogg@assets/sounds/breath-in.ogg --preload-file assets/sounds/breath-out.ogg@assets/sounds/breath-out.ogg --preload-file assets/sounds/bell.ogg@assets/sounds/bell.ogg
|
||||
WEB_LDFLAGS = -sUSE_GLFW=3 -sASYNCIFY -sALLOW_MEMORY_GROWTH=1 --shell-file $(WEB_SHELL) --preload-file [email protected] --preload-file [email protected] --preload-file themes/sky.ini@themes/sky.ini --preload-file themes/sky_dark.ini@themes/sky_dark.ini --preload-file themes/ocean.ini@themes/ocean.ini --preload-file themes/ocean_dark.ini@themes/ocean_dark.ini --preload-file themes/forest.ini@themes/forest.ini --preload-file themes/forest_dark.ini@themes/forest_dark.ini --preload-file themes/sunset.ini@themes/sunset.ini --preload-file themes/sunset_dark.ini@themes/sunset_dark.ini --preload-file themes/lavender.ini@themes/lavender.ini --preload-file themes/lavender_dark.ini@themes/lavender_dark.ini --preload-file themes/cherry.ini@themes/cherry.ini --preload-file themes/cherry_dark.ini@themes/cherry_dark.ini --preload-file icons/gear.png@icons/gear.png --preload-file icons/x.png@icons/x.png --preload-file icons/manual.png@icons/manual.png --preload-file icons/return.png@icons/return.png --preload-file icons/backward.png@icons/backward.png --preload-file icons/forward.png@icons/forward.png --preload-file icons/play.png@icons/play.png --preload-file icons/pause.png@icons/pause.png --preload-file icons/stat.png@icons/stat.png --preload-file icons/home.png@icons/home.png --preload-file icons/trash.png@icons/trash.png --preload-file icons/telegram.png@icons/telegram.png --preload-file icons/globe.png@icons/globe.png --preload-file icons/stripe.png@icons/stripe.png --preload-file icons/monero.png@icons/monero.png --preload-file assets/angel.jpg@assets/angel.jpg --preload-file assets/begin.jpg@assets/begin.jpg --preload-file assets/sounds/breath-in.ogg@assets/sounds/breath-in.ogg --preload-file assets/sounds/breath-out.ogg@assets/sounds/breath-out.ogg --preload-file assets/sounds/bell.ogg@assets/sounds/bell.ogg
|
||||
INBE_RAYLIB_CONFIG = $(filter-out -DSUPPORT_MODULE_RAUDIO=0 -DSUPPORT_FILEFORMAT_PNG=0 -DSUPPORT_FILEFORMAT_JPG=0 -DSUPPORT_FILEFORMAT_OGG=0,$(RAY_RAYLIB_CONFIG)) -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1
|
||||
|
||||
CFLAGS = -Wall -Wextra -std=c99 -Os -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1
|
||||
@@ -156,7 +156,7 @@ $(TARGET): $(SRC) theme.ini inbe.ini $(RAYLIB_A) $(LINUX_INBE_A) | $(LINUX_BUILD
|
||||
$(CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-I../liblotus/include \
|
||||
-Isrc \
|
||||
$(RAY_CFLAGS) \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
@@ -198,7 +198,7 @@ linux-aarch64: | $(LINUX_BUILD_DIR)
|
||||
LINUX_RAY_SDL_INCLUDE_DIR="$(AARCH64_RAY_SDL_INCLUDE_DIR)"
|
||||
|
||||
build-linux-arch:
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/obj-$(ARCH_NAME) ../vendor/raylib/build/sdl-$(ARCH_NAME)
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/obj-$(ARCH_NAME) vendor/raylib/build/sdl-$(ARCH_NAME)
|
||||
$(MAKE) -C $(RAYLIB_DIR) clean
|
||||
$(MAKE) -j1 -C $(RAYLIB_DIR) \
|
||||
CC="$(LINUX_CC)" \
|
||||
@@ -218,14 +218,14 @@ build-linux-arch:
|
||||
$(LINUX_CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-I../liblotus/include \
|
||||
-Isrc \
|
||||
$(LINUX_RAY_CFLAGS) \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
-o $(LINUX_BUILD_DIR)/inbe-linux-$(ARCH_NAME) \
|
||||
$(SRC) \
|
||||
$(LINUX_BUILD_DIR)/obj-$(ARCH_NAME)/libinbe.a \
|
||||
../vendor/raylib/build/sdl-$(ARCH_NAME)/libraylib.a \
|
||||
vendor/raylib/build/sdl-$(ARCH_NAME)/libraylib.a \
|
||||
$(LINUX_RAY_LDLIBS) \
|
||||
-lm -lpthread -ldl -lrt \
|
||||
$(LDFLAGS)
|
||||
@@ -287,7 +287,7 @@ $(WEB_TARGET): $(SRC) $(INBE_DIR)/inbe.c $(WEB_SHELL) $(WEB_RAYLIB_A) | $(WEB_BU
|
||||
$(WEB_CC) $(WEB_CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-I../liblotus/include \
|
||||
-Isrc \
|
||||
-o $@ \
|
||||
$(SRC) \
|
||||
$(INBE_DIR)/inbe.c \
|
||||
@@ -305,7 +305,7 @@ $(WIN_TARGET): $(SRC) $(WIN_RAYLIB_A) $(WIN_INBE_A) | $(WINDOWS_BUILD_DIR)
|
||||
$(WIN_CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-I../liblotus/include \
|
||||
-Isrc \
|
||||
-o $@ \
|
||||
$(SRC) \
|
||||
$(WIN_INBE_A) \
|
||||
@@ -333,7 +333,7 @@ clean-web:
|
||||
|
||||
clean-raylib:
|
||||
$(MAKE) -C $(RAYLIB_DIR) clean
|
||||
rm -rf ../vendor/raylib/build
|
||||
rm -rf vendor/raylib/build
|
||||
|
||||
# Distribution targets
|
||||
#
|
||||
@@ -371,7 +371,7 @@ dist-linux: linux
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/themes
|
||||
@cp themes/*.ini $(LINUX_BUILD_DIR)/dist/inbe-linux/themes/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/icons
|
||||
@cp ../icons/gear.png ../icons/x.png ../icons/manual.png ../icons/return.png ../icons/backward.png ../icons/forward.png ../icons/play.png ../icons/pause.png ../icons/stat.png $(LINUX_BUILD_DIR)/dist/inbe-linux/icons/
|
||||
@cp icons/gear.png icons/x.png icons/manual.png icons/return.png icons/backward.png icons/forward.png icons/play.png icons/pause.png icons/stat.png $(LINUX_BUILD_DIR)/dist/inbe-linux/icons/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/assets
|
||||
@cp assets/angel.jpg assets/begin.jpg $(LINUX_BUILD_DIR)/dist/inbe-linux/assets/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/assets/sounds
|
||||
@@ -397,7 +397,7 @@ dist-windows:
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/themes
|
||||
@cp themes/*.ini $(WINDOWS_BUILD_DIR)/dist/inbe-windows/themes/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/icons
|
||||
@cp ../icons/gear.png ../icons/x.png ../icons/manual.png ../icons/return.png ../icons/backward.png ../icons/forward.png ../icons/play.png ../icons/pause.png ../icons/stat.png $(WINDOWS_BUILD_DIR)/dist/inbe-windows/icons/
|
||||
@cp icons/gear.png icons/x.png icons/manual.png icons/return.png icons/backward.png icons/forward.png icons/play.png icons/pause.png icons/stat.png $(WINDOWS_BUILD_DIR)/dist/inbe-windows/icons/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/assets
|
||||
@cp assets/angel.jpg assets/begin.jpg $(WINDOWS_BUILD_DIR)/dist/inbe-windows/assets/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/assets/sounds
|
||||
@@ -430,7 +430,7 @@ android-copy-assets:
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets/themes
|
||||
cp themes/*.ini $(ANDROID_DIR)/app/src/main/assets/themes/
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets/icons
|
||||
@for icon in ../icons/*.png; do \
|
||||
@for icon in icons/*.png; do \
|
||||
base=$$(basename "$$icon"); \
|
||||
size=$$(identify -format '%wx%h' "$$icon"); \
|
||||
magick "$$icon" -filter point -resize "$$size!" "$(ANDROID_DIR)/app/src/main/assets/icons/$$base"; \
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1779560665,
|
||||
"narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 170 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 222 B |
|
After Width: | Height: | Size: 192 B |
|
After Width: | Height: | Size: 216 B |
|
After Width: | Height: | Size: 832 B |
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 173 B |
|
After Width: | Height: | Size: 110 B |
|
After Width: | Height: | Size: 151 B |
|
After Width: | Height: | Size: 165 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 325 B |
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 216 B |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 206 B |
|
After Width: | Height: | Size: 252 B |
|
After Width: | Height: | Size: 205 B |
|
After Width: | Height: | Size: 184 B |
|
After Width: | Height: | Size: 125 B |
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 159 B |
|
After Width: | Height: | Size: 157 B |
@@ -1,7 +1,7 @@
|
||||
# Icon sizes for Inner Breeze
|
||||
# Run 'make' to regenerate from ../../icons/inbe.png
|
||||
# Run 'make' to regenerate from ../icons/inbe.png
|
||||
|
||||
SOURCE_PNG := ../../icons/lotus.png
|
||||
SOURCE_PNG := ../icons/lotus.png
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 983 B |
|
Before Width: | Height: | Size: 636 B After Width: | Height: | Size: 636 B |
|
Before Width: | Height: | Size: 839 B After Width: | Height: | Size: 839 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -4,7 +4,7 @@
|
||||
#include "theme_meta.h"
|
||||
#include "version.h"
|
||||
#include "ui.h"
|
||||
#include "../../vendor/rini/src/rini.h"
|
||||
#include "../vendor/rini/src/rini.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
@@ -561,7 +561,7 @@ load_icon_texture(const char *name)
|
||||
if(FileExists(path))
|
||||
return load_pixel_texture(path);
|
||||
|
||||
snprintf(path, sizeof(path), "../icons/%s", name);
|
||||
snprintf(path, sizeof(path), "icons/%s", name);
|
||||
return load_pixel_texture(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
#include "theme.h"
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static LotusThemeScope scopes[LOTUS_THEME_MAX_SCOPES];
|
||||
static int scope_count = 0;
|
||||
|
||||
static void copy_text(char *dst, int size, const char *src)
|
||||
{
|
||||
snprintf(dst, (size_t)size, "%s", src ? src : "");
|
||||
}
|
||||
|
||||
static int hex_value(char c)
|
||||
{
|
||||
if(c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if(c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if(c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned char hex_byte(const char *text)
|
||||
{
|
||||
int hi = hex_value(text[0]);
|
||||
int lo = hex_value(text[1]);
|
||||
if(hi < 0 || lo < 0)
|
||||
return 0;
|
||||
return (unsigned char)(hi * 16 + lo);
|
||||
}
|
||||
|
||||
bool theme_parse_color(const char *text, Color *color)
|
||||
{
|
||||
int len;
|
||||
|
||||
if(text == NULL || color == NULL)
|
||||
return false;
|
||||
if(text[0] == '#')
|
||||
text++;
|
||||
|
||||
len = (int)strlen(text);
|
||||
if(len != 6 && len != 8)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < len; i++) {
|
||||
if(hex_value(text[i]) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
color->r = hex_byte(text);
|
||||
color->g = hex_byte(text + 2);
|
||||
color->b = hex_byte(text + 4);
|
||||
color->a = (len == 8) ? hex_byte(text + 6) : 255;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *theme_color_text(Color color, char *buffer, int size)
|
||||
{
|
||||
if(buffer == NULL || size <= 0)
|
||||
return "";
|
||||
|
||||
snprintf(buffer, (size_t)size, "#%02X%02X%02X%02X", color.r, color.g, color.b, color.a);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void theme_reset(void)
|
||||
{
|
||||
memset(scopes, 0, sizeof(scopes));
|
||||
scope_count = 0;
|
||||
}
|
||||
|
||||
LotusThemeScope *theme_scope(const char *name)
|
||||
{
|
||||
if(name == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i = 0; i < scope_count; i++) {
|
||||
if(strcmp(scopes[i].name, name) == 0)
|
||||
return &scopes[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const LotusThemeScope *theme_scope_at(int index)
|
||||
{
|
||||
if(index < 0 || index >= scope_count)
|
||||
return NULL;
|
||||
return &scopes[index];
|
||||
}
|
||||
|
||||
int theme_scope_count(void)
|
||||
{
|
||||
return scope_count;
|
||||
}
|
||||
|
||||
static LotusThemeValue *scope_value(LotusThemeScope *scope, const char *key)
|
||||
{
|
||||
if(scope == NULL || key == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i = 0; i < scope->count; i++) {
|
||||
if(strcmp(scope->values[i].key, key) == 0)
|
||||
return &scope->values[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static LotusThemeValue *scope_add_value(LotusThemeScope *scope, const char *key, Color color)
|
||||
{
|
||||
LotusThemeValue *value;
|
||||
|
||||
if(scope == NULL || key == NULL || key[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
value = scope_value(scope, key);
|
||||
if(value != NULL) {
|
||||
value->value = color;
|
||||
return value;
|
||||
}
|
||||
|
||||
if(scope->count >= LOTUS_THEME_MAX_VALUES)
|
||||
return NULL;
|
||||
|
||||
value = &scope->values[scope->count++];
|
||||
memset(value, 0, sizeof(*value));
|
||||
copy_text(value->key, LOTUS_THEME_NAME_SIZE, key);
|
||||
value->value = color;
|
||||
return value;
|
||||
}
|
||||
|
||||
static void load_scope_file(LotusThemeScope *scope)
|
||||
{
|
||||
FILE *file;
|
||||
char line[256];
|
||||
|
||||
if(scope == NULL || scope->path[0] == '\0')
|
||||
return;
|
||||
|
||||
file = fopen(scope->path, "r");
|
||||
if(file == NULL)
|
||||
return;
|
||||
|
||||
while(fgets(line, sizeof(line), file) != NULL) {
|
||||
char key[LOTUS_THEME_NAME_SIZE];
|
||||
char value[32];
|
||||
char *cursor = line;
|
||||
int key_len = 0;
|
||||
Color color;
|
||||
|
||||
while(isspace((unsigned char)*cursor))
|
||||
cursor++;
|
||||
if(*cursor == '#' || *cursor == '\0')
|
||||
continue;
|
||||
|
||||
while(*cursor != '\0' && !isspace((unsigned char)*cursor) &&
|
||||
key_len < LOTUS_THEME_NAME_SIZE - 1) {
|
||||
key[key_len++] = *cursor++;
|
||||
}
|
||||
key[key_len] = '\0';
|
||||
|
||||
while(isspace((unsigned char)*cursor))
|
||||
cursor++;
|
||||
if(*cursor == '"')
|
||||
cursor++;
|
||||
|
||||
int value_len = 0;
|
||||
while(*cursor != '\0' && *cursor != '"' && *cursor != '\n' &&
|
||||
!isspace((unsigned char)*cursor) && value_len < (int)sizeof(value) - 1) {
|
||||
value[value_len++] = *cursor++;
|
||||
}
|
||||
value[value_len] = '\0';
|
||||
|
||||
if(theme_parse_color(value, &color))
|
||||
scope_add_value(scope, key, color);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
LotusThemeScope *theme_register_scope(const char *name, const char *path)
|
||||
{
|
||||
LotusThemeScope *scope = theme_scope(name);
|
||||
if(scope == NULL) {
|
||||
if(scope_count >= LOTUS_THEME_MAX_SCOPES)
|
||||
return NULL;
|
||||
scope = &scopes[scope_count++];
|
||||
}
|
||||
|
||||
memset(scope, 0, sizeof(*scope));
|
||||
copy_text(scope->name, LOTUS_THEME_NAME_SIZE, name);
|
||||
copy_text(scope->path, LOTUS_THEME_PATH_SIZE, path);
|
||||
load_scope_file(scope);
|
||||
return scope;
|
||||
}
|
||||
|
||||
Color theme_get(const char *scope_name, const char *key)
|
||||
{
|
||||
LotusThemeValue *value = scope_value(theme_scope(scope_name), key);
|
||||
if(value != NULL)
|
||||
return value->value;
|
||||
|
||||
fprintf(stderr, "missing theme color: %s.%s\n",
|
||||
scope_name != NULL ? scope_name : "(null)",
|
||||
key != NULL ? key : "(null)");
|
||||
abort();
|
||||
}
|
||||
|
||||
bool theme_set_color(const char *scope_name, const char *key, Color color)
|
||||
{
|
||||
LotusThemeValue *value = scope_value(theme_scope(scope_name), key);
|
||||
if(value == NULL)
|
||||
return false;
|
||||
value->value = color;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theme_save_scope(const char *scope_name)
|
||||
{
|
||||
LotusThemeScope *scope = theme_scope(scope_name);
|
||||
FILE *file;
|
||||
char text[16];
|
||||
const char *dir;
|
||||
|
||||
if(scope == NULL || scope->path[0] == '\0')
|
||||
return false;
|
||||
|
||||
dir = GetDirectoryPath(scope->path);
|
||||
if(dir != NULL && dir[0] != '\0' && !DirectoryExists(dir))
|
||||
MakeDirectory(dir);
|
||||
|
||||
file = fopen(scope->path, "w");
|
||||
if(file == NULL)
|
||||
return false;
|
||||
|
||||
fprintf(file, "# Lotus theme: %s\n", scope->name);
|
||||
for(int i = 0; i < scope->count; i++)
|
||||
fprintf(file, "%s \"%s\"\n", scope->values[i].key,
|
||||
theme_color_text(scope->values[i].value, text, sizeof(text)));
|
||||
|
||||
fclose(file);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theme_save_all(void)
|
||||
{
|
||||
bool ok = true;
|
||||
for(int i = 0; i < scope_count; i++) {
|
||||
if(scopes[i].path[0] != '\0' && !theme_save_scope(scopes[i].name))
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void theme_draw_tk_border(Rectangle rec, int borderWidth, bool raised)
|
||||
{
|
||||
Color highlight = theme_get("lotus", "border_light");
|
||||
Color shadow = theme_get("lotus", "border_shadow");
|
||||
Color topLeft = raised ? highlight : shadow;
|
||||
Color bottomRight = raised ? shadow : highlight;
|
||||
|
||||
int x = (int)rec.x;
|
||||
int y = (int)rec.y;
|
||||
int w = (int)rec.width;
|
||||
int h = (int)rec.height;
|
||||
|
||||
DrawRectangle(x, y, w, borderWidth, topLeft);
|
||||
DrawRectangle(x, y, borderWidth, h, topLeft);
|
||||
DrawRectangle(x, y + h - borderWidth, w, borderWidth, bottomRight);
|
||||
DrawRectangle(x + w - borderWidth, y, borderWidth, h, bottomRight);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef THEME_H
|
||||
#define THEME_H
|
||||
|
||||
#include "raylib.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define LOTUS_THEME_MAX_SCOPES 16
|
||||
#define LOTUS_THEME_MAX_VALUES 48
|
||||
#define LOTUS_THEME_NAME_SIZE 64
|
||||
#define LOTUS_THEME_PATH_SIZE 256
|
||||
|
||||
typedef struct LotusThemeValue {
|
||||
char key[LOTUS_THEME_NAME_SIZE];
|
||||
Color value;
|
||||
} LotusThemeValue;
|
||||
|
||||
typedef struct LotusThemeScope {
|
||||
char name[LOTUS_THEME_NAME_SIZE];
|
||||
char path[LOTUS_THEME_PATH_SIZE];
|
||||
LotusThemeValue values[LOTUS_THEME_MAX_VALUES];
|
||||
int count;
|
||||
} LotusThemeScope;
|
||||
|
||||
void theme_reset(void);
|
||||
LotusThemeScope *theme_register_scope(const char *name, const char *path);
|
||||
LotusThemeScope *theme_scope(const char *name);
|
||||
const LotusThemeScope *theme_scope_at(int index);
|
||||
int theme_scope_count(void);
|
||||
Color theme_get(const char *scope, const char *key);
|
||||
bool theme_set_color(const char *scope, const char *key, Color color);
|
||||
bool theme_save_scope(const char *scope);
|
||||
bool theme_save_all(void);
|
||||
const char *theme_color_text(Color color, char *buffer, int size);
|
||||
bool theme_parse_color(const char *text, Color *color);
|
||||
void theme_draw_tk_border(Rectangle rec, int borderWidth, bool raised);
|
||||
|
||||
#endif
|
||||