M Project.toml => Project.toml +0 -11
@@ 6,17 6,6 @@ version = "0.1.0"
[deps]
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
CSyntax = "ea656a56-6ca6-5dda-bba5-7b6963a5f74c"
-ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
-DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
-Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
-ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
-ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
-LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
-MLJ = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
-PortAudio = "80ea8bcb-4634-5cb3-8ee8-a132660d1d2d"
-Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
-SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
-VideoIO = "d6d074c3-1acf-5d4c-9a43-ef38773959a2"
M src/Adjutant.jl => src/Adjutant.jl +9 -12
@@ 20,18 20,14 @@ include("node_editor.jl")
Base.@kwdef mutable struct AdjutantState
widgets = WidgetContainer()
end
-const adj = AdjutantState()
-
-if length(ARGS) == 1
- proj_path = abspath(ARGS[1])
- @assert isdir(proj_path)
- Pkg.activate(proj_path)
- init_func = include(joinpath(proj_path, "src", "main.jl"))
- init_func(adj)
-end
+
+function gui_main(func)
+adj = AdjutantState()
+
+func(adj)
# OpenGL 3.2 + GLSL 150
-const glsl_version = 150
+glsl_version = 150
GLFW.WindowHint(GLFW.CONTEXT_VERSION_MAJOR, 3)
GLFW.WindowHint(GLFW.CONTEXT_VERSION_MINOR, 2)
GLFW.WindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE) # 3.2+ only
@@ 57,7 53,7 @@ CImGui.StyleColorsDark()
ImGui_ImplGlfw_InitForOpenGL(window, true)
ImGui_ImplOpenGL3_Init(glsl_version)
-const binds = Dict(
+binds = Dict(
#name == "c" && mods == 2 && exit(0)
"Q" => () -> exit(0),
"C" => () -> clear_all!(adj),
@@ 70,7 66,7 @@ const binds = Dict(
"f" => () -> fit!(adj),
),
)
-const current_dict = Ref(binds)
+current_dict = Ref(binds)
function dispatch_keybinding(key, scancode, actions, mods)
name = GLFW.GetKeyName(key, scancode)
if name isa String && mods == 2 # Ctrl
@@ 138,5 134,6 @@ ImGui_ImplGlfw_Shutdown()
CImGui.DestroyContext(ctx)
GLFW.DestroyWindow(window)
+end
end
M src/node_editor.jl => src/node_editor.jl +2 -2
@@ 1,8 1,8 @@
+export NodeEditor, Node, NodeLink
+
using CImGui.LibCImGui
import CImGui.LibCImGui: ImVec2, ImColor
-import Random: randstring
-
#=
# Creating a node graph editor for ImGui
# Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff.
M src/processing.jl => src/processing.jl +3 -0
@@ 1,3 1,6 @@
+export Processor
+export newslot, getslot, setslot!
+
global const SLOTS = Dict{UUID, Observable}()
function newslot(::Type{T}=Any, init=nothing) where T
M src/widgets.jl => src/widgets.jl +4 -45
@@ 1,3 1,6 @@
+export Widget, AddWidgetButton, ClosureWidget
+export known_widgets, processor, get_processor
+
const known_widgets = Any[]
### Core ###
@@ 12,8 15,8 @@ Base.convert(::Type{W} where W<:Widget, x) = Widget(x, get_processor(x))
Base.convert(::Type{W} where W<:Widget, w::Widget) = w
name(w::Widget{T}) where T = string(T)
# FIXME: Unique name for IDs
-get_processor(x) = Processor()
processor(w::Widget{T}) where T = getfield(w, :p)
+get_processor(x) = Processor()
Base.@kwdef mutable struct WidgetContainer
widgets::Vector{Widget} = Widget[]
@@ 80,49 83,6 @@ function (awb::Widget{AddWidgetButton})(outer)
end
push!(known_widgets, AddWidgetButton)
-#=
-### Image Widgets ###
-
-mutable struct VideoCameraWidget
- dev
- image
-end
-function VideoCameraWidget(dev=VideoIO.opencamera())
- image = collect(transpose(read(dev)))
- return VideoCameraWidget(dev, image)
-end
-function (vcw::Widget{VideoCameraWidget})(outer)
- processor(vcw)()
-end
-function get_processor(vcw::VideoCameraWidget)
- return Processor(nothing, ["image_raw"]) do p
- image_raw = read(vcw.dev)
- vcw.image = collect(transpose(image_raw))
- setslot!(p, "image_raw", vcw.image)
- end
-end
-
-mutable struct OpenGLImageWidget
- image_id
-end
-OpenGLImageWidget() = OpenGLImageWidget(nothing)
-push!(known_widgets, OpenGLImageWidget)
-function (ow::Widget{OpenGLImageWidget})(_...)
- processor(ow)()
-end
-function get_processor(ow::OpenGLImageWidget)
- return Processor(["image"], nothing) do p
- image = getslot(p, "image")
- image = reshape(reinterpret(GLubyte, RGBA.(image)), (4,size(image)...))
- _, img_width, img_height = size(image)
- if ow.image_id === nothing
- ow.image_id = ImGui_ImplOpenGL3_CreateImageTexture(img_width, img_height)
- end
- ImGui_ImplOpenGL3_UpdateImageTexture(ow.image_id, image, img_width, img_height)
- CImGui.Image(Ptr{Cvoid}(ow.image_id), (img_width, img_height))
- end
-end
-
### Misc Widgets ###
Base.@kwdef mutable struct TextWidget
@@ 135,7 95,6 @@ function render_widget_form(::Type{TextWidget}, fields, outer)
str = fields[:str]
CImGui.InputText("Text", str, length(str))
end
-=#
struct ClosureWidget
func