Browse Source

Add option to theme based on desktop background

There's still some customization that needs to be done on the theme
assignment, but overall it's usable.
filter-focus
Macoy Madson 1 year ago
parent
commit
8a6d9ed141
  1. 3
      .gitmodules
  2. 1
      Dependencies/auto-color
  3. 2
      Dependencies/gamelib
  4. 1
      src/Config_Linux.cake
  5. 12
      src/FileHelper.cake
  6. 81
      src/ImGuiAutoColor.cake

3
.gitmodules

@ -22,3 +22,6 @@
[submodule "Dependencies/tracy"]
path = Dependencies/tracy
url = https://github.com/wolfpld/tracy
[submodule "Dependencies/auto-color"]
path = Dependencies/auto-color
url = gitea@macoy.me:macoy/auto-color.git

1
Dependencies/auto-color

@ -0,0 +1 @@
Subproject commit 685ddc2789b95270e77430eeeab138fea5a9af66

2
Dependencies/gamelib

@ -1 +1 @@
Subproject commit 8435230abb2f3246e6aa2f36dc8ec7342dc33792
Subproject commit d75b3f7aa95cd86b0b07ed26da3e3a17299b5a24

1
src/Config_Linux.cake

@ -2,6 +2,7 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/gamelib/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(add-cakelisp-search-directory "Dependencies/auto-color/src")
(add-cakelisp-search-directory "src")

12
src/FileHelper.cake

@ -5,7 +5,7 @@
;; From File Helper
"FileSystem.cake" "LoadSave.cake" "Export.cake" "Utilities.cake"
"Treemap.cake" "TreemapOpenGL.cake" "TreemapFileSystem.cake" "License.cake"
"Help.cake"
"Help.cake" "ImGuiAutoColor.cake"
;; From cakelisp
"FileUtilities.cake"
&comptime-only
@ -1318,14 +1318,6 @@
(scope ;; ImGui style customizations
(var imgui-style (& ImGuiStyle) (imgui-call GetStyle))
(set (field imgui-style FrameRounding) 6.f))
;; (scope
;; (var colors (* ImVec4) (field (imgui-call GetStyle) Colors))
;; (set (at ImGuiCol_Text colors) (ImVec4 0.44f 0.55f 0.63f 1.00f))
;; (set (at ImGuiCol_WindowBg colors) (ImVec4 0.01f 0.01f 0.01f 0.94f))
;; (set (at ImGuiCol_FrameBg colors) (ImVec4 0.05f 0.05f 0.04f 1.00f))
;; (set (at ImGuiCol_TitleBgActive colors) (ImVec4 0.28f 0.08f 0.02f 1.00f))
;; (set (at ImGuiCol_TitleBgCollapsed colors) (ImVec4 0.28f 0.12f 0.12f 1.00f))
;; (set (at ImGuiCol_Button colors) (ImVec4 0.28f 0.08f 0.02f 1.00f)))
(var directory-history (* dynstring) null)
(dynarray-set-capacity directory-history 64)
@ -1382,6 +1374,8 @@
(imgui-call MenuItem "Treemap" null (addr show-treemap))
(imgui-call Separator)
(imgui-call MenuItem "UI" null (addr show-imgui-demo-window))
(when (imgui-call MenuItem "Theme from desktop background")
(imgui-colors-from-current-background))
(imgui-call EndMenu))
(when (imgui-call BeginMenu "About")

81
src/ImGuiAutoColor.cake

@ -0,0 +1,81 @@
(import "ImGui.cake" "AutoColor.cake")
;; TODO: ImGui.cake import should handle this via export/auto-infect
(c-import "imgui.h")
(add-c-search-directory-module "Dependencies/imgui")
(defun-local auto-color-to-imgui-color (color auto-color &return ImVec4)
(return (ImVec4
(/ (at 0 color) 255.f)
(/ (at 1 color) 255.f)
(/ (at 2 color) 255.f)
1.00f)))
(defun imgui-colors-from-current-background ()
(scope
(var base16-colors ([] 16 auto-color) (array 0))
(when (auto-color-pick-from-current-background base16-colors)
(var colors (* ImVec4) (field (imgui-call GetStyle) Colors))
(set (at ImGuiCol_Text colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_TextDisabled colors) (auto-color-to-imgui-color (at 3 base16-colors)))
(set (at ImGuiCol_WindowBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_ChildBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_PopupBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_Border colors) (auto-color-to-imgui-color (at 14 base16-colors)))
(set (at ImGuiCol_BorderShadow colors) (auto-color-to-imgui-color (at 14 base16-colors)))
(set (at ImGuiCol_FrameBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_FrameBgHovered colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_FrameBgActive colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_TitleBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TitleBgActive colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_TitleBgCollapsed colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_MenuBarBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_ScrollbarBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_ScrollbarGrab colors) (auto-color-to-imgui-color (at 13 base16-colors)))
(set (at ImGuiCol_ScrollbarGrabHovered colors) (auto-color-to-imgui-color (at 14 base16-colors)))
(set (at ImGuiCol_ScrollbarGrabActive colors) (auto-color-to-imgui-color (at 15 base16-colors)))
(set (at ImGuiCol_CheckMark colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_SliderGrab colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_SliderGrabActive colors) (auto-color-to-imgui-color (at 6 base16-colors)))
(set (at ImGuiCol_Button colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_ButtonHovered colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_ButtonActive colors) (auto-color-to-imgui-color (at 6 base16-colors)))
(set (at ImGuiCol_Header colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_HeaderHovered colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_HeaderActive colors) (auto-color-to-imgui-color (at 9 base16-colors)))
(set (at ImGuiCol_Separator colors) (auto-color-to-imgui-color (at 10 base16-colors)))
(set (at ImGuiCol_SeparatorHovered colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_SeparatorActive colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_ResizeGrip colors) (auto-color-to-imgui-color (at 11 base16-colors)))
(set (at ImGuiCol_ResizeGripHovered colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_ResizeGripActive colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_Tab colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_TabHovered colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TabActive colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_TabUnfocused colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_TabUnfocusedActive colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_DockingPreview colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_DockingEmptyBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
(set (at ImGuiCol_PlotLines colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_PlotLinesHovered colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_PlotHistogram colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_PlotHistogramHovered colors) (auto-color-to-imgui-color (at 5 base16-colors)))
(set (at ImGuiCol_TableHeaderBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TableBorderStrong colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TableBorderLight colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TableRowBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_TableRowBgAlt colors) (auto-color-to-imgui-color (at 8 base16-colors)))
(set (at ImGuiCol_TextSelectedBg colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_DragDropTarget colors) (auto-color-to-imgui-color (at 7 base16-colors)))
(set (at ImGuiCol_NavHighlight colors) (auto-color-to-imgui-color (at 9 base16-colors)))
(set (at ImGuiCol_NavWindowingHighlight colors) (auto-color-to-imgui-color (at 2 base16-colors)))
(set (at ImGuiCol_NavWindowingDimBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
(set (at ImGuiCol_ModalWindowDimBg colors) (auto-color-to-imgui-color (at 2 base16-colors)))
;; (set (at ImGuiCol_Text colors) (auto-color-to-imgui-color (at 5 base16-colors)))
;; (set (at ImGuiCol_WindowBg colors) (auto-color-to-imgui-color (at 0 base16-colors)))
;; (set (at ImGuiCol_FrameBg colors) (auto-color-to-imgui-color (at 1 base16-colors)))
;; (set (at ImGuiCol_TitleBgActive colors) (auto-color-to-imgui-color (at 2 base16-colors)))
;; (set (at ImGuiCol_TitleBgCollapsed colors) (auto-color-to-imgui-color (at 3 base16-colors)))
;; (set (at ImGuiCol_Button colors) (auto-color-to-imgui-color (at 1 base16-colors)))
)))
Loading…
Cancel
Save