Skip to content

Commit

Permalink
Merge pull request #141 from Gnimuc/v1.91.0
Browse files Browse the repository at this point in the history
v1.91.0
  • Loading branch information
JamesWrigley authored Sep 4, 2024
2 parents 7f15f7c + 81549c9 commit 1468fe3
Show file tree
Hide file tree
Showing 32 changed files with 27,416 additions and 9,877 deletions.
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name = "CImGui"
uuid = "5d785b6c-b76f-510e-a07c-3070796c7e87"
authors = ["Yupei Qi <[email protected]>"]
version = "2.3.0"
version = "3.0.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
CImGuiPack_jll = "333409e9-af72-5310-9767-d6ad21a76a05"
CSyntax = "ea656a56-6ca6-5dda-bba5-7b6963a5f74c"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

Expand All @@ -21,8 +23,10 @@ MakieIntegration = ["GLFW", "ModernGL", "GLMakie"]

[compat]
CEnum = "0.4, 0.5"
CImGuiPack_jll = "0.3.0"
CImGuiPack_jll = "0.4.0"
CSyntax = "0.4"
Compat = "4.16.0"
DocStringExtensions = "0.9.3"
GLFW = "3"
GLMakie = "0.10.6"
ModernGL = "1"
Expand Down
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ makedocs(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://Gnimuc.github.io/CImGui.jl",
assets=String[],
size_threshold=500000,
size_threshold_warn=400000
size_threshold=2_000_000,
size_threshold_warn=1_500_000
),
pages=["index.md", "api.md", "backends.md", "makie.md", "changelog.md"]
)
Expand Down
15 changes: 15 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ Changelog](https://keepachangelog.com).
### Changed
- Simplified the [Makie integration](@ref) by requiring the latest GLMakie
version ([#142]).
- **Breaking**: We upgraded to [Dear ImGui
1.91.0](https://github.com/ocornut/imgui/releases/tag/v1.91.0). All the
breaking changes listed there apply to this release.
- **Breaking**: We now generate the high-level Julia wrappers automatically
([#141]), which is far easier to maintain but it's possible that some
functions will have changed signatures or been renamed. Here's a
(non-exhaustive) list of known changes:
- [`Combo()`](@ref) now longer requires passing the length of `items`.
- The old `Value*()` functions are now just named [`Value()`](@ref) and use
dispatch to select the right ImGui function to call.
- The `Combo()` and `ListBox()` methods that allowed passing a function to
generate the items are not wrapped. They may be wrapped in the future.

If you encounter any other breakages please open an issue, it could be a bug
in the wrappers.
- **Breaking**: [`render()`](@ref) would previously run on whatever task and
thread it was called on, but with multiple threads that could cause issues if
the task migrated. It now defaults to being pinned to thread 1 and there's a
Expand Down
6 changes: 5 additions & 1 deletion docs/src/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ CurrentModule = CImGui
# Backends
ImGui is a very embeddable library because it abstracts things like drawing to
the screen and creating windows to its *backends*. There are many official
backends, but currently CImGui.jl only supports the GLFW/OpenGL3 backend.
backends, but currently CImGui.jl only supports the GLFW/OpenGL3 backend. Other
popular backends like [SFML](https://github.com/zyedidia/SFML.jl) and
[SDL](https://github.com/ariejdl/SDL.jl) could be added in the future if someone
should invest time to make these packages work.


```@docs
set_backend
Expand Down
10 changes: 2 additions & 8 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,5 @@ the original C++ API, so any high-level abstraction should go into a more
high-level package. [`Redux.jl`](https://github.com/Gnimuc/Redux.jl) might be of
interest to you if you're looking for state management frameworks.

### Backend
The default backend is based on
[ModernGL](https://github.com/JuliaGL/ModernGL.jl) and
[GLFW](https://github.com/JuliaGL/GLFW.jl) which are stable and actively
maintained. Other popular backends like
[SFML](https://github.com/zyedidia/SFML.jl) and
[SDL](https://github.com/ariejdl/SDL.jl) could be added in the future if someone
should invest time to make these packages work in post Julia 1.0 era.
For writing tests you can use
[ImGuiTestEngine.jl](https://juliaimgui.github.io/ImGuiTestEngine.jl).
6 changes: 5 additions & 1 deletion examples/app_constrained_resize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ global function ShowExampleAppConstrainedResize(p_open::Ref{Bool})
desired_size = unsafe_load(data.DesiredSize)
max_size = max(desired_size.x, desired_size.y)
data.DesiredSize = ImVec2(max_size, max_size)

return nothing
end

function Step(data::Ptr{ImGuiSizeCallbackData})::Cvoid
Expand All @@ -20,6 +22,8 @@ global function ShowExampleAppConstrainedResize(p_open::Ref{Bool})
size_x = trunc(desired_size.x / step + 0.5) * step
size_y = trunc(desired_size.y / step + 0.5) * step
data.DesiredSize = ImVec2(size_x, size_y)

return nothing
end

square_fptr = @cfunction($Square, Cvoid, (Ptr{ImGuiSizeCallbackData},))
Expand Down Expand Up @@ -51,7 +55,7 @@ global function ShowExampleAppConstrainedResize(p_open::Ref{Bool})
CImGui.SameLine()
CImGui.Button("800x200") && CImGui.SetWindowSize(ImVec2(800, 200))
CImGui.PushItemWidth(200)
@c CImGui.Combo("Constraint", &type, desc, length(desc))
@c CImGui.Combo("Constraint", &type, desc)
@c CImGui.DragInt("Lines", &display_lines, 0.2, 1, 100)
CImGui.PopItemWidth()
@c CImGui.Checkbox("Auto-resize", &auto_resize)
Expand Down
4 changes: 2 additions & 2 deletions examples/app_long_text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function ShowExampleAppLongText(p_open::Ref{Bool})
clipper = CImGui.Clipper()
CImGui.Begin(clipper, lines)
while CImGui.Step(clipper)
s = CImGui.Get(clipper, :DisplayStart)
e = CImGui.Get(clipper, :DisplayEnd)-1
s = unsafe_load(clipper.DisplayStart)
e = unsafe_load(clipper.DisplayEnd)-1
foreach(i->CImGui.Text("$i The quick brown fox jumps over the lazy dog"), s:e)
end
CImGui.PopStyleVar()
Expand Down
4 changes: 2 additions & 2 deletions examples/demo_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ShowAboutWindow(p_open::Ref{Bool})
style = CImGui.GetStyle()

copy_to_clipboard = CImGui.Button("Copy to clipboard")
CImGui.BeginChildFrame(CImGui.GetID("cfginfos"), ImVec2(0, CImGui.GetTextLineHeightWithSpacing() * 18), CImGui.ImGuiWindowFlags_NoMove)
CImGui.BeginChild(CImGui.GetID("cfginfos"), ImVec2(0, CImGui.GetTextLineHeightWithSpacing() * 18), CImGui.ImGuiChildFlags_FrameStyle, CImGui.ImGuiWindowFlags_NoMove)
copy_to_clipboard && CImGui.LogToClipboard()

CImGui.Text("Dear ImGui $(CImGui.IMGUI_VERSION)")
Expand Down Expand Up @@ -88,7 +88,7 @@ function ShowAboutWindow(p_open::Ref{Bool})
CImGui.Text(@sprintf("style.ItemInnerSpacing: %.2f,%.2f", item_inner_spacing.x, item_inner_spacing.y))

copy_to_clipboard && CImGui.LogFinish()
CImGui.EndChildFrame()
CImGui.EndChild()
end
end
CImGui.End()
Expand Down
4 changes: 2 additions & 2 deletions examples/demo_layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function ShowDemoWindowLayout()
# child 1: no border, enable horizontal scrollbar
begin
window_flags = CImGui.ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? CImGui.ImGuiWindowFlags_NoScrollWithMouse : 0)
CImGui.BeginChild("Child1", ImVec2(CImGui.GetWindowContentRegionWidth() * 0.5, 260), false, window_flags)
CImGui.BeginChild("Child1", ImVec2(CImGui.GetContentRegionAvail().x * 0.5, 260), false, window_flags)
for i = 0:100-1
CImGui.Text(@sprintf("%04d: scrollable region", i))
(goto_line && line == i) && CImGui.SetScrollHereY()
Expand Down Expand Up @@ -197,7 +197,7 @@ function ShowDemoWindowLayout()
CImGui.Text("Manually wrapping:")
# ImGuiStyle& style = CImGui.GetStyle()
# buttons_count = 20
# window_visible_x2 = CImGui.GetWindowPos().x + CImGui.GetWindowContentRegionMax().x
# window_visible_x2 = CImGui.GetWindowPos().x + CImGui.GetContentRegionAvail().x
# for n = 0:buttons_count-1
# CImGui.PushID(n)
# CImGui.Button("Box", button_sz)
Expand Down
12 changes: 6 additions & 6 deletions examples/demo_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ function ShowDemoWindowMisc()
end

CImGui.Button("Hovering me sets the\nkeyboard capture flag")
CImGui.IsItemHovered() && CImGui.CaptureKeyboardFromApp(true)
CImGui.IsItemHovered() && CImGui.SetNextFrameWantCaptureKeyboard(true)
CImGui.SameLine()
CImGui.Button("Holding me clears the\nthe keyboard capture flag")
CImGui.IsItemActive() && CImGui.CaptureKeyboardFromApp(false)
CImGui.IsItemActive() && CImGui.SetNextFrameWantCaptureKeyboard(false)

CImGui.TreePop()
end
Expand All @@ -129,10 +129,10 @@ function ShowDemoWindowMisc()
CImGui.InputText("1", buf, length(buf))
CImGui.InputText("2", buf, length(buf))
CImGui.InputText("3", buf, length(buf))
CImGui.PushAllowKeyboardFocus(false)
CImGui.PushItemFlag(CImGui.ImGuiItemFlags_NoTabStop, true)
CImGui.InputText("4 (tab skip)", buf, length(buf))
# CImGui.SameLine(); ShowHelperMarker("Use CImGui.PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets.")
CImGui.PopAllowKeyboardFocus()
CImGui.PopItemFlag()
CImGui.InputText("5", buf, length(buf))
end
CImGui.TreePop()
Expand All @@ -153,11 +153,11 @@ function ShowDemoWindowMisc()
CImGui.InputText("2", buf, length(buf))
CImGui.IsItemActive() && (has_focus = 2;)

CImGui.PushAllowKeyboardFocus(false)
CImGui.PushItemFlag(CImGui.ImGuiItemFlags_NoTabStop, true)
focus_3 && CImGui.SetKeyboardFocusHere()
CImGui.InputText("3 (tab skip)", buf, length(buf))
CImGui.IsItemActive() && (has_focus = 3;)
CImGui.PopAllowKeyboardFocus()
CImGui.PopItemFlag()
end
if has_focus != 0
CImGui.Text("Item with focus: $has_focus")
Expand Down
17 changes: 8 additions & 9 deletions examples/demo_widgets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function ShowDemoWindowWidgets()
# arrow buttons with Repeater
@cstatic counter=Cint(0) begin
spacing = unsafe_load(CImGui.GetStyle().ItemInnerSpacing.x)
CImGui.PushButtonRepeat(true)
CImGui.PushItemFlag(CImGui.ImGuiItemFlags_ButtonRepeat, true)
CImGui.ArrowButton("##left", CImGui.ImGuiDir_Left) && (counter-=1;)
CImGui.SameLine(0.0, spacing)
CImGui.ArrowButton("##right", CImGui.ImGuiDir_Right) && (counter+=1;)
CImGui.PopButtonRepeat()
CImGui.PopItemFlag()
CImGui.SameLine()
CImGui.Text("$counter")
end
Expand All @@ -71,12 +71,11 @@ function ShowDemoWindowWidgets()

CImGui.LabelText("label", "Value")

@cstatic item_current=Cint(0)
items = ["AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO"]
begin
items=["AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO"]
@cstatic item_current=Cint(0) begin
# using the _simplified_ one-liner Combo() api here
# see "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api.
@c CImGui.Combo("combo", &item_current, items, length(items))
@c CImGui.Combo("combo", &item_current, items)
CImGui.SameLine()
CImGui.HelpMarker("Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n")
end
Expand Down Expand Up @@ -132,10 +131,10 @@ function ShowDemoWindowWidgets()

@cstatic listbox_item_current=Cint(1) listbox_items=["Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon"] begin
# list box
@c CImGui.ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, length(listbox_items), 4)
@c CImGui.ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, 4)
end
# CImGui.PushItemWidth(-1)
# CImGui.ListBox("##listbox2", &listbox_item_current2, listbox_items, length(listbox_items), 4)
# CImGui.ListBox("##listbox2", &listbox_item_current2, listbox_items, 4)
# CImGui.PopItemWidth()

CImGui.TreePop()
Expand Down Expand Up @@ -1035,7 +1034,7 @@ function ShowDemoWindowWidgets()
@cstatic current=Cint(1) begin
if item_type == 5
items = ["Apple", "Banana", "Cherry", "Kiwi"]
ret = @c CImGui.ListBox("ITEM: ListBox", &current, items, length(items), length(items))
ret = @c CImGui.ListBox("ITEM: ListBox", &current, items, length(items))
end
end
CImGui.BulletText(
Expand Down
3 changes: 3 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
CImGuiPack_jll = "333409e9-af72-5310-9767-d6ad21a76a05"
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Loading

0 comments on commit 1468fe3

Please sign in to comment.