154 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
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
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
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
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
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
3b87845d6b
Restore color_edit functionality 2017-11-02 23:12:04 +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
Joonas Javanainen
332ef93633
Adapt to 1.51 changes 2017-11-02 21:01:01 +02:00
Joonas Javanainen
0061a209b6
Concat NUL terminator to dynamic strings before format 2017-10-25 20:08:24 +03:00
Joonas Javanainen
5b0bbc011a
Simplify im_str macro 2017-10-24 20:38:15 +03:00
Joonas Javanainen
b609b6fa70 Merge pull request #75 from onelson/master
expose a method to set font_global_scale
2017-09-05 22:36:57 +03:00
Owen Nelson
29bd647f4d expose a method to set font_global_scale 2017-09-04 12:45:25 -07:00
Nick Palmer
bce412d625
Fixed doc tests 2017-09-02 21:54:15 +01:00
Nick Palmer
f5e9382fbe
Removed explicit returns in favour of the rustier implicit style 2017-09-02 20:09:47 +01:00
Nick Palmer
206056fc9f
Return the bool for pressed from the underlying functions and added
comments documenting example use.
2017-09-02 19:59:14 +01:00
Nick Palmer
5dd0079880
Added functions in lib for radios 2017-08-31 23:05:04 +01:00
Joonas Javanainen
96fe2a8e15
Builder constructors take &Ui instead 2017-07-13 00:15:13 +03:00