34 Commits

Author SHA1 Message Date
0221f06d5c updated color table 2026-02-02 23:36:20 +03:00
b5f3507b6e added more editor color keys 2026-02-02 23:14:32 +03:00
3277873d0c fixed windows popen, pclose 2026-01-31 06:12:43 +03:00
0db962db76 bump ver 2026-01-31 05:05:37 +03:00
2d015c6fb7 chore: refactor 2026-01-31 05:04:50 +03:00
4697f69dac added hellwal and matugen generators (WIP) 2026-01-29 00:55:01 +03:00
3e798f1fb8 updated scrot 2026-01-14 15:33:50 +03:00
6fc80daaa1 moved palletes and templates into categories in extra 2026-01-14 12:22:25 +03:00
4293421166 fixed qt instructions 2026-01-14 11:54:06 +03:00
78daab7176 restructured extra directory 2026-01-14 11:50:43 +03:00
56a499502f fix: turn off vsync while not focused 2026-01-13 00:28:28 +03:00
2b1c6d59c4 fix: brief freezes after file dialogs / fontconfig methods are used 2026-01-12 23:52:33 +03:00
d852d58948 tested and fixed new templates 2026-01-12 20:31:02 +03:00
41939f4df4 fixed hyprland and kvantum configs 2026-01-12 19:18:25 +03:00
a813b7f6c9 bump version 2026-01-12 14:45:10 +03:00
9803f4948b fix: run reload command detached 2026-01-12 14:39:00 +03:00
c17960d1e6 untested: added gtk, hyprland, qtct and kvantum templates 2026-01-12 14:30:40 +03:00
19291f35ee added telegram template 2026-01-12 14:00:47 +03:00
4d61ed3194 added firefox template 2026-01-12 13:13:08 +03:00
d722499e80 fixed borders in vscode template 2026-01-12 11:04:23 +03:00
e3cd9cd362 added vscode template 2026-01-12 10:50:51 +03:00
e256dcad2e added some palettes and templates 2026-01-03 03:55:36 +03:00
5b0599a958 changed default kitty config location 2025-12-21 23:39:31 +03:00
afa7275e37 Update README.md 2025-12-20 00:23:34 +03:00
fc5663839e Update README.md 2025-12-20 00:11:15 +03:00
997e7c3eae add pkgbuild 2025-12-19 23:36:21 +03:00
4229db457c merged dev 2025-12-19 23:32:17 +03:00
d17776b8e4 fix: minor ui fixes 2025-12-19 20:04:30 +03:00
8112096647 chore :refactored remaining views 2025-12-19 17:37:42 +03:00
4ada2c44ed chore: refactor 2025-12-19 17:22:23 +03:00
82998d688c build: write .clangd with proper compile_commands path on configure 2025-12-19 10:33:14 +03:00
6ac9c03ec4 fixed linux deps 2025-12-19 10:11:13 +03:00
2a433483d7 Merge branch 'master' into dev 2025-12-19 09:56:18 +03:00
ece7c84371 added cmake presets 2025-12-19 09:55:29 +03:00
121 changed files with 15753 additions and 1541 deletions

2
.gitignore vendored
View File

@@ -3,6 +3,8 @@
.vs
out
.clangd
build/
build-msvc/
CMakeCache.txt

29
.vscode/launch.json vendored
View File

@@ -1,7 +1,4 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
@@ -9,11 +6,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"--apply",
"--theme",
"dark"
],
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
@@ -32,21 +25,29 @@
}
]
},
{
{
"name": "Debug current target (LLDB)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"--apply",
"--theme",
"dark"
],
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"miDebuggerPath": "lldb"
},
{
"name": "Debug current target (MSVC)",
"type": "cppvsdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "integratedTerminal"
}
]
}

3
.vscode/settnigs.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"cmake.useCMakePresets": "always"
}

View File

@@ -1,6 +1,6 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync
pkgver=0.1.7
pkgver=1.1.0
pkgrel=1
pkgdesc="Color scheme manager"
arch=('x86_64')

View File

@@ -1,6 +1,6 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync-git
pkgver=r22.d8baae2
pkgver=r107.4229db4
pkgrel=1
pkgdesc="Color scheme manager (git version)"
arch=('x86_64')

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(clrsync VERSION 0.1.7 LANGUAGES CXX)
project(clrsync VERSION 1.1.0 LANGUAGES CXX)
include(GNUInstallDirs)
@@ -10,6 +10,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
file(WRITE "${CMAKE_SOURCE_DIR}/.clangd"
"CompileFlags:\n CompilationDatabase: ${CMAKE_BINARY_DIR}\n")
option(USE_SYSTEM_GLFW "Use system-installed GLFW instead of fetching it statically" OFF)
message(STATUS "USE_SYSTEM_GLFW: ${USE_SYSTEM_GLFW}")

325
CMakePresets.json Normal file
View File

@@ -0,0 +1,325 @@
{
"version": 6,
"configurePresets": [
{
"name": "base",
"hidden": true
},
{
"name": "debug",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux",
"hidden": true,
"inherits": "base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "windows",
"hidden": true,
"inherits": "base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "macos",
"hidden": true,
"inherits": "base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "gcc",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "clang",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "ninja",
"hidden": true,
"generator": "Ninja"
},
{
"name": "make",
"hidden": true,
"generator": "Unix Makefiles"
},
{
"name": "msvc-ninja",
"displayName": "MSVC (Ninja)",
"generator": "Ninja",
"hidden": true,
"binaryDir": "${sourceDir}/build/windows/msvc",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "msvc-vs2026",
"displayName": "MSVC (Visual Studio 18 2026)",
"generator": "Visual Studio 18 2026",
"binaryDir": "${sourceDir}/build/windows/msvc/vs2026",
"architecture": {
"value": "x64"
}
},
{
"name": "windows-msvc-ninja-debug",
"inherits": [
"windows",
"msvc-ninja",
"ninja",
"debug"
],
"displayName": "Windows · MSVC · Ninja · Debug",
"binaryDir": "${sourceDir}/build/windows/msvc/ninja/debug"
},
{
"name": "windows-msvc-ninja-release",
"inherits": [
"windows",
"msvc-ninja",
"ninja",
"release"
],
"displayName": "Windows · MSVC · Ninja · Release",
"binaryDir": "${sourceDir}/build/windows/msvc/ninja/release"
},
{
"name": "linux-gcc-ninja-debug",
"inherits": [
"linux",
"gcc",
"ninja",
"debug"
],
"displayName": "Linux · GCC · Ninja · Debug",
"binaryDir": "${sourceDir}/build/linux/gcc/ninja/debug"
},
{
"name": "linux-gcc-ninja-release",
"inherits": [
"linux",
"gcc",
"ninja",
"release"
],
"displayName": "Linux · GCC · Ninja · Release",
"binaryDir": "${sourceDir}/build/linux/gcc/ninja/release"
},
{
"name": "linux-gcc-make-debug",
"inherits": [
"linux",
"gcc",
"make",
"debug"
],
"displayName": "Linux · GCC · Make · Debug",
"binaryDir": "${sourceDir}/build/linux/gcc/make/debug"
},
{
"name": "linux-gcc-make-release",
"inherits": [
"linux",
"gcc",
"make",
"release"
],
"displayName": "Linux · GCC · Make · Release",
"binaryDir": "${sourceDir}/build/linux/gcc/make/release"
},
{
"name": "linux-clang-ninja-debug",
"inherits": [
"linux",
"clang",
"ninja",
"debug"
],
"displayName": "Linux · Clang · Ninja · Debug",
"binaryDir": "${sourceDir}/build/linux/clang/ninja/debug"
},
{
"name": "linux-clang-ninja-release",
"inherits": [
"linux",
"clang",
"ninja",
"release"
],
"displayName": "Linux · Clang · Ninja · Release",
"binaryDir": "${sourceDir}/build/linux/clang/ninja/release"
},
{
"name": "linux-clang-make-debug",
"inherits": [
"linux",
"clang",
"make",
"debug"
],
"displayName": "Linux · Clang · Make · Debug",
"binaryDir": "${sourceDir}/build/linux/clang/make/debug"
},
{
"name": "linux-clang-make-release",
"inherits": [
"linux",
"clang",
"make",
"release"
],
"displayName": "Linux · Clang · Make · Release",
"binaryDir": "${sourceDir}/build/linux/clang/make/release"
},
{
"name": "macos-appleclang-ninja-debug",
"inherits": [
"macos",
"clang",
"ninja",
"debug"
],
"displayName": "macOS · Apple Clang · Ninja · Debug",
"binaryDir": "${sourceDir}/build/macos/appleclang/ninja/debug"
},
{
"name": "macos-appleclang-ninja-release",
"inherits": [
"macos",
"clang",
"ninja",
"release"
],
"displayName": "macOS · Apple Clang · Ninja · Release",
"binaryDir": "${sourceDir}/build/macos/appleclang/ninja/release"
},
{
"name": "macos-appleclang-make-debug",
"inherits": [
"macos",
"clang",
"make",
"debug"
],
"displayName": "macOS · Apple Clang · Make · Debug",
"binaryDir": "${sourceDir}/build/macos/appleclang/make/debug"
},
{
"name": "macos-appleclang-make-release",
"inherits": [
"macos",
"clang",
"make",
"release"
],
"displayName": "macOS · Apple Clang · Make · Release",
"binaryDir": "${sourceDir}/build/macos/appleclang/make/release"
}
],
"buildPresets": [
{
"name": "vs-debug",
"configurePreset": "msvc-vs2026",
"configuration": "Debug"
},
{
"name": "vs-release",
"configurePreset": "msvc-vs2026",
"configuration": "Release"
},
{
"name": "msvc-ninja-debug",
"configurePreset": "windows-msvc-ninja-debug",
"configuration": "Debug"
},
{
"name": "msvc-ninja-release",
"configurePreset": "windows-msvc-ninja-release",
"configuration": "Release"
},
{
"name": "linux-gcc-ninja-debug",
"configurePreset": "linux-gcc-ninja-debug"
},
{
"name": "linux-gcc-ninja-release",
"configurePreset": "linux-gcc-ninja-release"
},
{
"name": "linux-gcc-make-debug",
"configurePreset": "linux-gcc-make-debug"
},
{
"name": "linux-gcc-make-release",
"configurePreset": "linux-gcc-make-release"
},
{
"name": "linux-clang-ninja-debug",
"configurePreset": "linux-clang-ninja-debug"
},
{
"name": "linux-clang-ninja-release",
"configurePreset": "linux-clang-ninja-release"
},
{
"name": "linux-clang-make-debug",
"configurePreset": "linux-clang-make-debug"
},
{
"name": "linux-clang-make-release",
"configurePreset": "linux-clang-make-release"
},
{
"name": "macos-appleclang-ninja-debug",
"configurePreset": "macos-appleclang-ninja-debug"
},
{
"name": "macos-appleclang-ninja-release",
"configurePreset": "macos-appleclang-ninja-release"
},
{
"name": "macos-appleclang-make-debug",
"configurePreset": "macos-appleclang-make-debug"
},
{
"name": "macos-appleclang-make-release",
"configurePreset": "macos-appleclang-make-release"
}
]
}

View File

@@ -3,8 +3,6 @@
# clrsync
**Notice:** This application is not yet released and is subject to change.
A theme management tool for synchronizing color schemes across multiple applications. clrsync allows to define color palettes once and apply them consistently to all configurable applications.
![Preview](assets/screenshot.png)
@@ -34,6 +32,7 @@ A theme management tool for synchronizing color schemes across multiple applicat
- [Usage](#usage)
- [CLI](#cli)
- [GUI](#gui)
- [Extras](#extras)
- [Acknowledgments](#acknowledgments)
## Features
@@ -47,6 +46,14 @@ A theme management tool for synchronizing color schemes across multiple applicat
### Linux
#### Arch Linux
Install the package from AUR using any helper or install manually
```shell
yay -S clrsync-git
```
#### Ubuntu
1. Download the latest .deb from the [releases page](https://github.com/obsqrbtz/clrsync/releases)
@@ -457,12 +464,16 @@ The GUI provides:
- **Template Editor**: Edit template files
- **Live Preview**: See changes in real-time
## Extras
You may find some pre-configured color schemes and templates in [extra](extra) directory of this repository.
## Acknowledgments
- **[matugen](https://github.com/InioX/matugen)** - A material you color generation tool
- **[hellwal](https://github.com/danihek/hellwal)** - Pywal-like color palette generator, but faster and in C
- **[Dear ImGui](https://github.com/ocornut/imgui)** - Bloat-free graphical user interface library for C++
- **[GLFW](https://www.glfw.org/)** - Multi-platform library for OpenGL, OpenGL ES and Vulkan development
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme

View File

@@ -1 +1 @@
0.1.7
1.1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 856 KiB

View File

@@ -7,13 +7,7 @@ if(WIN32)
freetype
URL https://download.savannah.gnu.org/releases/freetype/freetype-2.14.1.tar.gz
)
set(FT_DISABLE_ZLIB FALSE CACHE BOOL "" FORCE)
set(FT_DISABLE_BZIP2 TRUE CACHE BOOL "" FORCE)
set(FT_DISABLE_PNG TRUE CACHE BOOL "" FORCE)
set(FT_DISABLE_HARFBUZZ FALSE CACHE BOOL "" FORCE)
set(FT_DISABLE_BROTLI TRUE CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(freetype)
elseif(APPLE)
option(USE_SYSTEM_GLFW ON)
@@ -33,6 +27,8 @@ else()
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
find_package(PNG REQUIRED)
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
pkg_check_modules(HARFBUZZ harfbuzz)
pkg_check_modules(WAYLAND_CLIENT wayland-client)
pkg_check_modules(WAYLAND_EGL wayland-egl)
@@ -76,6 +72,10 @@ else()
endif()
set(FREETYPE_EXTRA_LIBS "")
if(BROTLIDEC_LIBRARY AND BROTLICOMMON_LIBRARY)
list(APPEND FREETYPE_EXTRA_LIBS ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
message(STATUS "Found Brotli libraries")
endif()
if(HARFBUZZ_FOUND)
list(APPEND FREETYPE_EXTRA_LIBS ${HARFBUZZ_LIBRARIES})
message(STATUS "Found HarfBuzz")

View File

@@ -12,11 +12,11 @@ output_path = '~/.config/clrsync/formats-demo'
[templates.kitty]
enabled = true
input_path = '~/.config/clrsync/templates/kitty.conf'
output_path = '~/.config/kitty/kitty_test.conf'
output_path = '~/.config/kitty/clrsync.conf'
reload_cmd = 'pkill -SIGUSR1 kitty'
[templates.nvim]
enabled = true
input_path = '~/.config/clrsync/templates/nvim.lua'
output_path = '~/.config/nvim/colors/clrsync.lua'
reload_cmd = ''
reload_cmd = ''

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#9A8652FF'
accent_secondary = '#9A8652FF'
background = '#111111FF'
base00 = '#111111FF'
base01 = '#668A51FF'
@@ -20,21 +21,72 @@ base0F = '#D2D2D2FF'
border = '#242424FF'
border_focused = '#2E2E2EFF'
cursor = '#D2D2D2FF'
# Editor - Basic
editor_background = '#111111FF'
editor_command = '#3A898CFF'
editor_comment = '#849899FF'
editor_disabled = '#849899FF'
editor_emphasis = '#A9DC86FF'
editor_error = '#AA4E4AFF'
editor_inactive = '#849899FF'
editor_line_number = '#849899FF'
editor_link = '#B0779EFF'
editor_main = '#D2D2D2FF'
editor_selected = '#242424FF'
editor_foreground = '#D2D2D2FF'
editor_line_highlight = '#191919FF'
editor_selection = '#242424FF'
editor_selection_inactive = '#1D1C1CFF'
editor_cursor = '#D2D2D2FF'
editor_whitespace = '#3A3A3AFF'
# Editor - Gutter
editor_gutter_background = '#111111FF'
editor_gutter_foreground = '#849899FF'
editor_line_number = '#849899FF'
editor_line_number_active = '#D2D2D2FF'
# Editor - Syntax
editor_comment = '#849899FF'
editor_string = '#9A8652FF'
editor_success = '#668A51FF'
editor_number = '#B47837FF'
editor_boolean = '#B47837FF'
editor_keyword = '#3A898CFF'
editor_operator = '#D2D2D2FF'
editor_function = '#A9DC86FF'
editor_variable = '#D2D2D2FF'
editor_parameter = '#B0779EFF'
editor_property = '#9A8652FF'
editor_constant = '#B47837FF'
editor_type = '#3A898CFF'
editor_class = '#3A898CFF'
editor_interface = '#3A898CFF'
editor_enum = '#3A898CFF'
editor_namespace = '#B0779EFF'
editor_attribute = '#A9DC86FF'
editor_decorator = '#A9DC86FF'
editor_tag = '#AA4E4AFF'
editor_punctuation = '#D2D2D2FF'
editor_link = '#B0779EFF'
editor_regex = '#AA477BFF'
editor_escape_character = '#B47837FF'
# Editor - Diagnostics
editor_invalid = '#AA4E4AFF'
editor_error = '#AA4E4AFF'
editor_error_background = '#3A1A1AFF'
editor_warning = '#B47837FF'
editor_warning_background = '#3A2A1AFF'
editor_info = '#3A898CFF'
editor_info_background = '#1A2A3AFF'
editor_hint = '#668A51FF'
editor_hint_background = '#1A2A1AFF'
# Editor - UI Elements
editor_active_line_border = '#2E2E2EFF'
editor_indent_guide = '#2A2A2AFF'
editor_indent_guide_active = '#3A3A3AFF'
editor_bracket_match = '#3A898CFF'
editor_search_match = '#9A865280'
editor_search_match_active = '#9A8652FF'
editor_find_range_highlight = '#9A865240'
# Editor - Diff
editor_deleted = '#AA4E4AFF'
editor_inserted = '#668A51FF'
editor_modified = '#9A8652FF'
editor_ignored = '#849899FF'
editor_folded_background = '#191919FF'
error = '#AA4E4AFF'
foreground = '#D2D2D2FF'
info = '#3A898CFF'

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#9A8652FF'
accent_secondary = '#9A8652FF'
background = '#E0E0E0FF'
base00 = '#E0E0E0FF'
base01 = '#668A51FF'
@@ -20,21 +21,72 @@ base0F = '#2A2A2AFF'
border = '#C5C5C5FF'
border_focused = '#B9B9B9FF'
cursor = '#2A2A2AFF'
# Editor - Basic
editor_background = '#E0E0E0FF'
editor_command = '#3A898CFF'
editor_comment = '#849899FF'
editor_disabled = '#A0A0A0FF'
editor_emphasis = '#4A7A2EFF'
editor_error = '#AA4E4AFF'
editor_inactive = '#A0A0A0FF'
editor_line_number = '#9A9A95FF'
editor_link = '#90577EFF'
editor_main = '#2A2A2AFF'
editor_selected = '#C9C9C9FF'
editor_foreground = '#2A2A2AFF'
editor_line_highlight = '#D5D5D5FF'
editor_selection = '#C9C9C9FF'
editor_selection_inactive = '#D2D2D2FF'
editor_cursor = '#2A2A2AFF'
editor_whitespace = '#B0B0B0FF'
# Editor - Gutter
editor_gutter_background = '#E0E0E0FF'
editor_gutter_foreground = '#9A9A95FF'
editor_line_number = '#9A9A95FF'
editor_line_number_active = '#2A2A2AFF'
# Editor - Syntax
editor_comment = '#849899FF'
editor_string = '#9A8652FF'
editor_success = '#668A51FF'
editor_number = '#B47837FF'
editor_boolean = '#B47837FF'
editor_keyword = '#3A898CFF'
editor_operator = '#2A2A2AFF'
editor_function = '#4A7A2EFF'
editor_variable = '#2A2A2AFF'
editor_parameter = '#90577EFF'
editor_property = '#9A8652FF'
editor_constant = '#B47837FF'
editor_type = '#3A898CFF'
editor_class = '#3A898CFF'
editor_interface = '#3A898CFF'
editor_enum = '#3A898CFF'
editor_namespace = '#90577EFF'
editor_attribute = '#4A7A2EFF'
editor_decorator = '#4A7A2EFF'
editor_tag = '#AA4E4AFF'
editor_punctuation = '#2A2A2AFF'
editor_link = '#90577EFF'
editor_regex = '#AA477BFF'
editor_escape_character = '#B47837FF'
# Editor - Diagnostics
editor_invalid = '#AA4E4AFF'
editor_error = '#AA4E4AFF'
editor_error_background = '#FFDDDDFF'
editor_warning = '#B47837FF'
editor_warning_background = '#FFF0D0FF'
editor_info = '#3A898CFF'
editor_info_background = '#D0F0FFFF'
editor_hint = '#668A51FF'
editor_hint_background = '#D0FFD0FF'
# Editor - UI Elements
editor_active_line_border = '#C5C5C5FF'
editor_indent_guide = '#CFCFCFFF'
editor_indent_guide_active = '#B0B0B0FF'
editor_bracket_match = '#3A898CFF'
editor_search_match = '#9A865280'
editor_search_match_active = '#9A8652FF'
editor_find_range_highlight = '#9A865240'
# Editor - Diff
editor_deleted = '#AA4E4AFF'
editor_inserted = '#668A51FF'
editor_modified = '#9A8652FF'
editor_ignored = '#A0A0A0FF'
editor_folded_background = '#D5D5D5FF'
error = '#AA4E4AFF'
foreground = '#2A2A2AFF'
info = '#3A898CFF'

View File

@@ -5,7 +5,7 @@ foreground {foreground}
background {background}
selection_foreground {on_surface}
selection_background {surface}
url_color {accent}
url_color {accent_secondary}
color0 {base00}
color8 {base08}

View File

@@ -3,91 +3,370 @@ vim.cmd("syntax reset")
vim.g.colors_name = "clrsync"
local palette = {
-- Editor colors
Default = "{editor_main.hex}",
Keyword = "{editor_command.hex}",
Number = "{editor_warning.hex}",
String = "{editor_string.hex}",
CharLiteral = "{editor_string.hex}",
Punctuation = "{editor_main.hex}",
Preprocessor = "{editor_emphasis.hex}",
Identifier = "{editor_main.hex}",
KnownIdentifier = "{editor_link.hex}",
PreprocIdentifier = "{editor_link.hex}",
-- General UI
bg = "{editor_background.hex}",
bg_alt = "{surface_variant.hex}",
fg = "{editor_foreground.hex}",
fg_alt = "{on_surface_variant.hex}",
grey = "{editor_line_number.hex}",
Comment = "{editor_comment.hex}",
MultiLineComment = "{editor_comment.hex}",
-- Accent / keyword colors
blue = "{editor_keyword.hex}",
cyan = "{editor_info.hex}",
violet = "{editor_link.hex}",
magenta = "{editor_parameter.hex}",
orange = "{editor_number.hex}",
yellow = "{editor_warning.hex}",
green = "{success.hex}",
red = "{error.hex}",
Background = "{editor_background.hex}",
Cursor = "{cursor.hex}",
-- Editor - Basic
cursor = "{cursor.hex}",
selection = "{editor_selection.hex}",
dark_blue = "{editor_selection.hex}",
line_highlight = "{editor_line_highlight.hex}",
Selection = "{editor_selected.hex}",
ErrorMarker = "{editor_error.hex}",
Breakpoint = "{editor_error.hex}",
-- Editor - Gutter
line_number = "{editor_line_number.hex}",
line_number_active = "{editor_line_number_active.hex}",
LineNumber = "{editor_line_number.hex}",
CurrentLineFill = "{surface_variant.hex}",
CurrentLineFillInactive = "{surface.hex}",
-- Editor - Syntax
comment = "{editor_comment.hex}",
string = "{editor_string.hex}",
number = "{editor_number.hex}",
boolean = "{editor_boolean.hex}",
keyword = "{editor_keyword.hex}",
operator = "{editor_operator.hex}",
function_ = "{editor_function.hex}",
variable = "{editor_variable.hex}",
parameter = "{editor_parameter.hex}",
property = "{editor_property.hex}",
constant = "{editor_constant.hex}",
type_ = "{editor_type.hex}",
tag = "{editor_tag.hex}",
punctuation = "{editor_punctuation.hex}",
link = "{editor_link.hex}",
regex = "{editor_regex.hex}",
attribute = "{editor_attribute.hex}",
decorator = "{editor_decorator.hex}",
escape_char = "{editor_escape_character.hex}",
CurrentLineEdge = "{border_focused.hex}",
-- Semantic colors
Success = "{success.hex}",
Warning = "{warning.hex}",
Error = "{error.hex}",
Info = "{info.hex}",
-- Editor - UI
border = "{border_focused.hex}",
indent_guide = "{editor_indent_guide.hex}",
search_match = "{editor_search_match.hex}",
search_match_active = "{editor_search_match_active.hex}",
bracket_match = "{editor_bracket_match.hex}",
whitespace = "{editor_whitespace.hex}",
-- Editor - Diagnostics
error_fg = "{editor_error.hex}",
warning_fg = "{editor_warning.hex}",
info_fg = "{editor_info.hex}",
hint_fg = "{editor_hint.hex}",
-- Editor - Diff
diff_add = "{editor_inserted.hex}",
diff_change = "{editor_modified.hex}",
diff_delete = "{editor_deleted.hex}",
-- Semantic
success = "{success.hex}",
warning = "{warning.hex}",
error = "{error.hex}",
info = "{info.hex}",
-- Base (terminal / muted)
base0 = "{background.hex}",
base1 = "{surface.hex}",
base2 = "{surface_variant.hex}",
base3 = "{border.hex}",
base4 = "{editor_line_number.hex}",
base5 = "{editor_comment.hex}",
base6 = "{editor_line_number.hex}",
base7 = "{on_surface_variant.hex}",
base8 = "{foreground.hex}",
}
-- Helper function to set highlights in Neovim
local function set_hl(group, opts)
vim.api.nvim_set_hl(0, group, opts)
end
vim.o.winborder = "rounded"
-- Basic editor highlights using the mapped palette
set_hl("Normal", { fg = palette.Default, bg = palette.Background })
set_hl("CursorLine", { bg = palette.CurrentLineFill })
set_hl("Visual", { bg = palette.Selection })
set_hl("LineNr", { fg = palette.LineNumber })
set_hl("CursorLineNr", { fg = palette.Keyword })
--- General UI
set_hl("Normal", { bg = palette.bg, fg = palette.fg })
set_hl("NormalFloat", { bg = palette.bg, fg = palette.fg })
set_hl("NormalBorder", { bg = palette.bg, fg = palette.fg })
set_hl("EndOfBuffer", { bg = palette.bg, fg = palette.bg })
-- Syntax highlights
set_hl("Comment", { fg = palette.Comment, italic = true })
set_hl("Constant", { fg = palette.Number })
set_hl("String", { fg = palette.String })
set_hl("Character", { fg = palette.CharLiteral })
set_hl("Identifier", { fg = palette.Identifier })
set_hl("Function", { fg = palette.Keyword })
set_hl("Statement", { fg = palette.Keyword })
set_hl("PreProc", { fg = palette.Preprocessor })
set_hl("Type", { fg = palette.Keyword })
set_hl("Special", { fg = palette.PreprocIdentifier })
set_hl("Underlined", { fg = palette.KnownIdentifier })
set_hl("Error", { fg = palette.ErrorMarker, bg = palette.Background })
set_hl("Todo", { fg = palette.Default, bg = palette.Keyword })
set_hl("Visual", { bg = palette.dark_blue })
set_hl("VisualBold", { bg = palette.dark_blue, bold = true })
-- Floating windows
set_hl("NormalFloat", { bg = palette.Background })
set_hl("FloatBorder", { fg = palette.CurrentLineEdge, bg = palette.Background })
set_hl("LineNr", { bg = palette.bg, fg = palette.grey })
set_hl("Cursor", { bg = palette.blue })
set_hl("CursorLine", { bg = palette.bg_alt })
set_hl("CursorLineNr", { bg = palette.bg_alt, fg = palette.fg })
set_hl("CursorColumn", { bg = palette.bg_alt })
-- Completion menu
set_hl("Pmenu", { bg = palette.Background })
set_hl("PmenuSel", { bg = palette.Keyword, fg = palette.Background })
set_hl("Folded", { bg = palette.bg_alt, fg = palette.base5 })
set_hl("FoldColumn", { bg = palette.bg, fg = palette.fg_alt })
set_hl("SignColumn", { bg = palette.bg })
set_hl("ColorColumn", { bg = palette.bg_alt })
-- Git and diagnostic highlights
set_hl("DiffAdd", { fg = palette.Success, bg = palette.Background })
set_hl("DiffChange", { fg = palette.Keyword, bg = palette.Background })
set_hl("DiffDelete", { fg = palette.ErrorMarker, bg = palette.Background })
set_hl("DiagnosticError", { fg = palette.Error })
set_hl("DiagnosticWarn", { fg = palette.Warning })
set_hl("DiagnosticInfo", { fg = palette.Info })
set_hl("DiagnosticHint", { fg = palette.PreprocIdentifier })
set_hl("IndentGuide", { fg = palette.indent_guide })
set_hl("IndentGuideEven", { link = "IndentGuide" })
set_hl("IndentGuideOdd", { link = "IndentGuide" })
-- Treesitter links
set_hl("TermCursor", { fg = palette.fg, reverse = true })
set_hl("TermCursorNC", { fg = palette.fg_alt, reverse = true })
set_hl("TermNormal", { link = "Normal" })
set_hl("TermNormalNC", { link = "TermNormal" })
set_hl("WildMenu", { bg = palette.dark_blue, fg = palette.fg })
set_hl("Separator", { fg = palette.fg_alt })
set_hl("VertSplit", { bg = palette.bg, fg = palette.grey })
set_hl("TabLine", { bg = palette.bg_alt, fg = palette.base7, bold = true })
set_hl("TabLineSel", { bg = palette.bg, fg = palette.blue, bold = true })
set_hl("TabLineFill", { bg = palette.base1, bold = true })
set_hl("StatusLine", { bg = palette.base3, fg = palette.base8 })
set_hl("StatusLineNC", { bg = palette.bg_alt, fg = palette.base6 })
set_hl("StatusLinePart", { bg = palette.bg_alt, fg = palette.base6, bold = true })
set_hl("StatusLinePartNC", { link = "StatusLinePart" })
set_hl("Pmenu", { bg = palette.bg_alt, fg = palette.fg })
set_hl("PmenuSel", { bg = palette.blue, fg = palette.base0 })
set_hl("PmenuSelBold", { bg = palette.blue, fg = palette.base0, bold = true })
set_hl("PmenuSbar", { bg = palette.bg_alt })
set_hl("PmenuThumb", { bg = palette.grey })
set_hl("FloatBorder", { fg = palette.border, bg = palette.bg })
--- Search, Highlight, Conceal
set_hl("Search", { bg = palette.dark_blue, fg = palette.fg })
set_hl("Substitute", { fg = palette.red, bold = true, strikethrough = true })
set_hl("IncSearch", { bg = palette.yellow, fg = palette.bg, bold = true })
set_hl("IncSearchCursor", { reverse = true })
set_hl("Conceal", { fg = palette.grey })
set_hl("SpecialKey", { fg = palette.violet, bold = true })
set_hl("NonText", { fg = palette.fg_alt, bold = true })
set_hl("MatchParen", { fg = palette.red, bold = true })
set_hl("Whitespace", { fg = palette.whitespace })
set_hl("Highlight", { bg = palette.bg_alt })
set_hl("HighlightSubtle", { link = "Highlight" })
set_hl("Question", { fg = palette.green, bold = true })
set_hl("File", { fg = palette.fg })
set_hl("Directory", { fg = palette.violet, bold = true })
set_hl("Title", { fg = palette.violet, bold = true })
set_hl("Bold", { bold = true })
set_hl("Emphasis", { italic = true })
--- Messages
set_hl("Msg", { fg = palette.green })
set_hl("MoreMsg", { fg = palette.blue })
set_hl("WarningMsg", { fg = palette.yellow })
set_hl("Error", { fg = palette.red })
set_hl("ErrorMsg", { fg = palette.red })
set_hl("ModeMsg", { fg = palette.violet })
set_hl("Todo", { fg = palette.yellow, bold = true })
set_hl("healthError", { link = "ErrorMsg" })
set_hl("healthSuccess", { link = "Msg" })
set_hl("healthWarning", { link = "WarningMsg" })
--- Syntax
set_hl("Tag", { fg = palette.cyan, bold = true })
set_hl("Link", { fg = palette.green, underline = true })
set_hl("URL", { link = "Link" })
set_hl("Underlined", { fg = palette.cyan, underline = true })
set_hl("Comment", { fg = palette.comment, italic = true })
set_hl("CommentBold", { fg = palette.comment, bold = true })
set_hl("SpecialComment", { fg = palette.base7, bold = true })
set_hl("Macro", { fg = palette.violet })
set_hl("Define", { fg = palette.violet, bold = true })
set_hl("Include", { fg = palette.violet, bold = true })
set_hl("PreProc", { fg = palette.violet, bold = true })
set_hl("PreCondit", { fg = palette.violet, bold = true })
set_hl("Label", { fg = palette.blue })
set_hl("Repeat", { fg = palette.blue })
set_hl("Keyword", { fg = palette.blue })
set_hl("Operator", { fg = palette.operator })
set_hl("Delimiter", { fg = palette.blue })
set_hl("Statement", { fg = palette.blue })
set_hl("Exception", { fg = palette.blue })
set_hl("Conditional", { fg = palette.blue })
set_hl("Variable", { fg = palette.variable })
set_hl("VariableBuiltin", { fg = palette.magenta, bold = true })
set_hl("Constant", { fg = palette.violet, bold = true })
set_hl("Number", { fg = palette.orange })
set_hl("Float", { link = "Number" })
set_hl("Boolean", { fg = palette.orange, bold = true })
set_hl("Enum", { fg = palette.orange })
set_hl("Character", { fg = palette.violet, bold = true })
set_hl("SpecialChar", { fg = palette.violet, bold = true })
set_hl("String", { fg = palette.green })
set_hl("StringDelimiter", { link = "String" })
set_hl("Special", { fg = palette.violet })
set_hl("SpecialBold", { fg = palette.violet, bold = true })
set_hl("Field", { fg = palette.violet })
set_hl("Argument", { fg = palette.parameter })
set_hl("Attribute", { fg = palette.attribute })
set_hl("Identifier", { fg = palette.variable })
set_hl("Property", { fg = palette.property })
set_hl("Function", { fg = palette.function_ })
set_hl("FunctionBuiltin", { fg = palette.function_, bold = true })
set_hl("KeywordFunction", { fg = palette.blue, bold = true })
set_hl("Method", { fg = palette.function_ })
set_hl("Type", { fg = palette.type_ })
set_hl("Typedef", { fg = palette.blue })
set_hl("TypeBuiltin", { fg = palette.type_, bold = true })
set_hl("Class", { fg = palette.blue })
set_hl("StorageClass", { fg = palette.blue })
set_hl("Structure", { fg = palette.blue })
set_hl("Regexp", { fg = palette.regex })
set_hl("RegexpSpecial", { fg = palette.regex })
set_hl("RegexpDelimiter", { fg = palette.regex, bold = true })
set_hl("RegexpKey", { fg = palette.regex, bold = true })
set_hl("CommentURL", { link = "URL" })
set_hl("CommentLabel", { link = "CommentBold" })
set_hl("CommentSection", { link = "CommentBold" })
set_hl("Noise", { link = "Comment" })
--- Diff
set_hl("DiffAddedGutter", { fg = palette.green, bold = true })
set_hl("DiffModifiedGutter", { fg = palette.orange, bold = true })
set_hl("DiffRemovedGutter", { fg = palette.red, bold = true })
set_hl("DiffAdd", { link = "DiffAddedGutter" })
set_hl("DiffChange", { link = "DiffModifiedGutter" })
set_hl("DiffDelete", { link = "DiffRemovedGutter" })
set_hl("diffAdded", { fg = palette.green, bg = palette.bg_alt })
set_hl("diffChanged", { fg = palette.violet })
set_hl("diffRemoved", { fg = palette.red, bg = palette.base3 })
set_hl("diffLine", { fg = palette.violet })
set_hl("diffIndexLine", { fg = palette.cyan })
set_hl("diffSubname", { fg = palette.cyan })
set_hl("diffFile", { fg = palette.cyan })
set_hl("diffOldFile", { fg = palette.blue })
set_hl("diffNewFile", { fg = palette.blue })
--- Markdown
set_hl("markdownCode", { link = "Comment" })
set_hl("markdownCodeBlock", { link = "markdownCode" })
set_hl("markdownH1", { bold = true })
set_hl("markdownH2", { bold = true })
set_hl("markdownLinkText", { underline = true })
--- LSP / Diagnostics
set_hl("LspHighlight", { bg = palette.bg_alt, bold = true })
set_hl("LspSignatureActiveParameter", { fg = palette.violet })
set_hl("DiagnosticError", { fg = palette.error })
set_hl("DiagnosticWarn", { fg = palette.warning })
set_hl("DiagnosticInfo", { fg = palette.info })
set_hl("DiagnosticHint", { fg = palette.hint_fg })
set_hl("DiagnosticFloatingError", { link = "ErrorMsg" })
set_hl("DiagnosticFloatingWarn", { link = "WarningMsg" })
set_hl("DiagnosticFloatingInfo", { link = "MoreMsg" })
set_hl("DiagnosticFloatingHint", { link = "Msg" })
set_hl("DiagnosticDefaultError", { link = "ErrorMsg" })
set_hl("DiagnosticDefaultWarn", { link = "WarningMsg" })
set_hl("DiagnosticDefaultInfo", { link = "MoreMsg" })
set_hl("DiagnosticDefaultHint", { link = "Msg" })
set_hl("DiagnosticVirtualTextError", { link = "ErrorMsg" })
set_hl("DiagnosticVirtualTextWarn", { link = "WarningMsg" })
set_hl("DiagnosticVirtualTextInfo", { link = "MoreMsg" })
set_hl("DiagnosticVirtualTextHint", { link = "Msg" })
set_hl("DiagnosticSignError", { link = "ErrorMsg" })
set_hl("DiagnosticSignWarning", { link = "WarningMsg" })
set_hl("DiagnosticSignInformation", { link = "MoreMsg" })
set_hl("DiagnosticSignHint", { link = "Msg" })
set_hl("LspReferenceText", { link = "LspHighlight" })
set_hl("LspReferenceRead", { link = "LspHighlight" })
set_hl("LspReferenceWrite", { link = "LspHighlight" })
--- Tree-Sitter
set_hl("@annotation", { link = "PreProc" })
set_hl("@attribute", { link = "Attribute" })
set_hl("@conditional", { link = "Conditional" })
set_hl("@comment", { link = "Comment" })
set_hl("@string", { fg = palette.String })
set_hl("@function", { fg = palette.Keyword })
set_hl("@variable", { fg = palette.Identifier })
set_hl("@keyword", { fg = palette.Keyword })
set_hl("@type", { fg = palette.Preprocessor })
set_hl("@constructor", { link = "Structure" })
set_hl("@constant", { link = "Constant" })
set_hl("@constant.builtin", { link = "Constant" })
set_hl("@constant.macro", { link = "Macro" })
set_hl("@error", { link = "Error" })
set_hl("@exception", { link = "Exception" })
set_hl("@field", { link = "Field" })
set_hl("@float", { link = "Float" })
set_hl("@function", { link = "Function" })
set_hl("@function.builtin", { link = "FunctionBuiltin" })
set_hl("@function.macro", { link = "Macro" })
set_hl("@include", { link = "Include" })
set_hl("@keyword", { link = "Keyword" })
set_hl("@keyword.function", { link = "KeywordFunction" })
set_hl("@label", { link = "Label" })
set_hl("@math", { link = "Special" })
set_hl("@method", { link = "Method" })
set_hl("@namespace", { link = "Directory" })
set_hl("@number", { link = "Number" })
set_hl("@boolean", { link = "Boolean" })
set_hl("@operator", { link = "Operator" })
set_hl("@parameter", { link = "Argument" })
set_hl("@parameter.reference", { link = "Argument" })
set_hl("@property", { link = "Property" })
set_hl("@punctuation.delimiter", { link = "Delimiter" })
set_hl("@punctuation.bracket", { link = "Delimiter" })
set_hl("@punctuation.special", { link = "Delimiter" })
set_hl("@repeat", { link = "Repeat" })
set_hl("@string", { link = "String" })
set_hl("@string.regex", { link = "StringDelimiter" })
set_hl("@string.escape", { link = "StringDelimiter" })
set_hl("@structure", { link = "Structure" })
set_hl("@tag", { link = "Tag" })
set_hl("@tag.attribute", { link = "Attribute" })
set_hl("@tag.delimiter", { link = "Delimiter" })
set_hl("@strong", { link = "Bold" })
set_hl("@uri", { link = "URL" })
set_hl("@warning", { link = "WarningMsg" })
set_hl("@danger", { link = "ErrorMsg" })
set_hl("@type", { link = "Type" })
set_hl("@type.builtin", { link = "TypeBuiltin" })
set_hl("@variable", { fg = palette.variable })
set_hl("@variable.builtin", { link = "VariableBuiltin" })
set_hl("@text", { link = "Normal" })
set_hl("@text.strong", { fg = palette.fg, bold = true })
set_hl("@text.emphasis", { link = "Emphasis" })
set_hl("@text.underline", { underline = true })
set_hl("@text.title", { link = "Title" })
set_hl("@text.uri", { link = "URL" })
set_hl("@text.note", { link = "MoreMsg" })
set_hl("@text.warning", { link = "WarningMsg" })
set_hl("@text.danger", { link = "ErrorMsg" })
set_hl("@todo", { link = "Todo" })
--- NetRW
set_hl("netrwClassify", { fg = palette.blue })
set_hl("netrwDir", { link = "Directory" })
set_hl("netrwExe", { fg = palette.green, bold = true })
set_hl("netrwMakefile", { fg = palette.yellow, bold = true })
set_hl("netrwTreeBar", { link = "Comment" })

52
extra/README.md Normal file
View File

@@ -0,0 +1,52 @@
# Extras
Pre-configured palettes and templates for clrsync.
## Palettes
| Palette | Preview |
|---------|---------|
| [Nord](palettes/dark/nord) | ![nord](palettes/dark/nord/nord.png) |
| [Cursed](palettes/dark/cursed) | ![cursed](palettes/dark/cursed/cursed.png) |
| [Cursed Light](palettes/light/cursed-light) | ![cursed-light](palettes/light/cursed-light/cursed-light.png) |
## Templates
### Terminals
- [Alacritty](templates/terminals/alacritty)
- [Ghostty](templates/terminals/ghostty)
- [Kitty](templates/terminals/kitty)
### Text Editors
- [Neovim](templates/text-editors/neovim)
- [VS Code](templates/text-editors/vscode)
### Browsers
- [Firefox](templates/browsers/firefox)
### Desktop
- [GTK](templates/desktop/gtk)
- [Qt](templates/desktop/qt)
### Window Managers
- [Hyprland](templates/wms/hyprland)
### Apps
- [Telegram](templates/apps/telegram)
## Contributing
To add a new palette:
1. Create a folder in `palettes/<dark/light>` with your palette name
2. Add your `.toml` palette file
3. Add a `readme.md` with description
4. Add a screenshot (`.png`)
5. Submit a PR
To add a new template:
1. Create a folder in `templates/<category>` with the app name
2. Add your template file(s)
3. Add a `readme.md` with installation instructions
4. Submit a PR

View File

@@ -1,54 +0,0 @@
[colors]
accent = '#95A328FF'
background = '#F5F5F5FF'
base00 = '#F5F5F5FF'
base01 = '#B44242FF'
base02 = '#95A328FF'
base03 = '#C9A305FF'
base04 = '#60928FFF'
base05 = '#7C435AFF'
base06 = '#A48B4AFF'
base07 = '#3D3D2FFF'
base08 = '#C0C0B8FF'
base09 = '#DC7671FF'
base0A = '#D4D430FF'
base0B = '#9E9052FF'
base0C = '#76C39BFF'
base0D = '#86596CFF'
base0E = '#B89A1FFF'
base0F = '#4F4F48FF'
border = '#D0D0C8FF'
border_focused = '#C9A305FF'
cursor = '#C9A305FF'
editor_background = '#F5F5F5FF'
editor_command = '#B89A1FFF'
editor_comment = '#A0A098FF'
editor_disabled = '#C0C0B8FF'
editor_emphasis = '#DC7671FF'
editor_error = '#B44242FF'
editor_inactive = '#A0A098FF'
editor_line_number = '#86596CFF'
editor_link = '#60928FFF'
editor_main = '#3D3D2FFF'
editor_selected = '#D0D0C8FF'
editor_selection_inactive = '#E0E0D8FF'
editor_string = '#5FA37BFF'
editor_success = '#95A328FF'
editor_warning = '#C9A305FF'
error = '#B44242FF'
foreground = '#3D3D2FFF'
info = '#60928FFF'
on_background = '#3D3D2FFF'
on_error = '#F5F5F5FF'
on_info = '#F5F5F5FF'
on_success = '#F5F5F5FF'
on_surface = '#3D3D2FFF'
on_surface_variant = '#CCCCCCFF'
on_warning = '#F5F5F5FF'
success = '#95A328FF'
surface = '#E8E8E8FF'
surface_variant = '#D0D0C8FF'
warning = '#C9A305FF'
[general]
name = 'cursed-light'

View File

@@ -1,54 +0,0 @@
[colors]
accent = '#95A328FF'
background = '#151515FF'
base00 = '#151515FF'
base01 = '#B44242FF'
base02 = '#95A328FF'
base03 = '#E1C135FF'
base04 = '#60928FFF'
base05 = '#7C435AFF'
base06 = '#A48B4AFF'
base07 = '#C2C2B0FF'
base08 = '#3F3639FF'
base09 = '#DC7671FF'
base0A = '#E8E85AFF'
base0B = '#9E9052FF'
base0C = '#76C39BFF'
base0D = '#86596CFF'
base0E = '#CEB34FFF'
base0F = '#B0AFA8FF'
border = '#3F3639FF'
border_focused = '#E1C135FF'
cursor = '#E1C135FF'
editor_background = '#151515FF'
editor_command = '#CEB34FFF'
editor_comment = '#7A7A7AFF'
editor_disabled = '#3F3639FF'
editor_emphasis = '#DC7671FF'
editor_error = '#B44242FF'
editor_inactive = '#3F3639FF'
editor_line_number = '#86596CFF'
editor_link = '#60928FFF'
editor_main = '#C2C2B0FF'
editor_selected = '#3F3639FF'
editor_selection_inactive = '#2A2A2AFF'
editor_string = '#76C39BFF'
editor_success = '#95A328FF'
editor_warning = '#E1C135FF'
error = '#B44242FF'
foreground = '#C2C2B0FF'
info = '#60928FFF'
on_background = '#C2C2B0FF'
on_error = '#151515FF'
on_info = '#151515FF'
on_success = '#151515FF'
on_surface = '#C2C2B0FF'
on_surface_variant = '#CCCCCCFF'
on_warning = '#151515FF'
success = '#95A328FF'
surface = '#1C1C1CFF'
surface_variant = '#1C1C1CFF'
warning = '#E1C135FF'
[general]
name = 'cursed'

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

View File

@@ -0,0 +1,106 @@
[colors]
accent = '#95A328FF'
accent_secondary = '#95A328FF'
background = '#151515FF'
base00 = '#151515FF'
base01 = '#B44242FF'
base02 = '#95A328FF'
base03 = '#E1C135FF'
base04 = '#60928FFF'
base05 = '#7C435AFF'
base06 = '#A48B4AFF'
base07 = '#C2C2B0FF'
base08 = '#3F3639FF'
base09 = '#DC7671FF'
base0A = '#E8E85AFF'
base0B = '#9E9052FF'
base0C = '#76C39BFF'
base0D = '#86596CFF'
base0E = '#CEB34FFF'
base0F = '#B0AFA8FF'
border = '#3F3639FF'
border_focused = '#E1C135FF'
cursor = '#E1C135FF'
# Editor - Basic
editor_background = '#151515FF'
editor_foreground = '#C2C2B0FF'
editor_line_highlight = '#1C1C1CFF'
editor_selection = '#3F3639FF'
editor_selection_inactive = '#2A2A2AFF'
editor_cursor = '#E1C135FF'
editor_whitespace = '#3F3639FF'
# Editor - Gutter
editor_gutter_background = '#151515FF'
editor_gutter_foreground = '#7A7A7AFF'
editor_line_number = '#86596CFF'
editor_line_number_active = '#C2C2B0FF'
# Editor - Syntax
editor_comment = '#7A7A7AFF'
editor_string = '#76C39BFF'
editor_number = '#DC7671FF'
editor_boolean = '#DC7671FF'
editor_keyword = '#CEB34FFF'
editor_operator = '#C2C2B0FF'
editor_function = '#95A328FF'
editor_variable = '#C2C2B0FF'
editor_parameter = '#60928FFF'
editor_property = '#76C39BFF'
editor_constant = '#DC7671FF'
editor_type = '#60928FFF'
editor_class = '#60928FFF'
editor_interface = '#60928FFF'
editor_enum = '#60928FFF'
editor_namespace = '#86596CFF'
editor_attribute = '#E1C135FF'
editor_decorator = '#E1C135FF'
editor_tag = '#B44242FF'
editor_punctuation = '#B0AFA8FF'
editor_link = '#60928FFF'
editor_regex = '#CEB34FFF'
editor_escape_character = '#DC7671FF'
# Editor - Diagnostics
editor_invalid = '#B44242FF'
editor_error = '#B44242FF'
editor_error_background = '#2A1515FF'
editor_warning = '#E1C135FF'
editor_warning_background = '#2A2515FF'
editor_info = '#60928FFF'
editor_info_background = '#15252AFF'
editor_hint = '#95A328FF'
editor_hint_background = '#1A2A15FF'
# Editor - UI Elements
editor_active_line_border = '#3F3639FF'
editor_indent_guide = '#2A2A2AFF'
editor_indent_guide_active = '#3F3639FF'
editor_bracket_match = '#E1C135FF'
editor_search_match = '#E1C13580'
editor_search_match_active = '#E1C135FF'
editor_find_range_highlight = '#E1C13540'
# Editor - Diff
editor_deleted = '#B44242FF'
editor_inserted = '#95A328FF'
editor_modified = '#E1C135FF'
editor_ignored = '#7A7A7AFF'
editor_folded_background = '#1C1C1CFF'
error = '#B44242FF'
foreground = '#C2C2B0FF'
info = '#60928FFF'
on_background = '#C2C2B0FF'
on_error = '#151515FF'
on_info = '#151515FF'
on_success = '#151515FF'
on_surface = '#C2C2B0FF'
on_surface_variant = '#CCCCCCFF'
on_warning = '#151515FF'
success = '#95A328FF'
surface = '#1C1C1CFF'
surface_variant = '#1C1C1CFF'
warning = '#E1C135FF'
[general]
name = 'cursed'

View File

@@ -0,0 +1,7 @@
# Cursed
A dark color scheme inspired by the `cursed` theme by [pyratebeard](https://pyratebeard.net).
![cursed](cursed.png)
[Download](cursed.toml)

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -0,0 +1,106 @@
[colors]
accent = '#A1CDFAFF'
accent_secondary = '#A1CDFAFF'
background = '#2E3440FF'
base00 = '#2E3440FF'
base01 = '#BF616AFF'
base02 = '#A3BE8CFF'
base03 = '#EBCB8BFF'
base04 = '#81A1C1FF'
base05 = '#B48EADFF'
base06 = '#88C0D0FF'
base07 = '#E5E9F0FF'
base08 = '#4C566AFF'
base09 = '#D08770FF'
base0A = '#EBCB8BFF'
base0B = '#A3BE8CFF'
base0C = '#8FBCBBFF'
base0D = '#5E81ACFF'
base0E = '#B48EADFF'
base0F = '#ECEFF4FF'
border = '#4C566AFF'
border_focused = '#88C0D0FF'
cursor = '#D8DEE9FF'
# Editor - Basic
editor_background = '#2E3440FF'
editor_foreground = '#D8DEE9FF'
editor_line_highlight = '#3B4252FF'
editor_selection = '#434C5EFF'
editor_selection_inactive = '#3B4252FF'
editor_cursor = '#D8DEE9FF'
editor_whitespace = '#4C566AFF'
# Editor - Gutter
editor_gutter_background = '#2E3440FF'
editor_gutter_foreground = '#4C566AFF'
editor_line_number = '#4C566AFF'
editor_line_number_active = '#D8DEE9FF'
# Editor - Syntax
editor_comment = '#616E88FF'
editor_string = '#A3BE8CFF'
editor_number = '#B48EADFF'
editor_boolean = '#B48EADFF'
editor_keyword = '#81A1C1FF'
editor_operator = '#D8DEE9FF'
editor_function = '#88C0D0FF'
editor_variable = '#D8DEE9FF'
editor_parameter = '#D8DEE9FF'
editor_property = '#8FBCBBFF'
editor_constant = '#B48EADFF'
editor_type = '#8FBCBBFF'
editor_class = '#8FBCBBFF'
editor_interface = '#8FBCBBFF'
editor_enum = '#8FBCBBFF'
editor_namespace = '#5E81ACFF'
editor_attribute = '#D08770FF'
editor_decorator = '#D08770FF'
editor_tag = '#BF616AFF'
editor_punctuation = '#ECEFF4FF'
editor_link = '#88C0D0FF'
editor_regex = '#EBCB8BFF'
editor_escape_character = '#D08770FF'
# Editor - Diagnostics
editor_invalid = '#BF616AFF'
editor_error = '#BF616AFF'
editor_error_background = '#3B2E2EFF'
editor_warning = '#EBCB8BFF'
editor_warning_background = '#3B3B2EFF'
editor_info = '#5E81ACFF'
editor_info_background = '#2E3440FF'
editor_hint = '#A3BE8CFF'
editor_hint_background = '#2E3B2EFF'
# Editor - UI Elements
editor_active_line_border = '#4C566AFF'
editor_indent_guide = '#3B4252FF'
editor_indent_guide_active = '#4C566AFF'
editor_bracket_match = '#88C0D0FF'
editor_search_match = '#EBCB8B80'
editor_search_match_active = '#EBCB8BFF'
editor_find_range_highlight = '#EBCB8B40'
# Editor - Diff
editor_deleted = '#BF616AFF'
editor_inserted = '#A3BE8CFF'
editor_modified = '#EBCB8BFF'
editor_ignored = '#616E88FF'
editor_folded_background = '#3B4252FF'
error = '#BF616AFF'
foreground = '#D8DEE9FF'
info = '#5E81ACFF'
on_background = '#D8DEE9FF'
on_error = '#2E3440FF'
on_info = '#2E3440FF'
on_success = '#2E3440FF'
on_surface = '#ECEFF4FF'
on_surface_variant = '#ECEFF4FF'
on_warning = '#2E3440FF'
success = '#A3BE8CFF'
surface = '#3B4252FF'
surface_variant = '#434C5EFF'
warning = '#EBCB8BFF'
[general]
name = 'nord'

View File

@@ -0,0 +1,7 @@
# Nord
A color scheme based on the [Nord](https://www.nordtheme.com/) palette.
![nord](nord.png)
[Download](nord.toml)

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -0,0 +1,106 @@
[colors]
accent = '#95A328FF'
accent_secondary = '#95A328FF'
background = '#F5F5F5FF'
base00 = '#F5F5F5FF'
base01 = '#B44242FF'
base02 = '#95A328FF'
base03 = '#C9A305FF'
base04 = '#60928FFF'
base05 = '#7C435AFF'
base06 = '#A48B4AFF'
base07 = '#3D3D2FFF'
base08 = '#C0C0B8FF'
base09 = '#DC7671FF'
base0A = '#D4D430FF'
base0B = '#9E9052FF'
base0C = '#76C39BFF'
base0D = '#86596CFF'
base0E = '#B89A1FFF'
base0F = '#4F4F48FF'
border = '#D0D0C8FF'
border_focused = '#C9A305FF'
cursor = '#C9A305FF'
# Editor - Basic
editor_background = '#F5F5F5FF'
editor_foreground = '#3D3D2FFF'
editor_line_highlight = '#E8E8E8FF'
editor_selection = '#D0D0C8FF'
editor_selection_inactive = '#E0E0D8FF'
editor_cursor = '#C9A305FF'
editor_whitespace = '#C0C0B8FF'
# Editor - Gutter
editor_gutter_background = '#F5F5F5FF'
editor_gutter_foreground = '#A0A098FF'
editor_line_number = '#86596CFF'
editor_line_number_active = '#3D3D2FFF'
# Editor - Syntax
editor_comment = '#A0A098FF'
editor_string = '#5FA37BFF'
editor_number = '#DC7671FF'
editor_boolean = '#DC7671FF'
editor_keyword = '#B89A1FFF'
editor_operator = '#3D3D2FFF'
editor_function = '#95A328FF'
editor_variable = '#3D3D2FFF'
editor_parameter = '#60928FFF'
editor_property = '#5FA37BFF'
editor_constant = '#DC7671FF'
editor_type = '#60928FFF'
editor_class = '#60928FFF'
editor_interface = '#60928FFF'
editor_enum = '#60928FFF'
editor_namespace = '#86596CFF'
editor_attribute = '#C9A305FF'
editor_decorator = '#C9A305FF'
editor_tag = '#B44242FF'
editor_punctuation = '#4F4F48FF'
editor_link = '#60928FFF'
editor_regex = '#B89A1FFF'
editor_escape_character = '#DC7671FF'
# Editor - Diagnostics
editor_invalid = '#B44242FF'
editor_error = '#B44242FF'
editor_error_background = '#FFEDEDFF'
editor_warning = '#C9A305FF'
editor_warning_background = '#FFF8E0FF'
editor_info = '#60928FFF'
editor_info_background = '#E0F8FFFF'
editor_hint = '#95A328FF'
editor_hint_background = '#E8FFE8FF'
# Editor - UI Elements
editor_active_line_border = '#D0D0C8FF'
editor_indent_guide = '#E0E0D8FF'
editor_indent_guide_active = '#C0C0B8FF'
editor_bracket_match = '#C9A305FF'
editor_search_match = '#C9A30580'
editor_search_match_active = '#C9A305FF'
editor_find_range_highlight = '#C9A30540'
# Editor - Diff
editor_deleted = '#B44242FF'
editor_inserted = '#95A328FF'
editor_modified = '#C9A305FF'
editor_ignored = '#A0A098FF'
editor_folded_background = '#E8E8E8FF'
error = '#B44242FF'
foreground = '#3D3D2FFF'
info = '#60928FFF'
on_background = '#3D3D2FFF'
on_error = '#F5F5F5FF'
on_info = '#F5F5F5FF'
on_success = '#F5F5F5FF'
on_surface = '#3D3D2FFF'
on_surface_variant = '#CCCCCCFF'
on_warning = '#F5F5F5FF'
success = '#95A328FF'
surface = '#E8E8E8FF'
surface_variant = '#D0D0C8FF'
warning = '#C9A305FF'
[general]
name = 'cursed-light'

View File

@@ -0,0 +1,7 @@
# Cursed Light
A light variant of the `cursed` color scheme.
![cursed-light](cursed-light.png)
[Download](cursed-light.toml)

View File

@@ -1,54 +0,0 @@
[colors]
accent = '#5E81ACFF'
background = '#2E3440FF'
base00 = '#2E3440FF'
base01 = '#BF616AFF'
base02 = '#A3BE8CFF'
base03 = '#EBCB8BFF'
base04 = '#81A1C1FF'
base05 = '#B48EADFF'
base06 = '#88C0D0FF'
base07 = '#E5E9F0FF'
base08 = '#4C566AFF'
base09 = '#D08770FF'
base0A = '#EBCB8BFF'
base0B = '#A3BE8CFF'
base0C = '#8FBCBBFF'
base0D = '#5E81ACFF'
base0E = '#B48EADFF'
base0F = '#ECEFF4FF'
border = '#4C566AFF'
border_focused = '#88C0D0FF'
cursor = '#D8DEE9FF'
editor_background = '#2E3440FF'
editor_command = '#81A1C1FF'
editor_comment = '#616E88FF'
editor_disabled = '#4C566AFF'
editor_emphasis = '#B48EADFF'
editor_error = '#BF616AFF'
editor_inactive = '#616E88FF'
editor_line_number = '#4C566AFF'
editor_link = '#88C0D0FF'
editor_main = '#D8DEE9FF'
editor_selected = '#434C5EFF'
editor_selection_inactive = '#3B4252FF'
editor_string = '#A3BE8CFF'
editor_success = '#A3BE8CFF'
editor_warning = '#EBCB8BFF'
error = '#BF616AFF'
foreground = '#D8DEE9FF'
info = '#5E81ACFF'
on_background = '#D8DEE9FF'
on_error = '#2E3440FF'
on_info = '#2E3440FF'
on_success = '#2E3440FF'
on_surface = '#ECEFF4FF'
on_surface_variant = '#ECEFF4FF'
on_warning = '#2E3440FF'
success = '#A3BE8CFF'
surface = '#3B4252FF'
surface_variant = '#434C5EFF'
warning = '#EBCB8BFF'
[general]
name = 'nord'

View File

@@ -0,0 +1,17 @@
# Telegram
1. Download the [template file](telegram.tdesktop-theme)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.telegram]
enabled = true
input_path = '~/.config/clrsync/templates/telegram.tdesktop-theme'
output_path = '~/clrsync.tdesktop-theme'
reload_cmd = ''
```
3. Apply the palette with clrsync and send the generated `clrsync.tdesktop-theme` file to yourself in Telegram
4. Click on the theme file in the Telegram dialog to apply it

View File

@@ -0,0 +1,213 @@
// Template mostly stolen from noctalia-shell
// https://github.com/noctalia-dev/noctalia-shell/blob/main/Assets/MatugenTemplates/telegram.tdesktop-theme
COLOR_GRAY: {border};
COLOR_DARK: {surface_variant};
windowBg: {background}; // Main background
windowFg: {on_background}; // Main text
windowBgOver: {surface_variant}; // Generic background on hover
windowBgRipple: {surface_variant}; // Ripple effect
windowFgOver: {on_surface_variant}; // Text on hover
windowSubTextFg: {foreground}60; // Minor text
windowSubTextFgOver: {foreground}80; // Minor text on hover
dialogsBg: {background}; // Sidebar background
dialogsBgActive: {surface}; // Active chat background
dialogsBgOver: {surface_variant}; // Hover background
dialogsRippleBg: {surface_variant}; // Ripple effect
dialogsRippleBgActive: {surface_variant}; // Ripple effect for active chat
dialogsNameFg: {foreground}; // Chat name
dialogsNameFgActive: {foreground}; // Chat name for active chat
dialogsNameFgOver: {foreground}; // Chat name on hover
dialogsTextFg: {foreground}; // Message preview
dialogsTextFgActive: {foreground}; // Message preview for active chat
dialogsTextFgOver: {foreground}; // Message preview on hover
dialogsTextFgService: {foreground}; // Service text (group sender name)
dialogsTextFgServiceActive: {foreground}; // Service text for active chat
dialogsTextFgServiceOver: {foreground}; // Service text on hover
dialogsDateFg: {foreground}60; // Date text
dialogsDateFgActive: {foreground}60; // Date text for active chat
dialogsDateFgOver: {foreground}60; // Date text on hover
dialogsDraftFg: {foreground}; // Draft label
dialogsDraftFgActive: {foreground}; // Draft label for active chat
dialogsDraftFgOver: {foreground}; // Draft label on hover
dialogsVerifiedIconBg: {accent}; // Verified badge background
dialogsVerifiedIconBgActive: {accent_secondary}; // Verified badge for active chat
dialogsVerifiedIconBgOver: {accent}; // Verified badge on hover
dialogsVerifiedIconFg: {background}; // Verified icon
dialogsVerifiedIconFgActive: {background}; // Verified icon for active chat
dialogsVerifiedIconFgOver: {background}; // Verified icon on hover
dialogsSendingIconFg: {foreground}; // Sending icon (clock)
dialogsSendingIconFgActive: {foreground}; // Sending icon for active chat
dialogsSendingIconFgOver: {foreground}; // Sending icon on hover
dialogsSentIconFg: {accent}; // Sent icon (tick)
dialogsSentIconFgActive: {accent_secondary}; // Sent icon for active chat
dialogsSentIconFgOver: {accent}; // Sent icon on hover
dialogsUnreadBg: {accent}; // Unread badge background
dialogsUnreadBgActive: {accent_secondary}; // Unread badge for active chat
dialogsUnreadBgOver: {accent}; // Unread badge on hover
dialogsUnreadBgMuted: {foreground}; // Muted unread badge
dialogsUnreadBgMutedActive: {foreground}; // Muted unread badge for active chat
dialogsUnreadBgMutedOver: {foreground}; // Muted unread badge on hover
dialogsUnreadFg: {background}; // Unread badge text
dialogsUnreadFgActive: {background}; // Unread badge text for active chat
dialogsUnreadFgOver: {background}; // Unread badge text on hover
dialogsChatIconFg: {foreground}; // Group/channel icon
dialogsChatIconFgActive: {foreground}; // Group/channel icon for active chat
dialogsChatIconFgOver: {foreground}; // Group/channel icon on hover
dialogsOnlineBadgeFg: {foreground}; // Online status
dialogsOnlineBadgeFgActive: {foreground}; // Online status for active chat
dialogsForwardBg: {surface}; // Forwarding panel background
dialogsForwardFg: {foreground}; // Forwarding panel text
dialogsMenuIconFg: {foreground}; // Main menu icon
dialogsMenuIconFgOver: {foreground}60; // Main menu icon on hover
windowBoldFg: {on_background}; // Bold text
windowBoldFgOver: {on_surface_variant}; // Bold text on hover
windowBgActive: {surface}; // Active items background
windowFgActive: {foreground}; // Active items text
windowActiveTextFg: {accent_secondary}; // Active items text
windowShadowFg: {border}; // Window shadow
windowShadowFgFallback: {border}; // Fallback for shadow
historyOutIconFg: {accent};
historyIconFgInverted: {on_surface};
msgServiceBg: {surface}80;
msgServiceFg: {foreground};
msgOutBg: {surface};
msgOutBgSelected: {surface_variant};
msgOutServiceFg: {on_surface};
msgOutDateFg: {foreground}80;
historySentIconFg: {foreground};
msgOutDateFgSelected: {foreground};
msgInBg: {surface_variant};
msgInBgSelected: {surface};
msgDateImgFg: {on_surface};
shadowFg: {border}; // General shadow
slideFadeOutBg: {background};
slideFadeOutShadowFg: {border};
imageBg: {surface};
imageBgTransparent: {surface};
activeButtonBg: {accent_secondary}; // Active button background
activeButtonBgOver: {surface_variant}; // Active button hover background
activeButtonBgRipple: {on_surface_variant}; // Active button ripple
activeButtonFg: {on_background}; // Active button text
activeButtonFgOver: {on_surface_variant}; // Active button hover text
activeButtonSecondaryFg: {on_background}; // Active button secondary text
activeButtonSecondaryFgOver: {on_surface_variant}; // Active button secondary hover text
activeLineFg: {accent};
dialogsBgActive: {surface};
lightButtonBg: {surface}; // Light button background
lightButtonBgOver: {surface_variant}; // Light button hover background
lightButtonBgRipple: {accent}; // Light button ripple
lightButtonFg: {on_surface}; // Light button text
lightButtonFgOver: {on_surface_variant}; // Light button hover text
attentionButtonFg: {error};
attentionButtonFgOver: {error};
attentionButtonBgOver: {surface_variant};
attentionButtonBgRipple: {on_surface};
outlineButtonBg: {surface}; // Outline button background
outlineButtonBgOver: {surface_variant}; // Outline button hover background
outlineButtonOutlineFg: {accent_secondary}; // Outline button color
outlineButtonBgRipple: {accent_secondary}; // Outline button ripple
menuBg: {surface};
menuBgOver: {surface_variant};
menuBgRipple: {accent_secondary};
menuIconFg: {on_surface};
menuIconFgOver: {on_surface_variant};
menuSubmenuArrowFg: {border};
menuFgDisabled: {border};
menuSeparatorFg: {border};
scrollBarBg: {accent}40; // Scroll bar background (40% opacity)
scrollBarBgOver: {accent_secondary}60; // Scroll bar hover background (60% opacity)
scrollBg: {surface_variant}40; // Scroll bar track (40% opacity)
scrollBgOver: {surface_variant}60; // Scroll bar track on hover (60% opacity)
smallCloseIconFg: {border};
smallCloseIconFgOver: {on_surface_variant};
radialFg: {accent_secondary};
radialBg: {surface};
placeholderFg: {border}; // Placeholder text
placeholderFgActive: {accent_secondary}; // Active placeholder text
inputBorderFg: {border}; // Input border
filterInputBorderFg: {border}; // Search input border
filterInputInactiveBg: {surface}; // Inactive search input background
checkboxFg: {accent_secondary}; // Checkbox color
// Filters sidebar (left side bar with folder filters)
sideBarBg: {surface}; // Filters sidebar background
sideBarBgActive: {surface_variant}; // Filters sidebar active filter background
sideBarBgRipple: {background}; // Filters sidebar ripple effect
sideBarTextFg: {foreground}; // Filters sidebar text
sideBarTextFgActive: {foreground}; // Filters sidebar active filter text
sideBarIconFg: {foreground}; // Filters sidebar icon
sideBarIconFgActive: {foreground}; // Filters sidebar active filter icon
sideBarBadgeBg: {accent}; // Filters sidebar badge background
sideBarBadgeBgMuted: {foreground}60; // Filters sidebar muted badge background
titleBg: {surface}; // Window title background
titleShadow: {border};
titleButtonFg: {on_surface}; // Title button color
titleButtonBgOver: {surface_variant}; // Title button hover background
titleButtonFgOver: {on_surface_variant}; // Title button hover color
titleButtonCloseBgOver: {error};
titleButtonCloseFgOver: {on_error};
titleFgActive: {on_surface}; // Active title text
titleFg: {on_surface}; // Inactive title text
trayCounterBg: {error}; // Tray counter background
trayCounterBgMute: {border}; // Muted tray counter background
trayCounterFg: {on_error}; // Tray counter text
trayCounterBgMacInvert: {error}; // Mac tray counter
trayCounterFgMacInvert: {on_error}; // Mac tray counter text
layerBg: {surface}99; // Layer background (60% opacity)
cancelIconFg: {error}; // Cancel icon
cancelIconFgOver: {error}; // Cancel icon on hover
boxBg: {surface}; // Box background
boxTextFg: {on_surface}; // Box text
boxTextFgGood: {accent_secondary}; // Box good text
boxTextFgError: {error}; // Box error text
boxTitleFg: {on_surface}; // Box title text
boxSearchBg: {surface}; // Box search field background
boxSearchCancelIconFg: {error}; // Box search cancel icon
boxSearchCancelIconFgOver: {error}; // Box search cancel icon on hover
contactsBg: {surface}; // Contacts background
contactsBgOver: {surface_variant}; // Contacts background on hover
contactsNameFg: {on_surface}; // Contact name
contactsStatusFg: {border}; // Contact status
contactsStatusFgOver: {on_surface_variant}; // Contact status on hover
contactsStatusFgOnline: {accent_secondary}; // Online contact status
photoCropFadeBg: {surface}cc; // Photo crop fade background
photoCropPointFg: {accent_secondary}; // Photo crop points
chat_inBubbleSelected: {surface_variant}; // inbox selected chat background
chat_outBubbleSelected: {surface_variant}; // outbox selected chat background

View File

@@ -0,0 +1,17 @@
# Firefox
1. Download the [template file](userChrome.css)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.firefox]
enabled = true
input_path = '~/.config/clrsync/templates/userChrome.css'
output_path = '~/.mozilla/firefox/<profile>/chrome/userChrome.css'
reload_cmd = ''
```
3. Enable `toolkit.legacyUserProfileCustomizations.stylesheets` in `about:config`
4. Restart Firefox to apply the theme

View File

@@ -0,0 +1,109 @@
/* clrsync Firefox Theme */
/* Place in: <Firefox Profile>/chrome/userChrome.css */
/* Enable: about:config -> toolkit.legacyUserProfileCustomizations.stylesheets = true */
:root {
--lwt-accent-color: {background} !important;
--lwt-text-color: {foreground} !important;
--toolbar-bgcolor: {surface} !important;
--toolbar-color: {on_surface} !important;
--toolbarbutton-hover-background: {surface_variant} !important;
--toolbarbutton-active-background: {border_focused} !important;
--toolbarbutton-icon-fill: {on_surface} !important;
--tab-selected-bgcolor: {surface} !important;
--tab-selected-textcolor: {foreground} !important;
--tab-loading-fill: {accent} !important;
--lwt-tab-text: {foreground} !important;
--tab-line-color: {accent} !important;
--urlbar-box-bgcolor: {surface_variant} !important;
--urlbar-box-text-color: {on_surface} !important;
--urlbar-box-hover-bgcolor: {surface} !important;
--urlbar-box-focus-bgcolor: {surface} !important;
--urlbar-popup-url-color: {editor_link} !important;
--arrowpanel-background: {surface} !important;
--arrowpanel-color: {on_surface} !important;
--arrowpanel-border-color: {border} !important;
--panel-separator-color: {border} !important;
--sidebar-background-color: {background} !important;
--sidebar-text-color: {foreground} !important;
--sidebar-border-color: {border} !important;
--toolbar-field-focus-background-color: {surface} !important;
--toolbar-field-focus-color: {on_surface} !important;
--toolbar-field-focus-border-color: {accent} !important;
}
#TabsToolbar {
background-color: {background} !important;
}
.tab-background[selected="true"] {
background-color: {surface} !important;
}
.tabbrowser-tab:hover > .tab-stack > .tab-background:not([selected="true"]) {
background-color: {surface_variant} !important;
}
.tab-line {
background-color: {accent} !important;
}
#nav-bar {
background-color: {surface} !important;
}
#urlbar-background {
background-color: {surface_variant} !important;
border-color: {border} !important;
}
#urlbar[focused="true"] > #urlbar-background {
background-color: {surface} !important;
border-color: {accent} !important;
}
#urlbar-input {
color: {on_surface} !important;
}
#PersonalToolbar {
background-color: {surface} !important;
}
menupopup, panel {
--panel-background: {surface} !important;
--panel-color: {on_surface} !important;
}
menupopup {
background-color: {surface} !important;
color: {on_surface} !important;
}
menuitem:hover, menu:hover {
background-color: {surface_variant} !important;
}
#sidebar-box {
background-color: {background} !important;
}
#sidebar-header {
background-color: {surface} !important;
border-bottom-color: {border} !important;
}
findbar {
background-color: {surface} !important;
color: {on_surface} !important;
}
* {
scrollbar-color: {surface_variant} {background} !important;
}

View File

@@ -0,0 +1,18 @@
@define-color accent_color {accent};
@define-color accent_bg_color {accent};
@define-color accent_fg_color {on_surface};
@define-color window_bg_color {background};
@define-color window_fg_color {foreground};
@define-color headerbar_bg_color {surface};
@define-color headerbar_fg_color {on_surface};
@define-color popover_bg_color {surface_variant};
@define-color popover_fg_color {on_surface_variant};
@define-color view_bg_color {background};
@define-color view_fg_color {foreground};
@define-color card_bg_color {surface};
@define-color card_fg_color {on_surface};
@define-color sidebar_bg_color {surface_variant};
@define-color sidebar_fg_color {on_surface};
@define-color sidebar_border_color @window_bg_color;
@define-color sidebar_backdrop_color @window_bg_color;

View File

@@ -0,0 +1,15 @@
# GTK
1. Download the [template file](gtk.css)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.gtk]
enabled = true
input_path = '~/.config/clrsync/templates/gtk.css'
output_path = '~/.config/gtk-3.0/gtk.css'
reload_cmd = ''
```
3. Restart GTK applications to apply the theme

View File

@@ -0,0 +1,571 @@
[%General]
author=Matugen, based on MaterialADW by Vince Liuice
comment=A Material You theme generated by Matugen
x11drag=none
alt_mnemonic=true
left_tabs=false
attach_active_tab=false
mirror_doc_tabs=true
group_toolbar_buttons=false
toolbar_item_spacing=0
toolbar_interior_spacing=2
spread_progressbar=true
composite=true
menu_shadow_depth=6
spread_menuitems=false
tooltip_shadow_depth=7
splitter_width=1
scroll_width=9
scroll_arrows=false
scroll_min_extent=60
slider_width=2
slider_handle_width=23
slider_handle_length=22
tickless_slider_handle_size=22
center_toolbar_handle=true
check_size=24
textless_progressbar=false
progressbar_thickness=2
menubar_mouse_tracking=true
toolbutton_style=1
double_click=false
translucent_windows=false
blurring=false
popup_blurring=false
vertical_spin_indicators=false
spin_button_width=24
fill_rubberband=false
merge_menubar_with_toolbar=true
small_icon_size=16
large_icon_size=32
button_icon_size=16
toolbar_icon_size=16
combo_as_lineedit=true
animate_states=true
button_contents_shift=false
combo_menu=true
hide_combo_checkboxes=true
combo_focus_rect=false
groupbox_top_label=true
inline_spin_indicators=true
joined_inactive_tabs=false
layout_spacing=3
layout_margin=3
scrollbar_in_view=true
transient_scrollbar=true
transient_groove=false
submenu_overlap=0
tooltip_delay=0
tree_branch_line=false
no_window_pattern=false
opaque=kaffeine,kmplayer,subtitlecomposer,kdenlive,vlc,smplayer,smplayer2,avidemux,avidemux2_qt4,avidemux3_qt4,avidemux3_qt5,kamoso,QtCreator,VirtualBox,VirtualBoxVM,trojita,dragon,digikam,lyx
reduce_window_opacity=0
respect_DE=true
scrollable_menu=false
submenu_delay=150
no_inactiveness=false
reduce_menu_opacity=0
click_behavior=2
contrast=1.00
dialog_button_layout=0
intensity=1.00
saturation=1.00
shadowless_popup=false
drag_from_buttons=false
menu_blur_radius=0
tooltip_blur_radius=0
[GeneralColors]
window.color={surface}
base.color={surface}
alt.base.color={surface}
button.color={surface_variant}
light.color={surface}
mid.light.color={surface_variant}
dark.color={surface_variant}
mid.color={surface_variant}
highlight.color={accent}
inactive.highlight.color={accent}
text.color={on_surface}
window.text.color={on_surface}
button.text.color={on_surface}
disabled.text.color={editor_disabled}
tooltip.text.color={on_surface}
highlight.text.color={on_surface}
link.color={base06}
link.visited.color={base0D}
progress.indicator.text.color={on_surface}
[Hacks]
transparent_ktitle_label=true
transparent_dolphin_view=true
transparent_pcmanfm_sidepane=true
blur_translucent=false
transparent_menutitle=true
respect_darkness=true
kcapacitybar_as_progressbar=true
force_size_grip=true
iconless_pushbutton=false
iconless_menu=false
disabled_icon_opacity=100
lxqtmainmenu_iconsize=16
normal_default_pushbutton=true
single_top_toolbar=true
tint_on_mouseover=0
transparent_pcmanfm_view=true
no_selection_tint=true
transparent_arrow_button=true
middle_click_scroll=false
opaque_colors=false
kinetic_scrolling=false
scroll_jump_workaround=true
centered_forms=false
noninteger_translucency=false
style_vertical_toolbars=false
blur_only_active_window=true
[PanelButtonCommand]
frame=true
frame.element=button
frame.top=6
frame.bottom=6
frame.left=6
frame.right=6
interior=true
interior.element=button
indicator.size=8
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
text.shadow=0
text.margin=4
text.iconspacing=4
indicator.element=arrow
frame.expansion=0
[PanelButtonTool]
inherits=PanelButtonCommand
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
text.bold=false
indicator.element=arrow
indicator.size=8
frame.expansion=0
[ToolbarButton]
frame=true
frame.element=tbutton
interior.element=tbutton
frame.top=16
frame.bottom=16
frame.left=16
frame.right=16
indicator.element=tarrow
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
text.bold=false
frame.expansion=32
[Dock]
inherits=PanelButtonCommand
interior.element=dock
frame.element=dock
frame.top=1
frame.bottom=1
frame.left=1
frame.right=1
text.normal.color={on_surface}
[DockTitle]
inherits=PanelButtonCommand
frame=false
interior=false
text.normal.color={on_surface}
text.focus.color={on_surface}
text.bold=false
[IndicatorSpinBox]
inherits=PanelButtonCommand
frame=true
interior=true
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
indicator.element=spin
indicator.size=8
text.normal.color={on_surface}
text.margin.top=2
text.margin.bottom=2
text.margin.left=2
text.margin.right=2
[RadioButton]
inherits=PanelButtonCommand
frame=false
interior.element=radio
text.normal.color={on_surface}
text.focus.color={on_surface}
min_width=+0.3font
min_height=+0.3font
[CheckBox]
inherits=PanelButtonCommand
frame=false
interior.element=checkbox
text.normal.color={on_surface}
text.focus.color={on_surface}
min_width=+0.3font
min_height=+0.3font
[Focus]
inherits=PanelButtonCommand
frame=true
frame.element=focus
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
frame.patternsize=14
[GenericFrame]
inherits=PanelButtonCommand
frame=true
interior=false
frame.element=common
interior.element=common
frame.top=1
frame.bottom=1
frame.left=1
frame.right=1
[LineEdit]
inherits=PanelButtonCommand
frame.element=lineedit
interior.element=lineedit
frame.top=6
frame.bottom=6
frame.left=6
frame.right=6
text.margin.top=2
text.margin.bottom=2
text.margin.left=2
text.margin.right=2
[ToolbarLineEdit]
frame.element=lineedit
interior.element=lineedit
[DropDownButton]
inherits=PanelButtonCommand
indicator.element=arrow-down
[IndicatorArrow]
indicator.element=arrow
indicator.size=8
[ToolboxTab]
inherits=PanelButtonCommand
text.normal.color={on_surface}
text.press.color={on_surface}
text.focus.color={on_surface}
[Tab]
inherits=PanelButtonCommand
interior.element=tab
text.margin.left=8
text.margin.right=8
text.margin.top=0
text.margin.bottom=0
frame.element=tab
indicator.element=tab
indicator.size=22
frame.top=8
frame.bottom=8
frame.left=8
frame.right=8
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
frame.expansion=0
text.bold=false
[TabFrame]
inherits=PanelButtonCommand
frame.element=tabframe
interior.element=tabframe
frame.top=6
frame.bottom=6
frame.left=6
frame.right=6
[TreeExpander]
inherits=PanelButtonCommand
indicator.size=8
indicator.element=tree
[HeaderSection]
inherits=PanelButtonCommand
interior.element=header
frame.element=header
frame.top=0
frame.bottom=1
frame.left=1
frame.right=1
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
frame.expansion=0
[SizeGrip]
indicator.element=resize-grip
[Toolbar]
inherits=PanelButtonCommand
indicator.element=toolbar
indicator.size=5
text.margin=0
interior.element=menubar
frame.element=menubar
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
frame.left=6
frame.right=6
frame.top=0
frame.bottom=1
frame.expansion=0
[Slider]
inherits=PanelButtonCommand
frame.element=slider
focusFrame=true
interior.element=slider
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3
[SliderCursor]
inherits=PanelButtonCommand
frame=false
interior.element=slidercursor
[Progressbar]
inherits=PanelButtonCommand
frame.element=progress
interior.element=progress
text.margin=0
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
text.bold=false
frame.expansion=8
[ProgressbarContents]
inherits=PanelButtonCommand
frame=true
frame.element=progress-pattern
interior.element=progress-pattern
[ItemView]
inherits=PanelButtonCommand
text.margin=0
frame.element=itemview
interior.element=itemview
frame.top=4
frame.bottom=4
frame.left=4
frame.right=4
text.margin.top=0
text.margin.bottom=0
text.margin.left=8
text.margin.right=8
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
min_width=+0.3font
min_height=+0.3font
frame.expansion=0
[Splitter]
interior.element=splitter
frame=false
indicator.size=0
[Scrollbar]
inherits=PanelButtonCommand
indicator.element=arrow
indicator.size=12
[ScrollbarSlider]
inherits=PanelButtonCommand
frame.element=scrollbarslider
interior=false
frame.left=5
frame.right=5
frame.top=5
frame.bottom=5
indicator.element=grip
indicator.size=12
[ScrollbarGroove]
inherits=PanelButtonCommand
interior=false
frame=false
[Menu]
inherits=PanelButtonCommand
frame.top=10
frame.bottom=10
frame.left=10
frame.right=10
frame.element=menu
interior.element=menu
text.normal.color={on_surface}
text.shadow=false
frame.expansion=0
text.bold=false
[MenuItem]
inherits=PanelButtonCommand
frame=true
frame.element=menuitem
interior.element=menuitem
indicator.element=menuitem
text.normal.color={on_surface}
text.focus.color={on_surface}
text.margin.top=0
text.margin.bottom=0
text.margin.left=6
text.margin.right=6
frame.top=4
frame.bottom=4
frame.left=4
frame.right=4
text.bold=false
frame.expansion=0
[MenuBar]
inherits=PanelButtonCommand
frame.element=menubar
interior.element=menubar
frame.bottom=0
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
frame.expansion=0
text.bold=false
[MenuBarItem]
inherits=PanelButtonCommand
interior=true
interior.element=menubaritem
frame.element=menubaritem
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
text.margin.left=4
text.margin.right=4
text.margin.top=0
text.margin.bottom=0
text.normal.color={on_surface}
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
text.bold=false
min_width=+0.3font
min_height=+0.3font
frame.expansion=0
[TitleBar]
inherits=PanelButtonCommand
frame=false
text.margin.top=2
text.margin.bottom=2
text.margin.left=2
text.margin.right=2
interior.element=titlebar
indicator.size=16
indicator.element=mdi
text.normal.color={on_surface}
text.focus.color={on_surface}
text.bold=false
text.italic=true
frame.expansion=0
[ComboBox]
inherits=PanelButtonCommand
frame.element=combo
interior.element=combo
frame.top=6
frame.bottom=6
frame.left=6
frame.right=6
text.margin.top=2
text.margin.bottom=2
text.margin.left=2
text.margin.right=2
text.focus.color={on_surface}
text.press.color={on_surface}
text.toggle.color={on_surface}
[GroupBox]
inherits=GenericFrame
frame=false
text.shadow=0
text.margin=0
text.normal.color={on_surface}
text.focus.color={on_surface}
text.bold=false
frame.expansion=0
[TabBarFrame]
inherits=GenericFrame
frame=false
frame.element=tabBarFrame
interior=false
frame.top=0
frame.bottom=0
frame.left=0
frame.right=0
[ToolTip]
inherits=GenericFrame
frame.top=6
frame.bottom=6
frame.left=6
frame.right=6
interior=true
text.shadow=0
text.margin=6
interior.element=tooltip
frame.element=tooltip
frame.expansion=6
[StatusBar]
inherits=GenericFrame
frame=false
interior=false
[Window]
interior=true
interior.element=window
frame=true
frame.element=window
frame.bottom=10
frame.top=10
text.disabled.color={editor_disabled}

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 170 KiB

View File

@@ -0,0 +1,4 @@
[ColorScheme]
active_colors={on_background}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {on_background}, #ffffff, {on_surface}, {background}, {background}, {border}, {accent}, {on_surface}, {base04}, {accent}, {surface}, {surface}, {surface}, {on_surface}, {base04}
disabled_colors={editor_disabled}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {editor_disabled}, #ffffff, {editor_disabled}, {background}, {background}, {border}, {surface_variant}, {on_surface_variant}, {base04}, {accent}, {surface}, {surface}, {surface}, {editor_disabled}, {base04}
inactive_colors={on_background}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {on_background}, #ffffff, {on_surface}, {background}, {background}, {border}, {surface_variant}, {on_surface_variant}, {base04}, {accent}, {surface}, {surface}, {surface}, {on_surface}, {base04}

View File

@@ -0,0 +1,48 @@
# Qt
1. Download the templates:
- Kvantum: [kvantum.kvconfig](kvantum.kvconfig) and [kvantum.svg](kvantum.svg)
- Qt5ct/Qt6ct: [qtct.conf](qtct.conf)
2. Configure the templates in `~/.config/clrsync/config.toml`:
```toml
[templates.kvantum]
enabled = true
input_path = '~/.config/clrsync/templates/kvantum/kvantum.kvconfig'
output_path = '~/.config/Kvantum/clrsync/clrsync.kvconfig'
reload_cmd = ''
[templates.kvantum-svg]
enabled = true
input_path = '~/.config/clrsync/templates/kvantum/kvantum.svg'
output_path = '~/.config/Kvantum/clrsync/clrsync.svg'
reload_cmd = ''
[templates.qt5ct]
enabled = true
input_path = '~/.config/clrsync/templates/qtct.conf'
output_path = '~/.config/qt5ct/colors/clrsync.conf'
reload_cmd = ''
[templates.qt6ct]
enabled = true
input_path = '~/.config/clrsync/templates/qtct.conf'
output_path = '~/.config/qt6ct/colors/clrsync.conf'
reload_cmd = ''
```
3. Set the theme in `~/.config/Kvantum/kvantum.kvconfig`:
```conf
[General]
theme=clrsync
```
4. Set the theme in `~/.config/qt5ct/qt5ct.conf` and `~/.config/qt6ct/qt6ct.conf`:
```conf
[Appearance]
color_scheme_path=$HOME/.config/qt5ct/colors/clrsync.conf
custom_palette=true
```

View File

@@ -0,0 +1,69 @@
[colors.primary]
background = '{background}'
foreground = '{foreground}'
[colors.cursor]
text = '{background}'
cursor = '{cursor}'
[colors.vi_mode_cursor]
text = '{background}'
cursor = '{cursor}'
[colors.selection]
text = 'CellForeground'
background = '{editor_selected}'
[colors.search.matches]
foreground = '{background}'
background = '{base0A}'
[colors.search.focused_match]
foreground = '{background}'
background = '{accent}'
[colors.footer_bar]
foreground = '{foreground}'
background = '{surface}'
[colors.hints.start]
foreground = '{background}'
background = '{warning}'
[colors.hints.end]
foreground = '{background}'
background = '{surface_variant}'
[colors.line_indicator]
foreground = 'None'
background = 'None'
[colors.normal]
black = '{base00}'
red = '{base08}'
green = '{base01}'
yellow = '{base02}'
blue = '{base06}'
magenta = '{base05}'
cyan = '{base0E}'
white = '{base07}'
[colors.bright]
black = '{border_focused}'
red = '{editor_error}'
green = '{editor_success}'
yellow = '{base0A}'
blue = '{editor_link}'
magenta = '{base0D}'
cyan = '{editor_comment}'
white = '{base0F}'
[colors.dim]
black = '{border}'
red = '{base0C}'
green = '{base01}'
yellow = '{editor_string}'
blue = '{base06}'
magenta = '{base05}'
cyan = '{base0E}'
white = '{base07}'

View File

@@ -0,0 +1,20 @@
# Alacritty
1. Download the [template file](alacritty.toml)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.alacritty]
enabled = true
input_path = '~/.config/clrsync/templates/alacritty.toml'
output_path = '~/.config/alacritty/clrsync.toml'
reload_cmd = ''
```
3. Import the generated color scheme in `~/.config/alacritty/alacritty.toml`:
```toml
[general]
import = ["clrsync.toml"]
```

View File

@@ -0,0 +1,26 @@
background = {background}
foreground = {foreground}
cursor-color = {cursor}
cursor-text = {foreground}
selection-background = {editor_selected}
selection-foreground = {foreground}
palette = 0={base00}
palette = 1={base08}
palette = 2={base01}
palette = 3={base02}
palette = 4={base06}
palette = 5={base05}
palette = 6={base0E}
palette = 7={base07}
palette = 8={border_focused}
palette = 9={editor_error}
palette = 10={editor_success}
palette = 11={base0A}
palette = 12={editor_link}
palette = 13={base0D}
palette = 14={editor_comment}
palette = 15={base0F}

View File

@@ -0,0 +1,19 @@
# Ghostty
1. Download the [template file](ghostty)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.ghostty]
enabled = true
input_path = '~/.config/clrsync/templates/ghostty'
output_path = '~/.config/ghostty/themes/clrsync'
reload_cmd = 'pkill -SIGUSR2 ghostty'
```
3. Set the generated color scheme in `~/.config/ghostty/config`:
```conf
theme = "clrsync"
```

View File

@@ -0,0 +1,32 @@
cursor {cursor}
cursor_text_color {background}
foreground {foreground}
background {background}
selection_foreground {on_surface}
selection_background {surface}
url_color {accent}
color0 {base00}
color8 {base08}
color1 {base01}
color9 {base09}
color2 {base02}
color10 {base0A}
color3 {base03}
color11 {base0B}
color4 {base04}
color12 {base0C}
color5 {base05}
color13 {base0D}
color6 {base06}
color14 {base0E}
color7 {base07}
color15 {base0F}

View File

@@ -0,0 +1,19 @@
# Kitty
1. Download the [template file](kitty.conf)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.kitty]
enabled = true
input_path = '~/.config/clrsync/templates/kitty.conf'
output_path = '~/.config/kitty/clrsync.conf'
reload_cmd = 'pkill -SIGUSR1 kitty'
```
3. Import the generated color scheme in `~/.config/kitty/kitty.conf`:
```conf
include clrsync.conf
```

View File

@@ -0,0 +1,372 @@
vim.cmd("highlight clear")
vim.cmd("syntax reset")
vim.g.colors_name = "clrsync"
local palette = {
-- General UI
bg = "{editor_background.hex}",
bg_alt = "{surface_variant.hex}",
fg = "{editor_foreground.hex}",
fg_alt = "{on_surface_variant.hex}",
grey = "{editor_line_number.hex}",
-- Accent / keyword colors
blue = "{editor_keyword.hex}",
cyan = "{editor_info.hex}",
violet = "{editor_link.hex}",
magenta = "{editor_parameter.hex}",
orange = "{editor_number.hex}",
yellow = "{editor_warning.hex}",
green = "{success.hex}",
red = "{error.hex}",
-- Editor - Basic
cursor = "{cursor.hex}",
selection = "{editor_selection.hex}",
dark_blue = "{editor_selection.hex}",
line_highlight = "{editor_line_highlight.hex}",
-- Editor - Gutter
line_number = "{editor_line_number.hex}",
line_number_active = "{editor_line_number_active.hex}",
-- Editor - Syntax
comment = "{editor_comment.hex}",
string = "{editor_string.hex}",
number = "{editor_number.hex}",
boolean = "{editor_boolean.hex}",
keyword = "{editor_keyword.hex}",
operator = "{editor_operator.hex}",
function_ = "{editor_function.hex}",
variable = "{editor_variable.hex}",
parameter = "{editor_parameter.hex}",
property = "{editor_property.hex}",
constant = "{editor_constant.hex}",
type_ = "{editor_type.hex}",
tag = "{editor_tag.hex}",
punctuation = "{editor_punctuation.hex}",
link = "{editor_link.hex}",
regex = "{editor_regex.hex}",
attribute = "{editor_attribute.hex}",
decorator = "{editor_decorator.hex}",
escape_char = "{editor_escape_character.hex}",
-- Editor - UI
border = "{border_focused.hex}",
indent_guide = "{editor_indent_guide.hex}",
search_match = "{editor_search_match.hex}",
search_match_active = "{editor_search_match_active.hex}",
bracket_match = "{editor_bracket_match.hex}",
whitespace = "{editor_whitespace.hex}",
-- Editor - Diagnostics
error_fg = "{editor_error.hex}",
warning_fg = "{editor_warning.hex}",
info_fg = "{editor_info.hex}",
hint_fg = "{editor_hint.hex}",
-- Editor - Diff
diff_add = "{editor_inserted.hex}",
diff_change = "{editor_modified.hex}",
diff_delete = "{editor_deleted.hex}",
-- Semantic
success = "{success.hex}",
warning = "{warning.hex}",
error = "{error.hex}",
info = "{info.hex}",
-- Base (terminal / muted)
base0 = "{background.hex}",
base1 = "{surface.hex}",
base2 = "{surface_variant.hex}",
base3 = "{border.hex}",
base4 = "{editor_line_number.hex}",
base5 = "{editor_comment.hex}",
base6 = "{editor_line_number.hex}",
base7 = "{on_surface_variant.hex}",
base8 = "{foreground.hex}",
}
local function set_hl(group, opts)
vim.api.nvim_set_hl(0, group, opts)
end
vim.o.winborder = "rounded"
--- General UI
set_hl("Normal", { bg = palette.bg, fg = palette.fg })
set_hl("NormalFloat", { bg = palette.bg, fg = palette.fg })
set_hl("NormalBorder", { bg = palette.bg, fg = palette.fg })
set_hl("EndOfBuffer", { bg = palette.bg, fg = palette.bg })
set_hl("Visual", { bg = palette.dark_blue })
set_hl("VisualBold", { bg = palette.dark_blue, bold = true })
set_hl("LineNr", { bg = palette.bg, fg = palette.grey })
set_hl("Cursor", { bg = palette.blue })
set_hl("CursorLine", { bg = palette.bg_alt })
set_hl("CursorLineNr", { bg = palette.bg_alt, fg = palette.fg })
set_hl("CursorColumn", { bg = palette.bg_alt })
set_hl("Folded", { bg = palette.bg_alt, fg = palette.base5 })
set_hl("FoldColumn", { bg = palette.bg, fg = palette.fg_alt })
set_hl("SignColumn", { bg = palette.bg })
set_hl("ColorColumn", { bg = palette.bg_alt })
set_hl("IndentGuide", { fg = palette.indent_guide })
set_hl("IndentGuideEven", { link = "IndentGuide" })
set_hl("IndentGuideOdd", { link = "IndentGuide" })
set_hl("TermCursor", { fg = palette.fg, reverse = true })
set_hl("TermCursorNC", { fg = palette.fg_alt, reverse = true })
set_hl("TermNormal", { link = "Normal" })
set_hl("TermNormalNC", { link = "TermNormal" })
set_hl("WildMenu", { bg = palette.dark_blue, fg = palette.fg })
set_hl("Separator", { fg = palette.fg_alt })
set_hl("VertSplit", { bg = palette.bg, fg = palette.grey })
set_hl("TabLine", { bg = palette.bg_alt, fg = palette.base7, bold = true })
set_hl("TabLineSel", { bg = palette.bg, fg = palette.blue, bold = true })
set_hl("TabLineFill", { bg = palette.base1, bold = true })
set_hl("StatusLine", { bg = palette.base3, fg = palette.base8 })
set_hl("StatusLineNC", { bg = palette.bg_alt, fg = palette.base6 })
set_hl("StatusLinePart", { bg = palette.bg_alt, fg = palette.base6, bold = true })
set_hl("StatusLinePartNC", { link = "StatusLinePart" })
set_hl("Pmenu", { bg = palette.bg_alt, fg = palette.fg })
set_hl("PmenuSel", { bg = palette.blue, fg = palette.base0 })
set_hl("PmenuSelBold", { bg = palette.blue, fg = palette.base0, bold = true })
set_hl("PmenuSbar", { bg = palette.bg_alt })
set_hl("PmenuThumb", { bg = palette.grey })
set_hl("FloatBorder", { fg = palette.border, bg = palette.bg })
--- Search, Highlight, Conceal
set_hl("Search", { bg = palette.dark_blue, fg = palette.fg })
set_hl("Substitute", { fg = palette.red, bold = true, strikethrough = true })
set_hl("IncSearch", { bg = palette.yellow, fg = palette.bg, bold = true })
set_hl("IncSearchCursor", { reverse = true })
set_hl("Conceal", { fg = palette.grey })
set_hl("SpecialKey", { fg = palette.violet, bold = true })
set_hl("NonText", { fg = palette.fg_alt, bold = true })
set_hl("MatchParen", { fg = palette.red, bold = true })
set_hl("Whitespace", { fg = palette.whitespace })
set_hl("Highlight", { bg = palette.bg_alt })
set_hl("HighlightSubtle", { link = "Highlight" })
set_hl("Question", { fg = palette.green, bold = true })
set_hl("File", { fg = palette.fg })
set_hl("Directory", { fg = palette.violet, bold = true })
set_hl("Title", { fg = palette.violet, bold = true })
set_hl("Bold", { bold = true })
set_hl("Emphasis", { italic = true })
--- Messages
set_hl("Msg", { fg = palette.green })
set_hl("MoreMsg", { fg = palette.blue })
set_hl("WarningMsg", { fg = palette.yellow })
set_hl("Error", { fg = palette.red })
set_hl("ErrorMsg", { fg = palette.red })
set_hl("ModeMsg", { fg = palette.violet })
set_hl("Todo", { fg = palette.yellow, bold = true })
set_hl("healthError", { link = "ErrorMsg" })
set_hl("healthSuccess", { link = "Msg" })
set_hl("healthWarning", { link = "WarningMsg" })
--- Syntax
set_hl("Tag", { fg = palette.cyan, bold = true })
set_hl("Link", { fg = palette.green, underline = true })
set_hl("URL", { link = "Link" })
set_hl("Underlined", { fg = palette.cyan, underline = true })
set_hl("Comment", { fg = palette.comment, italic = true })
set_hl("CommentBold", { fg = palette.comment, bold = true })
set_hl("SpecialComment", { fg = palette.base7, bold = true })
set_hl("Macro", { fg = palette.violet })
set_hl("Define", { fg = palette.violet, bold = true })
set_hl("Include", { fg = palette.violet, bold = true })
set_hl("PreProc", { fg = palette.violet, bold = true })
set_hl("PreCondit", { fg = palette.violet, bold = true })
set_hl("Label", { fg = palette.blue })
set_hl("Repeat", { fg = palette.blue })
set_hl("Keyword", { fg = palette.blue })
set_hl("Operator", { fg = palette.operator })
set_hl("Delimiter", { fg = palette.blue })
set_hl("Statement", { fg = palette.blue })
set_hl("Exception", { fg = palette.blue })
set_hl("Conditional", { fg = palette.blue })
set_hl("Variable", { fg = palette.variable })
set_hl("VariableBuiltin", { fg = palette.magenta, bold = true })
set_hl("Constant", { fg = palette.violet, bold = true })
set_hl("Number", { fg = palette.orange })
set_hl("Float", { link = "Number" })
set_hl("Boolean", { fg = palette.orange, bold = true })
set_hl("Enum", { fg = palette.orange })
set_hl("Character", { fg = palette.violet, bold = true })
set_hl("SpecialChar", { fg = palette.violet, bold = true })
set_hl("String", { fg = palette.green })
set_hl("StringDelimiter", { link = "String" })
set_hl("Special", { fg = palette.violet })
set_hl("SpecialBold", { fg = palette.violet, bold = true })
set_hl("Field", { fg = palette.violet })
set_hl("Argument", { fg = palette.parameter })
set_hl("Attribute", { fg = palette.attribute })
set_hl("Identifier", { fg = palette.variable })
set_hl("Property", { fg = palette.property })
set_hl("Function", { fg = palette.function_ })
set_hl("FunctionBuiltin", { fg = palette.function_, bold = true })
set_hl("KeywordFunction", { fg = palette.blue, bold = true })
set_hl("Method", { fg = palette.function_ })
set_hl("Type", { fg = palette.type_ })
set_hl("Typedef", { fg = palette.blue })
set_hl("TypeBuiltin", { fg = palette.type_, bold = true })
set_hl("Class", { fg = palette.blue })
set_hl("StorageClass", { fg = palette.blue })
set_hl("Structure", { fg = palette.blue })
set_hl("Regexp", { fg = palette.regex })
set_hl("RegexpSpecial", { fg = palette.regex })
set_hl("RegexpDelimiter", { fg = palette.regex, bold = true })
set_hl("RegexpKey", { fg = palette.regex, bold = true })
set_hl("CommentURL", { link = "URL" })
set_hl("CommentLabel", { link = "CommentBold" })
set_hl("CommentSection", { link = "CommentBold" })
set_hl("Noise", { link = "Comment" })
--- Diff
set_hl("DiffAddedGutter", { fg = palette.green, bold = true })
set_hl("DiffModifiedGutter", { fg = palette.orange, bold = true })
set_hl("DiffRemovedGutter", { fg = palette.red, bold = true })
set_hl("DiffAdd", { link = "DiffAddedGutter" })
set_hl("DiffChange", { link = "DiffModifiedGutter" })
set_hl("DiffDelete", { link = "DiffRemovedGutter" })
set_hl("diffAdded", { fg = palette.green, bg = palette.bg_alt })
set_hl("diffChanged", { fg = palette.violet })
set_hl("diffRemoved", { fg = palette.red, bg = palette.base3 })
set_hl("diffLine", { fg = palette.violet })
set_hl("diffIndexLine", { fg = palette.cyan })
set_hl("diffSubname", { fg = palette.cyan })
set_hl("diffFile", { fg = palette.cyan })
set_hl("diffOldFile", { fg = palette.blue })
set_hl("diffNewFile", { fg = palette.blue })
--- Markdown
set_hl("markdownCode", { link = "Comment" })
set_hl("markdownCodeBlock", { link = "markdownCode" })
set_hl("markdownH1", { bold = true })
set_hl("markdownH2", { bold = true })
set_hl("markdownLinkText", { underline = true })
--- LSP / Diagnostics
set_hl("LspHighlight", { bg = palette.bg_alt, bold = true })
set_hl("LspSignatureActiveParameter", { fg = palette.violet })
set_hl("DiagnosticError", { fg = palette.error })
set_hl("DiagnosticWarn", { fg = palette.warning })
set_hl("DiagnosticInfo", { fg = palette.info })
set_hl("DiagnosticHint", { fg = palette.hint_fg })
set_hl("DiagnosticFloatingError", { link = "ErrorMsg" })
set_hl("DiagnosticFloatingWarn", { link = "WarningMsg" })
set_hl("DiagnosticFloatingInfo", { link = "MoreMsg" })
set_hl("DiagnosticFloatingHint", { link = "Msg" })
set_hl("DiagnosticDefaultError", { link = "ErrorMsg" })
set_hl("DiagnosticDefaultWarn", { link = "WarningMsg" })
set_hl("DiagnosticDefaultInfo", { link = "MoreMsg" })
set_hl("DiagnosticDefaultHint", { link = "Msg" })
set_hl("DiagnosticVirtualTextError", { link = "ErrorMsg" })
set_hl("DiagnosticVirtualTextWarn", { link = "WarningMsg" })
set_hl("DiagnosticVirtualTextInfo", { link = "MoreMsg" })
set_hl("DiagnosticVirtualTextHint", { link = "Msg" })
set_hl("DiagnosticSignError", { link = "ErrorMsg" })
set_hl("DiagnosticSignWarning", { link = "WarningMsg" })
set_hl("DiagnosticSignInformation", { link = "MoreMsg" })
set_hl("DiagnosticSignHint", { link = "Msg" })
set_hl("LspReferenceText", { link = "LspHighlight" })
set_hl("LspReferenceRead", { link = "LspHighlight" })
set_hl("LspReferenceWrite", { link = "LspHighlight" })
--- Tree-Sitter
set_hl("@annotation", { link = "PreProc" })
set_hl("@attribute", { link = "Attribute" })
set_hl("@conditional", { link = "Conditional" })
set_hl("@comment", { link = "Comment" })
set_hl("@constructor", { link = "Structure" })
set_hl("@constant", { link = "Constant" })
set_hl("@constant.builtin", { link = "Constant" })
set_hl("@constant.macro", { link = "Macro" })
set_hl("@error", { link = "Error" })
set_hl("@exception", { link = "Exception" })
set_hl("@field", { link = "Field" })
set_hl("@float", { link = "Float" })
set_hl("@function", { link = "Function" })
set_hl("@function.builtin", { link = "FunctionBuiltin" })
set_hl("@function.macro", { link = "Macro" })
set_hl("@include", { link = "Include" })
set_hl("@keyword", { link = "Keyword" })
set_hl("@keyword.function", { link = "KeywordFunction" })
set_hl("@label", { link = "Label" })
set_hl("@math", { link = "Special" })
set_hl("@method", { link = "Method" })
set_hl("@namespace", { link = "Directory" })
set_hl("@number", { link = "Number" })
set_hl("@boolean", { link = "Boolean" })
set_hl("@operator", { link = "Operator" })
set_hl("@parameter", { link = "Argument" })
set_hl("@parameter.reference", { link = "Argument" })
set_hl("@property", { link = "Property" })
set_hl("@punctuation.delimiter", { link = "Delimiter" })
set_hl("@punctuation.bracket", { link = "Delimiter" })
set_hl("@punctuation.special", { link = "Delimiter" })
set_hl("@repeat", { link = "Repeat" })
set_hl("@string", { link = "String" })
set_hl("@string.regex", { link = "StringDelimiter" })
set_hl("@string.escape", { link = "StringDelimiter" })
set_hl("@structure", { link = "Structure" })
set_hl("@tag", { link = "Tag" })
set_hl("@tag.attribute", { link = "Attribute" })
set_hl("@tag.delimiter", { link = "Delimiter" })
set_hl("@strong", { link = "Bold" })
set_hl("@uri", { link = "URL" })
set_hl("@warning", { link = "WarningMsg" })
set_hl("@danger", { link = "ErrorMsg" })
set_hl("@type", { link = "Type" })
set_hl("@type.builtin", { link = "TypeBuiltin" })
set_hl("@variable", { fg = palette.variable })
set_hl("@variable.builtin", { link = "VariableBuiltin" })
set_hl("@text", { link = "Normal" })
set_hl("@text.strong", { fg = palette.fg, bold = true })
set_hl("@text.emphasis", { link = "Emphasis" })
set_hl("@text.underline", { underline = true })
set_hl("@text.title", { link = "Title" })
set_hl("@text.uri", { link = "URL" })
set_hl("@text.note", { link = "MoreMsg" })
set_hl("@text.warning", { link = "WarningMsg" })
set_hl("@text.danger", { link = "ErrorMsg" })
set_hl("@todo", { link = "Todo" })
--- NetRW
set_hl("netrwClassify", { fg = palette.blue })
set_hl("netrwDir", { link = "Directory" })
set_hl("netrwExe", { fg = palette.green, bold = true })
set_hl("netrwMakefile", { fg = palette.yellow, bold = true })
set_hl("netrwTreeBar", { link = "Comment" })

View File

@@ -0,0 +1,19 @@
# Neovim
1. Download the [template file](nvim.lua)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.nvim]
enabled = true
input_path = '~/.config/clrsync/templates/nvim.lua'
output_path = '~/.config/nvim/colors/clrsync.lua'
reload_cmd = ''
```
3. Set the colorscheme in your Neovim config:
```lua
vim.cmd.colorscheme 'clrsync'
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
# Visual Studio Code
1. Install the [clrsync VS Code theme](https://marketplace.visualstudio.com/items?itemName=obsqrbtz.clrsync)
2. Download the [template file](code.json)
3. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.vscode]
enabled = true
input_path = '~/.config/clrsync/templates/code.json'
output_path = '~/.vscode/extensions/obsqrbtz.clrsync-1.0.2/themes/clrsync-color-theme.json'
reload_cmd = ''
```
4. Set the `clrsync` color scheme in VS Code

View File

@@ -0,0 +1,25 @@
$primary = rgb({accent_stripped})
$surface = rgb({surface_stripped})
$secondary = rgb({accent_secondary_stripped})
$error = rgb({error_stripped})
$tertiary = rgb({base06_stripped})
$surface_lowest = rgb({background_stripped})
general {
col.active_border = $primary
col.inactive_border = $surface
}
group {
col.border_active = $secondary
col.border_inactive = $surface
col.border_locked_active = $error
col.border_locked_inactive = $surface
groupbar {
col.active = $secondary
col.inactive = $surface
col.locked_active = $error
col.locked_inactive = $surface
}
}

View File

@@ -0,0 +1,19 @@
# Hyprland
1. Download the [template file](hyprland.conf)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.hyprland]
enabled = true
input_path = '~/.config/clrsync/templates/hyprland.conf'
output_path = '~/.config/hypr/clrsync.conf'
reload_cmd = ''
```
3. Source the generated config in `~/.config/hypr/hyprland.conf`:
```conf
source = clrsync.conf
```

Binary file not shown.

View File

@@ -9,6 +9,8 @@
#include "core/common/version.hpp"
#include "core/config/config.hpp"
#include "core/io/toml_file.hpp"
#include "core/palette/hellwal_generator.hpp"
#include "core/palette/matugen_generator.hpp"
#include "core/palette/palette_file.hpp"
#include "core/palette/palette_manager.hpp"
#include "core/theme/theme_renderer.hpp"
@@ -91,6 +93,48 @@ void setup_argument_parser(argparse::ArgumentParser &program)
auto &group = program.add_mutually_exclusive_group();
group.add_argument("-t", "--theme").help("sets theme <theme_name> to apply");
group.add_argument("-p", "--path").help("sets theme file <path/to/theme> to apply");
program.add_argument("-g", "--generate").nargs(1).help("generate palette from <image path>");
program.add_argument("--generate-color")
.nargs(1)
.help("generate palette from a color (hex), used with --generator matugen");
program.add_argument("--generator")
.default_value(std::string("hellwal"))
.help("palette generator to use (hellwal)")
.metavar("GENERATOR");
program.add_argument("--matugen-type")
.default_value(std::string("scheme-tonal-spot"))
.help("matugen: Sets a custom color scheme type")
.metavar("TYPE");
program.add_argument("--matugen-mode")
.default_value(std::string("dark"))
.help("matugen: Which mode to use for the color scheme (light,dark)")
.metavar("MODE");
program.add_argument("--matugen-contrast")
.default_value(std::string("0.0"))
.help("matugen: contrast value from -1 to 1")
.metavar("FLOAT");
// hellwal generator options
program.add_argument("--hellwal-neon").help("hellwal: enable neon mode").flag();
program.add_argument("--hellwal-dark").help("hellwal: prefer dark palettes").flag();
program.add_argument("--hellwal-light").help("hellwal: prefer light palettes").flag();
program.add_argument("--hellwal-color").help("hellwal: enable color mode").flag();
program.add_argument("--hellwal-invert").help("hellwal: invert colors").flag();
program.add_argument("--hellwal-dark-offset")
.default_value(std::string("0.0"))
.help("hellwal: dark offset (float)")
.metavar("FLOAT");
program.add_argument("--hellwal-bright-offset")
.default_value(std::string("0.0"))
.help("hellwal: bright offset (float)")
.metavar("FLOAT");
program.add_argument("--hellwal-gray-scale")
.default_value(std::string("0.0"))
.help("hellwal: gray scale factor (float)")
.metavar("FLOAT");
}
int main(int argc, char *argv[])
@@ -136,6 +180,136 @@ int main(int argc, char *argv[])
return handle_apply_theme(program, default_theme);
}
if (program.is_used("--generate"))
{
std::string image_path;
if (program.is_used("--generate"))
image_path = program.get<std::string>("--generate");
std::string generator_name = program.get<std::string>("--generator");
clrsync::core::palette pal;
if (generator_name == "hellwal")
{
clrsync::core::hellwal_generator gen;
clrsync::core::hellwal_generator::options opts{};
if (program.is_used("--hellwal-neon"))
opts.neon = true;
if (program.is_used("--hellwal-dark"))
opts.dark = true;
if (program.is_used("--hellwal-light"))
opts.light = true;
if (program.is_used("--hellwal-color"))
opts.color = true;
if (program.is_used("--hellwal-invert"))
opts.invert = true;
try
{
std::string s1 = program.get<std::string>("--hellwal-dark-offset");
opts.dark_offset = std::stof(s1);
}
catch (...)
{
}
try
{
std::string s2 = program.get<std::string>("--hellwal-bright-offset");
opts.bright_offset = std::stof(s2);
}
catch (...)
{
}
try
{
std::string s3 = program.get<std::string>("--hellwal-gray-scale");
opts.gray_scale = std::stof(s3);
}
catch (...)
{
}
pal = gen.generate_from_image(image_path, opts);
}
else if (generator_name == "matugen")
{
clrsync::core::matugen_generator gen;
clrsync::core::matugen_generator::options opts{};
try
{
opts.type = program.get<std::string>("--matugen-type");
}
catch (...)
{
}
try
{
opts.type = program.get<std::string>("--matugen-type");
}
catch (...)
{
}
try
{
opts.mode = program.get<std::string>("--matugen-mode");
}
catch (...)
{
}
try
{
std::string s = program.get<std::string>("--matugen-contrast");
opts.contrast = std::stof(s);
}
catch (...)
{
}
if (program.is_used("--generate-color"))
{
std::string color = program.get<std::string>("--generate-color");
pal = gen.generate_from_color(color, opts);
}
else
{
pal = gen.generate_from_image(image_path, opts);
}
}
else
{
std::cerr << "Unknown generator: " << generator_name << std::endl;
return 1;
}
if (pal.name().empty())
{
std::filesystem::path p(image_path);
pal.set_name("generated:" + p.filename().string());
}
auto dir = clrsync::core::config::instance().palettes_path();
clrsync::core::palette_manager<clrsync::core::io::toml_file> pal_mgr;
pal_mgr.save_palette_to_file(pal, dir);
clrsync::core::theme_renderer<clrsync::core::io::toml_file> renderer;
std::filesystem::path file_path = std::filesystem::path(dir) / (pal.name() + ".toml");
auto res = renderer.apply_theme_from_path(file_path.string());
if (!res)
{
std::cerr << "Failed to apply generated palette: " << res.error().description()
<< std::endl;
return 1;
}
std::cout << "Generated and applied palette: " << pal.name() << std::endl;
return 0;
}
std::cout << program << std::endl;
return 0;

View File

@@ -1,5 +1,7 @@
set(CORE_SOURCES
palette/color.cpp
palette/hellwal_generator.cpp
palette/matugen_generator.cpp
io/toml_file.cpp
config/config.cpp
common/utils.cpp

View File

@@ -6,7 +6,7 @@
namespace clrsync::core
{
const std::string GIT_SEMVER = "0.1.6+git.gdff3e91";
const std::string GIT_SEMVER = "1.1.1+git.g3277873";
const std::string version_string();
} // namespace clrsync::core

View File

@@ -198,7 +198,7 @@ Result<void> config::save_config_value(const std::string &section, const std::st
if (!m_temp_file)
{
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
m_temp_file->parse();
(void)m_temp_file->parse();
}
m_temp_file->set_value(section, key, value);
@@ -347,7 +347,7 @@ Result<void> config::remove_template(const std::string &key)
if (!m_temp_file)
{
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
m_temp_file->parse();
(void)m_temp_file->parse();
}
m_temp_file->remove_section("templates." + key);
return m_temp_file->save_file();

View File

@@ -26,6 +26,7 @@ constexpr const char *COLOR_KEYS[] = {
"cursor",
"accent",
"accent_secondary",
// Semantic
"success",
@@ -38,22 +39,72 @@ constexpr const char *COLOR_KEYS[] = {
"on_warning",
"on_error",
// Editor
// Editor - Basic
"editor_background",
"editor_command",
"editor_comment",
"editor_disabled",
"editor_emphasis",
"editor_error",
"editor_inactive",
"editor_line_number",
"editor_link",
"editor_main",
"editor_selected",
"editor_foreground",
"editor_line_highlight",
"editor_selection",
"editor_selection_inactive",
"editor_cursor",
"editor_whitespace",
// Editor - Gutter
"editor_gutter_background",
"editor_gutter_foreground",
"editor_line_number",
"editor_line_number_active",
// Editor - Syntax
"editor_comment",
"editor_string",
"editor_success",
"editor_number",
"editor_boolean",
"editor_keyword",
"editor_operator",
"editor_function",
"editor_variable",
"editor_parameter",
"editor_property",
"editor_constant",
"editor_type",
"editor_class",
"editor_interface",
"editor_enum",
"editor_namespace",
"editor_attribute",
"editor_decorator",
"editor_tag",
"editor_punctuation",
"editor_link",
"editor_regex",
"editor_escape_character",
// Editor - Diagnostics
"editor_invalid",
"editor_error",
"editor_error_background",
"editor_warning",
"editor_warning_background",
"editor_info",
"editor_info_background",
"editor_hint",
"editor_hint_background",
// Editor - UI Elements
"editor_active_line_border",
"editor_indent_guide",
"editor_indent_guide_active",
"editor_bracket_match",
"editor_search_match",
"editor_search_match_active",
"editor_find_range_highlight",
// Editor - Diff
"editor_deleted",
"editor_inserted",
"editor_modified",
"editor_ignored",
"editor_folded_background",
// Terminal
"base00",
@@ -93,6 +144,7 @@ inline const std::unordered_map<std::string, uint32_t> DEFAULT_COLORS = {
{"cursor", 0xd2d2d2ff},
{"accent", 0x9a8652ff},
{"accent_secondary", 0x9a8652ff},
{"success", 0x668a51ff},
{"info", 0x3a898cff},
@@ -104,21 +156,72 @@ inline const std::unordered_map<std::string, uint32_t> DEFAULT_COLORS = {
{"on_warning", 0xd2d2d2ff},
{"on_error", 0xd2d2d2ff},
// Editor - Basic
{"editor_background", 0x111111ff},
{"editor_command", 0x3a898cff},
{"editor_comment", 0x849899ff},
{"editor_disabled", 0x849899ff},
{"editor_emphasis", 0xa9dc86ff},
{"editor_error", 0xaa4e4aff},
{"editor_inactive", 0x849899ff},
{"editor_line_number", 0x849899ff},
{"editor_link", 0xb0779eff},
{"editor_main", 0xd2d2d2ff},
{"editor_selected", 0x242424ff},
{"editor_foreground", 0xd2d2d2ff},
{"editor_line_highlight", 0x191919ff},
{"editor_selection", 0x242424ff},
{"editor_selection_inactive", 0x1d1c1cff},
{"editor_cursor", 0xd2d2d2ff},
{"editor_whitespace", 0x3a3a3aff},
// Editor - Gutter
{"editor_gutter_background", 0x111111ff},
{"editor_gutter_foreground", 0x849899ff},
{"editor_line_number", 0x849899ff},
{"editor_line_number_active", 0xd2d2d2ff},
// Editor - Syntax
{"editor_comment", 0x849899ff},
{"editor_string", 0x9a8652ff},
{"editor_success", 0x668a51ff},
{"editor_number", 0xb47837ff},
{"editor_boolean", 0xb47837ff},
{"editor_keyword", 0x3a898cff},
{"editor_operator", 0xd2d2d2ff},
{"editor_function", 0xa9dc86ff},
{"editor_variable", 0xd2d2d2ff},
{"editor_parameter", 0xb0779eff},
{"editor_property", 0x9a8652ff},
{"editor_constant", 0xb47837ff},
{"editor_type", 0x3a898cff},
{"editor_class", 0x3a898cff},
{"editor_interface", 0x3a898cff},
{"editor_enum", 0x3a898cff},
{"editor_namespace", 0xb0779eff},
{"editor_attribute", 0xa9dc86ff},
{"editor_decorator", 0xa9dc86ff},
{"editor_tag", 0xaa4e4aff},
{"editor_punctuation", 0xd2d2d2ff},
{"editor_link", 0xb0779eff},
{"editor_regex", 0xaa477bff},
{"editor_escape_character", 0xb47837ff},
// Editor - Diagnostics
{"editor_invalid", 0xaa4e4aff},
{"editor_error", 0xaa4e4aff},
{"editor_error_background", 0x3a1a1aff},
{"editor_warning", 0xb47837ff},
{"editor_warning_background", 0x3a2a1aff},
{"editor_info", 0x3a898cff},
{"editor_info_background", 0x1a2a3aff},
{"editor_hint", 0x668a51ff},
{"editor_hint_background", 0x1a2a1aff},
// Editor - UI Elements
{"editor_active_line_border", 0x2e2e2eff},
{"editor_indent_guide", 0x2a2a2aff},
{"editor_indent_guide_active", 0x3a3a3aff},
{"editor_bracket_match", 0x3a898cff},
{"editor_search_match", 0x9a865280},
{"editor_search_match_active", 0x9a8652ff},
{"editor_find_range_highlight", 0x9a865240},
// Editor - Diff
{"editor_deleted", 0xaa4e4aff},
{"editor_inserted", 0x668a51ff},
{"editor_modified", 0x9a8652ff},
{"editor_ignored", 0x849899ff},
{"editor_folded_background", 0x191919ff},
{"base00", 0x111111ff},
{"base01", 0x668a51ff},

View File

@@ -0,0 +1,19 @@
#ifndef CLRSYNC_CORE_PALETTE_GENERATOR_HPP
#define CLRSYNC_CORE_PALETTE_GENERATOR_HPP
#include <string>
#include "core/palette/palette.hpp"
namespace clrsync::core
{
class generator
{
public:
generator() = default;
virtual ~generator() = default;
virtual palette generate_from_image(const std::string &image_path) = 0;
};
} // namespace clrsync::core
#endif

View File

@@ -0,0 +1,232 @@
#include "hellwal_generator.hpp"
#include "core/palette/color.hpp"
#include <array>
#include <cstdio>
#include <filesystem>
#include <regex>
#include <string>
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif
namespace clrsync::core
{
static std::string run_command_capture_output(const std::string &cmd)
{
std::array<char, 4096> buffer;
std::string result;
FILE *pipe = popen(cmd.c_str(), "r");
if (!pipe)
return {};
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe) != nullptr)
{
result += buffer.data();
}
int rc = pclose(pipe);
(void)rc;
return result;
}
palette hellwal_generator::generate_from_image(const std::string &image_path)
{
options default_opts{};
return generate_from_image(image_path, default_opts);
}
palette hellwal_generator::generate_from_image(const std::string &image_path, const options &opts)
{
palette pal;
std::filesystem::path p(image_path);
pal.set_name("hellwal:" + p.filename().string());
pal.set_file_path(image_path);
std::string cmd = "hellwal -i '" + image_path + "' --json";
if (opts.neon)
cmd += " --neon-mode";
if (opts.dark)
cmd += " --dark";
if (opts.light)
cmd += " --light";
if (opts.color)
cmd += " --color";
if (opts.dark_offset > 0.0f)
cmd += " --dark-offset " + std::to_string(opts.dark_offset);
if (opts.bright_offset > 0.0f)
cmd += " --bright-offset " + std::to_string(opts.bright_offset);
if (opts.invert)
cmd += " --invert";
if (opts.gray_scale > 0.0f)
cmd += " --gray-scale " + std::to_string(opts.gray_scale);
std::string out = run_command_capture_output(cmd);
if (out.empty())
return {};
std::regex special_re(
"\"(background|foreground|cursor|border)\"\\s*:\\s*\"(#[0-9A-Fa-f]{6,8})\"");
for (std::sregex_iterator it(out.begin(), out.end(), special_re), end; it != end; ++it)
{
std::smatch m = *it;
std::string key = m[1].str();
std::string hex = m[2].str();
try
{
color col;
col.from_hex_string(hex);
pal.set_color(key, col);
}
catch (...)
{
}
}
std::regex color_re("\"color(\\d{1,2})\"\\s*:\\s*\"(#[0-9A-Fa-f]{6,8})\"");
for (std::sregex_iterator it(out.begin(), out.end(), color_re), end; it != end; ++it)
{
std::smatch m = *it;
int idx = std::stoi(m[1].str());
if (idx < 0 || idx > 15)
continue;
std::string hex = m[2].str();
std::string key = "base0";
if (idx < 10)
key += std::to_string(idx);
else
key += static_cast<char>('A' + (idx - 10));
try
{
color col;
col.from_hex_string(hex);
pal.set_color(key, col);
}
catch (...)
{
}
}
auto get_color_by_index = [&](int idx) -> const color & {
std::string key = "base0";
if (idx < 10)
key += std::to_string(idx);
else
key += static_cast<char>('A' + (idx - 10));
return pal.get_color(key);
};
pal.set_color("base00", get_color_by_index(0));
pal.set_color("base01", get_color_by_index(8));
pal.set_color("base02", get_color_by_index(8));
pal.set_color("base03", get_color_by_index(8));
pal.set_color("base04", get_color_by_index(7));
pal.set_color("base05", get_color_by_index(7));
pal.set_color("base06", get_color_by_index(15));
pal.set_color("base07", get_color_by_index(15));
pal.set_color("base08", get_color_by_index(1));
pal.set_color("base09", get_color_by_index(9));
pal.set_color("base0A", get_color_by_index(3));
pal.set_color("base0B", get_color_by_index(2));
pal.set_color("base0C", get_color_by_index(6));
pal.set_color("base0D", get_color_by_index(4));
pal.set_color("base0E", get_color_by_index(5));
pal.set_color("base0F", get_color_by_index(11));
pal.set_color("accent", get_color_by_index(4));
pal.set_color("accent_secondary", get_color_by_index(6));
pal.set_color("border", get_color_by_index(8));
pal.set_color("border_focused", get_color_by_index(4));
pal.set_color("error", get_color_by_index(1));
pal.set_color("warning", get_color_by_index(3));
pal.set_color("success", get_color_by_index(2));
pal.set_color("info", get_color_by_index(4));
pal.set_color("on_error", get_color_by_index(0));
pal.set_color("on_warning", get_color_by_index(0));
pal.set_color("on_success", get_color_by_index(0));
pal.set_color("on_info", get_color_by_index(0));
pal.set_color("surface", get_color_by_index(0));
pal.set_color("surface_variant", get_color_by_index(8));
pal.set_color("on_surface", get_color_by_index(7));
pal.set_color("on_surface_variant", get_color_by_index(7));
pal.set_color("on_background", get_color_by_index(7));
// Editor - Basic
pal.set_color("editor_background", get_color_by_index(0));
pal.set_color("editor_foreground", get_color_by_index(7));
pal.set_color("editor_line_highlight", get_color_by_index(8));
pal.set_color("editor_selection", get_color_by_index(8));
pal.set_color("editor_selection_inactive", get_color_by_index(8));
pal.set_color("editor_cursor", get_color_by_index(7));
pal.set_color("editor_whitespace", get_color_by_index(8));
// Editor - Gutter
pal.set_color("editor_gutter_background", get_color_by_index(0));
pal.set_color("editor_gutter_foreground", get_color_by_index(8));
pal.set_color("editor_line_number", get_color_by_index(8));
pal.set_color("editor_line_number_active", get_color_by_index(7));
// Editor - Syntax
pal.set_color("editor_comment", get_color_by_index(8));
pal.set_color("editor_string", get_color_by_index(2));
pal.set_color("editor_number", get_color_by_index(3));
pal.set_color("editor_boolean", get_color_by_index(3));
pal.set_color("editor_keyword", get_color_by_index(5));
pal.set_color("editor_operator", get_color_by_index(7));
pal.set_color("editor_function", get_color_by_index(11));
pal.set_color("editor_variable", get_color_by_index(7));
pal.set_color("editor_parameter", get_color_by_index(4));
pal.set_color("editor_property", get_color_by_index(2));
pal.set_color("editor_constant", get_color_by_index(3));
pal.set_color("editor_type", get_color_by_index(6));
pal.set_color("editor_class", get_color_by_index(6));
pal.set_color("editor_interface", get_color_by_index(6));
pal.set_color("editor_enum", get_color_by_index(6));
pal.set_color("editor_namespace", get_color_by_index(4));
pal.set_color("editor_attribute", get_color_by_index(11));
pal.set_color("editor_decorator", get_color_by_index(11));
pal.set_color("editor_tag", get_color_by_index(1));
pal.set_color("editor_punctuation", get_color_by_index(7));
pal.set_color("editor_link", get_color_by_index(4));
pal.set_color("editor_regex", get_color_by_index(5));
pal.set_color("editor_escape_character", get_color_by_index(3));
// Editor - Diagnostics
pal.set_color("editor_invalid", get_color_by_index(1));
pal.set_color("editor_error", get_color_by_index(1));
pal.set_color("editor_error_background", get_color_by_index(0));
pal.set_color("editor_warning", get_color_by_index(3));
pal.set_color("editor_warning_background", get_color_by_index(0));
pal.set_color("editor_info", get_color_by_index(4));
pal.set_color("editor_info_background", get_color_by_index(0));
pal.set_color("editor_hint", get_color_by_index(2));
pal.set_color("editor_hint_background", get_color_by_index(0));
// Editor - UI Elements
pal.set_color("editor_active_line_border", get_color_by_index(8));
pal.set_color("editor_indent_guide", get_color_by_index(8));
pal.set_color("editor_indent_guide_active", get_color_by_index(7));
pal.set_color("editor_bracket_match", get_color_by_index(6));
pal.set_color("editor_search_match", get_color_by_index(3));
pal.set_color("editor_search_match_active", get_color_by_index(3));
pal.set_color("editor_find_range_highlight", get_color_by_index(3));
// Editor - Diff
pal.set_color("editor_deleted", get_color_by_index(1));
pal.set_color("editor_inserted", get_color_by_index(2));
pal.set_color("editor_modified", get_color_by_index(3));
pal.set_color("editor_ignored", get_color_by_index(8));
pal.set_color("editor_folded_background", get_color_by_index(8));
return pal;
}
} // namespace clrsync::core

View File

@@ -0,0 +1,32 @@
#ifndef CLRSYNC_CORE_PALETTE_HELLWAL_GENERATOR_HPP
#define CLRSYNC_CORE_PALETTE_HELLWAL_GENERATOR_HPP
#include "core/palette/palette.hpp"
#include "generator.hpp"
namespace clrsync::core
{
class hellwal_generator : public generator
{
public:
hellwal_generator() = default;
~hellwal_generator() override = default;
struct options
{
bool neon = false;
bool dark = true;
bool light = false;
bool color = false;
float dark_offset = 0.0f;
float bright_offset = 0.0f;
bool invert = false;
float gray_scale = 0.0f;
};
palette generate_from_image(const std::string &image_path) override;
palette generate_from_image(const std::string &image_path, const options &opts);
};
} // namespace clrsync::core
#endif

View File

@@ -0,0 +1,277 @@
#include "matugen_generator.hpp"
#include "core/palette/color.hpp"
#include <array>
#include <cstdio>
#include <filesystem>
#include <regex>
#include <string>
#include <unordered_map>
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif
namespace clrsync::core
{
static std::string run_command_capture_output(const std::string &cmd)
{
std::array<char, 4096> buffer;
std::string result;
FILE *pipe = popen(cmd.c_str(), "r");
if (!pipe)
return {};
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe) != nullptr)
{
result += buffer.data();
}
int rc = pclose(pipe);
(void)rc;
return result;
}
static palette parse_matugen_output(const std::string &out, const matugen_generator::options &opts,
const std::string &pal_name, const std::string &file_path)
{
if (out.empty())
return {};
auto extract_json_object = [&](const std::string &s,
const std::string &obj_key) -> std::string {
std::regex re("\"" + obj_key + "\"\\s*:\\s*\\{");
std::smatch m;
if (!std::regex_search(s, m, re))
return {};
size_t open_pos = s.find('{', m.position(0));
if (open_pos == std::string::npos)
return {};
size_t i = open_pos + 1;
int depth = 1;
for (; i < s.size(); ++i)
{
if (s[i] == '{')
++depth;
else if (s[i] == '}')
{
--depth;
if (depth == 0)
break;
}
}
if (depth != 0)
return {};
return s.substr(open_pos + 1, i - open_pos - 1);
};
std::string mode_section = extract_json_object(out, "colors");
std::string target_section;
if (!mode_section.empty())
{
std::string wrapped = std::string("{") + mode_section + std::string("}");
target_section = extract_json_object(wrapped, opts.mode);
}
if (target_section.empty())
{
target_section = extract_json_object(out, opts.mode);
}
const std::string &parse_src = (target_section.empty() ? out : target_section);
std::regex kv_re("\"([a-zA-Z0-9_-]+)\"\\s*:\\s*\"(#?[A-Fa-f0-9]{6,8})\"");
std::unordered_map<std::string, std::string> clrsync_to_matu = {
{"accent", "primary"},
{"accent_secondary", "secondary"},
{"background", "background"},
{"foreground", "on_surface"},
{"on_background", "on_background"},
{"surface", "surface_container"},
{"on_surface", "on_surface"},
{"surface_variant", "surface_variant"},
{"on_surface_variant", "on_surface_variant"},
{"border", "outline_variant"},
{"border_focused", "outline"},
{"cursor", "on_surface"},
{"success", "primary"},
{"on_success", "on_primary"},
{"info", "tertiary"},
{"on_info", "on_tertiary"},
{"warning", "secondary"},
{"on_warning", "on_secondary"},
{"error", "error"},
{"on_error", "on_error"},
// Editor - Basic
{"editor_background", "background"},
{"editor_foreground", "on_surface"},
{"editor_line_highlight", "surface_container"},
{"editor_selection", "primary_container"},
{"editor_selection_inactive", "surface_container_low"},
{"editor_cursor", "on_surface"},
{"editor_whitespace", "outline_variant"},
// Editor - Gutter
{"editor_gutter_background", "background"},
{"editor_gutter_foreground", "outline"},
{"editor_line_number", "outline"},
{"editor_line_number_active", "on_surface"},
// Editor - Syntax
{"editor_comment", "outline"},
{"editor_string", "tertiary"},
{"editor_number", "secondary"},
{"editor_boolean", "secondary"},
{"editor_keyword", "primary"},
{"editor_operator", "on_surface"},
{"editor_function", "tertiary_container"},
{"editor_variable", "on_surface"},
{"editor_parameter", "tertiary"},
{"editor_property", "tertiary"},
{"editor_constant", "secondary"},
{"editor_type", "primary"},
{"editor_class", "primary"},
{"editor_interface", "primary"},
{"editor_enum", "primary"},
{"editor_namespace", "primary_container"},
{"editor_attribute", "tertiary_container"},
{"editor_decorator", "tertiary_container"},
{"editor_tag", "error"},
{"editor_punctuation", "on_surface"},
{"editor_link", "primary_container"},
{"editor_regex", "secondary_container"},
{"editor_escape_character", "secondary"},
// Editor - Diagnostics
{"editor_invalid", "error"},
{"editor_error", "error"},
{"editor_error_background", "error_container"},
{"editor_warning", "secondary"},
{"editor_warning_background", "secondary_container"},
{"editor_info", "tertiary"},
{"editor_info_background", "tertiary_container"},
{"editor_hint", "primary"},
{"editor_hint_background", "primary_container"},
// Editor - UI Elements
{"editor_active_line_border", "outline_variant"},
{"editor_indent_guide", "outline_variant"},
{"editor_indent_guide_active", "outline"},
{"editor_bracket_match", "primary"},
{"editor_search_match", "tertiary_container"},
{"editor_search_match_active", "tertiary"},
{"editor_find_range_highlight", "tertiary_container"},
// Editor - Diff
{"editor_deleted", "error"},
{"editor_inserted", "primary"},
{"editor_modified", "secondary"},
{"editor_ignored", "outline_variant"},
{"editor_folded_background", "surface_container"},
{"base00", "background"},
{"base01", "surface_container_lowest"},
{"base02", "surface_container_low"},
{"base03", "outline_variant"},
{"base04", "on_surface_variant"},
{"base05", "on_surface"},
{"base06", "inverse_on_surface"},
{"base07", "surface_bright"},
{"base08", "error"},
{"base09", "tertiary"},
{"base0A", "secondary"},
{"base0B", "primary"},
{"base0C", "tertiary_container"},
{"base0D", "primary_container"},
{"base0E", "secondary_container"},
{"base0F", "on_primary_container"},
};
std::unordered_map<std::string, std::string> matu_kv_map;
auto begin = std::sregex_iterator(parse_src.begin(), parse_src.end(), kv_re);
auto endit = std::sregex_iterator();
for (auto it = begin; it != endit; ++it)
{
std::smatch match = *it;
std::string key = match[1].str();
for (auto &c : key)
if (c == '-')
c = '_';
std::string val = match[2].str();
matu_kv_map[key] = val;
}
palette pal;
pal.set_name(pal_name);
pal.set_file_path(file_path);
for (const auto &[clrsync_key, matu_key] : clrsync_to_matu)
{
auto matu_it = matu_kv_map.find(matu_key);
if (matu_it == matu_kv_map.end())
continue;
color col;
col.from_hex_string(matu_it->second);
pal.set_color(clrsync_key, col);
}
return pal;
}
palette matugen_generator::generate_from_image(const std::string &image_path)
{
options default_opts{};
return generate_from_image(image_path, default_opts);
}
palette matugen_generator::generate_from_image(const std::string &image_path, const options &opts)
{
std::filesystem::path p(image_path);
std::string cmd = "matugen image '" + image_path + "'";
if (!opts.type.empty())
cmd += " --type '" + opts.type + "'";
if (!opts.mode.empty())
cmd += " --mode " + opts.mode;
if (opts.contrast != 0.0f)
cmd += " --contrast " + std::to_string(opts.contrast);
cmd += " --json hex --dry-run";
std::string out = run_command_capture_output(cmd);
if (out.empty())
return {};
return parse_matugen_output(out, opts, std::string("matugen:") + p.filename().string(),
image_path);
}
palette matugen_generator::generate_from_color(const std::string &color_hex)
{
options default_opts{};
return generate_from_color(color_hex, default_opts);
}
palette matugen_generator::generate_from_color(const std::string &color_hex, const options &opts)
{
std::string c = color_hex;
if (!c.empty() && c[0] == '#')
c = c.substr(1);
std::string cmd = "matugen color hex '" + c + "'";
if (!opts.type.empty())
cmd += " --type '" + opts.type + "'";
if (!opts.mode.empty())
cmd += " --mode " + opts.mode;
if (opts.contrast != 0.0f)
cmd += " --contrast " + std::to_string(opts.contrast);
cmd += " --json hex --dry-run";
std::string out = run_command_capture_output(cmd);
if (out.empty())
return {};
return parse_matugen_output(out, opts, std::string("matugen:color:") + color_hex, color_hex);
}
} // namespace clrsync::core

View File

@@ -0,0 +1,29 @@
#ifndef CLRSYNC_CORE_PALETTE_MATUGEN_GENERATOR_HPP
#define CLRSYNC_CORE_PALETTE_MATUGEN_GENERATOR_HPP
#include "core/palette/palette.hpp"
#include "generator.hpp"
namespace clrsync::core
{
class matugen_generator : public generator
{
public:
matugen_generator() = default;
~matugen_generator() override = default;
struct options
{
std::string type = "scheme-tonal-spot";
std::string mode = "dark";
float contrast = 0.0f; // -1..1
};
palette generate_from_image(const std::string &image_path) override;
palette generate_from_image(const std::string &image_path, const options &opts);
palette generate_from_color(const std::string &color_hex);
palette generate_from_color(const std::string &color_hex, const options &opts);
};
} // namespace clrsync::core
#endif

View File

@@ -6,6 +6,7 @@
#include "core/theme/template_manager.hpp"
#include <iostream>
#include <string>
#include <thread>
namespace clrsync::core
{
@@ -58,12 +59,15 @@ template <typename FileType> class theme_renderer
if (!tmpl.reload_command().empty())
{
int result = std::system(tmpl.reload_command().c_str());
if (result != 0)
{
std::cerr << "Warning: Command " << tmpl.reload_command()
<< " failed with code " << result << "\n";
}
std::string cmd = tmpl.reload_command();
std::thread([cmd]() {
int result = std::system(cmd.c_str());
if (result != 0)
{
std::cerr << "Warning: Reload command '" << cmd
<< "' failed with code " << result << "\n";
}
}).detach();
}
}
return Ok();

View File

@@ -1,27 +1,39 @@
set(GUI_SOURCES
main.cpp
views/color_scheme_editor.cpp
views/color_table_renderer.cpp
views/preview_renderer.cpp
controllers/theme_applier.cpp
views/template_editor.cpp
controllers/palette_controller.cpp
controllers/template_controller.cpp
helpers/imgui_helpers.cpp
helpers/imgui_helpers.hpp
views/about_window.cpp
views/settings_window.cpp
platform/windows/font_loader_windows.cpp
platform/linux/font_loader_linux.cpp
platform/macos/font_loader_macos.cpp
platform/linux/file_browser_linux.cpp
platform/windows/file_browser_windows.cpp
${CMAKE_SOURCE_DIR}/lib/color_text_edit/TextEditor.cpp
platform/linux/font_loader_linux.cpp
platform/macos/font_loader_macos.cpp
platform/windows/font_loader_windows.cpp
backend/glfw_opengl.cpp
ui_manager.cpp
theme/app_theme.cpp
views/color_scheme_editor.cpp
views/color_table_renderer.cpp
views/preview_renderer.cpp
views/template_editor.cpp
views/about_window.cpp
views/settings_window.cpp
controllers/theme_applier.cpp
controllers/palette_controller.cpp
controllers/template_controller.cpp
widgets/colors.cpp
widgets/dialogs.cpp
widgets/palette_selector.cpp
widgets/input_dialog.cpp
widgets/action_buttons.cpp
widgets/styled_checkbox.cpp
widgets/autocomplete.cpp
widgets/form_field.cpp
widgets/error_message.cpp
widgets/settings_buttons.cpp
widgets/section_header.cpp
widgets/link_button.cpp
widgets/centered_text.cpp
widgets/validation_message.cpp
widgets/template_controls.cpp
layout/main_layout.cpp
platform/windows/font_loader_windows.cpp
platform/linux/font_loader_linux.cpp
platform/macos/font_loader_macos.cpp
platform/linux/file_browser_linux.cpp
platform/windows/file_browser_windows.cpp
${CMAKE_SOURCE_DIR}/lib/color_text_edit/TextEditor.cpp
backend/glfw_opengl.cpp
ui_manager.cpp
)
if(MACOS)

View File

@@ -9,7 +9,6 @@ namespace clrsync::gui::backend{
std::string title = "clrsync";
int width = 1280;
int height = 720;
bool resizable = true;
bool decorated = true;
bool transparent_framebuffer = true;
float clear_color[4] = {0.1f, 0.1f, 0.1f, 0.0f};

View File

@@ -1,5 +1,6 @@
#include "gui/backend/glfw_opengl.hpp"
#include <iostream>
#include <string>
#include <GLFW/glfw3.h>
#include <imgui.h>
#include <imgui_impl_glfw.h>
@@ -15,6 +16,11 @@ glfw_opengl_backend::~glfw_opengl_backend()
glfw_opengl_backend::shutdown();
}
void glfw_opengl_backend::focus_callback(GLFWwindow*, int focused)
{
glfwSwapInterval(focused ? 1 : 0);
}
bool glfw_opengl_backend::initialize(const window_config &config)
{
glfwSetErrorCallback([](int error, const char* description) {
@@ -33,7 +39,7 @@ bool glfw_opengl_backend::initialize(const window_config &config)
#else
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
#endif
glfwWindowHint(GLFW_RESIZABLE, config.resizable ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE,GLFW_TRUE);
glfwWindowHint(GLFW_DECORATED, config.decorated ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, config.transparent_framebuffer ? GLFW_TRUE : GLFW_FALSE);
@@ -47,6 +53,7 @@ bool glfw_opengl_backend::initialize(const window_config &config)
glfwMakeContextCurrent(m_window);
glfwSwapInterval(1);
glfwSetWindowFocusCallback(m_window, focus_callback);
return true;
}
@@ -98,6 +105,22 @@ void *glfw_opengl_backend::get_graphics_context() const
return static_cast<void *>(m_window);
}
std::string glfw_opengl_backend::get_glfw_version() const
{
return glfwGetVersionString();
}
std::string glfw_opengl_backend::get_glfw_platform() const
{
switch (glfwGetPlatform()) {
case GLFW_PLATFORM_WAYLAND: return "Wayland";
case GLFW_PLATFORM_X11: return "X11";
case GLFW_PLATFORM_COCOA: return "Cocoa";
case GLFW_PLATFORM_WIN32: return "Win32";
default: return "Unknown";
}
}
bool glfw_opengl_backend::init_imgui_backend()
{
if (!m_window)

View File

@@ -23,12 +23,17 @@ namespace clrsync::gui::backend{
void* get_native_window() const override;
void* get_graphics_context() const override;
std::string get_glfw_version() const;
std::string get_glfw_platform() const;
bool init_imgui_backend() override;
void shutdown_imgui_backend() override;
void imgui_new_frame() override;
void imgui_render_draw_data(void* draw_data) override;
private:
static void focus_callback(GLFWwindow* window, int focused);
GLFWwindow* m_window = nullptr;
};
}

View File

@@ -61,6 +61,14 @@ void palette_controller::delete_current_palette()
reload_palettes();
}
void palette_controller::import_palette(const clrsync::core::palette &pal)
{
auto dir = clrsync::core::config::instance().palettes_path();
m_palette_manager.save_palette_to_file(pal, dir);
reload_palettes();
m_current_palette = pal;
}
void palette_controller::apply_current_theme() const
{
clrsync::core::theme_renderer<clrsync::core::io::toml_file> theme_renderer;

View File

@@ -25,6 +25,7 @@ class palette_controller
void save_current_palette();
void delete_current_palette();
void apply_current_theme() const;
void import_palette(const clrsync::core::palette &pal);
void set_color(const std::string &key, const clrsync::core::color &color);
private:

View File

@@ -1,162 +1,59 @@
#include "gui/controllers/theme_applier.hpp"
#include "imgui.h"
#include "gui/theme/app_theme.hpp"
namespace theme_applier
{
static uint32_t get_color_u32(const clrsync::core::palette &current, const std::string &key)
{
const auto &col = current.get_color(key);
const uint32_t hex = col.hex();
// Convert from RRGGBBAA to AABBGGRR (ImGui format)
const uint32_t r = (hex >> 24) & 0xFF;
const uint32_t g = (hex >> 16) & 0xFF;
const uint32_t b = (hex >> 8) & 0xFF;
const uint32_t a = hex & 0xFF;
return (a << 24) | (b << 16) | (g << 8) | r;
}
void apply_to_editor(TextEditor &editor, const clrsync::core::palette &current)
{
using namespace clrsync::gui::theme;
auto get_color_u32 = [&](const std::string &key) -> uint32_t {
const auto &col = current.get_color(key);
return color_utils::to_imgui_u32(col.hex());
};
auto palette = editor.GetPalette();
palette[int(TextEditor::PaletteIndex::Default)] = get_color_u32(current, "editor_main");
palette[int(TextEditor::PaletteIndex::Keyword)] = get_color_u32(current, "editor_command");
palette[int(TextEditor::PaletteIndex::Number)] = get_color_u32(current, "editor_warning");
palette[int(TextEditor::PaletteIndex::String)] = get_color_u32(current, "editor_string");
palette[int(TextEditor::PaletteIndex::CharLiteral)] = get_color_u32(current, "editor_string");
palette[int(TextEditor::PaletteIndex::Punctuation)] = get_color_u32(current, "editor_main");
palette[int(TextEditor::PaletteIndex::Preprocessor)] =
get_color_u32(current, "editor_emphasis");
palette[int(TextEditor::PaletteIndex::Identifier)] = get_color_u32(current, "editor_main");
palette[int(TextEditor::PaletteIndex::KnownIdentifier)] = get_color_u32(current, "editor_link");
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] =
get_color_u32(current, "editor_link");
// Basic syntax
palette[int(TextEditor::PaletteIndex::Default)] = get_color_u32("editor_foreground");
palette[int(TextEditor::PaletteIndex::Keyword)] = get_color_u32("editor_keyword");
palette[int(TextEditor::PaletteIndex::Number)] = get_color_u32("editor_number");
palette[int(TextEditor::PaletteIndex::String)] = get_color_u32("editor_string");
palette[int(TextEditor::PaletteIndex::CharLiteral)] = get_color_u32("editor_string");
palette[int(TextEditor::PaletteIndex::Punctuation)] = get_color_u32("editor_punctuation");
palette[int(TextEditor::PaletteIndex::Preprocessor)] = get_color_u32("editor_attribute");
palette[int(TextEditor::PaletteIndex::Identifier)] = get_color_u32("editor_variable");
palette[int(TextEditor::PaletteIndex::KnownIdentifier)] = get_color_u32("editor_function");
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] = get_color_u32("editor_constant");
palette[int(TextEditor::PaletteIndex::Comment)] = get_color_u32(current, "editor_comment");
palette[int(TextEditor::PaletteIndex::MultiLineComment)] =
get_color_u32(current, "editor_comment");
// Comments
palette[int(TextEditor::PaletteIndex::Comment)] = get_color_u32("editor_comment");
palette[int(TextEditor::PaletteIndex::MultiLineComment)] = get_color_u32("editor_comment");
palette[int(TextEditor::PaletteIndex::Background)] =
get_color_u32(current, "editor_background");
palette[int(TextEditor::PaletteIndex::Cursor)] = get_color_u32(current, "cursor");
// Background and cursor
palette[int(TextEditor::PaletteIndex::Background)] = get_color_u32("editor_background");
palette[int(TextEditor::PaletteIndex::Cursor)] = get_color_u32("editor_cursor");
palette[int(TextEditor::PaletteIndex::Selection)] = get_color_u32(current, "editor_selected");
palette[int(TextEditor::PaletteIndex::ErrorMarker)] = get_color_u32(current, "editor_error");
palette[int(TextEditor::PaletteIndex::Breakpoint)] = get_color_u32(current, "editor_error");
// Selection
palette[int(TextEditor::PaletteIndex::Selection)] = get_color_u32("editor_selection");
palette[int(TextEditor::PaletteIndex::ErrorMarker)] = get_color_u32("editor_error_background");
palette[int(TextEditor::PaletteIndex::Breakpoint)] = get_color_u32("editor_error");
palette[int(TextEditor::PaletteIndex::LineNumber)] =
get_color_u32(current, "editor_line_number");
// Line numbers
palette[int(TextEditor::PaletteIndex::LineNumber)] = get_color_u32("editor_line_number");
palette[int(TextEditor::PaletteIndex::CurrentLineFill)] =
get_color_u32(current, "surface_variant");
palette[int(TextEditor::PaletteIndex::CurrentLineFillInactive)] =
get_color_u32(current, "surface");
palette[int(TextEditor::PaletteIndex::CurrentLineEdge)] =
get_color_u32(current, "border_focused");
// Current line highlight
palette[int(TextEditor::PaletteIndex::CurrentLineFill)] = get_color_u32("editor_line_highlight");
palette[int(TextEditor::PaletteIndex::CurrentLineFillInactive)] = get_color_u32("editor_folded_background");
palette[int(TextEditor::PaletteIndex::CurrentLineEdge)] = get_color_u32("editor_active_line_border");
editor.SetPalette(palette);
}
void apply_to_imgui(const clrsync::core::palette &current)
{
auto getColor = [&](const std::string &key) -> ImVec4 {
const auto &col = current.get_color(key);
const uint32_t hex = col.hex();
return {((hex >> 24) & 0xFF) / 255.0f, ((hex >> 16) & 0xFF) / 255.0f,
((hex >> 8) & 0xFF) / 255.0f, ((hex) & 0xFF) / 255.0f};
};
ImGuiStyle &style = ImGui::GetStyle();
const ImVec4 bg = getColor("background");
const ImVec4 onBg = getColor("on_background");
const ImVec4 surface = getColor("surface");
const ImVec4 onSurface = getColor("on_surface");
const ImVec4 surfaceVariant = getColor("surface_variant");
const ImVec4 onSurfaceVariant = getColor("on_surface_variant");
const ImVec4 fg = getColor("foreground");
const ImVec4 fgInactive = getColor("editor_inactive");
const ImVec4 accent = getColor("accent");
const ImVec4 border = getColor("border");
const ImVec4 error = getColor("error");
const ImVec4 onError = getColor("on_error");
const ImVec4 success = getColor("success");
const ImVec4 onSuccess = getColor("on_success");
const ImVec4 warning = getColor("warning");
const ImVec4 onWarning = getColor("on_warning");
const ImVec4 info = getColor("info");
const ImVec4 onInfo = getColor("on_info");
style.Colors[ImGuiCol_WindowBg] = bg;
style.Colors[ImGuiCol_ChildBg] = surface;
style.Colors[ImGuiCol_PopupBg] = surface;
style.Colors[ImGuiCol_Border] = border;
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0, 0, 0, 0);
style.Colors[ImGuiCol_Text] = onSurface;
style.Colors[ImGuiCol_TextDisabled] = onSurfaceVariant;
style.Colors[ImGuiCol_TextSelectedBg] = accent;
style.Colors[ImGuiCol_Header] = surfaceVariant;
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(accent.x, accent.y, accent.z, 0.8f);
style.Colors[ImGuiCol_HeaderActive] = accent;
style.Colors[ImGuiCol_Button] = surfaceVariant;
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(accent.x, accent.y, accent.z, 0.6f);
style.Colors[ImGuiCol_ButtonActive] = accent;
style.Colors[ImGuiCol_FrameBg] = surfaceVariant;
style.Colors[ImGuiCol_FrameBgHovered] =
ImVec4(surfaceVariant.x * 1.1f, surfaceVariant.y * 1.1f, surfaceVariant.z * 1.1f, 1.0f);
style.Colors[ImGuiCol_FrameBgActive] =
ImVec4(surfaceVariant.x * 1.2f, surfaceVariant.y * 1.2f, surfaceVariant.z * 1.2f, 1.0f);
style.Colors[ImGuiCol_TitleBg] = surface;
style.Colors[ImGuiCol_TitleBgActive] = surfaceVariant;
style.Colors[ImGuiCol_TitleBgCollapsed] = surface;
style.Colors[ImGuiCol_ScrollbarBg] = surface;
style.Colors[ImGuiCol_ScrollbarGrab] = surfaceVariant;
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(accent.x, accent.y, accent.z, 0.6f);
style.Colors[ImGuiCol_ScrollbarGrabActive] = accent;
style.Colors[ImGuiCol_SliderGrab] = accent;
style.Colors[ImGuiCol_SliderGrabActive] =
ImVec4(accent.x * 1.2f, accent.y * 1.2f, accent.z * 1.2f, 1.0f);
style.Colors[ImGuiCol_CheckMark] = accent;
style.Colors[ImGuiCol_ResizeGrip] = surfaceVariant;
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(accent.x, accent.y, accent.z, 0.6f);
style.Colors[ImGuiCol_ResizeGripActive] = accent;
style.Colors[ImGuiCol_Tab] = surface;
style.Colors[ImGuiCol_TabHovered] = ImVec4(accent.x, accent.y, accent.z, 0.8f);
style.Colors[ImGuiCol_TabActive] = surfaceVariant;
style.Colors[ImGuiCol_TabUnfocused] = surface;
style.Colors[ImGuiCol_TabUnfocusedActive] = surfaceVariant;
style.Colors[ImGuiCol_TabSelectedOverline] = accent;
style.Colors[ImGuiCol_TableHeaderBg] = surfaceVariant;
style.Colors[ImGuiCol_TableBorderStrong] = border;
style.Colors[ImGuiCol_TableBorderLight] =
ImVec4(border.x * 0.7f, border.y * 0.7f, border.z * 0.7f, border.w);
style.Colors[ImGuiCol_TableRowBg] = ImVec4(0, 0, 0, 0);
style.Colors[ImGuiCol_TableRowBgAlt] =
ImVec4(onSurfaceVariant.x, onSurfaceVariant.y, onSurfaceVariant.z, 0.06f);
style.Colors[ImGuiCol_Separator] = border;
style.Colors[ImGuiCol_SeparatorHovered] = accent;
style.Colors[ImGuiCol_SeparatorActive] = accent;
style.Colors[ImGuiCol_MenuBarBg] = surface;
style.Colors[ImGuiCol_DockingPreview] = ImVec4(accent.x, accent.y, accent.z, 0.7f);
style.Colors[ImGuiCol_DockingEmptyBg] = bg;
clrsync::gui::theme::set_theme(current);
}
} // namespace theme_applier

View File

@@ -7,6 +7,7 @@
namespace theme_applier
{
void apply_to_imgui(const clrsync::core::palette &pal);
void apply_to_editor(TextEditor &editor, const clrsync::core::palette &pal);
} // namespace theme_applier

View File

@@ -1,266 +0,0 @@
#include <iostream>
#include <string>
#include "GLFW/glfw3.h"
#include "gui/views/settings_window.hpp"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "imgui_helpers.hpp"
#include "imgui_internal.h"
GLFWwindow *init_glfw()
{
glfwSetErrorCallback([](int error, const char *description) {
std::cerr << "GLFW Error " << error << ": " << description << std::endl;
});
if (!glfwInit())
{
std::cerr << "Failed to initialize GLFW\n";
return nullptr;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
#ifdef __APPLE__
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#else
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
#endif
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
GLFWwindow *w = glfwCreateWindow(1280, 720, "clrsync", nullptr, nullptr);
if (!w)
{
std::cerr << "Failed to create GLFW window\n";
return nullptr;
}
glfwMakeContextCurrent(w);
glfwSwapInterval(1);
return w;
}
void init_imgui(GLFWwindow *window, const std::string &ini_path)
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.IniFilename = ini_path.c_str();
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(window, true);
#ifdef __APPLE__
ImGui_ImplOpenGL3_Init("#version 150");
#else
ImGui_ImplOpenGL3_Init("#version 120");
#endif
}
void begin_frame()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void render_menu_bar(about_window *about, settings_window *settings)
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Settings"))
{
if (settings)
settings->show();
}
ImGui::Separator();
if (ImGui::MenuItem("Exit"))
{
glfwSetWindowShouldClose(glfwGetCurrentContext(), GLFW_TRUE);
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Help"))
{
if (ImGui::MenuItem("About"))
{
if (about)
about->show();
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
void setup_main_dockspace(bool &first_time)
{
const ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_MenuBar;
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::Begin("MainDockSpace", nullptr, flags);
ImGui::PopStyleVar(3);
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
if (first_time)
{
first_time = false;
ImGui::DockBuilderRemoveNode(dockspace_id);
ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace);
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
ImGuiID center, right;
ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 0.5f, &right, &center);
ImGuiDockNode *center_node = ImGui::DockBuilderGetNode(center);
if (center_node)
{
center_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
}
ImGui::DockBuilderDockWindow("Color Schemes", right);
ImGui::DockBuilderDockWindow("Color Preview", center);
ImGui::DockBuilderDockWindow("Templates", center);
ImGui::DockBuilderFinish(dockspace_id);
}
ImGui::DockSpace(dockspace_id, ImVec2{0, 0}, ImGuiDockNodeFlags_None);
ImGui::End();
}
void end_frame(GLFWwindow *window)
{
ImGui::Render();
int w, h;
glfwGetFramebufferSize(window, &w, &h);
glViewport(0, 0, w, h);
glClearColor(0.1f, 0.1f, 0.1f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
void shutdown(GLFWwindow *window)
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
}
namespace palette_utils
{
ImVec4 get_color(const clrsync::core::palette &pal, const std::string &key,
const std::string &fallback)
{
auto colors = pal.colors();
if (colors.empty())
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
auto it = colors.find(key);
if (it == colors.end() && !fallback.empty())
{
it = colors.find(fallback);
}
if (it != colors.end())
{
const auto &col = it->second;
const uint32_t hex = col.hex();
const float r = ((hex >> 24) & 0xFF) / 255.0f;
const float g = ((hex >> 16) & 0xFF) / 255.0f;
const float b = ((hex >> 8) & 0xFF) / 255.0f;
const float a = (hex & 0xFF) / 255.0f;
return ImVec4(r, g, b, a);
}
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
uint32_t get_color_u32(const clrsync::core::palette &pal, const std::string &key,
const std::string &fallback)
{
auto colors = pal.colors();
if (colors.empty())
return 0xFFFFFFFF;
auto it = colors.find(key);
if (it == colors.end() && !fallback.empty())
{
it = colors.find(fallback);
}
if (it != colors.end())
{
const auto &col = it->second;
const uint32_t hex = col.hex();
const uint32_t r = (hex >> 24) & 0xFF;
const uint32_t g = (hex >> 16) & 0xFF;
const uint32_t b = (hex >> 8) & 0xFF;
const uint32_t a = hex & 0xFF;
return (a << 24) | (b << 16) | (g << 8) | r;
}
return 0xFFFFFFFF;
}
bool render_delete_confirmation_popup(const std::string &popup_title, const std::string &item_name,
const std::string &item_type,
const clrsync::core::palette &pal,
const std::function<void()> &on_delete)
{
bool result = false;
if (ImGui::BeginPopupModal(popup_title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize))
{
ImVec4 warning_color = get_color(pal, "warning", "accent");
ImGui::TextColored(warning_color, "Are you sure you want to delete '%s'?",
item_name.c_str());
ImGui::Text("This action cannot be undone.");
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
float button_width = 120.0f;
float total_width = 2.0f * button_width + ImGui::GetStyle().ItemSpacing.x;
float window_width = ImGui::GetContentRegionAvail().x;
ImGui::SetCursorPosX((window_width - total_width) * 0.5f);
if (ImGui::Button("Delete", ImVec2(button_width, 0)))
{
on_delete();
result = true;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(button_width, 0)))
{
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
return result;
}
} // namespace palette_utils

View File

@@ -1,42 +0,0 @@
#ifndef CLRSYNC_IMGUI_HELPERS_HPP
#define CLRSYNC_IMGUI_HELPERS_HPP
#include "core/palette/palette.hpp"
#include "gui/views/about_window.hpp"
#include "imgui.h"
#include <functional>
#include <string>
struct GLFWwindow;
class settings_window;
GLFWwindow *init_glfw();
void init_imgui(GLFWwindow *window, const std::string &ini_path);
void begin_frame();
void setup_main_dockspace(bool &first_time);
void end_frame(GLFWwindow *window);
void shutdown(GLFWwindow *window);
void render_menu_bar(about_window *about, settings_window *settings);
namespace palette_utils
{
ImVec4 get_color(const clrsync::core::palette &pal, const std::string &key,
const std::string &fallback = "");
uint32_t get_color_u32(const clrsync::core::palette &pal, const std::string &key,
const std::string &fallback = "");
bool render_delete_confirmation_popup(const std::string &popup_title, const std::string &item_name,
const std::string &item_type,
const clrsync::core::palette &pal,
const std::function<void()> &on_delete);
} // namespace palette_utils
namespace imgui_helpers
{
inline ImVec4 get_palette_color(const clrsync::core::palette &pal, const std::string &key,
const std::string &fallback = "")
{
return palette_utils::get_color(pal, key, fallback);
}
} // namespace imgui_helpers
#endif // CLRSYNC_IMGUI_HELPERS_HPP

View File

@@ -0,0 +1,113 @@
#include "main_layout.hpp"
#include "imgui.h"
#include "imgui_internal.h"
namespace clrsync::gui::layout
{
namespace
{
constexpr float TOPBAR_HEIGHT = 36.0f;
constexpr float TOPBAR_PADDING_X = 12.0f;
constexpr float TOPBAR_PADDING_Y = 4.0f;
constexpr float BUTTON_SPACING = 8.0f;
}
void main_layout::render_menu_bar()
{
ImGuiViewport *vp = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(vp->Pos);
ImGui::SetNextWindowSize(ImVec2(vp->Size.x, TOPBAR_HEIGHT));
ImGui::SetNextWindowViewport(vp->ID);
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(TOPBAR_PADDING_X, TOPBAR_PADDING_Y));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(BUTTON_SPACING, 6.0f));
ImGui::Begin("##TopBar", nullptr, flags);
const char *settings_label = "Settings";
const char *about_label = "About";
ImGuiStyle &style = ImGui::GetStyle();
ImVec2 settings_size = ImGui::CalcTextSize(settings_label);
ImVec2 about_size = ImGui::CalcTextSize(about_label);
float total_width = settings_size.x + style.FramePadding.x * 2.0f + about_size.x +
style.FramePadding.x * 2.0f + style.ItemSpacing.x;
float pos_x = ImGui::GetWindowWidth() - total_width - TOPBAR_PADDING_X;
float button_height = ImGui::GetFrameHeight();
float window_height = ImGui::GetWindowHeight();
float center_y = (window_height - button_height) * 0.5f;
ImGui::SetCursorPos(ImVec2(pos_x, center_y));
if (ImGui::Button(settings_label))
m_show_settings = true;
ImGui::SameLine();
ImGui::SetCursorPosY(center_y);
if (ImGui::Button(about_label))
m_show_about = true;
ImGui::End();
ImGui::PopStyleVar(4);
}
void main_layout::setup_dockspace(bool &first_time)
{
const ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + TOPBAR_HEIGHT));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, viewport->Size.y - TOPBAR_HEIGHT));
ImGui::SetNextWindowViewport(viewport->ID);
constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoNavFocus;
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::Begin("MainDockSpace", nullptr, flags);
ImGui::PopStyleVar(3);
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
if (first_time)
{
first_time = false;
ImGui::DockBuilderRemoveNode(dockspace_id);
ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace);
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
ImGuiID center, right;
ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 0.40f, &right, &center);
ImGuiDockNode *center_node = ImGui::DockBuilderGetNode(center);
if (center_node)
center_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
ImGui::DockBuilderDockWindow("Color Schemes", right);
ImGui::DockBuilderDockWindow("Color Preview", center);
ImGui::DockBuilderDockWindow("Templates", center);
ImGui::DockBuilderFinish(dockspace_id);
}
ImGui::DockSpace(dockspace_id, ImVec2{0, 0}, ImGuiDockNodeFlags_None);
ImGui::End();
}
} // namespace clrsync::gui::layout

View File

@@ -0,0 +1,28 @@
#ifndef CLRSYNC_GUI_LAYOUT_MAIN_LAYOUT_HPP
#define CLRSYNC_GUI_LAYOUT_MAIN_LAYOUT_HPP
namespace clrsync::gui::layout
{
class main_layout
{
public:
void setup_dockspace(bool &first_time);
void render_menu_bar();
bool should_show_about() const { return m_show_about; }
bool should_show_settings() const { return m_show_settings; }
void clear_actions()
{
m_show_about = false;
m_show_settings = false;
}
private:
bool m_show_about = false;
bool m_show_settings = false;
};
} // namespace clrsync::gui::layout
#endif // CLRSYNC_GUI_LAYOUT_MAIN_LAYOUT_HPP

View File

@@ -1,17 +1,13 @@
#include <iostream>
#include <memory>
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include "core/common/error.hpp"
#include "core/common/utils.hpp"
#include "core/config/config.hpp"
#include "core/io/toml_file.hpp"
#include "gui/backend/glfw_opengl.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/platform/font_loader.hpp"
#include "gui/layout/main_layout.hpp"
#include "gui/ui_manager.hpp"
#include "gui/views/about_window.hpp"
#include "gui/views/color_scheme_editor.hpp"
@@ -37,13 +33,12 @@ int main(int, char **)
static std::string ini_path = (base.parent_path() / "layout.ini").string();
bool first_time = !std::filesystem::exists(ini_path);
printf("GLFW Version: %s\n", glfwGetVersionString());
auto backend = clrsync::gui::backend::glfw_opengl_backend();
auto window_config = clrsync::gui::backend::window_config();
window_config.title = "clrsync";
window_config.width = 1280;
window_config.height = 720;
window_config.decorated = true;
window_config.transparent_framebuffer = true;
if (!backend.initialize(window_config))
@@ -52,14 +47,8 @@ int main(int, char **)
return 1;
}
std::cout << "GLFW runtime platform: ";
switch (glfwGetPlatform()) {
case GLFW_PLATFORM_WAYLAND: std::cout << "Wayland\n"; break;
case GLFW_PLATFORM_X11: std::cout << "X11\n"; break;
case GLFW_PLATFORM_COCOA: std::cout << "Cocoa\n"; break;
case GLFW_PLATFORM_WIN32: std::cout << "Win32\n"; break;
default: std::cout << "Unknown\n";
}
std::cout << "GLFW Version: " << backend.get_glfw_version() << std::endl;
std::cout << "GLFW runtime platform: " << backend.get_glfw_platform() << std::endl;
clrsync::gui::ui_manager ui_manager(&backend);
@@ -74,18 +63,11 @@ int main(int, char **)
return 1;
}
font_loader loader;
ImFont *font = loader.load_font(clrsync::core::config::instance().font().c_str(),
clrsync::core::config::instance().font_size());
if (font)
ImGui::GetIO().FontDefault = font;
clrsync::gui::layout::main_layout main_layout;
color_scheme_editor colorEditor;
template_editor templateEditor;
template_editor templateEditor(&ui_manager);
about_window aboutWindow;
settings_window settingsWindow;
settings_window settingsWindow(&ui_manager);
colorEditor.set_template_editor(&templateEditor);
colorEditor.set_settings_window(&settingsWindow);
@@ -96,18 +78,25 @@ int main(int, char **)
{
backend.begin_frame();
loader.push_default_font();
ui_manager.push_default_font();
ui_manager.begin_frame();
render_menu_bar(&aboutWindow, &settingsWindow);
setup_main_dockspace(first_time);
main_layout.render_menu_bar();
main_layout.setup_dockspace(first_time);
if (main_layout.should_show_about())
aboutWindow.show();
if (main_layout.should_show_settings())
settingsWindow.show();
main_layout.clear_actions();
templateEditor.render();
colorEditor.render_controls_and_colors();
colorEditor.render_preview();
aboutWindow.render(colorEditor.controller().current_palette());
settingsWindow.render();
loader.pop_font();
ui_manager.pop_font();
ui_manager.end_frame();
backend.end_frame();

View File

@@ -3,6 +3,7 @@
#include "gui/platform/file_browser.hpp"
#include <gtk/gtk.h>
#include <filesystem>
#include <GLFW/glfw3.h>
namespace file_dialogs
{
@@ -38,7 +39,16 @@ std::string open_file_dialog(const std::string &title, const std::string &initia
}
std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{
char *filename = gtk_file_chooser_get_filename(chooser);
if (filename)
@@ -79,7 +89,16 @@ std::string save_file_dialog(const std::string &title, const std::string &initia
}
std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{
char *filename = gtk_file_chooser_get_filename(chooser);
if (filename)
@@ -113,7 +132,16 @@ std::string select_folder_dialog(const std::string &title, const std::string &in
}
std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{
char *filename = gtk_file_chooser_get_filename(chooser);
if (filename)

View File

@@ -6,9 +6,10 @@
#include <algorithm>
#include <fontconfig/fontconfig.h>
#include <imgui.h>
#include <GLFW/glfw3.h>
std::string font_loader::find_font_linux(const char *font_name)
{
{
FcInit();
FcPattern *pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_name));
@@ -64,7 +65,6 @@ void font_loader::pop_font()
std::vector<std::string> font_loader::get_system_fonts()
{
std::vector<std::string> fonts;
FcInit();
FcPattern *pattern = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, nullptr);
@@ -73,7 +73,7 @@ std::vector<std::string> font_loader::get_system_fonts()
if (fs)
{
for (int i = 0; i < fs->nfont; i++)
{
{
FcChar8 *family = nullptr;
if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch)
{

317
src/gui/theme/app_theme.cpp Normal file
View File

@@ -0,0 +1,317 @@
#include "app_theme.hpp"
#include <algorithm>
namespace clrsync::gui::theme
{
ImVec4 color_utils::from_hex(uint32_t hex)
{
return {
((hex >> 24) & 0xFF) / 255.0f,
((hex >> 16) & 0xFF) / 255.0f,
((hex >> 8) & 0xFF) / 255.0f,
(hex & 0xFF) / 255.0f
};
}
uint32_t color_utils::to_imgui_u32(uint32_t hex)
{
const uint32_t r = (hex >> 24) & 0xFF;
const uint32_t g = (hex >> 16) & 0xFF;
const uint32_t b = (hex >> 8) & 0xFF;
const uint32_t a = hex & 0xFF;
return (a << 24) | (b << 16) | (g << 8) | r;
}
ImVec4 color_utils::with_alpha(const ImVec4 &color, float alpha)
{
return {color.x, color.y, color.z, std::clamp(alpha, 0.0f, 1.0f)};
}
ImVec4 color_utils::lighten(const ImVec4 &color, float amount)
{
return {
std::clamp(color.x + (1.0f - color.x) * amount, 0.0f, 1.0f),
std::clamp(color.y + (1.0f - color.y) * amount, 0.0f, 1.0f),
std::clamp(color.z + (1.0f - color.z) * amount, 0.0f, 1.0f),
color.w
};
}
ImVec4 color_utils::darken(const ImVec4 &color, float amount)
{
return {
std::clamp(color.x * (1.0f - amount), 0.0f, 1.0f),
std::clamp(color.y * (1.0f - amount), 0.0f, 1.0f),
std::clamp(color.z * (1.0f - amount), 0.0f, 1.0f),
color.w
};
}
ImVec4 color_utils::blend(const ImVec4 &a, const ImVec4 &b, float t)
{
t = std::clamp(t, 0.0f, 1.0f);
return {
a.x + (b.x - a.x) * t,
a.y + (b.y - a.y) * t,
a.z + (b.z - a.z) * t,
a.w + (b.w - a.w) * t
};
}
app_theme::app_theme(const core::palette &palette)
{
apply_palette(palette);
}
ImVec4 app_theme::get_palette_color(const std::string &key,
const std::string &fallback) const
{
auto colors = m_palette.colors();
if (colors.empty())
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
auto it = colors.find(key);
if (it == colors.end() && !fallback.empty())
it = colors.find(fallback);
if (it != colors.end())
return color_utils::from_hex(it->second.hex());
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
void app_theme::apply_palette(const core::palette &palette)
{
m_palette = palette;
if (palette.colors().empty())
return;
const ImVec4 background = get_palette_color("background");
const ImVec4 on_background = get_palette_color("on_background");
const ImVec4 surface = get_palette_color("surface");
const ImVec4 on_surface = get_palette_color("on_surface");
const ImVec4 surface_variant = get_palette_color("surface_variant");
const ImVec4 on_surface_variant = get_palette_color("on_surface_variant");
const ImVec4 border_base = get_palette_color("border");
const ImVec4 border_focused_base = get_palette_color("border_focused");
const ImVec4 accent_base = get_palette_color("accent");
const ImVec4 accent_secondary_base = get_palette_color("accent_secondary");
const ImVec4 success_base = get_palette_color("success");
const ImVec4 on_success_base = get_palette_color("on_success");
const ImVec4 warning_base = get_palette_color("warning");
const ImVec4 on_warning_base = get_palette_color("on_warning");
const ImVec4 error_base = get_palette_color("error");
const ImVec4 on_error_base = get_palette_color("on_error");
const ImVec4 info_base = get_palette_color("info");
const ImVec4 on_info_base = get_palette_color("on_info");
m_window_bg = background;
m_child_bg = color_utils::with_alpha(surface, 0.0f); // Transparent child bg
m_popup_bg = color_utils::with_alpha(surface_variant, 0.98f);
m_modal_dim_bg = ImVec4(0.0f, 0.0f, 0.0f, 0.5f);
m_text = on_surface;
m_text_disabled = on_surface_variant;
m_text_selected_bg = color_utils::with_alpha(accent_base, 0.4f);
m_border = border_base;
m_border_focused = border_focused_base;
m_separator = border_base;
m_button = surface_variant;
m_button_hovered = color_utils::with_alpha(accent_base, 0.7f);
m_button_active = accent_base;
m_header = surface_variant;
m_header_hovered = color_utils::with_alpha(accent_base, 0.7f);
m_header_active = accent_base;
m_frame_bg = surface_variant;
m_frame_bg_hovered = color_utils::lighten(surface_variant, 0.08f);
m_frame_bg_active = color_utils::lighten(surface_variant, 0.15f);
m_tab = surface;
m_tab_hovered = color_utils::with_alpha(accent_base, 0.7f);
m_tab_active = surface_variant;
m_tab_unfocused = surface;
m_tab_unfocused_active = surface_variant;
m_scrollbar_bg = color_utils::with_alpha(surface, 0.5f);
m_scrollbar_grab = surface_variant;
m_scrollbar_grab_hovered = color_utils::with_alpha(accent_base, 0.7f);
m_scrollbar_grab_active = accent_base;
m_slider_grab = accent_base;
m_slider_grab_active = color_utils::lighten(accent_base, 0.2f);
m_table_header_bg = surface_variant;
m_table_border_strong = border_base;
m_table_border_light = color_utils::darken(border_base, 0.3f);
m_table_row_bg = ImVec4(0, 0, 0, 0);
m_table_row_bg_alt = color_utils::with_alpha(on_surface_variant, 0.04f);
m_title_bg = surface;
m_title_bg_active = surface_variant;
m_title_bg_collapsed = color_utils::with_alpha(surface, 0.75f);
m_docking_preview = color_utils::with_alpha(accent_base, 0.7f);
m_docking_empty_bg = background;
m_accent = accent_base;
m_accent_secondary = accent_secondary_base;
m_success = success_base;
m_success_hovered = color_utils::lighten(success_base, 0.2f);
m_success_active = color_utils::darken(success_base, 0.2f);
m_on_success = on_success_base;
m_warning = warning_base;
m_warning_hovered = color_utils::lighten(warning_base, 0.2f);
m_warning_active = color_utils::darken(warning_base, 0.2f);
m_on_warning = on_warning_base;
m_error = error_base;
m_error_hovered = color_utils::lighten(error_base, 0.2f);
m_error_active = color_utils::darken(error_base, 0.2f);
m_on_error = on_error_base;
m_info = info_base;
m_info_hovered = color_utils::lighten(info_base, 0.2f);
m_info_active = color_utils::darken(info_base, 0.2f);
m_on_info = on_info_base;
m_checkmark = accent_base;
m_resize_grip = color_utils::with_alpha(surface_variant, 0.5f);
m_resize_grip_hovered = color_utils::with_alpha(accent_base, 0.7f);
m_resize_grip_active = accent_base;
m_autocomplete_bg = color_utils::with_alpha(surface_variant, 0.98f);
m_autocomplete_border = border_focused_base;
m_autocomplete_selected = color_utils::with_alpha(accent_base, 0.9f);
m_autocomplete_text = on_surface;
m_autocomplete_selected_text = on_surface;
m_autocomplete_dim_text = on_surface_variant;
}
void app_theme::apply_style_vars() const
{
ImGuiStyle &style = ImGui::GetStyle();
style.WindowRounding = WINDOW_ROUNDING;
style.ChildRounding = FRAME_ROUNDING;
style.FrameRounding = FRAME_ROUNDING;
style.PopupRounding = POPUP_ROUNDING;
style.ScrollbarRounding = SCROLLBAR_ROUNDING;
style.GrabRounding = GRAB_ROUNDING;
style.TabRounding = TAB_ROUNDING;
style.FrameBorderSize = FRAME_BORDER_SIZE;
style.WindowBorderSize = WINDOW_BORDER_SIZE;
style.PopupBorderSize = POPUP_BORDER_SIZE;
style.WindowPadding = WINDOW_PADDING;
style.FramePadding = FRAME_PADDING;
style.ItemSpacing = ITEM_SPACING;
style.ItemInnerSpacing = ITEM_INNER_SPACING;
style.ScrollbarSize = 12.0f;
style.GrabMinSize = 10.0f;
style.SeparatorTextBorderSize = 1.0f;
style.IndentSpacing = 20.0f;
}
void app_theme::apply_to_imgui() const
{
apply_style_vars();
ImGuiStyle &style = ImGui::GetStyle();
style.Colors[ImGuiCol_WindowBg] = m_window_bg;
style.Colors[ImGuiCol_ChildBg] = m_child_bg;
style.Colors[ImGuiCol_PopupBg] = m_popup_bg;
style.Colors[ImGuiCol_ModalWindowDimBg] = m_modal_dim_bg;
style.Colors[ImGuiCol_Text] = m_text;
style.Colors[ImGuiCol_TextDisabled] = m_text_disabled;
style.Colors[ImGuiCol_TextSelectedBg] = m_text_selected_bg;
style.Colors[ImGuiCol_Border] = m_border;
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0, 0, 0, 0);
style.Colors[ImGuiCol_Separator] = m_separator;
style.Colors[ImGuiCol_SeparatorHovered] = m_accent;
style.Colors[ImGuiCol_SeparatorActive] = m_accent;
style.Colors[ImGuiCol_Button] = m_button;
style.Colors[ImGuiCol_ButtonHovered] = m_button_hovered;
style.Colors[ImGuiCol_ButtonActive] = m_button_active;
style.Colors[ImGuiCol_Header] = m_header;
style.Colors[ImGuiCol_HeaderHovered] = m_header_hovered;
style.Colors[ImGuiCol_HeaderActive] = m_header_active;
style.Colors[ImGuiCol_FrameBg] = m_frame_bg;
style.Colors[ImGuiCol_FrameBgHovered] = m_frame_bg_hovered;
style.Colors[ImGuiCol_FrameBgActive] = m_frame_bg_active;
style.Colors[ImGuiCol_Tab] = m_tab;
style.Colors[ImGuiCol_TabHovered] = m_tab_hovered;
style.Colors[ImGuiCol_TabActive] = m_tab_active;
style.Colors[ImGuiCol_TabUnfocused] = m_tab_unfocused;
style.Colors[ImGuiCol_TabUnfocusedActive] = m_tab_unfocused_active;
style.Colors[ImGuiCol_TabSelectedOverline] = m_accent;
style.Colors[ImGuiCol_ScrollbarBg] = m_scrollbar_bg;
style.Colors[ImGuiCol_ScrollbarGrab] = m_scrollbar_grab;
style.Colors[ImGuiCol_ScrollbarGrabHovered] = m_scrollbar_grab_hovered;
style.Colors[ImGuiCol_ScrollbarGrabActive] = m_scrollbar_grab_active;
style.Colors[ImGuiCol_SliderGrab] = m_slider_grab;
style.Colors[ImGuiCol_SliderGrabActive] = m_slider_grab_active;
style.Colors[ImGuiCol_TableHeaderBg] = m_table_header_bg;
style.Colors[ImGuiCol_TableBorderStrong] = m_table_border_strong;
style.Colors[ImGuiCol_TableBorderLight] = m_table_border_light;
style.Colors[ImGuiCol_TableRowBg] = m_table_row_bg;
style.Colors[ImGuiCol_TableRowBgAlt] = m_table_row_bg_alt;
style.Colors[ImGuiCol_TitleBg] = m_title_bg;
style.Colors[ImGuiCol_TitleBgActive] = m_title_bg_active;
style.Colors[ImGuiCol_TitleBgCollapsed] = m_title_bg_collapsed;
style.Colors[ImGuiCol_MenuBarBg] = m_window_bg;
style.Colors[ImGuiCol_DockingPreview] = m_docking_preview;
style.Colors[ImGuiCol_DockingEmptyBg] = m_docking_empty_bg;
style.Colors[ImGuiCol_CheckMark] = m_checkmark;
style.Colors[ImGuiCol_ResizeGrip] = m_resize_grip;
style.Colors[ImGuiCol_ResizeGripHovered] = m_resize_grip_hovered;
style.Colors[ImGuiCol_ResizeGripActive] = m_resize_grip_active;
style.Colors[ImGuiCol_NavHighlight] = m_accent;
style.Colors[ImGuiCol_NavWindowingHighlight] = color_utils::with_alpha(m_accent, 0.7f);
style.Colors[ImGuiCol_NavWindowingDimBg] = m_modal_dim_bg;
style.Colors[ImGuiCol_PlotLines] = m_accent;
style.Colors[ImGuiCol_PlotLinesHovered] = m_accent;
style.Colors[ImGuiCol_PlotHistogram] = m_accent;
style.Colors[ImGuiCol_PlotHistogramHovered] = color_utils::lighten(m_accent, 0.2f);
}
static app_theme g_current_theme;
app_theme &current_theme()
{
return g_current_theme;
}
void set_theme(const core::palette &palette)
{
g_current_theme.apply_palette(palette);
g_current_theme.apply_to_imgui();
}
} // namespace clrsync::gui::theme

235
src/gui/theme/app_theme.hpp Normal file
View File

@@ -0,0 +1,235 @@
#ifndef CLRSYNC_GUI_THEME_APP_THEME_HPP
#define CLRSYNC_GUI_THEME_APP_THEME_HPP
#include "core/palette/palette.hpp"
#include "imgui.h"
#include <string>
namespace clrsync::gui::theme
{
struct color_utils
{
static ImVec4 from_hex(uint32_t hex);
static uint32_t to_imgui_u32(uint32_t hex);
static ImVec4 with_alpha(const ImVec4 &color, float alpha);
static ImVec4 lighten(const ImVec4 &color, float amount);
static ImVec4 darken(const ImVec4 &color, float amount);
static ImVec4 blend(const ImVec4 &a, const ImVec4 &b, float t);
};
class app_theme
{
public:
app_theme() = default;
explicit app_theme(const core::palette &palette);
void apply_palette(const core::palette &palette);
ImVec4 window_bg() const { return m_window_bg; }
ImVec4 child_bg() const { return m_child_bg; }
ImVec4 popup_bg() const { return m_popup_bg; }
ImVec4 modal_dim_bg() const { return m_modal_dim_bg; }
ImVec4 text() const { return m_text; }
ImVec4 text_disabled() const { return m_text_disabled; }
ImVec4 text_selected_bg() const { return m_text_selected_bg; }
ImVec4 border() const { return m_border; }
ImVec4 border_focused() const { return m_border_focused; }
ImVec4 separator() const { return m_separator; }
ImVec4 button() const { return m_button; }
ImVec4 button_hovered() const { return m_button_hovered; }
ImVec4 button_active() const { return m_button_active; }
ImVec4 header() const { return m_header; }
ImVec4 header_hovered() const { return m_header_hovered; }
ImVec4 header_active() const { return m_header_active; }
ImVec4 frame_bg() const { return m_frame_bg; }
ImVec4 frame_bg_hovered() const { return m_frame_bg_hovered; }
ImVec4 frame_bg_active() const { return m_frame_bg_active; }
ImVec4 tab() const { return m_tab; }
ImVec4 tab_hovered() const { return m_tab_hovered; }
ImVec4 tab_active() const { return m_tab_active; }
ImVec4 tab_unfocused() const { return m_tab_unfocused; }
ImVec4 tab_unfocused_active() const { return m_tab_unfocused_active; }
ImVec4 scrollbar_bg() const { return m_scrollbar_bg; }
ImVec4 scrollbar_grab() const { return m_scrollbar_grab; }
ImVec4 scrollbar_grab_hovered() const { return m_scrollbar_grab_hovered; }
ImVec4 scrollbar_grab_active() const { return m_scrollbar_grab_active; }
ImVec4 slider_grab() const { return m_slider_grab; }
ImVec4 slider_grab_active() const { return m_slider_grab_active; }
ImVec4 table_header_bg() const { return m_table_header_bg; }
ImVec4 table_border_strong() const { return m_table_border_strong; }
ImVec4 table_border_light() const { return m_table_border_light; }
ImVec4 table_row_bg() const { return m_table_row_bg; }
ImVec4 table_row_bg_alt() const { return m_table_row_bg_alt; }
ImVec4 title_bg() const { return m_title_bg; }
ImVec4 title_bg_active() const { return m_title_bg_active; }
ImVec4 title_bg_collapsed() const { return m_title_bg_collapsed; }
ImVec4 docking_preview() const { return m_docking_preview; }
ImVec4 docking_empty_bg() const { return m_docking_empty_bg; }
ImVec4 accent() const { return m_accent; }
ImVec4 accent_secondary() const { return m_accent_secondary; }
ImVec4 success() const { return m_success; }
ImVec4 success_hovered() const { return m_success_hovered; }
ImVec4 success_active() const { return m_success_active; }
ImVec4 on_success() const { return m_on_success; }
ImVec4 warning() const { return m_warning; }
ImVec4 warning_hovered() const { return m_warning_hovered; }
ImVec4 warning_active() const { return m_warning_active; }
ImVec4 on_warning() const { return m_on_warning; }
ImVec4 error() const { return m_error; }
ImVec4 error_hovered() const { return m_error_hovered; }
ImVec4 error_active() const { return m_error_active; }
ImVec4 on_error() const { return m_on_error; }
ImVec4 info() const { return m_info; }
ImVec4 info_hovered() const { return m_info_hovered; }
ImVec4 info_active() const { return m_info_active; }
ImVec4 on_info() const { return m_on_info; }
ImVec4 checkmark() const { return m_checkmark; }
ImVec4 resize_grip() const { return m_resize_grip; }
ImVec4 resize_grip_hovered() const { return m_resize_grip_hovered; }
ImVec4 resize_grip_active() const { return m_resize_grip_active; }
ImVec4 autocomplete_bg() const { return m_autocomplete_bg; }
ImVec4 autocomplete_border() const { return m_autocomplete_border; }
ImVec4 autocomplete_selected() const { return m_autocomplete_selected; }
ImVec4 autocomplete_text() const { return m_autocomplete_text; }
ImVec4 autocomplete_selected_text() const { return m_autocomplete_selected_text; }
ImVec4 autocomplete_dim_text() const { return m_autocomplete_dim_text; }
static constexpr float WINDOW_ROUNDING = 6.0f;
static constexpr float FRAME_ROUNDING = 4.0f;
static constexpr float POPUP_ROUNDING = 6.0f;
static constexpr float SCROLLBAR_ROUNDING = 4.0f;
static constexpr float GRAB_ROUNDING = 4.0f;
static constexpr float TAB_ROUNDING = 4.0f;
static constexpr float FRAME_BORDER_SIZE = 1.0f;
static constexpr float WINDOW_BORDER_SIZE = 1.0f;
static constexpr float POPUP_BORDER_SIZE = 1.0f;
static constexpr ImVec2 WINDOW_PADDING{10.0f, 10.0f};
static constexpr ImVec2 FRAME_PADDING{8.0f, 5.0f};
static constexpr ImVec2 ITEM_SPACING{8.0f, 6.0f};
static constexpr ImVec2 ITEM_INNER_SPACING{6.0f, 4.0f};
void apply_to_imgui() const;
void apply_style_vars() const;
private:
ImVec4 get_palette_color(const std::string &key,
const std::string &fallback = "") const;
core::palette m_palette;
ImVec4 m_window_bg{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_child_bg{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_popup_bg{0.098f, 0.098f, 0.098f, 0.98f};
ImVec4 m_modal_dim_bg{0.0f, 0.0f, 0.0f, 0.5f};
ImVec4 m_text{0.83f, 0.83f, 0.83f, 1.0f};
ImVec4 m_text_disabled{0.52f, 0.60f, 0.60f, 1.0f};
ImVec4 m_text_selected_bg{0.60f, 0.52f, 0.32f, 0.5f};
ImVec4 m_border{0.14f, 0.14f, 0.14f, 1.0f};
ImVec4 m_border_focused{0.18f, 0.18f, 0.18f, 1.0f};
ImVec4 m_separator{0.14f, 0.14f, 0.14f, 1.0f};
ImVec4 m_button{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_button_hovered{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_button_active{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_header{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_header_hovered{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_header_active{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_frame_bg{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_frame_bg_hovered{0.12f, 0.12f, 0.12f, 1.0f};
ImVec4 m_frame_bg_active{0.14f, 0.14f, 0.14f, 1.0f};
ImVec4 m_tab{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_tab_hovered{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_tab_active{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_tab_unfocused{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_tab_unfocused_active{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_scrollbar_bg{0.067f, 0.067f, 0.067f, 0.5f};
ImVec4 m_scrollbar_grab{0.14f, 0.14f, 0.14f, 1.0f};
ImVec4 m_scrollbar_grab_hovered{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_scrollbar_grab_active{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_slider_grab{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_slider_grab_active{0.72f, 0.62f, 0.38f, 1.0f};
ImVec4 m_table_header_bg{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_table_border_strong{0.14f, 0.14f, 0.14f, 1.0f};
ImVec4 m_table_border_light{0.10f, 0.10f, 0.10f, 1.0f};
ImVec4 m_table_row_bg{0.0f, 0.0f, 0.0f, 0.0f};
ImVec4 m_table_row_bg_alt{0.83f, 0.83f, 0.83f, 0.04f};
ImVec4 m_title_bg{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_title_bg_active{0.098f, 0.098f, 0.098f, 1.0f};
ImVec4 m_title_bg_collapsed{0.067f, 0.067f, 0.067f, 0.75f};
ImVec4 m_docking_preview{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_docking_empty_bg{0.067f, 0.067f, 0.067f, 1.0f};
ImVec4 m_accent{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_accent_secondary{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_success{0.40f, 0.54f, 0.32f, 1.0f};
ImVec4 m_success_hovered{0.48f, 0.65f, 0.38f, 1.0f};
ImVec4 m_success_active{0.32f, 0.43f, 0.26f, 1.0f};
ImVec4 m_on_success{0.82f, 0.82f, 0.82f, 1.0f};
ImVec4 m_warning{0.71f, 0.47f, 0.22f, 1.0f};
ImVec4 m_warning_hovered{0.85f, 0.56f, 0.26f, 1.0f};
ImVec4 m_warning_active{0.57f, 0.38f, 0.17f, 1.0f};
ImVec4 m_on_warning{0.82f, 0.82f, 0.82f, 1.0f};
ImVec4 m_error{0.67f, 0.31f, 0.29f, 1.0f};
ImVec4 m_error_hovered{0.80f, 0.37f, 0.35f, 1.0f};
ImVec4 m_error_active{0.53f, 0.25f, 0.23f, 1.0f};
ImVec4 m_on_error{0.82f, 0.82f, 0.82f, 1.0f};
ImVec4 m_info{0.23f, 0.54f, 0.55f, 1.0f};
ImVec4 m_info_hovered{0.27f, 0.65f, 0.66f, 1.0f};
ImVec4 m_info_active{0.18f, 0.43f, 0.44f, 1.0f};
ImVec4 m_on_info{0.82f, 0.82f, 0.82f, 1.0f};
ImVec4 m_checkmark{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_resize_grip{0.14f, 0.14f, 0.14f, 0.5f};
ImVec4 m_resize_grip_hovered{0.60f, 0.52f, 0.32f, 0.7f};
ImVec4 m_resize_grip_active{0.60f, 0.52f, 0.32f, 1.0f};
ImVec4 m_autocomplete_bg{0.098f, 0.098f, 0.098f, 0.98f};
ImVec4 m_autocomplete_border{0.25f, 0.25f, 0.28f, 1.0f};
ImVec4 m_autocomplete_selected{0.60f, 0.52f, 0.32f, 0.9f};
ImVec4 m_autocomplete_text{0.85f, 0.85f, 0.9f, 1.0f};
ImVec4 m_autocomplete_selected_text{1.0f, 1.0f, 1.0f, 1.0f};
ImVec4 m_autocomplete_dim_text{0.52f, 0.60f, 0.60f, 1.0f};
};
app_theme &current_theme();
void set_theme(const core::palette &palette);
} // namespace clrsync::gui::theme
#endif // CLRSYNC_GUI_THEME_APP_THEME_HPP

View File

@@ -1,5 +1,8 @@
#include "gui/ui_manager.hpp"
#include "gui/backend/backend.hpp"
#include "gui/platform/font_loader.hpp"
#include "gui/platform/file_browser.hpp"
#include "core/config/config.hpp"
#include <imgui.h>
@@ -8,11 +11,14 @@ namespace clrsync::gui
ui_manager::ui_manager(backend::backend_interface* backend)
: m_backend(backend)
{
m_font_loader = new font_loader();
}
ui_manager::~ui_manager()
{
shutdown();
delete m_font_loader;
m_font_loader = nullptr;
}
bool ui_manager::initialize(const ui_config& config)
@@ -44,6 +50,13 @@ bool ui_manager::initialize(const ui_config& config)
return false;
}
ImFont *font = m_font_loader->load_font(
clrsync::core::config::instance().font().c_str(),
clrsync::core::config::instance().font_size());
if (font)
io.FontDefault = font;
return true;
}
@@ -68,4 +81,57 @@ void ui_manager::end_frame()
ImGui::Render();
m_backend->imgui_render_draw_data(ImGui::GetDrawData());
}
}
void ui_manager::push_default_font()
{
if (m_font_loader)
m_font_loader->push_default_font();
}
void ui_manager::pop_font()
{
if (m_font_loader)
m_font_loader->pop_font();
}
std::vector<std::string> ui_manager::get_system_fonts() const
{
if (m_font_loader)
return m_font_loader->get_system_fonts();
return {};
}
bool ui_manager::reload_font(const char* font_name, float size)
{
if (!m_font_loader)
return false;
ImFont* font = m_font_loader->load_font(font_name, size);
if (font)
{
ImGui::GetIO().FontDefault = font;
return true;
}
return false;
}
std::string ui_manager::open_file_dialog(const std::string& title,
const std::string& initial_path,
const std::vector<std::string>& filters)
{
return file_dialogs::open_file_dialog(title, initial_path, filters);
}
std::string ui_manager::save_file_dialog(const std::string& title,
const std::string& initial_path,
const std::vector<std::string>& filters)
{
return file_dialogs::save_file_dialog(title, initial_path, filters);
}
std::string ui_manager::select_folder_dialog(const std::string& title,
const std::string& initial_path)
{
return file_dialogs::select_folder_dialog(title, initial_path);
}
}

View File

@@ -1,6 +1,10 @@
#ifndef CLRSYNC_UI_MANAGER_HPP
#define CLRSYNC_UI_MANAGER_HPP
#include <string>
#include <vector>
class font_loader;
struct ImFont;
namespace clrsync::gui::backend
{
@@ -29,9 +33,25 @@ public:
void begin_frame();
void end_frame();
void push_default_font();
void pop_font();
std::vector<std::string> get_system_fonts() const;
bool reload_font(const char* font_name, float size);
std::string open_file_dialog(const std::string& title = "Open File",
const std::string& initial_path = "",
const std::vector<std::string>& filters = {});
std::string save_file_dialog(const std::string& title = "Save File",
const std::string& initial_path = "",
const std::vector<std::string>& filters = {});
std::string select_folder_dialog(const std::string& title = "Select Folder",
const std::string& initial_path = "");
private:
backend::backend_interface *m_backend;
void *m_imgui_context = nullptr;
font_loader *m_font_loader = nullptr;
};
}

View File

@@ -1,11 +1,11 @@
#include "gui/views/about_window.hpp"
#include "core/common/version.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/widgets/centered_text.hpp"
#include "gui/widgets/colors.hpp"
#include "gui/widgets/link_button.hpp"
#include "imgui.h"
about_window::about_window()
{
}
about_window::about_window() = default;
void about_window::render(const clrsync::core::palette &pal)
{
@@ -16,21 +16,13 @@ void about_window::render(const clrsync::core::palette &pal)
if (ImGui::Begin("About clrsync", &m_visible, ImGuiWindowFlags_NoResize))
{
const float window_width = ImGui::GetContentRegionAvail().x;
using namespace clrsync::gui::widgets;
ImGui::PushFont(ImGui::GetFont());
const char *title = "clrsync";
const float title_size = ImGui::CalcTextSize(title).x;
ImGui::SetCursorPosX((window_width - title_size) * 0.5f);
ImVec4 title_color = palette_utils::get_color(pal, "info", "accent");
ImGui::TextColored(title_color, "%s", title);
ImGui::PopFont();
ImVec4 title_color = palette_color(pal, "info", "accent");
centered_text("clrsync", title_color);
std::string version = "Version " + clrsync::core::version_string();
const float version_size = ImGui::CalcTextSize(version.c_str()).x;
ImGui::SetCursorPosX((window_width - version_size) * 0.5f);
ImVec4 subtitle_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
ImGui::TextColored(subtitle_color, "%s", version.c_str());
ImVec4 subtitle_color = palette_color(pal, "editor_inactive", "foreground");
centered_text("Version " + clrsync::core::version_string(), subtitle_color);
ImGui::Spacing();
ImGui::Separator();
@@ -40,47 +32,25 @@ void about_window::render(const clrsync::core::palette &pal)
ImGui::Spacing();
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
ImGui::Text("Links:");
constexpr float button_width = 200.0f;
float spacing = ImGui::GetStyle().ItemSpacing.x;
float total_width = 2.0f * button_width + spacing;
const float button_width = 200.0f;
const float spacing = ImGui::GetStyle().ItemSpacing.x;
const float total_width = 2.0f * button_width + spacing;
ImGui::SetCursorPosX((window_width - total_width) * 0.5f);
if (ImGui::Button("GitHub Repository", ImVec2(button_width, 0)))
{
#ifdef _WIN32
system("start https://github.com/obsqrbtz/clrsync");
#elif __APPLE__
system("open https://github.com/obsqrbtz/clrsync");
#else
system("xdg-open https://github.com/obsqrbtz/clrsync");
#endif
}
ImGui::SameLine();
if (ImGui::Button("Documentation", ImVec2(button_width, 0)))
{
#ifdef _WIN32
system("start https://binarygoose.dev/projects/clrsync/overview/");
#elif __APPLE__
system("open https://binarygoose.dev/projects/clrsync/overview/");
#else
system("xdg-open https://binarygoose.dev/projects/clrsync/overview/");
#endif
}
centered_buttons(total_width, [button_width]() {
link_button("GitHub Repository", "https://github.com/obsqrbtz/clrsync", button_width);
ImGui::SameLine();
link_button("Documentation", "https://binarygoose.dev/projects/clrsync/overview/", button_width);
});
ImGui::Spacing();
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
ImVec4 license_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
ImGui::TextColored(license_color, "MIT License");
ImGui::TextColored(subtitle_color, "MIT License");
ImGui::TextWrapped(
"Copyright (c) 2025 Daniel Dada\n\n"
"Permission is hereby granted, free of charge, to any person obtaining a copy "
@@ -93,4 +63,4 @@ void about_window::render(const clrsync::core::palette &pal)
"copies or substantial portions of the Software.");
}
ImGui::End();
}
}

View File

@@ -1,11 +1,18 @@
#include "color_scheme_editor.hpp"
#include "core/palette/hellwal_generator.hpp"
#include "core/palette/matugen_generator.hpp"
#include "gui/controllers/theme_applier.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/platform/file_browser.hpp"
#include "gui/widgets/action_buttons.hpp"
#include "gui/widgets/dialogs.hpp"
#include "gui/widgets/input_dialog.hpp"
#include "gui/widgets/palette_selector.hpp"
#include "imgui.h"
#include "settings_window.hpp"
#include "template_editor.hpp"
#include <cstdio>
#include <filesystem>
#include <iostream>
#include <ranges>
color_scheme_editor::color_scheme_editor()
{
@@ -20,6 +27,8 @@ color_scheme_editor::color_scheme_editor()
{
std::cout << "WARNING: No palette loaded, skipping theme application\n";
}
setup_widgets();
}
void color_scheme_editor::notify_palette_changed()
@@ -78,124 +87,319 @@ void color_scheme_editor::render_controls()
ImGui::Text("Palette:");
ImGui::SameLine();
ImGui::SetNextItemWidth(200.0f);
if (ImGui::BeginCombo("##scheme", current.name().c_str()))
{
for (const auto &name : palettes | std::views::keys)
{
const bool selected = current.name() == name;
if (ImGui::Selectable(name.c_str(), selected))
{
m_controller.select_palette(name);
apply_themes();
}
if (selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Select a color palette to edit");
m_palette_selector.render(m_controller, 200.0f);
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
static char new_palette_name_buf[128] = "";
if (ImGui::Button(" + New "))
{
new_palette_name_buf[0] = 0;
ImGui::OpenPopup("New Palette");
m_new_palette_dialog.open("New Palette",
"Enter a name for the new palette:", "Palette name...");
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Create a new palette");
if (ImGui::BeginPopupModal("New Palette", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
m_new_palette_dialog.render();
m_generate_dialog.render();
ImGui::SameLine();
m_action_buttons.render(current);
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button("Generate"))
{
ImGui::Text("Enter a name for the new palette:");
ImGui::Spacing();
m_show_generate_modal = true;
}
ImGui::SetNextItemWidth(250);
ImGui::InputTextWithHint("##new_palette_input", "Palette name...", new_palette_name_buf,
IM_ARRAYSIZE(new_palette_name_buf));
if (m_show_generate_modal)
{
ImGui::OpenPopup("Generate Palette");
m_show_generate_modal = false;
}
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
if (ImGui::BeginPopupModal("Generate Palette", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::Text("Generator:");
const char *generators[] = {"hellwal", "matugen"};
ImGui::SameLine();
ImGui::SetNextItemWidth(160.0f);
ImGui::Combo("##gen_select", &m_generator_idx, generators, IM_ARRAYSIZE(generators));
bool can_create = strlen(new_palette_name_buf) > 0;
if (!can_create)
ImGui::BeginDisabled();
if (ImGui::Button("Create", ImVec2(120, 0)))
if (m_generator_idx == 0) // hellwal
{
m_controller.create_palette(new_palette_name_buf);
m_controller.select_palette(new_palette_name_buf);
apply_themes();
new_palette_name_buf[0] = 0;
ImGui::CloseCurrentPopup();
ImGui::Separator();
ImGui::Text("hellwal options");
ImGui::Spacing();
// image selector
ImGui::Text("Image:");
ImGui::SameLine();
ImGui::SetNextItemWidth(300.0f);
{
char buf[1024];
std::strncpy(buf, m_gen_image_path.c_str(), sizeof(buf));
buf[sizeof(buf) - 1] = '\0';
if (ImGui::InputText("##gen_image", buf, sizeof(buf)))
{
m_gen_image_path = buf;
}
}
ImGui::SameLine();
if (ImGui::Button("Browse##gen_image"))
{
std::string res = file_dialogs::open_file_dialog("Select Image", m_gen_image_path,
{"png", "jpg", "jpeg", "bmp"});
if (!res.empty())
m_gen_image_path = res;
}
ImGui::Checkbox("Neon mode", &m_gen_neon);
ImGui::Text("Modes (can combine):");
ImGui::Checkbox("Dark", &m_gen_dark);
ImGui::SameLine();
ImGui::Checkbox("Light", &m_gen_light);
ImGui::SameLine();
ImGui::Checkbox("Color", &m_gen_color);
ImGui::SliderFloat("Dark offset", &m_gen_dark_offset, 0.0f, 1.0f);
ImGui::SliderFloat("Bright offset", &m_gen_bright_offset, 0.0f, 1.0f);
ImGui::Checkbox("Invert colors", &m_gen_invert);
ImGui::SliderFloat("Gray scale", &m_gen_gray_scale, 0.0f, 1.0f);
}
if (!can_create)
ImGui::EndDisabled();
if (m_generator_idx == 1) // matugen
{
ImGui::Separator();
ImGui::Text("matugen options");
ImGui::Spacing();
ImGui::Text("Image:");
ImGui::SameLine();
ImGui::SetNextItemWidth(300.0f);
{
char buf[1024];
std::strncpy(buf, m_gen_image_path.c_str(), sizeof(buf));
buf[sizeof(buf) - 1] = '\0';
if (ImGui::InputText("##gen_image", buf, sizeof(buf)))
{
m_gen_image_path = buf;
}
}
ImGui::SameLine();
if (ImGui::Button("Browse##gen_image"))
{
std::string res = file_dialogs::open_file_dialog("Select Image", m_gen_image_path,
{"png", "jpg", "jpeg", "bmp"});
if (!res.empty())
m_gen_image_path = res;
}
ImGui::Text("Mode:");
ImGui::SameLine();
const char *modes[] = {"dark", "light"};
int mode_idx = (m_matugen_mode == "light") ? 1 : 0;
ImGui::SetNextItemWidth(120.0f);
ImGui::Combo("##matugen_mode", &mode_idx, modes, IM_ARRAYSIZE(modes));
m_matugen_mode = (mode_idx == 1) ? "light" : "dark";
ImGui::Text("Type:");
ImGui::SameLine();
const char *types[] = {"scheme-content", "scheme-expressive", "scheme-fidelity",
"scheme-fruit-salad", "scheme-monochrome", "scheme-neutral",
"scheme-rainbow", "scheme-tonal-spot"};
int type_idx = 7; // default index for scheme-tonal-spot
for (int i = 0; i < IM_ARRAYSIZE(types); ++i)
{
if (m_matugen_type == types[i])
{
type_idx = i;
break;
}
}
ImGui::SetNextItemWidth(260.0f);
ImGui::Combo("##matugen_type", &type_idx, types, IM_ARRAYSIZE(types));
m_matugen_type = types[type_idx];
ImGui::SliderFloat("Contrast", &m_matugen_contrast, -1.0f, 1.0f);
ImGui::Spacing();
ImGui::Checkbox("Use color (instead of image)", &m_matugen_use_color);
if (m_matugen_use_color)
{
ImGui::Text("Color:");
ImGui::SameLine();
ImGui::ColorEdit3("##matugen_color", m_matugen_color_vec);
// update hex string from vec
int r = static_cast<int>(m_matugen_color_vec[0] * 255.0f + 0.5f);
int g = static_cast<int>(m_matugen_color_vec[1] * 255.0f + 0.5f);
int b = static_cast<int>(m_matugen_color_vec[2] * 255.0f + 0.5f);
char hexbuf[8];
std::snprintf(hexbuf, sizeof(hexbuf), "%02X%02X%02X", r, g, b);
m_matugen_color_hex = hexbuf;
}
}
ImGui::Separator();
if (ImGui::Button("Generate", ImVec2(120, 0)))
{
try
{
if (m_generator_idx == 0)
{
clrsync::core::hellwal_generator gen;
clrsync::core::hellwal_generator::options opts;
opts.neon = m_gen_neon;
opts.dark = m_gen_dark;
opts.light = m_gen_light;
opts.color = m_gen_color;
opts.dark_offset = m_gen_dark_offset;
opts.bright_offset = m_gen_bright_offset;
opts.invert = m_gen_invert;
opts.gray_scale = m_gen_gray_scale;
auto image_path = m_gen_image_path;
if (image_path.empty())
{
image_path = file_dialogs::open_file_dialog("Select Image", "",
{"png", "jpg", "jpeg", "bmp"});
}
auto pal = gen.generate_from_image(image_path, opts);
if (pal.name().empty())
{
std::filesystem::path p(image_path);
pal.set_name(std::string("hellwal:") + p.filename().string());
}
m_controller.import_palette(pal);
m_controller.select_palette(pal.name());
apply_themes();
}
else if (m_generator_idx == 1)
{
clrsync::core::matugen_generator gen;
clrsync::core::matugen_generator::options opts;
opts.mode = m_matugen_mode;
opts.type = m_matugen_type;
opts.contrast = m_matugen_contrast;
auto image_path = m_gen_image_path;
clrsync::core::palette pal;
if (m_matugen_use_color)
{
// pass hex without '#' to generator
std::string hex = m_matugen_color_hex;
if (!hex.empty() && hex[0] == '#')
hex = hex.substr(1);
pal = gen.generate_from_color(hex, opts);
if (pal.name().empty())
{
pal.set_name(std::string("matugen:color:") + hex);
}
}
else
{
if (image_path.empty())
{
image_path = file_dialogs::open_file_dialog(
"Select Image", "", {"png", "jpg", "jpeg", "bmp"});
}
pal = gen.generate_from_image(image_path, opts);
if (pal.name().empty())
{
std::filesystem::path p(image_path);
pal.set_name(std::string("matugen:") + p.filename().string());
}
}
if (pal.name().empty())
{
std::filesystem::path p(image_path);
pal.set_name(std::string("matugen:") + p.filename().string());
}
m_controller.import_palette(pal);
m_controller.select_palette(pal.name());
apply_themes();
}
}
catch (const std::exception &e)
{
std::cerr << "Generation failed: " << e.what() << std::endl;
}
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(120, 0)))
{
new_palette_name_buf[0] = 0;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::SameLine();
if (ImGui::Button(" Save "))
{
m_controller.save_current_palette();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Save current palette to file");
ImGui::SameLine();
auto error = palette_utils::get_color(current, "error");
auto error_hover = ImVec4(error.x * 1.1f, error.y * 1.1f, error.z * 1.1f, error.w);
auto error_active = ImVec4(error.x * 0.8f, error.y * 0.8f, error.z * 0.8f, error.w);
auto on_error = palette_utils::get_color(current, "on_error");
ImGui::PushStyleColor(ImGuiCol_Button, error);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_hover);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, error_active);
ImGui::PushStyleColor(ImGuiCol_Text, on_error);
if (ImGui::Button(" Delete "))
{
m_show_delete_confirmation = true;
}
ImGui::PopStyleColor(4);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Delete current palette");
if (m_show_delete_confirmation)
{
ImGui::OpenPopup("Delete Palette?");
m_show_delete_confirmation = false;
}
palette_utils::render_delete_confirmation_popup("Delete Palette?", current.name(), "palette",
current, [this]() {
m_controller.delete_current_palette();
apply_themes();
});
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 16);
if (ImGui::Button(" Apply Theme "))
{
m_controller.apply_current_theme();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Apply current palette to all enabled templates");
clrsync::gui::widgets::delete_confirmation_dialog("Delete Palette?", current.name(), "palette",
current, [this]() {
m_controller.delete_current_palette();
apply_themes();
});
ImGui::PopStyleVar(2);
}
void color_scheme_editor::setup_widgets()
{
m_palette_selector.set_on_selection_changed([this](const std::string &name) {
m_controller.select_palette(name);
apply_themes();
});
m_new_palette_dialog.set_on_submit([this](const std::string &name) {
m_controller.create_palette(name);
m_controller.select_palette(name);
apply_themes();
});
m_generate_dialog.set_on_submit([this](const std::string &image_path) {
try
{
clrsync::core::hellwal_generator gen;
auto pal = gen.generate_from_image(image_path);
if (pal.name().empty())
{
std::filesystem::path p(image_path);
pal.set_name(std::string("hellwal:") + p.filename().string());
}
m_controller.import_palette(pal);
m_controller.select_palette(pal.name());
apply_themes();
}
catch (const std::exception &e)
{
std::cerr << "Failed to generate palette: " << e.what() << std::endl;
}
});
m_generate_dialog.set_path_browse_callback(
[this](const std::string &current_path) -> std::string {
return file_dialogs::open_file_dialog("Select Image", current_path,
{"png", "jpg", "jpeg", "bmp"});
});
m_action_buttons.add_button({" Save ", "Save current palette to file",
[this]() { m_controller.save_current_palette(); }});
m_action_buttons.add_button({" Delete ", "Delete current palette",
[this]() { m_show_delete_confirmation = true; }, true, true});
m_action_buttons.add_button({" Apply Theme ", "Apply current palette to all enabled templates",
[this]() { m_controller.apply_current_theme(); }});
m_action_buttons.set_spacing(16.0f);
}

View File

@@ -4,6 +4,9 @@
#include "gui/controllers/palette_controller.hpp"
#include "gui/views/color_table_renderer.hpp"
#include "gui/views/preview_renderer.hpp"
#include "gui/widgets/action_buttons.hpp"
#include "gui/widgets/input_dialog.hpp"
#include "gui/widgets/palette_selector.hpp"
class template_editor;
class settings_window;
@@ -32,6 +35,7 @@ class color_scheme_editor
void render_controls();
void apply_themes();
void notify_palette_changed();
void setup_widgets();
palette_controller m_controller;
color_table_renderer m_color_table;
@@ -39,6 +43,31 @@ class color_scheme_editor
template_editor *m_template_editor{nullptr};
settings_window *m_settings_window{nullptr};
bool m_show_delete_confirmation{false};
clrsync::gui::widgets::palette_selector m_palette_selector;
clrsync::gui::widgets::input_dialog m_new_palette_dialog;
clrsync::gui::widgets::input_dialog m_generate_dialog;
int m_generator_idx{0};
bool m_show_generate_modal{false};
// hellwal
std::string m_gen_image_path;
bool m_gen_neon{false};
bool m_gen_dark{true};
bool m_gen_light{false};
bool m_gen_color{false};
float m_gen_dark_offset{0.0f};
float m_gen_bright_offset{0.0f};
bool m_gen_invert{false};
float m_gen_gray_scale{0.0f};
// matugen
std::string m_matugen_mode{"dark"};
std::string m_matugen_type{"scheme-tonal-spot"};
float m_matugen_contrast{0.0f};
// matugen color option
bool m_matugen_use_color{false};
float m_matugen_color_vec[3]{1.0f, 0.0f, 0.0f};
std::string m_matugen_color_hex{"FF0000"};
clrsync::gui::widgets::action_buttons m_action_buttons;
};
#endif // CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP

View File

@@ -1,5 +1,5 @@
#include "gui/views/color_table_renderer.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/widgets/colors.hpp"
#include "imgui.h"
#include <algorithm>
#include <cctype>
@@ -36,7 +36,7 @@ void color_table_renderer::render_color_row(const std::string &name,
ImGui::TableSetColumnIndex(0);
const float key_col_width = ImGui::GetContentRegionAvail().x;
ImVec4 text_color = palette_utils::get_color(current, "info", "accent");
ImVec4 text_color = clrsync::gui::widgets::palette_color(current, "info", "accent");
ImGui::PushStyleColor(ImGuiCol_Text, text_color);
const bool copied = ImGui::Selectable(name.c_str(), false, 0, ImVec2(key_col_width, 0.0f));
ImGui::PopStyleColor();
@@ -107,13 +107,14 @@ void color_table_renderer::render(const clrsync::core::palette &current,
{
if (current.colors().empty())
{
ImVec4 warning_color = palette_utils::get_color(current, "warning", "accent");
ImVec4 warning_color = clrsync::gui::widgets::palette_color(current, "warning", "accent");
ImGui::TextColored(warning_color, "No palette loaded");
return;
}
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 6));
ImGui::AlignTextToFramePadding();
ImGui::Text("Filter:");
ImGui::SameLine();
ImGui::SetNextItemWidth(200);
@@ -153,7 +154,8 @@ void color_table_renderer::render(const clrsync::core::palette &current,
if (!has_matches)
return;
ImGui::PushStyleColor(ImGuiCol_Text, palette_utils::get_color(current, "accent"));
ImGui::PushStyleColor(ImGuiCol_Text,
clrsync::gui::widgets::palette_color(current, "accent"));
bool header_open = ImGui::TreeNodeEx(title, ImGuiTreeNodeFlags_DefaultOpen |
ImGuiTreeNodeFlags_SpanAvailWidth);
ImGui::PopStyleColor();
@@ -182,19 +184,43 @@ void color_table_renderer::render(const clrsync::core::palette &current,
draw_table("General UI", "##general_ui",
{"background", "on_background", "surface", "on_surface", "surface_variant",
"on_surface_variant", "foreground", "cursor", "accent"});
draw_table("Borders", "##borders", {"border_focused", "border"});
"on_surface_variant", "border_focused", "border", "foreground", "cursor", "accent",
"accent_secondary"});
draw_table(
"Semantic Colors", "##semantic",
{"success", "info", "warning", "error", "on_success", "on_info", "on_warning", "on_error"});
draw_table("Editor", "##editor",
{"editor_background", "editor_command", "editor_comment", "editor_disabled",
"editor_emphasis", "editor_error", "editor_inactive", "editor_line_number",
"editor_link", "editor_main", "editor_selected", "editor_selection_inactive",
"editor_string", "editor_success", "editor_warning"});
draw_table("Editor - Basic", "##editor_basic",
{"editor_background", "editor_foreground", "editor_line_highlight",
"editor_selection", "editor_selection_inactive", "editor_cursor",
"editor_whitespace"});
draw_table("Editor - Gutter", "##editor_gutter",
{"editor_gutter_background", "editor_gutter_foreground", "editor_line_number",
"editor_line_number_active"});
draw_table("Editor - Syntax", "##editor_syntax",
{"editor_comment", "editor_string", "editor_number", "editor_boolean",
"editor_keyword", "editor_operator", "editor_function", "editor_variable",
"editor_parameter", "editor_property", "editor_constant", "editor_type",
"editor_class", "editor_interface", "editor_enum", "editor_namespace",
"editor_attribute", "editor_decorator", "editor_tag", "editor_punctuation",
"editor_link", "editor_regex", "editor_escape_character"});
draw_table("Editor - Diagnostics", "##editor_diagnostics",
{"editor_invalid", "editor_error", "editor_error_background", "editor_warning",
"editor_warning_background", "editor_info", "editor_info_background",
"editor_hint", "editor_hint_background"});
draw_table("Editor - UI Elements", "##editor_ui",
{"editor_active_line_border", "editor_indent_guide", "editor_indent_guide_active",
"editor_bracket_match", "editor_search_match", "editor_search_match_active",
"editor_find_range_highlight"});
draw_table("Editor - Diff", "##editor_diff",
{"editor_deleted", "editor_inserted", "editor_modified", "editor_ignored",
"editor_folded_background"});
draw_table("Terminal (Base16)", "##terminal",
{"base00", "base01", "base02", "base03", "base04", "base05", "base06", "base07",

View File

@@ -1,6 +1,6 @@
#include "gui/views/preview_renderer.hpp"
#include "gui/controllers/theme_applier.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/widgets/colors.hpp"
#include "imgui.h"
#include <algorithm>
#include <array>
@@ -236,7 +236,7 @@ void preview_renderer::render(const clrsync::core::palette &current)
{
if (current.colors().empty())
{
ImVec4 error_color = palette_utils::get_color(current, "error", "accent");
ImVec4 error_color = clrsync::gui::widgets::palette_color(current, "error", "accent");
ImGui::TextColored(error_color, "Current palette is empty");
return;
}

View File

@@ -1,25 +1,28 @@
#include "gui/views/settings_window.hpp"
#include "core/common/error.hpp"
#include "core/config/config.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/platform/file_browser.hpp"
#include "gui/platform/font_loader.hpp"
#include "gui/ui_manager.hpp"
#include "gui/widgets/section_header.hpp"
#include "imgui.h"
#include <cstring>
settings_window::settings_window()
: m_font_size(14), m_selected_font_idx(0), m_settings_changed(false), m_current_tab(0)
settings_window::settings_window(clrsync::gui::ui_manager *ui_mgr) : m_ui_manager(ui_mgr)
{
m_default_theme[0] = '\0';
m_palettes_path[0] = '\0';
m_font[0] = '\0';
font_loader loader;
m_available_fonts = loader.get_system_fonts();
if (m_ui_manager)
m_available_fonts = m_ui_manager->get_system_fonts();
setup_widgets();
load_settings();
}
void settings_window::setup_widgets()
{
m_form.set_path_browse_callback([this](const std::string &current_path) -> std::string {
if (m_ui_manager)
return m_ui_manager->select_folder_dialog("Select Directory", current_path);
return "";
});
}
void settings_window::render()
{
if (!m_visible)
@@ -29,8 +32,7 @@ void settings_window::render()
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_FirstUseEver,
ImVec2(0.5f, 0.5f));
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoCollapse;
if (ImGui::Begin("Settings", &m_visible, window_flags))
if (ImGui::Begin("Settings", &m_visible, ImGuiWindowFlags_NoCollapse))
{
if (ImGui::BeginTabBar("SettingsTabs", ImGuiTabBarFlags_None))
{
@@ -49,10 +51,33 @@ void settings_window::render()
ImGui::EndTabBar();
}
render_status_messages();
m_error.render(m_current_palette);
ImGui::Separator();
render_action_buttons();
clrsync::gui::widgets::settings_buttons_callbacks callbacks{
.on_ok =
[this]() {
apply_settings();
if (!m_error.has_error())
{
m_visible = false;
m_settings_changed = false;
}
},
.on_apply =
[this]() {
apply_settings();
if (!m_error.has_error())
m_settings_changed = false;
},
.on_reset = [this]() { reset_to_defaults(); },
.on_cancel =
[this]() {
load_settings();
m_visible = false;
}};
m_buttons.render(callbacks, m_settings_changed);
}
ImGui::End();
}
@@ -61,31 +86,22 @@ void settings_window::load_settings()
{
auto &cfg = clrsync::core::config::instance();
std::string default_theme = cfg.default_theme();
strncpy(m_default_theme, default_theme.c_str(), sizeof(m_default_theme) - 1);
m_default_theme[sizeof(m_default_theme) - 1] = '\0';
std::string palettes_path = cfg.palettes_path();
strncpy(m_palettes_path, palettes_path.c_str(), sizeof(m_palettes_path) - 1);
m_palettes_path[sizeof(m_palettes_path) - 1] = '\0';
std::string font = cfg.font();
strncpy(m_font, font.c_str(), sizeof(m_font) - 1);
m_font[sizeof(m_font) - 1] = '\0';
m_default_theme = cfg.default_theme();
m_palettes_path = cfg.palettes_path();
m_font = cfg.font();
m_font_size = cfg.font_size();
m_selected_font_idx = 0;
for (int i = 0; i < static_cast<int>(m_available_fonts.size()); i++)
{
if (m_available_fonts[i] == font)
if (m_available_fonts[i] == m_font)
{
m_selected_font_idx = i;
break;
}
}
m_font_size = cfg.font_size();
m_error_message.clear();
m_error.clear();
m_settings_changed = false;
}
@@ -93,286 +109,132 @@ void settings_window::apply_settings()
{
auto &cfg = clrsync::core::config::instance();
if (strlen(m_default_theme) == 0)
if (m_default_theme.empty())
{
m_error_message = "Default theme cannot be empty";
m_error.set("Default theme cannot be empty");
return;
}
if (strlen(m_palettes_path) == 0)
if (m_palettes_path.empty())
{
m_error_message = "Palettes path cannot be empty";
m_error.set("Palettes path cannot be empty");
return;
}
if (strlen(m_font) == 0)
if (m_font.empty())
{
m_error_message = "Font cannot be empty";
m_error.set("Font cannot be empty");
return;
}
if (m_font_size < 8 || m_font_size > 48)
{
m_error_message = "Font size must be between 8 and 48";
m_error.set("Font size must be between 8 and 48");
return;
}
auto result1 = cfg.set_default_theme(m_default_theme);
if (!result1)
{
m_error_message = "Failed to set default theme: " + result1.error().description();
m_error.set("Failed to set default theme: " + result1.error().description());
return;
}
auto result2 = cfg.set_palettes_path(m_palettes_path);
if (!result2)
{
m_error_message = "Failed to set palettes path: " + result2.error().description();
m_error.set("Failed to set palettes path: " + result2.error().description());
return;
}
auto result3 = cfg.set_font(m_font);
if (!result3)
{
m_error_message = "Failed to set font: " + result3.error().description();
m_error.set("Failed to set font: " + result3.error().description());
return;
}
auto result4 = cfg.set_font_size(m_font_size);
if (!result4)
{
m_error_message = "Failed to set font size: " + result4.error().description();
m_error.set("Failed to set font size: " + result4.error().description());
return;
}
font_loader fn_loader;
auto font = fn_loader.load_font(m_font, m_font_size);
if (font)
ImGui::GetIO().FontDefault = font;
if (m_ui_manager && !m_ui_manager->reload_font(m_font.c_str(), m_font_size))
{
m_error.set("Failed to load font: " + m_font);
return;
}
m_error_message.clear();
m_error.clear();
m_settings_changed = false;
}
void settings_window::render_general_tab()
{
ImGui::Spacing();
using namespace clrsync::gui::widgets;
auto accent_color = palette_utils::get_color(m_current_palette, "accent");
ImGui::TextColored(accent_color, "Theme Settings");
ImGui::Separator();
ImGui::Spacing();
section_header("Theme Settings", m_current_palette);
ImGui::Text("Default Theme:");
ImGui::SameLine();
show_help_marker("The default color scheme to load on startup");
ImGui::SetNextItemWidth(-100.0f);
if (ImGui::InputText("##default_theme", m_default_theme, sizeof(m_default_theme)))
form_field_config theme_cfg;
theme_cfg.label = "Default Theme";
theme_cfg.label_width = 150.0f;
theme_cfg.tooltip = "The default color scheme to load on startup";
theme_cfg.field_width = -100.0f;
if (m_form.render_text(theme_cfg, m_default_theme))
m_settings_changed = true;
ImGui::Spacing();
section_header("Path Settings", m_current_palette);
ImGui::TextColored(accent_color, "Path Settings");
ImGui::Separator();
ImGui::Spacing();
ImGui::Text("Palettes Directory:");
ImGui::SameLine();
show_help_marker("Directory where color palettes are stored\nSupports ~ for home directory");
ImGui::SetNextItemWidth(-120.0f);
if (ImGui::InputText("##palettes_path", m_palettes_path, sizeof(m_palettes_path)))
form_field_config path_cfg;
path_cfg.label = "Palettes Directory";
path_cfg.label_width = 150.0f;
path_cfg.tooltip = "Directory where color palettes are stored\nSupports ~ for home directory";
path_cfg.field_width = -1.0f;
path_cfg.type = field_type::path;
if (m_form.render_path(path_cfg, m_palettes_path))
m_settings_changed = true;
ImGui::SameLine();
if (ImGui::Button("Browse"))
{
std::string selected_path =
file_dialogs::select_folder_dialog("Select Palettes Directory", m_palettes_path);
if (!selected_path.empty())
{
strncpy(m_palettes_path, selected_path.c_str(), sizeof(m_palettes_path) - 1);
m_palettes_path[sizeof(m_palettes_path) - 1] = '\0';
m_settings_changed = true;
}
}
}
void settings_window::render_appearance_tab()
{
ImGui::Spacing();
using namespace clrsync::gui::widgets;
auto accent_color = palette_utils::get_color(m_current_palette, "accent");
ImGui::TextColored(accent_color, "Font Settings");
ImGui::Separator();
ImGui::Spacing();
section_header("Font Settings", m_current_palette);
ImGui::Text("Font Family:");
ImGui::SameLine();
show_help_marker("Select font family for the application interface");
ImGui::SetNextItemWidth(-1.0f);
if (ImGui::BeginCombo("##font", m_font))
{
for (int i = 0; i < static_cast<int>(m_available_fonts.size()); i++)
{
bool is_selected = (i == m_selected_font_idx);
if (ImGui::Selectable(m_available_fonts[i].c_str(), is_selected))
{
m_selected_font_idx = i;
strncpy(m_font, m_available_fonts[i].c_str(), sizeof(m_font) - 1);
m_font[sizeof(m_font) - 1] = '\0';
m_settings_changed = true;
}
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::Spacing();
ImGui::Text("Font Size:");
ImGui::SameLine();
show_help_marker("Font size for the application interface (8-48)");
ImGui::SetNextItemWidth(120.0f);
int old_size = m_font_size;
if (ImGui::SliderInt("##font_size", &m_font_size, 8, 48, "%d px"))
{
if (old_size != m_font_size)
m_settings_changed = true;
}
ImGui::SameLine();
if (ImGui::Button("Reset"))
{
m_font_size = 14;
form_field_config font_cfg;
font_cfg.label = "Font Family";
font_cfg.label_width = 150.0f;
font_cfg.tooltip = "Select font family for the application interface";
font_cfg.field_width = -1.0f;
font_cfg.type = field_type::combo;
if (m_form.render_combo(font_cfg, m_available_fonts, m_selected_font_idx, m_font))
m_settings_changed = true;
}
}
void settings_window::render_status_messages()
{
if (!m_error_message.empty())
{
ImGui::Spacing();
auto error_bg_color = palette_utils::get_color(m_current_palette, "error");
auto error_text_color = palette_utils::get_color(m_current_palette, "on_error");
ImGui::PushStyleColor(ImGuiCol_ChildBg, error_bg_color);
ImGui::PushStyleColor(ImGuiCol_Border, error_bg_color);
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
if (ImGui::BeginChild("##error_box", ImVec2(0, 0),
ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_Borders))
{
ImGui::PushStyleColor(ImGuiCol_Text, error_text_color);
ImGui::TextWrapped("Error: %s", m_error_message.c_str());
ImGui::PopStyleColor();
ImGui::Spacing();
ImGui::PushStyleColor(ImGuiCol_Button,
ImVec4(error_bg_color.x * 0.8f, error_bg_color.y * 0.8f,
error_bg_color.z * 0.8f, error_bg_color.w));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
ImVec4(error_bg_color.x * 0.6f, error_bg_color.y * 0.6f,
error_bg_color.z * 0.6f, error_bg_color.w));
ImGui::PushStyleColor(ImGuiCol_Text, error_text_color);
if (ImGui::Button("Dismiss##error"))
m_error_message.clear();
ImGui::PopStyleColor(3);
}
ImGui::EndChild();
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(2);
}
}
void settings_window::render_action_buttons()
{
ImGui::Spacing();
float button_width = 100.0f;
float spacing = ImGui::GetStyle().ItemSpacing.x;
float window_width = ImGui::GetContentRegionAvail().x;
float total_buttons_width = 4 * button_width + 3 * spacing;
float start_pos = (window_width - total_buttons_width) * 0.5f;
if (start_pos > 0)
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + start_pos);
if (ImGui::Button("OK", ImVec2(button_width, 0)))
{
apply_settings();
if (m_error_message.empty())
{
m_visible = false;
m_settings_changed = false;
}
}
ImGui::SameLine();
bool apply_disabled = !m_settings_changed;
if (apply_disabled)
{
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
}
if (ImGui::Button("Apply", ImVec2(button_width, 0)) && !apply_disabled)
{
apply_settings();
if (m_error_message.empty())
{
m_settings_changed = false;
}
}
if (apply_disabled)
{
ImGui::PopStyleVar();
}
ImGui::SameLine();
if (ImGui::Button("Reset", ImVec2(button_width, 0)))
{
reset_to_defaults();
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(button_width, 0)))
{
load_settings();
m_visible = false;
m_error_message.clear();
m_settings_changed = false;
}
}
void settings_window::show_help_marker(const char *desc)
{
ImGui::TextDisabled("(?)");
if (ImGui::BeginItemTooltip())
{
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
form_field_config size_cfg;
size_cfg.label = "Font Size",
size_cfg.label_width = 150.0f;
size_cfg.tooltip = "Font size for the application interface (8-48)";
size_cfg.field_width = 120.0f;
size_cfg.type = field_type::slider;
size_cfg.min_value = 8.0f;
size_cfg.max_value = 48.0f;
size_cfg.format = "%d px";
size_cfg.show_reset = true;
size_cfg.default_value = 14;
if (m_form.render_slider(size_cfg, m_font_size))
m_settings_changed = true;
}
void settings_window::reset_to_defaults()
{
strncpy(m_default_theme, "dark", sizeof(m_default_theme));
strncpy(m_palettes_path, "~/.config/clrsync/palettes", sizeof(m_palettes_path));
strncpy(m_font, "JetBrains Mono Nerd Font", sizeof(m_font));
m_default_theme = "dark";
m_palettes_path = "~/.config/clrsync/palettes";
m_font = "JetBrains Mono Nerd Font";
m_font_size = 14;
m_error_message.clear();
m_error.clear();
m_settings_changed = true;
}
}

View File

@@ -2,59 +2,53 @@
#define CLRSYNC_GUI_SETTINGS_WINDOW_HPP
#include "core/palette/palette.hpp"
#include "gui/widgets/error_message.hpp"
#include "gui/widgets/form_field.hpp"
#include "gui/widgets/settings_buttons.hpp"
#include <string>
#include <vector>
namespace clrsync::gui
{
class ui_manager;
}
class settings_window
{
public:
settings_window();
settings_window(clrsync::gui::ui_manager* ui_mgr);
void render();
void show()
{
m_visible = true;
}
void hide()
{
m_visible = false;
}
bool is_visible() const
{
return m_visible;
}
void show() { m_visible = true; }
void hide() { m_visible = false; }
bool is_visible() const { return m_visible; }
void set_palette(const clrsync::core::palette& palette) { m_current_palette = palette; }
private:
void load_settings();
void save_settings();
void apply_settings();
void render_general_tab();
void render_appearance_tab();
void render_status_messages();
void render_action_buttons();
void show_help_marker(const char *desc);
void reset_to_defaults();
public:
void set_palette(const clrsync::core::palette &palette)
{
m_current_palette = palette;
}
void setup_widgets();
bool m_visible{false};
bool m_settings_changed{false};
char m_default_theme[128];
char m_palettes_path[512];
char m_font[128];
int m_font_size;
std::string m_default_theme;
std::string m_palettes_path;
std::string m_font;
int m_font_size{14};
int m_selected_font_idx{0};
std::vector<std::string> m_available_fonts;
int m_selected_font_idx;
std::string m_error_message;
bool m_settings_changed;
int m_current_tab;
clrsync::core::palette m_current_palette;
clrsync::gui::ui_manager* m_ui_manager;
clrsync::gui::widgets::form_field m_form;
clrsync::gui::widgets::error_message m_error;
clrsync::gui::widgets::settings_buttons m_buttons;
};
#endif // CLRSYNC_GUI_SETTINGS_WINDOW_HPP

View File

@@ -3,8 +3,10 @@
#include "core/config/config.hpp"
#include "core/palette/color_keys.hpp"
#include "core/theme/theme_template.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/platform/file_browser.hpp"
#include "gui/theme/app_theme.hpp"
#include "gui/widgets/colors.hpp"
#include "gui/widgets/dialogs.hpp"
#include "gui/ui_manager.hpp"
#include "imgui.h"
#include <algorithm>
#include <filesystem>
@@ -18,14 +20,12 @@ const std::vector<std::string> COLOR_FORMATS = {
"l", "hsl", "hsla"};
}
template_editor::template_editor() : m_template_name("new_template")
template_editor::template_editor(clrsync::gui::ui_manager* ui_mgr)
: m_ui_manager(ui_mgr)
{
m_autocomplete_bg_color = ImVec4(0.12f, 0.12f, 0.15f, 0.98f);
m_autocomplete_border_color = ImVec4(0.4f, 0.4f, 0.45f, 1.0f);
m_autocomplete_selected_color = ImVec4(0.25f, 0.45f, 0.75f, 0.9f);
m_autocomplete_text_color = ImVec4(0.85f, 0.85f, 0.9f, 1.0f);
m_autocomplete_selected_text_color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
m_autocomplete_dim_text_color = ImVec4(0.6f, 0.6f, 0.7f, 1.0f);
m_control_state.name = "new_template";
update_autocomplete_colors();
TextEditor::LanguageDefinition lang;
lang.mName = "Template";
@@ -47,6 +47,44 @@ template_editor::template_editor() : m_template_name("new_template")
m_editor.SetText("# Enter your template here\n# Use {color_key} for color variables\n# "
"Examples: {color.hex}, {color.rgb}, {color.r}\n\n");
m_editor.SetShowWhitespaces(false);
setup_callbacks();
}
void template_editor::setup_callbacks()
{
m_callbacks.on_new = [this]() { new_template(); };
m_callbacks.on_save = [this]() { save_template(); };
m_callbacks.on_delete = [this]() { delete_template(); };
m_callbacks.on_enabled_changed = [this](bool enabled) {
m_template_controller.set_template_enabled(m_control_state.name, enabled);
};
m_callbacks.on_browse_input = [this](const std::string& path) -> std::string {
return m_ui_manager->open_file_dialog("Select Template File", path);
};
m_callbacks.on_browse_output = [this](const std::string& path) -> std::string {
return m_ui_manager->save_file_dialog("Select Output File", path);
};
m_callbacks.on_input_path_changed = [this](const std::string& path) {
m_template_controller.set_template_input_path(m_control_state.name, path);
};
m_callbacks.on_output_path_changed = [this](const std::string& path) {
m_template_controller.set_template_output_path(m_control_state.name, path);
};
m_callbacks.on_reload_command_changed = [this](const std::string& cmd) {
m_template_controller.set_template_reload_command(m_control_state.name, cmd);
};
}
void template_editor::update_autocomplete_colors()
{
const auto &t = clrsync::gui::theme::current_theme();
m_autocomplete_bg_color = t.autocomplete_bg();
m_autocomplete_border_color = t.autocomplete_border();
m_autocomplete_selected_color = t.autocomplete_selected();
m_autocomplete_text_color = t.autocomplete_text();
m_autocomplete_selected_text_color = t.autocomplete_selected_text();
m_autocomplete_dim_text_color = t.autocomplete_dim_text();
}
void template_editor::apply_current_palette(const clrsync::core::palette &pal)
@@ -55,8 +93,11 @@ void template_editor::apply_current_palette(const clrsync::core::palette &pal)
auto colors = pal.colors();
if (colors.empty())
return;
using namespace clrsync::gui::theme;
auto get_color_u32 = [&](const std::string &key, const std::string &fallback = "") -> uint32_t {
return palette_utils::get_color_u32(pal, key, fallback);
return clrsync::gui::widgets::palette_color_u32(pal, key, fallback);
};
auto palette = m_editor.GetPalette();
@@ -66,47 +107,30 @@ void template_editor::apply_current_palette(const clrsync::core::palette &pal)
palette[int(TextEditor::PaletteIndex::Number)] = get_color_u32("editor_warning", "warning");
palette[int(TextEditor::PaletteIndex::String)] = get_color_u32("editor_string", "success");
palette[int(TextEditor::PaletteIndex::CharLiteral)] = get_color_u32("editor_string", "success");
palette[int(TextEditor::PaletteIndex::Punctuation)] =
get_color_u32("editor_main", "foreground");
palette[int(TextEditor::PaletteIndex::Preprocessor)] =
get_color_u32("editor_emphasis", "accent");
palette[int(TextEditor::PaletteIndex::Punctuation)] = get_color_u32("editor_main", "foreground");
palette[int(TextEditor::PaletteIndex::Preprocessor)] = get_color_u32("editor_emphasis", "accent");
palette[int(TextEditor::PaletteIndex::Identifier)] = get_color_u32("editor_main", "foreground");
palette[int(TextEditor::PaletteIndex::KnownIdentifier)] = get_color_u32("editor_link", "info");
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] =
get_color_u32("editor_link", "info");
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] = get_color_u32("editor_link", "info");
palette[int(TextEditor::PaletteIndex::Comment)] =
get_color_u32("editor_comment", "editor_inactive");
palette[int(TextEditor::PaletteIndex::MultiLineComment)] =
get_color_u32("editor_comment", "editor_inactive");
palette[int(TextEditor::PaletteIndex::Comment)] = get_color_u32("editor_comment", "editor_inactive");
palette[int(TextEditor::PaletteIndex::MultiLineComment)] = get_color_u32("editor_comment", "editor_inactive");
palette[int(TextEditor::PaletteIndex::Background)] =
get_color_u32("editor_background", "background");
palette[int(TextEditor::PaletteIndex::Background)] = get_color_u32("editor_background", "background");
palette[int(TextEditor::PaletteIndex::Cursor)] = get_color_u32("cursor", "accent");
palette[int(TextEditor::PaletteIndex::Selection)] =
get_color_u32("editor_selected", "surface_variant");
palette[int(TextEditor::PaletteIndex::Selection)] = get_color_u32("editor_selected", "surface_variant");
palette[int(TextEditor::PaletteIndex::ErrorMarker)] = get_color_u32("editor_error", "error");
palette[int(TextEditor::PaletteIndex::Breakpoint)] = get_color_u32("editor_error", "error");
palette[int(TextEditor::PaletteIndex::LineNumber)] =
get_color_u32("editor_line_number", "editor_inactive");
palette[int(TextEditor::PaletteIndex::LineNumber)] = get_color_u32("editor_line_number", "editor_inactive");
palette[int(TextEditor::PaletteIndex::CurrentLineFill)] = get_color_u32("surface_variant");
palette[int(TextEditor::PaletteIndex::CurrentLineFillInactive)] = get_color_u32("surface");
palette[int(TextEditor::PaletteIndex::CurrentLineEdge)] =
get_color_u32("border_focused", "border");
palette[int(TextEditor::PaletteIndex::CurrentLineEdge)] = get_color_u32("border_focused", "border");
m_editor.SetPalette(palette);
m_autocomplete_bg_color = palette_utils::get_color(pal, "surface", "background");
m_autocomplete_bg_color.w = 0.98f;
m_autocomplete_border_color = palette_utils::get_color(pal, "border", "surface_variant");
m_autocomplete_selected_color = palette_utils::get_color(pal, "accent", "surface_variant");
m_autocomplete_text_color = palette_utils::get_color(pal, "on_surface", "foreground");
m_autocomplete_selected_text_color = palette_utils::get_color(pal, "on_surface", "foreground");
m_autocomplete_dim_text_color =
palette_utils::get_color(pal, "on_surface_variant", "editor_inactive");
update_autocomplete_colors();
}
void template_editor::update_autocomplete_suggestions()
@@ -358,9 +382,9 @@ void template_editor::render()
m_show_delete_confirmation = false;
}
palette_utils::render_delete_confirmation_popup(
"Delete Template?", m_template_name, "template", m_current_palette, [this]() {
bool success = m_template_controller.remove_template(m_template_name);
clrsync::gui::widgets::delete_confirmation_dialog(
"Delete Template?", m_control_state.name, "template", m_current_palette, [this]() {
bool success = m_template_controller.remove_template(m_control_state.name);
if (success)
{
new_template();
@@ -368,7 +392,7 @@ void template_editor::render()
}
else
{
m_validation_error = "Failed to delete template";
m_validation.set("Failed to delete template");
}
});
@@ -377,225 +401,29 @@ void template_editor::render()
void template_editor::render_controls()
{
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 8));
if (ImGui::Button(" + New "))
{
new_template();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Create a new template");
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyPressed(ImGuiKey_S))
{
save_template();
}
ImGui::SameLine();
if (ImGui::Button(" Save "))
{
save_template();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Save template (Ctrl+S)");
if (m_is_editing_existing)
{
ImGui::SameLine();
auto error = palette_utils::get_color(m_current_palette, "error");
auto error_hover = ImVec4(error.x * 1.1f, error.y * 1.1f, error.z * 1.1f, error.w);
auto error_active = ImVec4(error.x * 0.8f, error.y * 0.8f, error.z * 0.8f, error.w);
auto on_error = palette_utils::get_color(m_current_palette, "on_error");
ImGui::PushStyleColor(ImGuiCol_Button, error);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_hover);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, error_active);
ImGui::PushStyleColor(ImGuiCol_Text, on_error);
if (ImGui::Button(" Delete "))
{
delete_template();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Delete this template");
ImGui::PopStyleColor(4);
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 10);
bool enabled_changed = false;
if (m_enabled)
{
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
ImVec4 success_on_color =
palette_utils::get_color(m_current_palette, "on_success", "on_surface");
ImVec4 success_hover =
ImVec4(success_color.x * 1.2f, success_color.y * 1.2f, success_color.z * 1.2f, 0.6f);
ImGui::PushStyleColor(ImGuiCol_FrameBg,
ImVec4(success_color.x, success_color.y, success_color.z, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, success_hover);
ImGui::PushStyleColor(ImGuiCol_CheckMark, success_on_color);
}
else
{
ImVec4 error_color = palette_utils::get_color(m_current_palette, "error", "accent");
ImVec4 error_on_color =
palette_utils::get_color(m_current_palette, "on_error", "on_surface");
ImVec4 error_hover =
ImVec4(error_color.x * 1.2f, error_color.y * 1.2f, error_color.z * 1.2f, 0.6f);
ImGui::PushStyleColor(ImGuiCol_FrameBg,
ImVec4(error_color.x, error_color.y, error_color.z, 0.5f));
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, error_hover);
ImGui::PushStyleColor(ImGuiCol_CheckMark, error_on_color);
}
enabled_changed = ImGui::Checkbox("Enabled", &m_enabled);
ImGui::PopStyleColor(3);
if (enabled_changed && m_is_editing_existing)
{
m_template_controller.set_template_enabled(m_template_name, m_enabled);
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Enable/disable this template for theme application");
ImGui::PopStyleVar();
ImGui::Spacing();
ImGui::AlignTextToFramePadding();
ImGui::Text("Name:");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180.0f);
char name_buf[256] = {0};
snprintf(name_buf, sizeof(name_buf), "%s", m_template_name.c_str());
if (ImGui::InputText("##template_name", name_buf, sizeof(name_buf)))
{
m_template_name = name_buf;
if (!m_template_name.empty())
{
m_validation_error = "";
}
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Unique name for this template");
ImGui::AlignTextToFramePadding();
ImGui::Text("Input:");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(-120.0f);
char input_path_buf[512] = {0};
snprintf(input_path_buf, sizeof(input_path_buf), "%s", m_input_path.c_str());
if (ImGui::InputTextWithHint("##input_path", "Path to template file...", input_path_buf,
sizeof(input_path_buf)))
{
m_input_path = input_path_buf;
if (!m_input_path.empty())
{
m_validation_error = "";
}
if (m_is_editing_existing)
{
m_template_controller.set_template_input_path(m_template_name, m_input_path);
}
}
ImGui::SameLine();
if (ImGui::Button("Browse##input"))
{
std::string selected_path =
file_dialogs::open_file_dialog("Select Template File", m_input_path);
if (!selected_path.empty())
{
m_input_path = selected_path;
if (m_is_editing_existing)
{
m_template_controller.set_template_input_path(m_template_name, m_input_path);
}
m_validation_error = "";
}
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Path where the template source file is stored");
ImGui::AlignTextToFramePadding();
ImGui::Text("Output:");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(-120.0f);
char path_buf[512] = {0};
snprintf(path_buf, sizeof(path_buf), "%s", m_output_path.c_str());
if (ImGui::InputTextWithHint("##output_path", "Path for generated config...", path_buf,
sizeof(path_buf)))
{
m_output_path = path_buf;
if (!m_output_path.empty())
{
m_validation_error = "";
}
if (m_is_editing_existing)
{
m_template_controller.set_template_output_path(m_template_name, m_output_path);
}
}
ImGui::SameLine();
if (ImGui::Button("Browse##output"))
{
std::string selected_path =
file_dialogs::save_file_dialog("Select Output File", m_output_path);
if (!selected_path.empty())
{
m_output_path = selected_path;
if (m_is_editing_existing)
{
m_template_controller.set_template_output_path(m_template_name, m_output_path);
}
m_validation_error = "";
}
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Path where the processed config will be written");
ImGui::AlignTextToFramePadding();
ImGui::Text("Reload:");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(-FLT_MIN);
char reload_buf[512] = {0};
snprintf(reload_buf, sizeof(reload_buf), "%s", m_reload_command.c_str());
if (ImGui::InputTextWithHint("##reload_cmd", "Command to reload app (optional)...", reload_buf,
sizeof(reload_buf)))
{
m_reload_command = reload_buf;
if (m_is_editing_existing)
{
m_template_controller.set_template_reload_command(m_template_name, m_reload_command);
}
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Shell command to run after applying theme (e.g., 'pkill -USR1 kitty')");
if (!m_validation_error.empty())
{
ImGui::Spacing();
ImVec4 error_color = palette_utils::get_color(m_current_palette, "error", "accent");
ImGui::PushStyleColor(ImGuiCol_Text, error_color);
ImGui::TextWrapped("%s", m_validation_error.c_str());
ImGui::PopStyleColor();
}
m_controls.render(m_control_state, m_callbacks, m_current_palette, m_validation);
}
void template_editor::render_editor()
{
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8, 4));
if (!m_is_editing_existing)
if (!m_control_state.is_editing_existing)
{
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
ImVec4 success_color = clrsync::gui::widgets::palette_color(m_current_palette, "success", "accent");
ImGui::PushStyleColor(ImGuiCol_Text, success_color);
ImGui::Text(" New Template");
ImGui::PopStyleColor();
}
else
{
ImGui::Text(" %s", m_template_name.c_str());
ImGui::Text(" %s", m_control_state.name.c_str());
auto trim_right = [](const std::string &s) -> std::string {
size_t end = s.find_last_not_of("\r\n");
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
@@ -608,7 +436,7 @@ void template_editor::render_editor()
if (m_has_unsaved_changes)
{
ImGui::SameLine();
ImVec4 warning_color = palette_utils::get_color(m_current_palette, "warning", "accent");
ImVec4 warning_color = clrsync::gui::widgets::palette_color(m_current_palette, "warning", "accent");
ImGui::PushStyleColor(ImGuiCol_Text, warning_color);
ImGui::Text("(unsaved)");
ImGui::PopStyleColor();
@@ -695,9 +523,9 @@ void template_editor::render_template_list()
ImGui::TextDisabled("(%d)", (int)m_template_controller.templates().size());
ImGui::Separator();
if (!m_is_editing_existing)
if (!m_control_state.is_editing_existing)
{
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
ImVec4 success_color = clrsync::gui::widgets::palette_color(m_current_palette, "success", "accent");
ImVec4 success_bg = ImVec4(success_color.x, success_color.y, success_color.z, 0.5f);
ImGui::PushStyleColor(ImGuiCol_Text, success_color);
ImGui::PushStyleColor(ImGuiCol_Header, success_bg);
@@ -710,11 +538,11 @@ void template_editor::render_template_list()
for (const auto &[key, tmpl] : templates)
{
const bool selected = (m_template_name == key && m_is_editing_existing);
const bool selected = (m_control_state.name == key && m_control_state.is_editing_existing);
if (!tmpl.enabled())
{
ImVec4 disabled_color = palette_utils::get_color(
ImVec4 disabled_color = clrsync::gui::widgets::palette_color(
m_current_palette, "on_surface_variant", "editor_inactive");
ImGui::PushStyleColor(ImGuiCol_Text, disabled_color);
}
@@ -795,44 +623,43 @@ bool template_editor::is_valid_path(const std::string &path)
void template_editor::save_template()
{
std::string trimmed_name = m_template_name;
std::string trimmed_name = m_control_state.name;
trimmed_name.erase(0, trimmed_name.find_first_not_of(" \t\n\r"));
trimmed_name.erase(trimmed_name.find_last_not_of(" \t\n\r") + 1);
std::string trimmed_input_path = m_input_path;
std::string trimmed_input_path = m_control_state.input_path;
trimmed_input_path.erase(0, trimmed_input_path.find_first_not_of(" \t\n\r"));
trimmed_input_path.erase(trimmed_input_path.find_last_not_of(" \t\n\r") + 1);
std::string trimmed_path = m_output_path;
std::string trimmed_path = m_control_state.output_path;
trimmed_path.erase(0, trimmed_path.find_first_not_of(" \t\n\r"));
trimmed_path.erase(trimmed_path.find_last_not_of(" \t\n\r") + 1);
if (trimmed_name.empty())
{
m_validation_error = "Error: Template name cannot be empty!";
m_validation.set("Error: Template name cannot be empty!");
return;
}
if (trimmed_input_path.empty())
{
m_validation_error = "Error: Input path cannot be empty!";
m_validation.set("Error: Input path cannot be empty!");
return;
}
if (trimmed_path.empty())
{
m_validation_error = "Error: Output path cannot be empty!";
m_validation.set("Error: Output path cannot be empty!");
return;
}
if (!is_valid_path(trimmed_path))
{
m_validation_error =
"Error: Output path is invalid! Must be a valid file path with directory.";
m_validation.set("Error: Output path is invalid! Must be a valid file path with directory.");
return;
}
m_validation_error = "";
m_validation.clear();
auto &cfg = clrsync::core::config::instance();
@@ -847,7 +674,7 @@ void template_editor::save_template()
}
catch (const std::exception &e)
{
m_validation_error = "Error: Could not create directory for input path";
m_validation.set("Error: Could not create directory for input path");
return;
}
}
@@ -857,7 +684,7 @@ void template_editor::save_template()
std::ofstream out(template_file);
if (!out.is_open())
{
m_validation_error = "Failed to write template file";
m_validation.set("Failed to write template file");
return;
}
@@ -865,20 +692,20 @@ void template_editor::save_template()
out.close();
clrsync::core::theme_template tmpl(trimmed_name, template_file.string(), trimmed_path);
tmpl.set_reload_command(m_reload_command);
tmpl.set_enabled(m_enabled);
tmpl.set_reload_command(m_control_state.reload_command);
tmpl.set_enabled(m_control_state.enabled);
auto result = cfg.update_template(trimmed_name, tmpl);
if (!result)
{
m_validation_error = "Error saving template: " + result.error().description();
m_validation.set("Error saving template: " + result.error().description());
return;
}
m_template_name = trimmed_name;
m_input_path = trimmed_input_path;
m_output_path = trimmed_path;
m_is_editing_existing = true;
m_control_state.name = trimmed_name;
m_control_state.input_path = trimmed_input_path;
m_control_state.output_path = trimmed_path;
m_control_state.is_editing_existing = true;
m_saved_content = m_editor.GetText();
m_has_unsaved_changes = false;
@@ -893,13 +720,13 @@ void template_editor::load_template(const std::string &name)
if (it != templates.end())
{
const auto &tmpl = it->second;
m_template_name = name;
m_input_path = tmpl.template_path();
m_output_path = tmpl.output_path();
m_reload_command = tmpl.reload_command();
m_enabled = tmpl.enabled();
m_is_editing_existing = true;
m_validation_error = "";
m_control_state.name = name;
m_control_state.input_path = tmpl.template_path();
m_control_state.output_path = tmpl.output_path();
m_control_state.reload_command = tmpl.reload_command();
m_control_state.enabled = tmpl.enabled();
m_control_state.is_editing_existing = true;
m_validation.clear();
std::ifstream in(tmpl.template_path());
if (in.is_open())
@@ -918,31 +745,31 @@ void template_editor::load_template(const std::string &name)
}
else
{
m_validation_error = "Error loading template: Failed to open file";
m_validation.set("Error loading template: Failed to open file");
}
}
}
void template_editor::new_template()
{
m_template_name = "new_template";
m_control_state.name = "new_template";
std::string default_content =
"# Enter your template here\n# Use {color_key} for color variables\n# "
"Examples: {color.hex}, {color.rgb}, {color.r}\n\n";
m_editor.SetText(default_content);
m_saved_content = default_content;
m_input_path = "";
m_output_path = "";
m_reload_command = "";
m_enabled = true;
m_is_editing_existing = false;
m_validation_error = "";
m_control_state.input_path = "";
m_control_state.output_path = "";
m_control_state.reload_command = "";
m_control_state.enabled = true;
m_control_state.is_editing_existing = false;
m_validation.clear();
m_has_unsaved_changes = false;
}
void template_editor::delete_template()
{
if (!m_is_editing_existing || m_template_name.empty())
if (!m_control_state.is_editing_existing || m_control_state.name.empty())
return;
m_show_delete_confirmation = true;
@@ -951,4 +778,4 @@ void template_editor::delete_template()
void template_editor::refresh_templates()
{
m_template_controller.refresh();
}
}

View File

@@ -4,14 +4,21 @@
#include "color_text_edit/TextEditor.h"
#include "core/palette/palette.hpp"
#include "gui/controllers/template_controller.hpp"
#include "gui/widgets/template_controls.hpp"
#include "gui/widgets/validation_message.hpp"
#include "imgui.h"
#include <string>
#include <vector>
namespace clrsync::gui
{
class ui_manager;
}
class template_editor
{
public:
template_editor();
template_editor(clrsync::gui::ui_manager* ui_mgr);
void render();
void apply_current_palette(const clrsync::core::palette &pal);
@@ -21,28 +28,27 @@ class template_editor
void render_template_list();
void render_autocomplete(const ImVec2 &editor_pos);
void update_autocomplete_suggestions();
void update_autocomplete_colors();
void save_template();
void load_template(const std::string &name);
void new_template();
void delete_template();
void refresh_templates();
void setup_callbacks();
bool is_valid_path(const std::string &path);
template_controller m_template_controller;
TextEditor m_editor;
std::string m_template_name;
std::string m_input_path;
std::string m_output_path;
std::string m_reload_command;
std::string m_validation_error;
std::string m_saved_content;
bool m_has_unsaved_changes = false;
clrsync::gui::widgets::template_control_state m_control_state;
clrsync::gui::widgets::template_controls m_controls;
clrsync::gui::widgets::template_control_callbacks m_callbacks;
clrsync::gui::widgets::validation_message m_validation;
bool m_enabled{true};
bool m_is_editing_existing{false};
std::string m_saved_content;
bool m_has_unsaved_changes{false};
bool m_show_delete_confirmation{false};
bool m_show_autocomplete{false};
@@ -62,6 +68,7 @@ class template_editor
ImVec4 m_autocomplete_dim_text_color;
clrsync::core::palette m_current_palette;
clrsync::gui::ui_manager* m_ui_manager;
};
#endif // CLRSYNC_GUI_TEMPLATE_EDITOR_HPP

View File

@@ -0,0 +1,75 @@
#include "action_buttons.hpp"
#include "colors.hpp"
#include "imgui.h"
namespace clrsync::gui::widgets
{
action_buttons::action_buttons() = default;
void action_buttons::add_button(const action_button &button)
{
m_buttons.push_back(button);
}
void action_buttons::clear()
{
m_buttons.clear();
}
void action_buttons::render(const core::palette &)
{
if (m_buttons.empty())
return;
if (m_use_separator)
{
ImGui::Separator();
ImGui::Spacing();
}
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(m_spacing, 8));
bool first = true;
for (const auto &button : m_buttons)
{
if (!first)
ImGui::SameLine();
first = false;
bool has_style = false;
if (button.use_error_style)
{
push_error_button_style();
has_style = true;
}
else if (button.use_success_style)
{
push_success_button_style();
has_style = true;
}
bool disabled = !button.enabled;
if (disabled)
ImGui::BeginDisabled();
if (ImGui::Button(button.label.c_str()))
{
if (button.on_click)
button.on_click();
}
if (disabled)
ImGui::EndDisabled();
if (has_style)
pop_button_style();
if (!button.tooltip.empty() && ImGui::IsItemHovered())
ImGui::SetTooltip("%s", button.tooltip.c_str());
}
ImGui::PopStyleVar();
}
} // namespace clrsync::gui::widgets

View File

@@ -0,0 +1,46 @@
#ifndef CLRSYNC_GUI_WIDGETS_ACTION_BUTTONS_HPP
#define CLRSYNC_GUI_WIDGETS_ACTION_BUTTONS_HPP
#include "core/palette/palette.hpp"
#include <functional>
#include <string>
#include <vector>
namespace clrsync::gui::widgets
{
struct action_button
{
std::string label;
std::string tooltip;
std::function<void()> on_click;
bool enabled = true;
bool use_error_style = false;
bool use_success_style = false;
};
class action_buttons
{
public:
action_buttons();
void add_button(const action_button &button);
void clear();
void render(const core::palette &theme_palette);
void set_spacing(float spacing) { m_spacing = spacing; }
void set_use_separator(bool use) { m_use_separator = use; }
private:
std::vector<action_button> m_buttons;
float m_spacing = 8.0f;
bool m_use_separator = false;
};
} // namespace clrsync::gui::widgets
#endif // CLRSYNC_GUI_WIDGETS_ACTION_BUTTONS_HPP

View File

@@ -0,0 +1,287 @@
#include "autocomplete.hpp"
#include "colors.hpp"
#include "imgui.h"
#include <algorithm>
namespace clrsync::gui::widgets
{
autocomplete_widget::autocomplete_widget()
: m_selected_index(0), m_show_autocomplete(false), m_dismissed(false), m_dismiss_brace_pos(-1)
{
m_bg_color = ImVec4(0.12f, 0.12f, 0.15f, 0.98f);
m_border_color = ImVec4(0.4f, 0.4f, 0.45f, 1.0f);
m_selected_color = ImVec4(0.25f, 0.45f, 0.75f, 0.9f);
m_text_color = ImVec4(0.85f, 0.85f, 0.9f, 1.0f);
m_selected_text_color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
m_dim_text_color = ImVec4(0.6f, 0.6f, 0.7f, 1.0f);
}
void autocomplete_widget::update_suggestions(const TextEditor& editor,
const std::vector<std::string>& available_keys,
const std::vector<std::string>& available_formats)
{
m_suggestions.clear();
auto cursor = editor.GetCursorPosition();
std::string line = editor.GetCurrentLineText();
int col = cursor.mColumn;
// Check if inside '{'
int brace_pos = -1;
for (int i = col - 1; i >= 0; --i)
{
if (i < (int)line.length())
{
if (line[i] == '{')
{
brace_pos = i;
break;
}
else if (line[i] == '}' || line[i] == ' ' || line[i] == '\t')
{
break;
}
}
}
if (brace_pos < 0)
{
m_show_autocomplete = false;
m_dismissed = false;
return;
}
if (m_dismissed)
{
bool should_reset_dismissal = false;
if (cursor.mLine != m_dismiss_position.mLine || brace_pos != m_dismiss_brace_pos ||
abs(cursor.mColumn - m_dismiss_position.mColumn) > 3)
{
should_reset_dismissal = true;
}
if (should_reset_dismissal)
{
m_dismissed = false;
}
else
{
m_show_autocomplete = false;
return;
}
}
m_prefix = line.substr(brace_pos + 1, col - brace_pos - 1);
m_start_pos = TextEditor::Coordinates(cursor.mLine, brace_pos + 1);
size_t dot_pos = m_prefix.find('.');
if (dot_pos != std::string::npos)
{
std::string color_key = m_prefix.substr(0, dot_pos);
std::string format_prefix = m_prefix.substr(dot_pos + 1);
bool valid_key = std::find(available_keys.begin(), available_keys.end(), color_key) != available_keys.end();
if (valid_key)
{
for (const auto &fmt : available_formats)
{
if (format_prefix.empty() || fmt.find(format_prefix) == 0 ||
fmt.find(format_prefix) != std::string::npos)
{
m_suggestions.push_back(color_key + "." + fmt);
}
}
}
}
else
{
for (const auto& key : available_keys)
{
if (m_prefix.empty() || key.find(m_prefix) == 0 ||
key.find(m_prefix) != std::string::npos)
{
m_suggestions.push_back(key);
}
}
}
std::sort(m_suggestions.begin(), m_suggestions.end(),
[this](const std::string &a, const std::string &b) {
bool a_prefix = a.find(m_prefix) == 0;
bool b_prefix = b.find(m_prefix) == 0;
if (a_prefix != b_prefix)
return a_prefix;
return a < b;
});
m_show_autocomplete = !m_suggestions.empty();
if (m_show_autocomplete && m_selected_index >= (int)m_suggestions.size())
{
m_selected_index = 0;
}
}
void autocomplete_widget::render(const ImVec2& editor_pos, TextEditor& editor)
{
if (!m_show_autocomplete || m_suggestions.empty())
return;
float line_height = ImGui::GetTextLineHeightWithSpacing();
float char_width = ImGui::GetFontSize() * 0.5f;
auto cursor = editor.GetCursorPosition();
const float line_number_width = 50.0f;
ImVec2 popup_pos;
popup_pos.x = editor_pos.x + line_number_width + (m_start_pos.mColumn * char_width);
popup_pos.y = editor_pos.y + ((cursor.mLine + 1) * line_height);
ImGui::SetNextWindowPos(popup_pos, ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(300, 0));
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_AlwaysAutoResize;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(6, 6));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 2));
ImGui::PushStyleColor(ImGuiCol_WindowBg, m_bg_color);
ImGui::PushStyleColor(ImGuiCol_Border, m_border_color);
if (ImGui::Begin("##autocomplete", nullptr, flags))
{
ImGui::PushStyleColor(ImGuiCol_Text, m_dim_text_color);
if (m_prefix.find('.') != std::string::npos)
ImGui::Text("Formats");
else
ImGui::Text("Color Keys");
ImGui::PopStyleColor();
ImGui::Separator();
int max_items = std::min((int)m_suggestions.size(), 8);
for (int i = 0; i < max_items; ++i)
{
const auto &suggestion = m_suggestions[i];
bool is_selected = (i == m_selected_index);
if (is_selected)
{
ImVec4 selected_hover = m_selected_color;
selected_hover.w = std::min(selected_hover.w + 0.1f, 1.0f);
ImGui::PushStyleColor(ImGuiCol_Header, m_selected_color);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, selected_hover);
ImGui::PushStyleColor(ImGuiCol_Text, m_selected_text_color);
}
else
{
ImVec4 normal_bg = m_bg_color;
normal_bg.w = 0.5f;
ImVec4 hover_bg = m_selected_color;
hover_bg.w = 0.3f;
ImGui::PushStyleColor(ImGuiCol_Header, normal_bg);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, hover_bg);
ImGui::PushStyleColor(ImGuiCol_Text, m_text_color);
}
std::string display_text = " " + suggestion;
if (ImGui::Selectable(display_text.c_str(), is_selected, ImGuiSelectableFlags_None, ImVec2(0, 0)))
{
auto start = m_start_pos;
auto end = editor.GetCursorPosition();
editor.SetSelection(start, end);
editor.Delete();
editor.InsertText(suggestion + "}");
m_show_autocomplete = false;
m_dismissed = false;
}
ImGui::PopStyleColor(3);
if (is_selected && ImGui::IsWindowAppearing())
{
ImGui::SetScrollHereY();
}
}
if (m_suggestions.size() > 8)
{
ImGui::Separator();
ImGui::PushStyleColor(ImGuiCol_Text, m_dim_text_color);
ImGui::Text(" +%d more", (int)m_suggestions.size() - 8);
ImGui::PopStyleColor();
}
ImGui::Separator();
ImGui::PushStyleColor(ImGuiCol_Text, m_dim_text_color);
ImGui::Text(" Tab/Enter: accept | Esc: dismiss");
ImGui::PopStyleColor();
}
ImGui::End();
ImGui::PopStyleColor(2);
ImGui::PopStyleVar(3);
}
void autocomplete_widget::apply_palette(const core::palette& palette)
{
m_bg_color = palette_color(palette, "surface", "background");
m_bg_color.w = 0.98f;
m_border_color = palette_color(palette, "border", "surface_variant");
m_selected_color = palette_color(palette, "accent", "surface_variant");
m_text_color = palette_color(palette, "on_surface", "foreground");
m_selected_text_color = palette_color(palette, "on_surface", "foreground");
m_dim_text_color = palette_color(palette, "on_surface_variant", "editor_inactive");
}
bool autocomplete_widget::handle_input(TextEditor& editor)
{
if (!m_show_autocomplete || m_suggestions.empty())
return false;
bool handled = false;
if (ImGui::IsKeyPressed(ImGuiKey_DownArrow))
{
m_selected_index = (m_selected_index + 1) % (int)m_suggestions.size();
handled = true;
}
else if (ImGui::IsKeyPressed(ImGuiKey_UpArrow))
{
m_selected_index = (m_selected_index - 1 + (int)m_suggestions.size()) % (int)m_suggestions.size();
handled = true;
}
else if (ImGui::IsKeyPressed(ImGuiKey_Tab) || ImGui::IsKeyPressed(ImGuiKey_Enter))
{
if (m_selected_index >= 0 && m_selected_index < (int)m_suggestions.size())
{
auto start = m_start_pos;
auto end = editor.GetCursorPosition();
editor.SetSelection(start, end);
editor.Delete();
editor.InsertText(m_suggestions[m_selected_index] + "}");
m_show_autocomplete = false;
m_dismissed = false;
}
handled = true;
}
else if (ImGui::IsKeyPressed(ImGuiKey_Escape))
{
m_dismissed = true;
m_dismiss_position = editor.GetCursorPosition();
m_dismiss_brace_pos = -1;
m_show_autocomplete = false;
handled = true;
}
return handled;
}
} // namespace clrsync::gui::widgets

View File

@@ -0,0 +1,53 @@
#ifndef CLRSYNC_GUI_WIDGETS_AUTOCOMPLETE_HPP
#define CLRSYNC_GUI_WIDGETS_AUTOCOMPLETE_HPP
#include "core/palette/palette.hpp"
#include "color_text_edit/TextEditor.h"
#include "imgui.h"
#include <string>
#include <vector>
namespace clrsync::gui::widgets
{
class autocomplete_widget
{
public:
autocomplete_widget();
void update_suggestions(const TextEditor& editor,
const std::vector<std::string>& available_keys,
const std::vector<std::string>& available_formats);
void render(const ImVec2& editor_pos, TextEditor& editor);
void apply_palette(const core::palette& palette);
bool handle_input(TextEditor& editor);
bool is_visible() const { return m_show_autocomplete; }
void dismiss() { m_dismissed = true; m_show_autocomplete = false; }
private:
std::vector<std::string> m_suggestions;
std::string m_prefix;
TextEditor::Coordinates m_start_pos;
int m_selected_index;
bool m_show_autocomplete;
bool m_dismissed;
TextEditor::Coordinates m_dismiss_position;
int m_dismiss_brace_pos;
ImVec4 m_bg_color;
ImVec4 m_border_color;
ImVec4 m_selected_color;
ImVec4 m_text_color;
ImVec4 m_selected_text_color;
ImVec4 m_dim_text_color;
};
} // namespace clrsync::gui::widgets
#endif // CLRSYNC_GUI_WIDGETS_AUTOCOMPLETE_HPP

View File

@@ -0,0 +1,23 @@
#include "centered_text.hpp"
namespace clrsync::gui::widgets
{
void centered_text(const std::string& text, const ImVec4& color)
{
float window_width = ImGui::GetContentRegionAvail().x;
float text_width = ImGui::CalcTextSize(text.c_str()).x;
ImGui::SetCursorPosX((window_width - text_width) * 0.5f);
ImGui::TextColored(color, "%s", text.c_str());
}
void centered_buttons(float total_width, const std::function<void()>& render_buttons)
{
float window_width = ImGui::GetContentRegionAvail().x;
float start_pos = (window_width - total_width) * 0.5f;
if (start_pos > 0)
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + start_pos);
render_buttons();
}
} // namespace clrsync::gui::widgets

View File

@@ -0,0 +1,16 @@
#ifndef CLRSYNC_GUI_WIDGETS_CENTERED_TEXT_HPP
#define CLRSYNC_GUI_WIDGETS_CENTERED_TEXT_HPP
#include "imgui.h"
#include <functional>
#include <string>
namespace clrsync::gui::widgets
{
void centered_text(const std::string& text, const ImVec4& color = ImVec4(1, 1, 1, 1));
void centered_buttons(float total_width, const std::function<void()>& render_buttons);
} // namespace clrsync::gui::widgets
#endif // CLRSYNC_GUI_WIDGETS_CENTERED_TEXT_HPP

View File

@@ -0,0 +1,81 @@
#include "colors.hpp"
namespace clrsync::gui::widgets
{
ImVec4 palette_color(const core::palette &pal, const std::string &key,
const std::string &fallback)
{
auto colors = pal.colors();
if (colors.empty())
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
auto it = colors.find(key);
if (it == colors.end() && !fallback.empty())
it = colors.find(fallback);
if (it != colors.end())
return theme::color_utils::from_hex(it->second.hex());
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
uint32_t palette_color_u32(const core::palette &pal, const std::string &key,
const std::string &fallback)
{
auto colors = pal.colors();
if (colors.empty())
return 0xFFFFFFFF;
auto it = colors.find(key);
if (it == colors.end() && !fallback.empty())
it = colors.find(fallback);
if (it != colors.end())
return theme::color_utils::to_imgui_u32(it->second.hex());
return 0xFFFFFFFF;
}
void push_success_button_style()
{
const auto &t = theme::current_theme();
ImGui::PushStyleColor(ImGuiCol_Button, t.success());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, t.success_hovered());
ImGui::PushStyleColor(ImGuiCol_ButtonActive, t.success_active());
ImGui::PushStyleColor(ImGuiCol_Text, t.on_success());
}
void push_error_button_style()
{
const auto &t = theme::current_theme();
ImGui::PushStyleColor(ImGuiCol_Button, t.error());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, t.error_hovered());
ImGui::PushStyleColor(ImGuiCol_ButtonActive, t.error_active());
ImGui::PushStyleColor(ImGuiCol_Text, t.on_error());
}
void push_warning_button_style()
{
const auto &t = theme::current_theme();
ImGui::PushStyleColor(ImGuiCol_Button, t.warning());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, t.warning_hovered());
ImGui::PushStyleColor(ImGuiCol_ButtonActive, t.warning_active());
ImGui::PushStyleColor(ImGuiCol_Text, t.on_warning());
}
void push_info_button_style()
{
const auto &t = theme::current_theme();
ImGui::PushStyleColor(ImGuiCol_Button, t.info());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, t.info_hovered());
ImGui::PushStyleColor(ImGuiCol_ButtonActive, t.info_active());
ImGui::PushStyleColor(ImGuiCol_Text, t.on_info());
}
void pop_button_style()
{
ImGui::PopStyleColor(4);
}
} // namespace clrsync::gui::widgets

View File

@@ -0,0 +1,32 @@
#ifndef CLRSYNC_GUI_WIDGETS_COLORS_HPP
#define CLRSYNC_GUI_WIDGETS_COLORS_HPP
#include "core/palette/palette.hpp"
#include "gui/theme/app_theme.hpp"
#include "imgui.h"
#include <string>
namespace clrsync::gui::widgets
{
ImVec4 palette_color(const core::palette &pal, const std::string &key,
const std::string &fallback = "");
uint32_t palette_color_u32(const core::palette &pal, const std::string &key,
const std::string &fallback = "");
inline const theme::app_theme &theme() { return theme::current_theme(); }
void push_success_button_style();
void push_error_button_style();
void push_warning_button_style();
void push_info_button_style();
void pop_button_style();
} // namespace clrsync::gui::widgets
#endif // CLRSYNC_GUI_WIDGETS_COLORS_HPP

View File

@@ -0,0 +1,46 @@
#include "dialogs.hpp"
#include "colors.hpp"
#include "imgui.h"
namespace clrsync::gui::widgets
{
bool delete_confirmation_dialog(const std::string &popup_title, const std::string &item_name,
const std::string &item_type, const core::palette &theme_palette,
const std::function<void()> &on_delete)
{
bool result = false;
if (ImGui::BeginPopupModal(popup_title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize))
{
ImVec4 warning_color = palette_color(theme_palette, "warning", "accent");
ImGui::TextColored(warning_color, "Are you sure you want to delete '%s'?",
item_name.c_str());
ImGui::Text("This action cannot be undone.");
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
float button_width = 120.0f;
float total_width = 2.0f * button_width + ImGui::GetStyle().ItemSpacing.x;
float window_width = ImGui::GetContentRegionAvail().x;
ImGui::SetCursorPosX((window_width - total_width) * 0.5f);
if (ImGui::Button("Delete", ImVec2(button_width, 0)))
{
on_delete();
result = true;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(button_width, 0)))
{
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
return result;
}
} // namespace clrsync::gui::widgets

Some files were not shown because too many files have changed in this diff Show More