417 Commits

Author SHA1 Message Date
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
Malik Olivier Boussejra
05b382e317 WindowDrawList: Wrap add_rect method
This patch uses bitflags to set the whether the corners are rounded.
Hence the `ImDrawCornerFlags` struct is defined, but only used
internally.

Externally, the valule of the flags can be changed with methods on the
`Rect` structure such as `round_top_right` or `round_bot_left`.

This patch wraps both ImDrawList_AddRectFilled and ImDrawList_AddRect.
ImDrawList_AddRectFilled is seen as a particular case of `add_rect`
where `filled` is set to `true`.
2018-04-16 15:09:55 +09:00
Malik Olivier Boussejra
db97041936 window_draw_list.rs: Basic structure to wrap ImGui's draw API
This patch makes the basic structure for a wrapper around Dear ImGui's
drawing API.

1. Implement `with_window_draw_list` method on Ui. Call this method to
get access to the `WindowDrawList` object. This object holds the methods
to access ImGui's drawing API.

2. Dear ImGui uses the ImU32 (an unsigned c_int) to represent colors in
the drawing API. This commit wraps this type with ImColor for
convenience.  Any color representation (3or4-tuples, 3or4-arrays, ImU32
or ImVec4) can be converted into ImColor for convenience.

3. Difference between WindowDrawList and ChannelsSplit: Most drawing
functions can be called on WindowDrawList and ChannelsSplit objects.
However for safety, some functions can only be called on WindowDrawList
or ChannelsSplit instance. For example `channels_set_current` can only
be called after channels have been split.  To avoid code duplication,
functions common to WindowDrawList and ChannelsSplit are implemented
within the `impl_draw_list_methods` macro.

4. Implement drawing functions (in this commit, add_line only).  Calling
`add_line` returns a default representation of the line to be drawn, but
does not draw it. Then parameters, such as thickness, can be set.  You
must call `build` to draw the line. All drawing functions will be
implemented following this pattern.
2018-04-16 15:09:55 +09:00
Joonas Javanainen
b6e5086eb2
Merge pull request #112 from Lymia/master
Implement custom fonts.
2018-04-16 08:51:02 +03:00
Joonas Javanainen
a662155972
Merge pull request #110 from malikolivier/add-miscellaneous-wrappers
Add some helper functions: mouse_delta, get_window_size, is_item_active
2018-04-16 08:49:12 +03:00
Joonas Javanainen
282c5dfd2d
Merge pull request #114 from ebarnard/update-glium
Update glium to 0.21
2018-04-16 08:45:55 +03:00
Edward Barnard
f815daefd3 Update glium to 0.21 2018-04-14 22:38:34 +01:00
Malik Olivier Boussejra
1a1fe3bad5 Wrap get_text_line_height_with_spacing && get_item_rect_size 2018-04-13 14:27:22 +00:00
Malik Olivier Boussejra
43ea9a9693 Wrap BeginGroup / EndGroup 2018-04-13 14:19:37 +00:00
Malik Olivier Boussejra
6515779000 Wrap utilities to get and set Ui's cursor
This utilities are set_cursor_screen_pos, set_cursor_pos, get_cursor_screen_pos
and get_cursor_pos.
2018-04-13 14:12:29 +00:00
Malik Olivier Boussejra
435eeaf892 imgui: Add with_style_and_color_vars convenient function
Wraps with_style_vars and with_color_vars inside a single call.
2018-04-13 13:49:06 +00:00
Malik Olivier Boussejra
4ccae8bc10 Revert "imgui: Add get_window_width, get_window_height helper functions"
This reverts commit 0d10358942409cf8fad6fcb730dbedfbd7149df7.

`get_window_size` already exists and it's very easy to get just one
of the dimentions. As a result, delete get_window_width and
get_window_height.
2018-04-13 13:46:27 +00:00
Lymia Aluysia
c5775ef53c
Adjust custom font functions to use Into with ImVec2. 2018-04-13 04:26:16 -05:00
Lymia Aluysia
228192bb9b
Use f32 instead of f64 for font sizes/etc for consistancy with imgui. 2018-04-13 04:21:01 -05:00
Lymia Aluysia
5b2c1f0861
Implement custom fonts. 2018-04-07 20:30:47 -05:00
Joonas Javanainen
65ac8d1aa8
Merge pull request #109 from malikolivier/update_mouse_cursor
Allow mouse cursor to be updated
2018-03-26 19:11:03 +02:00
Malik Olivier Boussejra
0d10358942 imgui: Add get_window_width, get_window_height helper functions 2018-03-26 17:21:27 +09:00
Malik Olivier Boussejra
d6897b1556 ImGui: Add safe wrapper around igGetWindowSize 2018-03-26 17:17:46 +09:00
Malik Olivier Boussejra
72ddc788b1 imgui: Ui: Add is_item_active 2018-03-26 17:17:02 +09:00
Malik Olivier Boussejra
abbbfdfa79 imgui: Add mouse_delta 2018-03-26 17:17:02 +09:00
Malik Olivier Boussejra
813365e6a8 examples: Add support for changing mouse cursor
If ImGui's mouse_draw_cursor is set to `true`, then ImGui draws the
cursor by itself, so this commits hids the OS cursor.

If ImGui's mouse_draw_cursor is set to `false`, then this commits
updates the OS cursor to the value set by the `set_mouse_cursor`
function provided by the ImGui instance.

For our use case, it seems safe to unwrap the result of the call to
glutin::Window::set_cursor_state, as an error can only potentially when
the `Grab` cursor state is used [1]. In ImGui's use case, the `Grab` state
is never used.

[1] https://docs.rs/crate/winit/0.11.2/source/src/platform/linux/x11/window.rs
2018-03-26 17:11:34 +09:00
Malik Olivier Boussejra
785f773966 imgui: Add method to set/get mouse cursor
Include some documentation as well.
2018-03-26 14:04:00 +09:00
Joonas Javanainen
e90a92c582
Merge pull request #106 from malikolivier/master
lib.rs: Add function to know whever Ctrl, Alt or Shift are pressed
2018-03-15 21:17:57 +02:00
Joonas Javanainen
d3261f17bf
Merge pull request #107 from malikolivier/fix-winit-warning
examples: Fix winit deprecation warnings
2018-03-15 21:17:35 +02:00
Malik Olivier Boussejra
e86cd8838d examples: Fix winit deprecation warnings
Since the following pull request
https://github.com/tomaka/winit/pull/319, `winit` has deprecated
`get_inner_size_points()` and `get_inner_size_pixels()`.

We replace the deprecated API by `get_inner_size()` and
`hidpi_factor()`. The size in points in computed from the returned
hidpi_factor.
2018-03-15 21:25:02 +09:00
Malik Olivier Boussejra
42be8d69ed lib.rs: Add function to know whever Ctrl, Alt or Shift are pressed 2018-03-15 14:57:58 +09:00
Joonas Javanainen
bafe886ebb
Merge pull request #99 from shockham/master
Update glium to 0.20
2018-01-31 09:23:41 +02:00
shockham
081b0e7bf4 Update glium to 0.20 in imgui-examples 2018-01-30 12:56:44 +00:00
shockham
4f3ef1cc26 Update glium to 0.20 2018-01-30 12:36:03 +00:00
Joonas Javanainen
e9fecb3c41
Bump version to 0.0.19-pre 2017-12-23 14:25:43 +02:00
Joonas Javanainen
1fc53dbbdb
Release: 0.0.18 2017-12-23 14:14:35 +02:00
Joonas Javanainen
b4ff8411f7
Merge pull request #95 from shawnscode/macro
Use $crate instead of ::imgui.
2017-12-13 12:13:39 +02:00
Joonas Javanainen
8f4440947e
Merge pull request #93 from o01eg/upd-glium
Update glium to 0.19.
2017-12-13 12:13:14 +02:00
Jingkai Mao
bef6702a8f Use $crate instead of ::imgui. 2017-12-13 14:57:53 +08:00
O01eg
822ed103f8
Update glium to 0.19. 2017-12-12 15:03:16 +03:00
Joonas Javanainen
a74a6c05f2
Fix docs.rs badge 2017-11-24 01:03:56 +02:00
Joonas Javanainen
45f3683053
Add docs.rs badge 2017-11-23 22:06:54 +02:00