190 Commits

Author SHA1 Message Date
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
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
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
785f773966 imgui: Add method to set/get mouse cursor
Include some documentation as well.
2018-03-26 14:04:00 +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
Jingkai Mao
bef6702a8f Use $crate instead of ::imgui. 2017-12-13 14:57:53 +08:00
Joonas Javanainen
6a363840ec
Upgrade to imgui/cimgui 1.52 2017-11-12 23:32:44 +02:00
Joonas Javanainen
a67f190cd2
Add tooltip functionality and is_item_hovered 2017-11-07 20:04:27 +02:00
Joonas Javanainen
d634c1a1ad
Remove various deprecations 2017-11-07 19:00:32 +02:00
Joonas Javanainen
a7581e73c0
Small updates to test_window_impl 2017-11-06 22:53:37 +02:00
Joonas Javanainen
947a4e2dbe
Add a color button example 2017-11-05 21:54:56 +02:00
Joonas Javanainen
6695f613df
Color button doesn't use ColorFormat :/ 2017-11-05 21:42:55 +02:00
Joonas Javanainen
ad6a5ada1b
Rename enums EditableColor* -> Color* 2017-11-05 21:42:30 +02:00
Joonas Javanainen
c718bce60d
Add set_color_edit_options 2017-11-04 12:18:09 +02:00
Joonas Javanainen
97fa401fa4
Add ColorButton 2017-11-04 12:14:47 +02:00
Joonas Javanainen
76f2089b06
Reformat 2017-11-04 11:17:13 +02:00
Joonas Javanainen
c12d543514
Re-export imgui_sys as sys 2017-11-04 11:14:58 +02:00
Joonas Javanainen
9d47482a11
Add docs, export all config enums 2017-11-04 11:14:44 +02:00
Joonas Javanainen
42150784cb
Fix formatting 2017-11-04 10:44:52 +02:00
Joonas Javanainen
6ac40b1100
Take ref_color by reference 2017-11-04 10:44:16 +02:00
Joonas Javanainen
c9e5db5aa5
Add ColorPicker widget 2017-11-04 10:08:06 +02:00
Joonas Javanainen
b9e0de93b0
Various ImStr/ImString updates 2017-11-04 09:05:43 +02:00
Joonas Javanainen
b31f649c19
Use igTextUnformatted in Ui::text
We already have a slice so this is faster.
2017-11-02 23:57:35 +02:00
Joonas Javanainen
63ceb71d44
Use an enum instead of two booleans 2017-11-02 23:48:36 +02:00
Joonas Javanainen
3b87845d6b
Restore color_edit functionality 2017-11-02 23:12:04 +02:00
Joonas Javanainen
f54fae81f1
Deprecate Window::bg_alpha in preparation for 1.52 2017-11-02 22:06:14 +02:00
Joonas Javanainen
907f9dbdeb
Reformat with rustfmt 0.9.0 2017-11-02 22:01:02 +02:00
Joonas Javanainen
f92e21bf30
Upgrade to bitflags 1.0 and namespacing 2017-11-02 21:52:43 +02:00
Joonas Javanainen
3116430f07
Update cimgui to the latest version 2017-11-02 21:32:19 +02:00