Browse Source

Make auto theming optional

filter-focus
Macoy Madson 1 year ago
parent
commit
b49dddfa97
  1. 9
      src/FileHelper.cake
  2. 11
      src/ImGuiAutoColor.cake
  3. 3
      src/LoadSave.cake

9
src/FileHelper.cake

@ -51,6 +51,7 @@
(var-global g-userdata-dict (* directory-entry-userdata) null)
(var-global g-treemap-use-theme-for-colorization bool true)
(var-global g-auto-theme-from-background bool true)
;; Is SDL_Scancode, but I don't want to have to include SDL in every file that wants these
(def-type-alias-global category-keybind (unsigned int))
@ -1392,7 +1393,9 @@
(set last-time-saved (SDL_GetPerformanceCounter)))
(task-system-run-thread-pinned-tasks)
(update-auto-color-theme)
(when g-auto-theme-from-background
(update-auto-color-theme))
;; Get keyboard input
(var num-sdl-keys int 0)
@ -1416,8 +1419,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-start))
(imgui-call MenuItem "Theme from desktop background" null
(addr g-auto-theme-from-background))
(imgui-call EndMenu))
(when (imgui-call BeginMenu "About")

11
src/ImGuiAutoColor.cake

@ -146,7 +146,12 @@
;; Smoothly interpolate between current and target colors
(var before-update-values ([] 16 auto-color))
(memcpy before-update-values current-base16-colors (sizeof before-update-values))
(var transition-speed float (* 0.5f (- target-set-time current-time)))
(var time-delta float (- current-time target-set-time))
(var transition-total-time float 0.5f)
(var transition-speed float (/ time-delta transition-total-time))
(when (< 1.f transition-speed)
(set transition-speed 1.f))
(each-in-array target-base16-colors i
(each-in-range 3 component
(var current-value float (at i component current-interpolate-base16-colors))
@ -154,8 +159,8 @@
(set target-value (/ target-value 255.f))
(set (at i component current-interpolate-base16-colors)
(+ current-value
(* transition-speed
(- current-value target-value))))
(* (- target-value current-value)
transition-speed)))
(set (at i component current-base16-colors)
(type-cast (round (* 255.f (at i component current-interpolate-base16-colors)))
(unsigned char)))))

3
src/LoadSave.cake

@ -24,6 +24,7 @@
category-last-used-key int
is-first-time-run bool
treemap-use-theme-for-colorization bool
auto-theme-from-background bool
file-colorizers (* file-colorizer) (override 'dynarray)
categories-dict (* category-spec) (override 'dictionary)
categorized-entries (* directory-entry-userdata) (override 'strdict))
@ -47,6 +48,7 @@
(set (field userdata category-last-used-key) g-category-last-used-key)
(set (field userdata is-first-time-run) g-is-first-time-run)
(set (field userdata treemap-use-theme-for-colorization) g-treemap-use-theme-for-colorization)
(set (field userdata auto-theme-from-background) g-auto-theme-from-background)
(set (field userdata categories-dict) g-categories-dict)
(set (field userdata categorized-entries) g-userdata-dict)
(set (field userdata file-colorizers) g-file-colorizers)
@ -178,6 +180,7 @@
(set g-category-last-used-key (field userdata category-last-used-key))
(set g-is-first-time-run (field userdata is-first-time-run))
(set g-treemap-use-theme-for-colorization (field userdata treemap-use-theme-for-colorization))
(set g-auto-theme-from-background (field userdata auto-theme-from-background))
(dict-free g-categories-dict)
(set g-categories-dict (field userdata categories-dict))

Loading…
Cancel
Save