@ -1,7 +1,12 @@
( import "ImGui.cake" "AutoColor.cake" )
( import "ImGui.cake" "TaskSystem.cake"
"AutoColor.cake"
&comptime-only "CHelpers.cake" )
;; TODO Need infect
( add-c-search-directory-module "Dependencies/enkiTS/src" )
;; TODO: ImGui.cake import should handle this via export/auto-infect
( c-import "imgui.h" )
( c-import "imgui.h" "<stdlib.h>" "<stdio.h>" )
( add-c-search-directory-module "Dependencies/imgui" )
( defun-local auto-color-to-imgui-color ( color auto-color &return ImVec4 )
@ -11,71 +16,79 @@
( / ( 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 0 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 1 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 12 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 2 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 0 base16-colors ) ) )
( set ( at ImGuiCol_TabUnfocused colors ) ( auto-color-to-imgui-color ( at 2 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 13 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 ) ) )
( def-task set-imgui-colors-from-base16 ( base16-colors ( * auto-color )
succeeded ( * bool ) )
( when ( deref succeeded )
( 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 0 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 1 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 12 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 2 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 0 base16-colors ) ) )
( set ( at ImGuiCol_TabUnfocused colors ) ( auto-color-to-imgui-color ( at 2 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 13 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)))
) ) )
( free succeeded )
( free base16-colors ) )
( def-task pick-colors-from-background ( base16-colors ( * auto-color )
succeeded-out ( * bool ) )
( fprintf stderr "Picking colors\n" )
( set ( deref succeeded-out ) ( auto-color-pick-from-current-background base16-colors ) )
( fprintf stderr "Picking colors: %s\n" ( ? ( deref succeeded-out ) "succeeded" "failed" ) ) )
( defun imgui-colors-from-current-background ( )
( var-cast-to base16-colors ( * auto-color ) ( calloc 16 ( sizeof ( type auto-color ) ) ) )
( var-cast-to succeeded ( * bool ) ( malloc ( sizeof ( type bool ) ) ) )
( task-system-execute
( pick-colors-from-background base16-colors succeeded )
( set-imgui-colors-from-base16 :pin-to-main-thread base16-colors succeeded ) ) )