rev: 21c5e6d2f665d0e8b4ff917a51b664c895dab2ed tukan/tukan/dockgui.sc -rw-r--r-- 6.4 KiB View raw Log this file
21c5e6d2f665 — Leonard Ritter * renamed project from Liminal to Tukan 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import .glmain
import .stage
import .icons
import .sdl

using import .gl
using import glm
using import .imgui

let on-frame = (fnchain "on-dockgui-frame")
let on-define-main-menu = (fnchain "on-define-main-menu")
let on-define-dock = (fnchain "on-define-dock")
let on-define-windows = (fnchain "on-define-windows")

fn PushStyleRootWindow ()
    PushStyleVar ImGuiStyleVar_WindowRounding 0
    PushStyleVar ImGuiStyleVar_WindowPadding
        vec2 0 0
fn PopStyleRootWindow ()
    PopStyleVar 2

global SansFont = (nullof (pointer ImFont))
global FixedFont = (nullof (pointer ImFont))

'append stage.init-gfx
    fn ()
        let assets =
            .. module-dir "/../assets/core/fonts"
        let sansfont =
            .. assets "/DejaVuSans.ttf"
        let fixedfont =
            .. assets "/UbuntuMono-R.ttf"
        let fontawesome =
            .. assets "/fontawesome-webfont.ttf"
        let materialicons =
            .. assets "/MaterialIcons-Regular.ttf"
        let kenneyicons =
            .. assets "/kenney-icon-font.ttf"

        let io =
            GetIO;

        # merge in icons from Font Awesome
        var icons_config =
            ImFontConfig
                FontDataOwnedByAtlas = true
                OversampleH = 3
                OversampleV = 1
                MergeMode = true
                PixelSnapH = true

        SansFont =
            ImFontAtlas_AddFontFromFileTTF io.Fonts sansfont 13 null null

        #ImFontAtlas_AddFontFromFileTTF io.Fonts fontawesome 13 icons_config icons.fa_icon_range
        var icon_range = icons.md_icon_range
        ImFontAtlas_AddFontFromFileTTF io.Fonts materialicons 13 icons_config icon_range
        #ImFontAtlas_AddFontFromFileTTF io.Fonts kenneyicons 13 icons_config icons.ki_icon_range
        FixedFont =
            ImFontAtlas_AddFontFromFileTTF io.Fonts fixedfont 13 null null

        sdl.ImGui_ImplSdlGL3_Init glmain.window

        fn make-color (r g b a)
            let h s v = (ColorConvertRGBtoHSV r g b)
            let v =
                ? (s < 0.1)
                    1.0 - v
                    v
            let r g b = (ColorConvertHSVtoRGB h s v)
            ImVec4 r g b a

        let style =
            GetStyle;

        define-macro set-style
            let name r g b a = (decons args 5)
            let name = (name as Syntax as Symbol as string)
            let name = (Symbol (.. "ImGuiCol_" name))
            list (do =)
                list (do @) (list (do .) 'style 'Colors) name
                list make-color r g b a

        # @DougBinks
        style.FrameRounding = 3
        set-style Text                  0.00 0.00 0.00 1.00
        set-style TextDisabled          0.60 0.60 0.60 1.00
        set-style WindowBg              0.94 0.94 0.94 1.00
        set-style ChildWindowBg         0.00 0.00 0.00 0.00
        set-style Border                0.00 0.00 0.00 0.39
        set-style BorderShadow          1.00 1.00 1.00 0.10
        set-style FrameBg               1.00 1.00 1.00 1.00
        set-style FrameBgHovered        0.26 0.59 0.98 0.40
        set-style FrameBgActive         0.26 0.59 0.98 0.67
        set-style TitleBg               0.96 0.96 0.96 1.00
        set-style TitleBgCollapsed      1.00 1.00 1.00 0.51
        set-style TitleBgActive         0.82 0.82 0.82 1.00
        set-style MenuBarBg             0.86 0.86 0.86 1.00
        set-style ScrollbarBg           0.98 0.98 0.98 0.53
        set-style ScrollbarGrab         0.69 0.69 0.69 0.80
        set-style ScrollbarGrabHovered  0.49 0.49 0.49 0.80
        set-style ScrollbarGrabActive   0.49 0.49 0.49 1.00
        #set-style ComboBg               0.86 0.86 0.86 0.99
        set-style CheckMark             0.26 0.59 0.98 1.00
        set-style SliderGrab            0.26 0.59 0.98 0.78
        set-style SliderGrabActive      0.26 0.59 0.98 1.00
        set-style Button                0.26 0.59 0.98 0.40
        set-style ButtonHovered         0.26 0.59 0.98 1.00
        set-style ButtonActive          0.06 0.53 0.98 1.00
        set-style Header                0.26 0.59 0.98 0.31
        set-style HeaderHovered         0.26 0.59 0.98 0.80
        set-style HeaderActive          0.26 0.59 0.98 1.00
        set-style Column                0.39 0.39 0.39 1.00
        set-style ColumnHovered         0.26 0.59 0.98 0.78
        set-style ColumnActive          0.26 0.59 0.98 1.00
        set-style ResizeGrip            1.00 1.00 1.00 0.50
        set-style ResizeGripHovered     0.26 0.59 0.98 0.67
        set-style ResizeGripActive      0.26 0.59 0.98 0.95
        set-style CloseButton           0.59 0.59 0.59 0.50
        set-style CloseButtonHovered    0.98 0.39 0.36 1.00
        set-style CloseButtonActive     0.98 0.39 0.36 1.00
        set-style PlotLines             0.39 0.39 0.39 1.00
        set-style PlotLinesHovered      1.00 0.43 0.35 1.00
        set-style PlotHistogram         0.90 0.70 0.00 1.00
        set-style PlotHistogramHovered  1.00 0.60 0.00 1.00
        set-style TextSelectedBg        0.26 0.59 0.98 0.35
        set-style PopupBg               1.00 1.00 1.00 0.94
        set-style ModalWindowDarkening  0.20 0.20 0.20 0.35

'append glmain.on-event
    fn (event)
        sdl.ImGui_ImplSdlGL3_ProcessEvent event

'append glmain.on-draw
    fn draw (s size)
        sdl.ImGui_ImplSdlGL3_NewFrame glmain.window

        on-frame s size
        SetNextWindowSize (vec2 size)
        PushStyleRootWindow;
        Begin "Main" null
            |
                ImGuiWindowFlags_NoTitleBar
                ImGuiWindowFlags_NoResize
                ImGuiWindowFlags_NoMove
                ImGuiWindowFlags_NoCollapse
                ImGuiWindowFlags_NoScrollWithMouse
                ImGuiWindowFlags_MenuBar
                ImGuiWindowFlags_NoSavedSettings
                ImGuiWindowFlags_NoBringToFrontOnFocus
                ImGuiWindowFlags_NoFocusOnAppearing
        PopStyleRootWindow;
        if (BeginMenuBar)
            on-define-main-menu;
            EndMenuBar;

        BeginWorkspace;

        on-define-dock;

        EndWorkspace;

        PushStyleRootWindow;
        End;
        PopStyleRootWindow;

        on-define-windows;

        glBindFramebuffer GL_FRAMEBUFFER 0
        glViewport 0 0 size.x size.y
        #glClearColor 0 0 1 1
        #glClear GL_COLOR_BUFFER_BIT
        #blit-framebuffer screen.framebuffer 0 size
        Render;

do
    let on-frame
        on-define-main-menu
        on-define-windows
        on-define-dock
        SansFont
        FixedFont

    locals;