453 Commits

Author SHA1 Message Date
Malik Olivier Boussejra
adfa447d2f [cimgui 1.53.1] Style: Add PopupRounding, FrameBorderSize, WindowBorderSize, PopupBorderSize 2018-04-30 11:43:17 +09:00
Malik Olivier Boussejra
3b231d9838 [cimgui 1.53.1] Rename ChildWindowRounding to ChildRounding
Add deprecation warning for each renamed variant.

However, it will just fail to compile if the deprecated variant is used
inside a match statement. It is not possible to make aliases of variants
in Rust.
2018-04-30 11:28:17 +09:00
Malik Olivier Boussejra
d4eb0fd33a [cimgui 1.53.1] DrawList: Add ImDrawListFlags to ImDrawList 2018-04-30 00:23:50 +09:00
Malik Olivier Boussejra
dbc96892cd [cimgui 1.53.1] DrawList: Remove anti_aliased: bool final parameter
There is no way I know of to make a deprecation warning in such a case.
Code that uses ImDrawList_AddPolyline or ImDrawList_AddConvexPolyFilled will
break.
2018-04-30 00:23:50 +09:00
Malik Olivier Boussejra
37b60a5af0 [cimgui 1.53.1] Rename ImGuiTextBuffer_append() to appendf()
This commit does not include deprecation warning.
Indeed, defining a `ImGuiTextBuffer_append` function with a deprecation
warning would require to write a variadic function in rust. However,
this is impossible, and the FFI rust doc says so:
https://doc.rust-lang.org/book/first-edition/ffi.html#variadic-functions

Dear ImGui did not deprecate `append()`, they simply renamed it too.
2018-04-30 00:23:50 +09:00
Malik Olivier Boussejra
d2e6d41619 [cimgui 1.53.1] Obsolete igSetNextWindowContentWidth
There is a small change of behaviour: previous height value is not
preserved when igSetNextWindowContentWidth is used. There is no way
around it unless we mess with imgui's internals.

Official Dear ImGui chose this easy solution as well:

    static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }

429f48bb4f/imgui.h (L1132)
2018-04-30 00:23:50 +09:00
Malik Olivier Boussejra
8d3e1a82fc [cimgui 1.53.1] Obsolete igIsRootWindowOrAnyChildHovered()
Update struct for ImGuiHoveredFlags.

NB: igIsWindowHovered, and thus igIsRootWindowOrAnyChildHovered, are
broken now because of a bug.
The fix is commited upstream, but not released yet.
baebcfcfaf

I guess nothing can be done but wait for the next cimgui release.
2018-04-30 00:23:28 +09:00
Malik Olivier Boussejra
2df079e563 [cimgui 1.53.1] Obsolete sys::igIsRootWindowOrAnyChildFocused()
Should use `igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows)`
instead.
2018-04-29 23:53:39 +09:00
Malik Olivier Boussejra
f3e994f582 [cimgui 1.53.1] Obsolete sys::igIsRootWindowFocused()
Should use `sys::igIsWindowFocused(ImGuiFocusedFlags_RootWindow)`
instead.
2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
24c37293e4 imgui-sys: Fix binding to igIsWindowFocused
This commit adds the `ImGuiFocusedFlags' input flag that was missing.
2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
a5ed022eee [cimgui 1.53.1] Rename ImGuiTreeNodeFlags::AllowOverlapMode to ImGuiTreeNodeFlags::AllowItemOvelap 2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
0c71370546 imgui-sys: Add raw binding to GetFrameHeight 2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
1d10578471 [cimgui 1.53.1] Rename igGetItemsLineHeightWithSpacing to igGetFrameHeightWithSpacing 2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
cf15d49e36 [cimgui 1.53.1] Rename Ui::show_test_window to Ui::show_demo_window 2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
817ecc2005 CHANGELOG: Upgrade cimgui to 1.53.1 2018-04-29 23:49:26 +09:00
Malik Olivier Boussejra
ddd7f7ef7b Update cimgui to 1.53.1
Update cimgui, fixing #97 and #88.

As a side note, the previous version has some compiler warning showing
up during build:

warning: third-party/cimgui/imgui/imgui.cpp: In function ‘void ImGui::RenderTriangle(ImVec2, ImGuiDir, float)’:
warning: third-party/cimgui/imgui/imgui.cpp:3136:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
warning:          r = -r; // ...fall through, no break!
warning:          ~~^~~~

The new version has no warning.
2018-04-29 23:49:26 +09:00
Joonas Javanainen
1bdb2226d2
Revert "Bump minimum Rust version to 1.23"
This reverts commit 767ac84749f1ddb88fb850d58b535c2bd31ea820.
2018-04-29 12:02:06 +03:00
Joonas Javanainen
99aeb18299
Merge pull request #116 from michaelfairley/master
Add drag widgets
2018-04-29 11:57:15 +03:00
Joonas Javanainen
767ac84749
Bump minimum Rust version to 1.23
Damn you pkg-config crate :( :(
2018-04-29 11:38:38 +03:00
Joonas Javanainen
544d7de930
Merge pull request #111 from malikolivier/draw-api
Wraps the dear ImGui custom drawing API
2018-04-29 11:35:23 +03:00
Joonas Javanainen
779ac2edd0
Merge pull request #118 from parasyte/update/gfx
Update gfx
2018-04-29 11:29:49 +03:00
Jay Oster
96b6f6b59c Fix color scheme with gfx
- gfx uses an sRGB framebuffer, which means it expects all vertex colors to be in linear space
- imgui provides vertex colors in sRGB space! This causes the appearance of washed out colors
- Fix the color space conflict by converting the imgui colors to linear space
2018-04-26 20:04:40 -07:00
Jay Oster
1d64e4e185 Update gfx
- Fixes the screen resolution and mouse coordinates on macOS
- Fixes the blurry font by using linear filtering on the texture sampler
2018-04-26 20:01:54 -07:00
Michael Fairley
90c096183c Add drag widgets 2018-04-24 15:22:08 -05:00
Malik Olivier Boussejra
892fe558a3 WindowDrawList: Get rid of DrawApi trait
Since there are no mutable borrows in the WindowDrawList API, we can remove all
draw functions from ChannelsSplit and just use the same `draw_list' all
the time, as shown in the `WindowDrawList::channels_split` example.

This approach makes the `DrawAPI` trait pointless so it can be removed, and
ChannelsSplit is reduced to a type with just one function:
`set_current`.
2018-04-24 13:23:39 +09:00
Malik Olivier Boussejra
9a9484ff21 ChannelsSplit: Rename channels_set_current to set_current
Fancier API
2018-04-24 13:23:08 +09:00
Malik Olivier Boussejra
454e98037e Do not allow to create coexisting instances of WindowDrawList
At run time, the environment checks that at most one instance of
WindowDrawList exists using a static boolean: WINDOW_DRAW_LIST_LOADED.

If two WindowDrawList could exist at the same time, there would be
several instances of the same `*mut ImDrawList`, which could lead
to unfathomable bad things.

When a WindowDrawList is created, WINDOW_DRAW_LIST_LOADED is set to
true. And when it is dropped, WINDOW_DRAW_LIST_LOADED is set to false.
Creating a new WindowDrawList while WINDOW_DRAW_LIST_LOADED is true
causes a panic.

AtomicBool could have been used instead of a bool for
WINDOW_DRAW_LIST_LOADED. Though it allows to avoid the use of `unsafe { }`,
the construct we are doing is already inherently unsafe.
WindowDrawList and Ui are !Send and !Sync, so they cannot anyway be shared
among threads.
So we'd better be explicit and use an unsafe block with a normal bool.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
082d5e47f9 window_draw_list: Fix awkward wording in doc 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
734292fdab imgui: Make ChannelsSplit struct visible outside the crate 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
29b0d20fc1 ChannelsSplit: Panic when channel index overflows 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
95577a0d8c ui: Rename to with_window_draw_list ot get_window_draw_list 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
9a65a64eca WindowDrawList: Cannot use WindowDrawList::new outside of crate 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
3aa807b173 DrawAPI: Remove unused lifetime 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
7be9f15acb window_draw_list: Fix typo in doc 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
746bdc5ef3 ImColor: Derive Eq, PartialEq, Debug 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
43a2484c22 ImMouseButton: Derive Copy, Clone, Eq, PartialEq, Debug
For convenience.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
eab85ea871 with_window_draw_list: Fix example test
The test was failing because no `main` function was defined, as explained
in the rustdoc documentation [1].

Add the "no_run" flag. This way, there is no attempt to run the test
code. Only compile checks are done. Thus defining a `main` function is
unnecessary.
Moreover "export crate imgui" is implicit, so removed.

[1] https://doc.rust-lang.org/stable/rustdoc/documentation-tests.html#pre-processing-examples.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
664660a090 Add missing imports in example code 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
2312f4121a test_drawing_channels_split: Add an example for channels_split
As channels_split may be difficult to understand, this commit adds a simple
example of its usage.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
c27748852d test_window_impl: show_example_app_custom_rendering: Include drawing canvas
Include drawing canvas example into show_example_app_custom_rendering.
The example contains now everything included in the original C++ example
provided with dear imgui.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
ab908106d3 test_window_impl.rs: Add first part half of show_example_app_custom_rendering
show_example_app_custom_rendering is implemented exactly as it is in the
original Dear ImGui in C++. The result should be the same.

The only difference is that `DragFloat`, used to control the size of the
drawings, is not implement as of now.

This example demonstrates how the custom drawing API can be used.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
738a9c978e ui: Wrap get_content_region_avail 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
c58a93bfc1 ui: Wrap invisible_button 2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
15048ad698 ui: Add mouse helper methods is_mouse_{dragging,down,clicked}
This commit defines a new enum: `ImMouseButton`, which is used in the
public-facing API of mouse-related methods.

The discriminant values of the ImMouseButton enum are the value used
internally by ImGui to represent the buttons of the mouse.
2018-04-16 15:14:04 +09:00
Malik Olivier Boussejra
a60465cd40 ui: Wrap dummy 2018-04-16 15:14:01 +09:00
Malik Olivier Boussejra
4358360d47 window_draw_list.rs: Wrap ImDrawList_PushClipRect
This commit adds two methods to the drawing APIs: with_clip_rect and
with_clip_rect_intersect.

Both wrap ImDrawList_PushClipRect and ImDrawList_PopClipRect.
However, with_clip_rect_intersect sets the `intersect` argument of
ImDrawList_PushClipRect to `true`.
2018-04-16 15:09:55 +09:00
Malik Olivier Boussejra
35db5fca72 window_draw_list.rs: Wrap add_bezier_curve 2018-04-16 15:09:55 +09:00
Malik Olivier Boussejra
8471bd4034 window_draw_list.rs: Wrap add_triangle 2018-04-16 15:09:55 +09:00
Malik Olivier Boussejra
878de089e8 window_draw_list.rs: Wrap add_circle
ImDrawList_AddCircle was missing an argument in the bindings, resulting
in UB. This patches includes it and wrap the AddCircle API.
2018-04-16 15:09:55 +09:00
Malik Olivier Boussejra
d1879b2a04 window_draw_list.rs: Add add_rect_filled_multicolor
As `add_rect_filled_multicolor` does not have any option, the `build`
pattern is not used and calling `add_rect_filled_multicolor` directly
draws the rectangle on the window.
2018-04-16 15:09:55 +09:00