7 Commits

Author SHA1 Message Date
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
69 changed files with 2048 additions and 726 deletions

View File

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

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(clrsync VERSION 1.0.5 LANGUAGES CXX)
project(clrsync VERSION 1.1.0 LANGUAGES CXX)
include(GNUInstallDirs)

View File

@@ -1 +1 @@
1.0.5
1.1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 856 KiB

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#9A8652FF'
accent_secondary = '#9A8652FF'
background = '#111111FF'
base00 = '#111111FF'
base01 = '#668A51FF'

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#9A8652FF'
accent_secondary = '#9A8652FF'
background = '#E0E0E0FF'
base00 = '#E0E0E0FF'
base01 = '#668A51FF'

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

@@ -1,308 +1,52 @@
# Extras
This directory contains additional palettes and pre-configured templates for various applications.
## Navigation
- [Palettes](#palettes)
- [Cursed](#cursed)
- [Cursed Light](#cursed-light)
- [Nord](#nord)
- [Pre-configured Templates](#pre-configured-templates)
- [Terminal Emulators](#terminal-emulators)
- [Kitty](#kitty)
- [Alacritty](#alacritty)
- [Ghostty](#ghostty)
- [Text Editors](#text-editors)
- [Neovim](#neovim)
- [Visual Studio Code](#visual-studio-code)
- [Browsers](#browsers)
- [Firefox](#firefox)
- [Applications](#applications)
- [Telegram](#telegram)
- [Desktop Themes](#desktop-themes)
- [GTK](#gtk)
- [Qt Applications](#qt-applications)
- [Window Managers](#window-managers)
- [Hyprland](#hyprland)
Pre-configured palettes and templates for clrsync.
## Palettes
### Cursed
| 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) |
A dark color scheme inspired by the `cursed` theme by [pyratebeard](https://pyratebeard.net).
## Templates
<details>
<summary>Preview</summary>
![cursed](img/cursed.png)
</details>
### Cursed Light
A light variant of the `cursed` color scheme.
<details>
<summary>Preview</summary>
![cursed-light](img/cursed-light.png)
</details>
### Nord
A color scheme based on the `Nord` palette.
<details>
<summary>Preview</summary>
![nord](img/nord.png)
</details>
## Pre-configured Templates
### Terminal Emulators
#### Kitty
1. Download the [template file](templates/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
```
#### Alacritty
1. Download the [template file](templates/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"]
```
#### Ghostty
1. Download the [template file](templates/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"
```
### Terminals
- [Alacritty](templates/terminals/alacritty)
- [Ghostty](templates/terminals/ghostty)
- [Kitty](templates/terminals/kitty)
### Text Editors
#### Neovim
1. Download the [template file](templates/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'
```
#### Visual Studio Code
1. Install the [clrsync VS Code theme](https://marketplace.visualstudio.com/items?itemName=obsqrbtz.clrsync)
2. Download the [template file](templates/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
- [Neovim](templates/text-editors/neovim)
- [VS Code](templates/text-editors/vscode)
### Browsers
- [Firefox](templates/browsers/firefox)
#### Firefox
1. Go to `about:config` and set `toolkit.legacyUserProfileCustomizations.stylesheets` to `true`
2. Go to `about:support` and find your profile directory
3. Create a `chrome` directory in your profile
4. Download the [template file](templates/userChrome.css)
5. Configure clrsync to output to `<profile>/chrome/userChrome.css`:
```toml
[templates.firefox]
enabled = true
input_path = '~/.config/clrsync/templates/userChrome.css'
output_path = '<profile directory>/chrome/userChrome.css'
reload_cmd = ''
```
### Applications
#### Telegram
1. Download the [template file](templates/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
### Desktop Themes
#### GTK
1. Download the [template file](templates/gtk.css)
2. Configure the template in `~/.config/clrsync/config.toml`:
```toml
[templates.gtk3]
enabled = true
input_path = '~/.config/clrsync/templates/gtk.css'
output_path = '~/.config/gtk-3.0/colors.css'
reload_cmd = ''
[templates.gtk4]
enabled = true
input_path = '~/.config/clrsync/templates/gtk.css'
output_path = '~/.config/gtk-4.0/colors.css'
reload_cmd = ''
```
3. Import the color scheme at the top of `~/.config/gtk-3.0/gtk.css`, `~/.config/gtk-4.0/gtk.css`, and `~/.config/gtk-4.0/gtk-dark.css`:
```css
@import 'colors.css';
```
#### Qt Applications
1. Download the templates:
- Kvantum: [kvantum.kvconfig](templates/kvantum/kvantum.kvconfig) and [kvantum.svg](templates/kvantum/kvantum.svg)
- Qt5ct/Qt6ct: [qtct.conf](templates/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
```
### Desktop
- [GTK](templates/desktop/gtk)
- [Qt](templates/desktop/qt)
### Window Managers
- [Hyprland](templates/wms/hyprland)
#### Hyprland
### Apps
- [Telegram](templates/apps/telegram)
1. Download the [template file](templates/hyprland.conf)
## Contributing
2. Configure the template in `~/.config/clrsync/config.toml`:
To add a new palette:
```toml
[templates.hyprland]
enabled = true
input_path = '~/.config/clrsync/templates/hyprland.conf'
output_path = '~/.config/hypr/hyprland/clrsync.conf'
reload_cmd = ''
```
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
3. Source the color theme in your Hyprland config:
To add a new template:
```conf
source=~/.config/hypr/hyprland/clrsync.conf
```
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

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#95A328FF'
accent_secondary = '#95A328FF'
background = '#151515FF'
base00 = '#151515FF'
base01 = '#B44242FF'

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)

View File

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#A1CDFAFF'
accent_secondary = '#A1CDFAFF'
background = '#2E3440FF'
base00 = '#2E3440FF'
base01 = '#BF616AFF'

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)

View File

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -1,5 +1,6 @@
[colors]
accent = '#95A328FF'
accent_secondary = '#95A328FF'
background = '#F5F5F5FF'
base00 = '#F5F5F5FF'
base01 = '#B44242FF'

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

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

@@ -39,7 +39,7 @@ dialogsDraftFgActive: {foreground}; // Draft label for active chat
dialogsDraftFgOver: {foreground}; // Draft label on hover
dialogsVerifiedIconBg: {accent}; // Verified badge background
dialogsVerifiedIconBgActive: {accent}; // Verified badge for active chat
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
@@ -50,11 +50,11 @@ dialogsSendingIconFgActive: {foreground}; // Sending icon for active chat
dialogsSendingIconFgOver: {foreground}; // Sending icon on hover
dialogsSentIconFg: {accent}; // Sent icon (tick)
dialogsSentIconFgActive: {accent}; // Sent icon for active chat
dialogsSentIconFgActive: {accent_secondary}; // Sent icon for active chat
dialogsSentIconFgOver: {accent}; // Sent icon on hover
dialogsUnreadBg: {accent}; // Unread badge background
dialogsUnreadBgActive: {accent}; // Unread badge for active chat
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
@@ -79,7 +79,7 @@ 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}; // Active items text
windowActiveTextFg: {accent_secondary}; // Active items text
windowShadowFg: {border}; // Window shadow
windowShadowFgFallback: {border}; // Fallback for shadow
historyOutIconFg: {accent};
@@ -105,7 +105,7 @@ slideFadeOutShadowFg: {border};
imageBg: {surface};
imageBgTransparent: {surface};
activeButtonBg: {accent}; // Active button background
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
@@ -128,12 +128,12 @@ attentionButtonBgRipple: {on_surface};
outlineButtonBg: {surface}; // Outline button background
outlineButtonBgOver: {surface_variant}; // Outline button hover background
outlineButtonOutlineFg: {accent}; // Outline button color
outlineButtonBgRipple: {accent}; // Outline button ripple
outlineButtonOutlineFg: {accent_secondary}; // Outline button color
outlineButtonBgRipple: {accent_secondary}; // Outline button ripple
menuBg: {surface};
menuBgOver: {surface_variant};
menuBgRipple: {accent};
menuBgRipple: {accent_secondary};
menuIconFg: {on_surface};
menuIconFgOver: {on_surface_variant};
menuSubmenuArrowFg: {border};
@@ -141,22 +141,22 @@ menuFgDisabled: {border};
menuSeparatorFg: {border};
scrollBarBg: {accent}40; // Scroll bar background (40% opacity)
scrollBarBgOver: {accent}60; // Scroll bar hover background (60% 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};
radialFg: {accent_secondary};
radialBg: {surface};
placeholderFg: {border}; // Placeholder text
placeholderFgActive: {accent}; // Active 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}; // Checkbox color
checkboxFg: {accent_secondary}; // Checkbox color
// Filters sidebar (left side bar with folder filters)
sideBarBg: {surface}; // Filters sidebar background
@@ -192,7 +192,7 @@ cancelIconFgOver: {error}; // Cancel icon on hover
boxBg: {surface}; // Box background
boxTextFg: {on_surface}; // Box text
boxTextFgGood: {accent}; // Box good text
boxTextFgGood: {accent_secondary}; // Box good text
boxTextFgError: {error}; // Box error text
boxTitleFg: {on_surface}; // Box title text
boxSearchBg: {surface}; // Box search field background
@@ -204,10 +204,10 @@ 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}; // Online contact status
contactsStatusFgOnline: {accent_secondary}; // Online contact status
photoCropFadeBg: {surface}cc; // Photo crop fade background
photoCropPointFg: {accent}; // Photo crop points
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,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

@@ -76,7 +76,7 @@ menu_blur_radius=0
tooltip_blur_radius=0
[GeneralColors]
window.color={background}
window.color={surface}
base.color={surface}
alt.base.color={surface}
button.color={surface_variant}
@@ -86,14 +86,14 @@ dark.color={surface_variant}
mid.color={surface_variant}
highlight.color={accent}
inactive.highlight.color={accent}
text.color={on_background}
window.text.color={on_background}
button.text.color={on_surface_variant}
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={base04}
link.visited.color={base05}
link.color={base06}
link.visited.color={base0D}
progress.indicator.text.color={on_surface}
[Hacks]

View File

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 170 KiB

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

@@ -1,88 +0,0 @@
@define-color accent_color {accent};
@define-color accent_bg_color {accent};
@define-color accent_fg_color {on_surface};
@define-color destructive_color {error};
@define-color destructive_bg_color {error};
@define-color destructive_fg_color {on_error};
@define-color success_color {success};
@define-color success_bg_color {success};
@define-color success_fg_color {on_success};
@define-color warning_color {warning};
@define-color warning_bg_color {warning};
@define-color warning_fg_color {on_warning};
@define-color error_color {error};
@define-color error_bg_color {error};
@define-color error_fg_color {on_error};
@define-color window_bg_color {background};
@define-color window_fg_color {on_background};
@define-color view_bg_color {background};
@define-color view_fg_color {foreground};
@define-color headerbar_bg_color {surface};
@define-color headerbar_fg_color {on_surface};
@define-color headerbar_border_color {border};
@define-color headerbar_backdrop_color @window_bg_color;
@define-color headerbar_shade_color {border};
@define-color sidebar_bg_color {surface_variant};
@define-color sidebar_fg_color {on_surface};
@define-color sidebar_border_color {border};
@define-color sidebar_backdrop_color @window_bg_color;
@define-color sidebar_shade_color {border};
@define-color card_bg_color {surface};
@define-color card_fg_color {on_surface};
@define-color card_shade_color {border};
@define-color dialog_bg_color {surface};
@define-color dialog_fg_color {on_surface};
@define-color popover_bg_color {surface_variant};
@define-color popover_fg_color {on_surface_variant};
@define-color shade_color {border};
@define-color scrollbar_outline_color {border};
@define-color blue_1 {base0C};
@define-color blue_2 {base04};
@define-color blue_3 {base04};
@define-color blue_4 {base04};
@define-color blue_5 {base04};
@define-color green_1 {success};
@define-color green_2 {success};
@define-color green_3 {success};
@define-color green_4 {base02};
@define-color green_5 {base02};
@define-color yellow_1 {base0B};
@define-color yellow_2 {base03};
@define-color yellow_3 {base03};
@define-color yellow_4 {base03};
@define-color yellow_5 {base03};
@define-color orange_1 {warning};
@define-color orange_2 {warning};
@define-color orange_3 {warning};
@define-color orange_4 {warning};
@define-color orange_5 {warning};
@define-color red_1 {error};
@define-color red_2 {error};
@define-color red_3 {error};
@define-color red_4 {base01};
@define-color red_5 {base01};
@define-color purple_1 {base0D};
@define-color purple_2 {base05};
@define-color purple_3 {base05};
@define-color purple_4 {base05};
@define-color purple_5 {base05};
@define-color brown_1 {base0E};
@define-color brown_2 {base0E};
@define-color brown_3 {base0E};
@define-color brown_4 {base0E};
@define-color brown_5 {base0E};
@define-color light_1 {on_background};
@define-color light_2 {on_surface};
@define-color light_3 {on_surface_variant};
@define-color light_4 {border};
@define-color light_5 {border};
@define-color dark_1 {border};
@define-color dark_2 {surface_variant};
@define-color dark_3 {surface};
@define-color dark_4 {background};
@define-color dark_5 {base00};
scale trough highlight {
background: {accent}
}

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,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,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,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'
```

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

@@ -1,9 +1,9 @@
$primary = rgb({accent.hex_stripped})
$surface = rgb({surface.hex_stripped})
$secondary = rgb({base04.hex_stripped})
$error = rgb({error.hex_stripped})
$tertiary = rgb({base06.hex_stripped})
$surface_lowest = rgb({background.hex_stripped})
$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

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 = "1.0.4+git.g2b1c6d5";
const std::string GIT_SEMVER = "1.0.5+git.g2d015c6";
const std::string version_string();
} // namespace clrsync::core

View File

@@ -26,6 +26,7 @@ constexpr const char *COLOR_KEYS[] = {
"cursor",
"accent",
"accent_secondary",
// Semantic
"success",
@@ -93,6 +94,7 @@ inline const std::unordered_map<std::string, uint32_t> DEFAULT_COLORS = {
{"cursor", 0xd2d2d2ff},
{"accent", 0x9a8652ff},
{"accent_secondary", 0x9a8652ff},
{"success", 0x668a51ff},
{"info", 0x3a898cff},

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,176 @@
#include "hellwal_generator.hpp"
#include "core/palette/color.hpp"
#include <array>
#include <cstdio>
#include <filesystem>
#include <regex>
#include <string>
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));
pal.set_color("editor_background", get_color_by_index(0));
pal.set_color("editor_main", get_color_by_index(7));
pal.set_color("editor_comment", get_color_by_index(8));
pal.set_color("editor_disabled", get_color_by_index(8));
pal.set_color("editor_inactive", get_color_by_index(8));
pal.set_color("editor_string", get_color_by_index(2));
pal.set_color("editor_command", get_color_by_index(5));
pal.set_color("editor_emphasis", get_color_by_index(11));
pal.set_color("editor_link", get_color_by_index(4));
pal.set_color("editor_line_number", get_color_by_index(8));
pal.set_color("editor_selected", get_color_by_index(8));
pal.set_color("editor_selection_inactive", get_color_by_index(8));
pal.set_color("editor_error", get_color_by_index(1));
pal.set_color("editor_warning", get_color_by_index(3));
pal.set_color("editor_success", get_color_by_index(2));
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,221 @@
#include "matugen_generator.hpp"
#include "core/palette/color.hpp"
#include <array>
#include <cstdio>
#include <filesystem>
#include <regex>
#include <string>
#include <unordered_map>
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_background", "background"},
{"editor_main", "on_surface"},
{"editor_comment", "outline"},
{"editor_string", "tertiary"},
{"editor_emphasis", "primary"},
{"editor_command", "secondary"},
{"editor_link", "primary_container"},
{"editor_error", "error"},
{"editor_warning", "secondary"},
{"editor_success", "primary"},
{"editor_disabled", "outline_variant"},
{"editor_inactive", "outline_variant"},
{"editor_line_number", "outline"},
{"editor_selected", "primary_container"},
{"editor_selection_inactive", "surface_container_low"},
{"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

@@ -1,38 +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
views/about_window.cpp
views/settings_window.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
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

@@ -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,53 @@
#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");
palette[int(TextEditor::PaletteIndex::Default)] = get_color_u32("editor_main");
palette[int(TextEditor::PaletteIndex::Keyword)] = get_color_u32("editor_command");
palette[int(TextEditor::PaletteIndex::Number)] = get_color_u32("editor_warning");
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_main");
palette[int(TextEditor::PaletteIndex::Preprocessor)] = get_color_u32("editor_emphasis");
palette[int(TextEditor::PaletteIndex::Identifier)] = get_color_u32("editor_main");
palette[int(TextEditor::PaletteIndex::KnownIdentifier)] = get_color_u32("editor_link");
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] = get_color_u32("editor_link");
palette[int(TextEditor::PaletteIndex::Comment)] = get_color_u32(current, "editor_comment");
palette[int(TextEditor::PaletteIndex::MultiLineComment)] =
get_color_u32(current, "editor_comment");
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");
palette[int(TextEditor::PaletteIndex::Background)] = get_color_u32("editor_background");
palette[int(TextEditor::PaletteIndex::Cursor)] = get_color_u32("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");
palette[int(TextEditor::PaletteIndex::Selection)] = get_color_u32("editor_selected");
palette[int(TextEditor::PaletteIndex::ErrorMarker)] = get_color_u32("editor_error");
palette[int(TextEditor::PaletteIndex::Breakpoint)] = get_color_u32("editor_error");
palette[int(TextEditor::PaletteIndex::LineNumber)] =
get_color_u32(current, "editor_line_number");
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");
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");
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

@@ -5,40 +5,44 @@
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();
const float bar_height = 30.0f;
ImGui::SetNextWindowPos(vp->Pos);
ImGui::SetNextWindowSize(ImVec2(vp->Size.x, bar_height));
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(8, 2));
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_FramePadding, ImVec2(8, 3));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(BUTTON_SPACING, 6.0f));
ImGui::Begin("##TopBar", nullptr, flags);
ImGuiStyle &style = ImGui::GetStyle();
style.FrameBorderSize = 1.0f;
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 - style.WindowPadding.x;
float pos_x = ImGui::GetWindowWidth() - total_width - TOPBAR_PADDING_X;
float button_height = ImGui::GetFrameHeight();
float window_height = ImGui::GetWindowHeight();
@@ -47,29 +51,24 @@ void main_layout::render_menu_bar()
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();
const float topbar_height = 32.0f;
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + topbar_height));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, viewport->Size.y - topbar_height));
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 |
@@ -80,9 +79,8 @@ void main_layout::setup_dockspace(bool &first_time)
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 3));
ImGui::Begin("MainDockSpace", nullptr, flags);
ImGui::PopStyleVar(4);
ImGui::PopStyleVar(3);
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
@@ -95,13 +93,11 @@ void main_layout::setup_dockspace(bool &first_time)
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
ImGuiID center, right;
ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 0.5f, &right, &center);
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);

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,12 +1,17 @@
#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/widgets/dialogs.hpp"
#include "gui/widgets/palette_selector.hpp"
#include "gui/widgets/input_dialog.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>
color_scheme_editor::color_scheme_editor()
@@ -89,16 +94,251 @@ void color_scheme_editor::render_controls()
if (ImGui::Button(" + New "))
{
m_new_palette_dialog.open("New Palette", "Enter a name for the new palette:", "Palette name...");
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");
m_new_palette_dialog.render();
m_generate_dialog.render();
ImGui::SameLine();
m_action_buttons.render(current);
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button("Generate"))
{
m_show_generate_modal = true;
}
if (m_show_generate_modal)
{
ImGui::OpenPopup("Generate Palette");
m_show_generate_modal = false;
}
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));
if (m_generator_idx == 0) // hellwal
{
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 (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)))
{
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
if (m_show_delete_confirmation)
{
ImGui::OpenPopup("Delete Palette?");
@@ -106,10 +346,10 @@ void color_scheme_editor::render_controls()
}
clrsync::gui::widgets::delete_confirmation_dialog("Delete Palette?", current.name(), "palette",
current, [this]() {
m_controller.delete_current_palette();
apply_themes();
});
current, [this]() {
m_controller.delete_current_palette();
apply_themes();
});
ImGui::PopStyleVar(2);
}
@@ -127,25 +367,39 @@ void color_scheme_editor::setup_widgets()
apply_themes();
});
m_action_buttons.add_button({
" Save ",
"Save current palette to file",
[this]() { m_controller.save_current_palette(); }
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({
" Delete ",
"Delete current palette",
[this]() { m_show_delete_confirmation = true; },
true,
true
});
m_action_buttons.add_button({" Save ", "Save current palette to file",
[this]() { m_controller.save_current_palette(); }});
m_action_buttons.add_button({
" Apply Theme ",
"Apply current palette to all enabled templates",
[this]() { m_controller.apply_current_theme(); }
});
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,9 +4,9 @@
#include "gui/controllers/palette_controller.hpp"
#include "gui/views/color_table_renderer.hpp"
#include "gui/views/preview_renderer.hpp"
#include "gui/widgets/palette_selector.hpp"
#include "gui/widgets/input_dialog.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;
@@ -46,6 +46,27 @@ class color_scheme_editor
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;
};

View File

@@ -118,11 +118,8 @@ void color_table_renderer::render(const clrsync::core::palette &current,
ImGui::Text("Filter:");
ImGui::SameLine();
ImGui::SetNextItemWidth(200);
bool filter_changed =
ImGui::InputTextWithHint("##color_filter",
"Search colors...",
m_filter_text,
sizeof(m_filter_text));
bool filter_changed = ImGui::InputTextWithHint("##color_filter", "Search colors...",
m_filter_text, sizeof(m_filter_text));
if (m_filter_text[0] != '\0')
{
@@ -157,7 +154,8 @@ void color_table_renderer::render(const clrsync::core::palette &current,
if (!has_matches)
return;
ImGui::PushStyleColor(ImGuiCol_Text, clrsync::gui::widgets::palette_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();
@@ -186,7 +184,7 @@ 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"});
"on_surface_variant", "foreground", "cursor", "accent", "accent_secondary"});
draw_table("Borders", "##borders", {"border_focused", "border"});

View File

@@ -3,6 +3,7 @@
#include "core/config/config.hpp"
#include "core/palette/color_keys.hpp"
#include "core/theme/theme_template.hpp"
#include "gui/theme/app_theme.hpp"
#include "gui/widgets/colors.hpp"
#include "gui/widgets/dialogs.hpp"
#include "gui/ui_manager.hpp"
@@ -24,12 +25,7 @@ template_editor::template_editor(clrsync::gui::ui_manager* ui_mgr)
{
m_control_state.name = "new_template";
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);
update_autocomplete_colors();
TextEditor::LanguageDefinition lang;
lang.mName = "Template";
@@ -80,12 +76,26 @@ void template_editor::setup_callbacks()
};
}
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)
{
m_current_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 clrsync::gui::widgets::palette_color_u32(pal, key, fallback);
};
@@ -97,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 = clrsync::gui::widgets::palette_color(pal, "surface", "background");
m_autocomplete_bg_color.w = 0.98f;
m_autocomplete_border_color = clrsync::gui::widgets::palette_color(pal, "border", "surface_variant");
m_autocomplete_selected_color = clrsync::gui::widgets::palette_color(pal, "accent", "surface_variant");
m_autocomplete_text_color = clrsync::gui::widgets::palette_color(pal, "on_surface", "foreground");
m_autocomplete_selected_text_color = clrsync::gui::widgets::palette_color(pal, "on_surface", "foreground");
m_autocomplete_dim_text_color =
clrsync::gui::widgets::palette_color(pal, "on_surface_variant", "editor_inactive");
update_autocomplete_colors();
}
void template_editor::update_autocomplete_suggestions()

View File

@@ -28,6 +28,7 @@ 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);

View File

@@ -17,7 +17,7 @@ void action_buttons::clear()
m_buttons.clear();
}
void action_buttons::render(const core::palette &theme_palette)
void action_buttons::render(const core::palette &)
{
if (m_buttons.empty())
return;
@@ -37,30 +37,16 @@ void action_buttons::render(const core::palette &theme_palette)
ImGui::SameLine();
first = false;
int style_colors_pushed = 0;
bool has_style = false;
if (button.use_error_style)
{
auto error = palette_color(theme_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_color(theme_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);
style_colors_pushed = 4;
push_error_button_style();
has_style = true;
}
else if (button.use_success_style)
{
auto success = palette_color(theme_palette, "success", "accent");
auto success_hover = ImVec4(success.x * 1.1f, success.y * 1.1f, success.z * 1.1f, success.w);
auto success_active = ImVec4(success.x * 0.8f, success.y * 0.8f, success.z * 0.8f, success.w);
auto on_success = palette_color(theme_palette, "on_success", "on_surface");
ImGui::PushStyleColor(ImGuiCol_Button, success);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, success_hover);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, success_active);
ImGui::PushStyleColor(ImGuiCol_Text, on_success);
style_colors_pushed = 4;
push_success_button_style();
has_style = true;
}
bool disabled = !button.enabled;
@@ -70,21 +56,17 @@ void action_buttons::render(const core::palette &theme_palette)
if (ImGui::Button(button.label.c_str()))
{
if (button.on_click)
{
button.on_click();
}
}
if (disabled)
ImGui::EndDisabled();
if (style_colors_pushed > 0)
ImGui::PopStyleColor(style_colors_pushed);
if (has_style)
pop_button_style();
if (!button.tooltip.empty() && ImGui::IsItemHovered())
{
ImGui::SetTooltip("%s", button.tooltip.c_str());
}
}
ImGui::PopStyleVar();

View File

@@ -12,20 +12,11 @@ ImVec4 palette_color(const core::palette &pal, const std::string &key,
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 theme::color_utils::from_hex(it->second.hex());
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
@@ -38,21 +29,53 @@ uint32_t palette_color_u32(const core::palette &pal, const std::string &key,
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 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

@@ -2,6 +2,7 @@
#define CLRSYNC_GUI_WIDGETS_COLORS_HPP
#include "core/palette/palette.hpp"
#include "gui/theme/app_theme.hpp"
#include "imgui.h"
#include <string>
@@ -14,6 +15,18 @@ ImVec4 palette_color(const core::palette &pal, const std::string &key,
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

@@ -1,6 +1,7 @@
#include "input_dialog.hpp"
#include "imgui.h"
#include <cstring>
#include <string>
namespace clrsync::gui::widgets
{
@@ -41,6 +42,21 @@ bool input_dialog::render()
IM_ARRAYSIZE(m_input_buffer),
ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::SameLine();
if (ImGui::Button("Browse"))
{
if (m_on_browse)
{
std::string initial = m_input_buffer;
std::string res = m_on_browse(initial);
if (!res.empty())
{
std::strncpy(m_input_buffer, res.c_str(), IM_ARRAYSIZE(m_input_buffer) - 1);
m_input_buffer[IM_ARRAYSIZE(m_input_buffer) - 1] = '\0';
}
}
}
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
@@ -108,4 +124,9 @@ void input_dialog::set_on_cancel(const std::function<void()> &callback)
m_on_cancel = callback;
}
void input_dialog::set_path_browse_callback(const std::function<std::string(const std::string &)> &callback)
{
m_on_browse = callback;
}
} // namespace clrsync::gui::widgets

View File

@@ -18,6 +18,7 @@ class input_dialog
void set_on_submit(const std::function<void(const std::string &)> &callback);
void set_on_cancel(const std::function<void()> &callback);
void set_path_browse_callback(const std::function<std::string(const std::string &)> &callback);
bool is_open() const { return m_is_open; }
@@ -31,6 +32,7 @@ class input_dialog
std::function<void(const std::string &)> m_on_submit;
std::function<void()> m_on_cancel;
std::function<std::string(const std::string &)> m_on_browse;
};
} // namespace clrsync::gui::widgets

View File

@@ -5,11 +5,10 @@
namespace clrsync::gui::widgets
{
void section_header(const std::string& title, const core::palette& palette)
void section_header(const std::string &title, const core::palette &)
{
ImGui::Spacing();
auto accent_color = palette_color(palette, "accent");
ImGui::TextColored(accent_color, "%s", title.c_str());
ImGui::TextColored(theme().accent(), "%s", title.c_str());
ImGui::Separator();
ImGui::Spacing();
}