opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
oscimgui.h
Go to the documentation of this file.
1#pragma once
2
10#include <liboscar/maths/rect.h>
20
21#include <concepts>
22#include <cstdarg>
23#include <cstddef>
24#include <functional>
25#include <initializer_list>
26#include <optional>
27#include <span>
28#include <string>
29#include <string_view>
30#include <utility>
31
32namespace osc { class App; }
33namespace osc { class Camera; }
34namespace osc { class Event; }
35namespace osc { struct PolarPerspectiveCamera; }
36namespace osc { class RenderTexture; }
37namespace osc { class Texture2D; }
38
39struct ImDrawList;
40
41namespace osc::ui
42{
43 class Context;
44
45 // Represents the runtime configuration of a UI context.
47 public:
49
50 // Sets the resource path to an `imgui.ini` file that acts as the "base" config
51 // when the user doesn't already have one in their user data directory.
53
54 // Sets the UI's main font as a merged combination of a 'standard' font
55 // and an 'icon' font, where the latter contains UTF8-to-glyph mappings
56 // for arbitrary icons.
61 );
62
63 class Impl;
64 private:
65 friend class Context;
66 CopyOnUpdPtr<Impl> impl() const { return impl_; }
67
69 };
70
71 // Represents the top-level UI context that `ui::` functions talk to
72 // when drawing the UI.
73 class Context final {
74 public:
75 // Constructs a global UI context with the given configuration.
76 explicit Context(App&, const ContextConfiguration& = {});
77
78 Context(const Context&) = delete;
80
81 // Shuts down the global UI context.
83
86
87 // Shuts down and constructs this `UiContext` in-place.
88 void reset();
89
90 // Returns true if the UI handled the event.
92
93 // Should be called at the start of each frame (e.g. `Widget::on_draw()`).
95
96 // Should be called at the end of each frame (e.g. the end of `Widget::on_draw()`).
97 void render();
98 private:
100 void shutdown(App*);
101 };
102
103 // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)
105
107 {
108 void draw_text_v(CStringView fmt, va_list);
109 inline void draw_text(CStringView fmt, ...)
110 {
112 va_start(args, fmt);
113 draw_text_v(fmt, args);
114 va_end(args);
115 }
116 }
118 template<typename... Args>
120 {
121 detail::draw_text(fmt, std::forward<Args>(args)...);
122 }
123
124 namespace detail
125 {
126 void draw_text_disabled_v(CStringView fmt, va_list);
127 inline void draw_text_disabled(CStringView fmt, ...)
128 {
129 va_list args;
130 va_start(args, fmt);
131 draw_text_disabled_v(fmt, args);
132 va_end(args);
133 }
134 }
136 template<typename... Args>
138 {
139 detail::draw_text_disabled(fmt, std::forward<Args>(args)...);
140 }
141
142 namespace detail
143 {
144 void draw_text_wrapped_v(CStringView fmt, va_list);
145 inline void draw_text_wrapped(CStringView fmt, ...)
146 {
147 va_list args;
148 va_start(args, fmt);
149 draw_text_wrapped_v(fmt, args);
150 va_end(args);
151 }
152 }
154 template<typename... Args>
156 {
157 detail::draw_text_wrapped(fmt, std::forward<Args>(args)...);
158 }
159
162
164
165 enum class TreeNodeFlag : unsigned {
166 None = 0,
167 DefaultOpen = 1<<0,
168 OpenOnArrow = 1<<1, // only open when clicking on the arrow part
169 Leaf = 1<<2, // no collapsing, no arrow (use as a convenience for leaf nodes)
170 Bullet = 1<<3, // display a bullet instead of arrow. IMPORTANT: node can still be marked open/close if you don't also set the `Leaf` flag!
171 DrawLinesToNodes = 1<<4,
172 DrawLinesFull = 1<<5,
173 NUM_FLAGS = 6,
174 };
176
178
180
181 void tree_pop();
182
184
185 bool begin_menu(CStringView sv, bool enabled = true);
186 void end_menu();
187
189 CStringView label,
190 std::optional<KeyCombination> shortcut = {},
191 bool selected = false,
192 bool enabled = true
193 );
194
196 CStringView label,
197 std::optional<KeyCombination> shortcut,
198 bool* p_selected,
199 bool enabled = true
200 );
201
204
205 enum class TabItemFlag : unsigned {
206 None = 0,
207 NoReorder = 1<<0, // disable reordering this tab or having another tab cross over this tab
208 NoCloseButton = 1<<1, // track whether `p_open` was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
209 UnsavedDocument = 1<<2, // display a dot next to the title + (internally) set `ImGuiTabItemFlags_NoAssumedClosure`
210 SetSelected = 1<<3, // trigger flag to programmatically make the tab selected when calling `begin_tab_item`
211 NUM_FLAGS = 4,
212 };
214
215 bool begin_tab_item(CStringView label, bool* p_open = nullptr, TabItemFlags = {});
217
219
220 void set_num_columns(int count = 1, std::optional<CStringView> id = std::nullopt, bool border = true);
221 float get_column_width(int column_index = -1);
223
224 // Places the cursor on the same line as the previous item, with the given
225 // offset/spacing in device-independent pixels.
226 void same_line(float offset_from_start_x = 0.0f, float spacing = -1.0f);
227
228 enum class MouseButton {
229 Left,
230 Right,
231 Middle,
233 };
234
235 struct ID final {
236 public:
237 explicit ID() = default;
238 explicit ID(unsigned int value) : value_{value} {}
239
240 unsigned int value() const { return value_; }
241 private:
242 unsigned int value_ = 0; // defaults to "no ID"
243 };
244
250
251 enum class SliderFlag : unsigned {
252 None = 0,
253 Logarithmic = 1<<0,
254 AlwaysClamp = 1<<1,
255 NoInput = 1<<2,
256 NUM_FLAGS = 3,
257 };
259
260 enum class DataType {
261 Float,
263 };
264
265 enum class TextInputFlag : unsigned {
266 None = 0,
267 ReadOnly = 1<<0,
268 EnterReturnsTrue = 1<<1,
269 NUM_FLAGS = 2,
270 };
272
274 bool draw_selectable(CStringView label, bool selected = false);
275 bool draw_checkbox(CStringView label, bool* v);
276 bool draw_float_slider(CStringView label, float* v, float v_min, float v_max, const char* format = "%.3f", SliderFlags = {});
277 bool draw_scalar_input(CStringView label, DataType data_type, void* p_data, const void* p_step = nullptr, const void* p_step_fast = nullptr, const char* format = nullptr, TextInputFlags = {});
278 bool draw_int_input(CStringView label, int* v, int step = 1, int step_fast = 100, TextInputFlags = {});
279 bool draw_size_t_input(CStringView label, size_t* v, size_t step = 1, size_t step_fast = 100, TextInputFlags = {});
280 bool draw_double_input(CStringView label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", TextInputFlags = {});
281 bool draw_float_input(CStringView label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", TextInputFlags = {});
282 bool draw_float3_input(CStringView label, float v[3], const char* format = "%.3f", TextInputFlags = {});
283 bool draw_vector3_input(CStringView label, Vector3& v, const char* format = "%.3f", TextInputFlags = {});
286 // Draws an interactive button with the given label and with a given size in device-independent pixels.
287 bool draw_button(CStringView label, const Vector2& size = {});
290 // Draws an interactive, but invisible, button with the given label and the given size in device-independent pixels.
294 // Draws an invisible, non-interactive "dummy" element in the UI with the given size in device-independent pixels.
295 void draw_dummy(const Vector2& size);
296 // Draws an invisible, non-interactive "dummy" element that is `num_lines` * text line height high.
298
299 enum class ComboFlag : unsigned {
300 None = 0,
301 NoArrowButton = 1<<0,
302 NUM_FLAGS = 1,
303 };
305
308
311
313
314 enum class PanelFlag : unsigned {
315 None = 0,
316
317 NoMove = 1<<0,
318 NoTitleBar = 1<<1,
319 NoResize = 1<<2,
320 NoSavedSettings = 1<<3,
321 NoScrollbar = 1<<4,
322 NoInputs = 1<<5,
323 NoBackground = 1<<6,
324 NoCollapse = 1<<7,
325 NoDecoration = 1<<8,
326 NoDocking = 1<<9,
327 NoNav = 1<<10,
328
329 MenuBar = 1<<11,
330 AlwaysAutoResize = 1<<12,
331 HorizontalScrollbar = 1<<13,
333
334 NUM_FLAGS = 15,
335 };
337
338 bool begin_panel(CStringView name, bool* p_open = nullptr, PanelFlags = {});
339 void end_panel();
340
341 enum class ChildPanelFlag : unsigned {
342 None = 0,
343 Border = 1<<0,
344 NUM_FLAGS = 1,
345 };
347
348 // Begins a child panel within a parent panel with the given ID, device-independent pixel size, and flags.
349 bool begin_child_panel(CStringView str_id, const Vector2& size = {}, ChildPanelFlags child_flags = {}, PanelFlags panel_flags = {});
351
353
354 namespace detail
355 {
356 void set_tooltip_v(CStringView fmt, va_list);
357 }
358 inline void set_tooltip(CStringView fmt, ...)
359 {
361 va_start(args, fmt);
363 va_end(args);
364 }
365
367
368 // Returns the height of the current frame in device-independent pixels.
370
371 // Returns the size of the content region that's available from the current
372 // cursor position within the current panel in device-independent pixels.
374
375 // Returns the position that the panel cursor started at relative to the top-left
376 // corner of the current panel in device-independent pixels.
378
379 // Returns the current position of the panel cursor relative to the top-left corner
380 // of the current panel in device-independent pixels.
382
383 // Sets the current position of the panel cursor relative to the top-left corner
384 // of the panel in device-independent pixels.
386
387 // Returns the current x position of the panel cursor relative to the left edge
388 // of the current panel in device-independent pixels.
390
391 // Sets the current x position of the panel cursor relative to the left edge of
392 // the current panel in device-independent pixels.
394
395 // Returns the current position of the panel cursor in ui space in device-independent pixels.
397
398 // Sets the current position of the panel cursor in ui space in device-independent pixels.
400
401 enum class Conditional {
402 Always,
403 Once,
404 Appearing,
406 };
407
409
411
413
414 void set_next_panel_bg_alpha(float alpha);
415
416 enum class HoveredFlag : unsigned {
417 None = 0,
418 AllowWhenDisabled = 1<<0,
421 AllowWhenOverlapped = 1<<3,
422 DelayNormal = 1<<4,
423 ForTooltip = 1<<5,
424 RootAndChildPanels = 1<<6,
425 ChildPanels = 1<<7,
426 NUM_FLAGS = 8,
427 };
429
431
432 void begin_disabled(bool disabled = true);
434
437
439 void push_id(int);
440 template<std::integral T> void push_id(T number) { push_id(static_cast<int>(number)); }
441 void push_id(std::string_view);
442 void push_id(const void*);
443
444 void pop_id();
445
446 ID get_id(std::string_view);
447
448 enum class ItemFlag : unsigned {
449 None = 0,
450 Disabled = 1<<0,
451 Inputable = 1<<1,
452 NUM_FLAGS = 2,
453 };
455
456 void set_next_item_size(Rect); // note: ImGui API assumes cursor is located at `p1` already
457 bool add_item(Rect bounds, ID);
458 bool is_item_hoverable(Rect bounds, ID);
459
461
463
464 void indent(float indent_w = 0.0f);
465 void unindent(float indent_w = 0.0f);
466
468 bool is_key_pressed(Key, bool repeat = true);
471
472 enum class ColorVar {
473 Text,
474 Button,
477 FrameBg,
478 PopupBg,
481 CheckMark,
483 PanelBg,
485 };
486
494
497
511
514 void pop_style_var(int count = 1);
515
516 enum class PopupFlag : unsigned {
517 None = 0,
518 MouseButtonLeft = 1<<0,
519 MouseButtonRight = 1<<1,
520 NUM_FLAGS = 2,
521 };
523
527 bool begin_popup_modal(CStringView name, bool* p_open = nullptr, PanelFlags = {});
528 void end_popup();
529
532
535
538
540 void set_next_item_open(bool is_open);
546
547 enum class TableFlag : unsigned {
548 None = 0,
549 BordersInner = 1<<0,
550 BordersInnerV = 1<<1,
551 NoSavedSettings = 1<<2,
552 PadOuterX = 1<<3,
553 Resizable = 1<<4,
554 ScrollY = 1<<5,
555 SizingStretchProp = 1<<6,
556 SizingStretchSame = 1<<7,
557 Sortable = 1<<8,
558 SortTristate = 1<<9,
559 NUM_FLAGS = 10,
560 };
562
566 bool begin_table(CStringView str_id, int column, TableFlags = {}, const Vector2& outer_size = {}, float inner_width = 0.0f);
568
569 enum class SortDirection {
570 None,
571 Ascending,
574 };
575
577 ID column_id{};
578 size_t column_index = 0;
579 size_t sort_order = 0;
580 SortDirection sort_direction = SortDirection::None;
581 };
582
584 std::vector<TableColumnSortSpec> get_table_column_sort_specs();
585
586 enum class ColumnFlag : unsigned {
587 None = 0,
588 NoSort = 1<<0,
589 WidthStretch = 1<<1,
590 NUM_FLAGS = 2,
591 };
593
597 void table_setup_column(CStringView label, ColumnFlags = {}, float init_width_or_weight = 0.0f, ID = ID{});
598 void end_table();
599
601 void pop_style_color(int count = 1);
602
604
609 std::optional<Texture2D> get_font_texture();
610
612
614
616 protected:
617 DrawListAPI() = default;
618 DrawListAPI(const DrawListAPI&) = default;
619 DrawListAPI(DrawListAPI&&) noexcept = default;
620 DrawListAPI& operator=(const DrawListAPI&) = default;
621 DrawListAPI& operator=(DrawListAPI&&) noexcept = default;
622 public:
623 virtual ~DrawListAPI() noexcept = default;
624
625 void add_rect(const Rect& ui_rect, const Color& color, float rounding = 0.0f, float thickness = 1.0f);
626 void add_rect_filled(const Rect& ui_rect, const Color& color, float rounding = 0.0f);
627 void add_circle(const Circle& ui_circle, const Color& color, int num_segments = 0, float thickness = 1.0f);
628 void add_circle_filled(const Circle& ui_circle, const Color& color, int num_segments = 0);
629 void add_text(const Vector2& ui_position, const Color& color, CStringView text);
630 void add_line(const Vector2& ui_start, const Vector2& ui_end, const Color& color, float thickness = 1.0f);
631 void add_triangle_filled(const Vector2 ui_p0, const Vector2& ui_p1, const Vector2& ui_p2, const Color& color);
632 void push_clip_rect(const Rect&, bool intersect_with_currect_clip_rect = false);
633 void pop_clip_rect();
634
635 void render_to(RenderTexture&);
636 private:
637 virtual ImDrawList& impl_get_drawlist() = 0;
638 };
639
640 class DrawListView : public DrawListAPI {
641 public:
642 explicit DrawListView(ImDrawList* inner_list) :
643 inner_list_{inner_list}
644 {}
645 private:
646 ImDrawList& impl_get_drawlist() final { return *inner_list_; }
647
648 ImDrawList* inner_list_;
649 };
650
651 class DrawList final : public DrawListAPI {
652 public:
654 DrawList(const DrawList&) = delete;
655 DrawList(DrawList&&) noexcept;
656 DrawList& operator=(const DrawList&) = delete;
657 DrawList& operator=(DrawList&&) noexcept;
658 ~DrawList() noexcept override;
659
660 operator DrawListView () { return DrawListView{underlying_drawlist_.get()}; }
661
662 private:
663 ImDrawList& impl_get_drawlist() final { return *underlying_drawlist_; }
664
665 std::unique_ptr<ImDrawList> underlying_drawlist_;
666 };
667
670
672
673 // applies "dark" theme to current UI context
675
676 // updates a polar camera's rotation, position, etc. from UI keyboard input state
679 const Rect& viewport_rect,
680 std::optional<AABB> maybe_scene_world_space_aabb
681 );
682
683 // updates a polar camera's rotation, position, etc. from UI input state (all)
686 const Rect& viewport_rect,
687 std::optional<AABB> maybe_scene_world_space_aabb
688 );
689
691 Camera&,
693 );
694
695 // returns the UI content region available in ui space as a `Rect`
697
698 // Draws a texture within the UI.
699 //
700 // - `texture`: the texture to draw within the UI.
701 // - `dimensions`: the dimensions, in device-independent pixels, that the image
702 // should occupy in the UI. Default: `texture.device_independent_dimensions()`.
703 // - `region_uv_coordinates`: texture coordinates in texture space (`(0, 0)` means bottom-left,
704 // `(1, 1)` means top-right) that designate the region within `texture` that should be sampled
705 // to produce the image within the UI (e.g. for cropping, flipping). Default: entire contents
706 // `texture`.
708 const Texture2D& texture,
709 std::optional<Vector2> dimensions = std::nullopt,
710 const Rect& region_uv_coordinates = Rect::from_corners({0.0f, 0.0f}, {1.0f, 1.0f})
711 );
713 const RenderTexture&
714 );
716 const RenderTexture&,
717 Vector2 dimensions
718 );
719
720 // returns the dimensions of a button with the given content
723
726 Vector2 dimensions = {0.0f, 0.0f}
727 );
728
729 // draws a texture within the UI as a clickable button
732 const Texture2D&,
733 Vector2 dimensions,
734 const Rect& texture_coordinates
735 );
738 const Texture2D&,
739 Vector2 dimensions
740 );
741
742 // returns the ui space bounding rectangle of the last-drawn item in
743 // device-independent pixels.
745
746 // returns the screen space bounding rectangle of the last-drawn item
747 // in device-independent pixels.
749
750 // adds a screenshot annotation around the last drawn item to the
751 // application-level annotation collector
752 //
753 // equivalent to: `App::upd().add_main_window_frame_annotation(label, get_last_drawn_item_screen_rect());`
755
756 // hittest the last-drawn item in the UI
757 struct HittestResult final {
758 Rect item_ui_rect = {};
759 bool is_hovered = false;
760 bool is_left_click_released_without_dragging = false;
761 bool is_right_click_released_without_dragging = false;
762 };
765
766 // returns `true` if any scancode in the provided range is currently pressed down
767 bool any_of_keys_down(std::span<const Key>);
768 bool any_of_keys_down(std::initializer_list<const Key>);
769
770 // returns `true` if any scancode in the provided range was pressed down this frame
771 bool any_of_keys_pressed(std::span<const Key>);
772 bool any_of_keys_pressed(std::initializer_list<const Key>);
773
774 // returns true if the user is pressing either left- or right-Ctrl
776
777 // returns `true` if the user is pressing either:
778 //
779 // - left Ctrl
780 // - right Ctrl
781 // - left Super (mac)
782 // - right Super (mac)
784
785 // returns `true` if the user is pressing either left- or right-shift
787
788 // returns `true` if the user is pressing either left- or right-alt
790
791 // returns `true` if the specified mouse button was released without the user dragging
794
795 // returns `true` if the user is dragging their mouse with any button pressed
797
798 // (lower-level tooltip methods: prefer using higher-level 'draw_tooltip(txt)' methods)
799 void begin_tooltip(std::optional<float> wrap_width = std::nullopt);
800 void end_tooltip(std::optional<float> wrap_width = std::nullopt);
801
805
806 // draws an overlay tooltip (content only)
808
809 // draws an overlay tooltip (content only) if the last item is hovered
812 HoveredFlags = HoveredFlag::ForTooltip
813 );
814
815 // draws an overlay tooltip with a header and description
816 void draw_tooltip(CStringView header, CStringView description = {});
817
818 // equivalent to `if (ui::is_item_hovered(flags)) draw_tooltip(header, description);`
820 CStringView header,
821 CStringView description = {},
822 HoveredFlags = HoveredFlag::ForTooltip
823 );
824
825 // draws a help text marker `"(?)"` and display a tooltip when the user hovers over it
826 void draw_help_marker(CStringView header, CStringView description);
827
828 // draws a help text marker `"(?)"` and display a tooltip when the user hovers over it
830
831 // draws a text input that manipulates a `std::string`
833 CStringView label,
834 std::string& edited_string,
835 TextInputFlags = {}
836 );
837
838 // draws a text input that contains `hint` as a placeholder and manipulates a `std::string`
840 CStringView label,
841 CStringView hint,
842 std::string& edited_string,
843 TextInputFlags = {}
844 );
845
846 // behaves like `ui::draw_float_input`, but understood to manipulate the scene scale
848 CStringView label,
849 float& v,
850 float step = 0.0f,
851 float step_fast = 0.0f,
852 TextInputFlags = {}
853 );
854
855 // behaves like `ui::draw_float3_input`, but understood to manipulate the scene scale
857 CStringView label,
858 Vector3&,
859 TextInputFlags = {}
860 );
861
862 // behaves like `ui::draw_float_slider`, but understood to manipulate the scene scale
864 CStringView label,
865 float& v,
866 float v_min,
867 float v_max,
868 SliderFlags flags = {}
869 );
870
871 // behaves like `ui::draw_float_input`, but edits the given value as a mass (kg)
873 CStringView label,
874 float& v,
875 float step = 0.0f,
876 float step_fast = 0.0f,
877 TextInputFlags = {}
878 );
879
880 // behaves like `ui::draw_float_input`, but edits the given angular value in degrees
882 CStringView label,
883 Radians& v
884 );
885
886 // behaves like `ui::draw_float3_input`, but edits the given angular value in degrees
888 CStringView label,
890 CStringView format = "%.3f"
891 );
892
893 // behaves like `ui::draw_float_slider`, but edits the given angular value as degrees
895 CStringView label,
896 Radians& v,
897 Radians min,
898 Radians max
899 );
900
901 // returns "minimal" panel flags (i.e. no title bar, can't move the panel - ideal for images etc.)
903
904 // returns `true` if the area of the main window's workspace is greater than zero.
906
907 // returns a `Rect` that indicates where the current workspace area is in the main
908 // application window
909 //
910 // the returned `Rect` is given in ui space, such that:
911 //
912 // - it's measured in device-independent pixels
913 // - starts in the top-left corner
914 // - ends in the bottom-right corner
916
917 // returns a `Rect` that indicates where the current workspace area is in the main
918 // application window
919 //
920 // the returned `Rect` is given in screen space, such that:
921 //
922 // - it's measured in device-independent pixels
923 // - starts in the bottom-left corner
924 // - ends in the top-right corner
926
927 // returns the dimensions of the current workspace area in device-independent pixels in the
928 // main application window.
930
931 // returns the aspect ratio (width divided by height) of the device-independent pixel dimensions
932 // of the current workspace area in the main application window
934
935 // returns `true` if the user's mouse is within the current workspace area of the main application
936 // window
938
939 // begin a menu that's attached to the top of the main application window, end it with `ui::end_panel()`
941 CStringView label,
942 float height = ui::get_frame_height(),
943 PanelFlags = {PanelFlag::NoScrollbar, PanelFlag::NoSavedSettings, PanelFlag::MenuBar}
944 );
945
946 // begin a menu that's attached to the bottom of the main application window, end it with `ui::end_panel()`
948
949 // behaves like `ui::draw_button`, but is centered on the current line
951
952 // behaves like `ui::draw_text`, but is centered on the current line
954
955 // behaves like `ui::draw_text`, but is vertically and horizontally centered in the remaining content of the current panel
957
958 // behaves like `ui::draw_text`, but with a disabled style and centered on the current line
960
961 // behaves like `ui::draw_text`, but with a disabled style and centered in the remaining content of the current panel
963
964 // behaves like `ui::draw_text`, but centered in the current table column
966
967 // behaves like `ui::draw_text`, but with a faded/muted style
969
970 // behaves like `ui::draw_text`, but with a warning style (e.g. orange)
972
973 // returns `true` if the last drawn item (e.g. an input) should be saved based on heuristics
974 //
975 // - if the item was deactivated (e.g. due to focusing something else), it should be saved
976 // - if there's an active edit and the user presses enter, it should be saved
977 // - if there's an active edit and the user presses tab, it should be saved
979
980 void pop_item_flags(int n = 1);
981
983 CStringView label,
984 size_t* current,
985 size_t size,
986 const std::function<CStringView(size_t)>& accessor
987 );
988
990 CStringView label,
991 size_t* current,
992 std::span<const CStringView> items
993 );
994
997
999 CStringView label,
1000 float* v,
1001 float min,
1002 float max,
1003 CStringView format = "%.3f",
1004 SliderFlags = {}
1005 );
1006
1007 // updates a polar camera's rotation, position, etc. from UI mouse input state, assuming
1008 // the viewport it's connected to has the given device-independent pixel dimensions.
1011 Vector2 viewport_dimensions
1012 );
1013
1014 // an operation that a ui `Gizmo` shall perform
1015 enum class GizmoOperation : unsigned {
1016 None = 0,
1017 Translate = 1<<0,
1018 Rotate = 1<<1,
1019 Scale = 1<<2,
1020 NUM_FLAGS = 3,
1021 };
1023
1024 // the mode (coordinate space) that a `Gizmo` presents its manipulations in
1025 enum class GizmoMode {
1026 Local,
1027 World,
1028 NUM_OPTIONS,
1029 };
1030
1031 // Represents the step size that the gizmo should stick to when the user is
1032 // using a gizmo operation.
1034 std::optional<Vector3> scale;
1035 std::optional<Radians> rotation;
1036 std::optional<Vector3> position;
1037 };
1038
1039 // a UI gizmo that manipulates the given model matrix using user-interactable drag handles, arrows, etc.
1040 class Gizmo final {
1041 public:
1042
1043 // if the user manipulated the gizmo, updates `model_matrix` to match the
1044 // post-manipulation transform and returns a world space transform that
1045 // represents the "difference" added by the user's manipulation. I.e.:
1046 //
1047 // transform_returned * model_matrix_before = model_matrix_after
1048 //
1049 // note: a user-enacted rotation/scale may not happen at the origin, so if
1050 // you're thinking "oh I'm only handling rotation/scaling, so I'll
1051 // ignore the translational part of the transform" then you're in
1052 // for a nasty surprise: T(origin)*R*S*T(-origin)
1053 std::optional<Transform> draw(
1054 Matrix4x4& model_matrix, // edited in-place
1055 const Matrix4x4& view_matrix,
1056 const Matrix4x4& projection_matrix,
1057 const Rect& ui_rect,
1058 const GizmoOperationSnappingSteps* snap = nullptr,
1059 const AABB* local_bounds = nullptr
1060 );
1061
1062 // same as `draw`, but draws to the foreground draw list, rather than the
1063 // draw list of the currently active panel
1064 std::optional<Transform> draw_to_foreground(
1065 Matrix4x4& model_matrix, // edited in-place
1066 const Matrix4x4& view_matrix,
1067 const Matrix4x4& projection_matrix,
1068 const Rect& ui_rect,
1069 const GizmoOperationSnappingSteps* snap = nullptr,
1070 const AABB* local_bounds = nullptr
1071 );
1072
1073 bool is_using() const;
1074 bool was_using() const { return was_using_last_frame_; }
1075 bool is_over() const;
1076 GizmoOperation operation() const { return operation_; }
1077 void set_operation(GizmoOperation operation) { operation_ = operation; }
1078 GizmoMode mode() const { return mode_; }
1079 void set_mode(GizmoMode mode) { mode_ = mode; }
1080
1081 // updates the gizmo based on keyboard inputs (e.g. pressing `G` enables grab mode)
1083 private:
1084 std::optional<Transform> draw_to(
1085 Matrix4x4& model_matrix,
1086 const Matrix4x4& view_matrix,
1087 const Matrix4x4& projection_matrix,
1088 const Rect& ui_rect,
1089 ImDrawList* draw_list,
1091 const AABB* local_bounds
1092 );
1093
1094 UID id_;
1095 GizmoOperation operation_ = GizmoOperation::Translate;
1096 GizmoMode mode_ = GizmoMode::World;
1097 bool was_using_last_frame_ = false;
1098 };
1099
1100 constexpr float gizmo_annotation_offset()
1101 {
1102 return 15.0f;
1103 }
1104
1106 Gizmo&
1107 );
1108
1110 GizmoMode&
1111 );
1112
1114 Gizmo&,
1115 bool can_translate = true,
1116 bool can_rotate = true,
1117 bool can_scale = true,
1118 CStringView translate_button_text = "T",
1119 CStringView rotate_button_text = "R",
1120 CStringView scale_button_text = "S"
1121 );
1122
1125 bool can_translate = true,
1126 bool can_rotate = true,
1127 bool can_scale = true,
1128 CStringView translate_button_text = "T",
1129 CStringView rotate_button_text = "R",
1130 CStringView scale_button_text = "S"
1131 );
1132
1133 // oscar bindings for `ImPlot`
1134 //
1135 // the design/types used here differ from `ImPlot` in order to provide
1136 // consistency with the rest of the `osc` ecosystem
1137 namespace plot
1138 {
1139 enum class PlotFlags {
1140 None = 0,
1141 NoTitle = 1<<0,
1142 NoLegend = 1<<1,
1143 NoMouseText = 1<<2,
1144 NoInputs = 1<<3,
1145 NoMenus = 1<<4,
1146 NoBoxSelect = 1<<5,
1147 NoFrame = 1<<6,
1148
1149 Default = None,
1150 };
1151 constexpr PlotFlags operator|(PlotFlags lhs, PlotFlags rhs)
1152 {
1153 return static_cast<PlotFlags>(std::to_underlying(lhs) | std::to_underlying(rhs));
1154 }
1155 constexpr PlotFlags operator^(PlotFlags lhs, PlotFlags rhs)
1156 {
1157 return static_cast<PlotFlags>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
1158 }
1159 constexpr bool operator&(PlotFlags lhs, PlotFlags rhs)
1160 {
1161 return (std::to_underlying(lhs) & std::to_underlying(rhs)) != 0;
1162 }
1163
1164 enum class PlotStyleVar {
1165 // `Vector2`: additional fit padding as a percentage of the fit extents (e.g. Vector2{0.1, 0.2} would add 10 % to the X axis and 20 % to the Y axis)
1166 FitPadding,
1167
1168 // `Vector2`: padding between the item frame and plot area, labels, or outside legends (i.e. main padding)
1169 PlotPadding,
1170
1171 // `float`: thickness of the border around plot area
1172 PlotBorderSize,
1173
1174 // `Vector2`: text padding around annotation labels
1175 AnnotationPadding,
1176
1177 NUM_OPTIONS
1178 };
1179
1180 enum class PlotColorVar {
1181 // plot line/outline color (defaults to the next unused color in the current colormap)
1182 Line,
1183
1184 // plot area background color (defaults to `ColorVar::PanelBg`)
1185 PlotBackground,
1186
1187 NUM_OPTIONS,
1188 };
1189
1190 enum class Axis {
1191 X1, // enabled by default
1192 Y1, // enabled by default
1193
1194 NUM_OPTIONS,
1195 };
1196
1197 enum class AxisFlags {
1198 None = 0,
1199 NoLabel = 1<<0,
1200 NoGridLines = 1<<1,
1201 NoTickMarks = 1<<2,
1202 NoTickLabels = 1<<3,
1203 NoMenus = 1<<5,
1204 AutoFit = 1<<11,
1205 LockMin = 1<<14,
1206 LockMax = 1<<15,
1207
1208 Default = None,
1209 Lock = LockMin | LockMax,
1210 NoDecorations = NoLabel | NoGridLines | NoTickMarks | NoTickLabels,
1211 };
1212
1213 constexpr AxisFlags operator|(AxisFlags lhs, AxisFlags rhs)
1214 {
1215 return static_cast<AxisFlags>(std::to_underlying(lhs) | std::to_underlying(rhs));
1216 }
1217
1218 enum class Condition {
1219 Always, // unconditional, i.e. the function should always do what is being asked
1220 Once, // only perform the action once per runtime session (only the first call will succeed)
1221 NUM_OPTIONS,
1222 };
1223
1224 enum class MarkerType {
1225 None, // i.e. no marker
1226 Circle,
1227 NUM_OPTIONS,
1228 };
1229
1230 enum class DragToolFlag : uint8_t {
1231 None = 0,
1232 NoFit = 1<<1,
1233 NoInputs = 1<<2,
1234 NUM_FLAGS = 2,
1235
1236 Default = None,
1237 };
1239
1240 enum class Location {
1241 Center,
1242 North,
1243 NorthEast,
1244 East,
1245 SouthEast,
1246 South,
1247 SouthWest,
1248 West,
1249 NorthWest,
1250 NUM_OPTIONS,
1251
1252 Default = Center,
1253 };
1254
1255 enum class LegendFlags {
1256 None = 0,
1257 Outside = 1<<4,
1258
1259 Default = None,
1260 };
1261
1262 constexpr bool operator&(LegendFlags lhs, LegendFlags rhs)
1263 {
1264 return (std::to_underlying(lhs) & std::to_underlying(rhs)) != 0;
1265 }
1266
1267 constexpr LegendFlags operator^(LegendFlags lhs, LegendFlags rhs)
1268 {
1269 return static_cast<LegendFlags>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
1270 }
1271
1272 // draws the plotting demo in its own panel
1273 void show_demo_panel();
1274
1275 // starts a 2D plotting context
1276 //
1277 // - if this function returns `true`, then `plot::end` MUST be called
1278 // - `title` must be unique to the current ID scope/stack
1279 // - `size` is the total size of the plot including axis labels, title, etc.
1280 // you can call `get_plot_screen_rect` after finishing setup to figure out
1281 // the bounds of the plot area (i.e. where the data is)
1282 bool begin(CStringView title, Vector2 size, PlotFlags = PlotFlags::Default);
1283
1284 // ends a 2D plotting context
1285 //
1286 // this must be called if `plot::begin` returns `true`
1287 void end();
1288
1289 // temporarily modifies a style variable of `float` type. Must be paired with `pop_style_var`
1290 void push_style_var(PlotStyleVar, float);
1291
1292 // temporarily modifies a style variable of `Vector2` type. Must be paired with `pop_style_var`
1293 void push_style_var(PlotStyleVar, Vector2);
1294
1295 // undoes `count` temporary style variable modifications that were enacted by `push_style_var`
1296 void pop_style_var(int count = 1);
1297
1298 // temporarily modifies a style color variable. Must be paired with `pop_style_color`
1299 void push_style_color(PlotColorVar, const Color&);
1300
1301 // undoes `count` temporary style color modifications that were enacted by `push_style_color`
1302 void pop_style_color(int count = 1);
1303
1304 // enables an axis or sets the label and/or the flags of an existing axis
1305 void setup_axis(Axis, std::optional<CStringView> label = std::nullopt, AxisFlags = AxisFlags::Default);
1306
1307 // sets the label and/or the flags for the primary X and Y axes (shorthand for two calls to `setup_axis`)
1308 void setup_axes(CStringView x_label, CStringView y_label, AxisFlags x_flags = AxisFlags::Default, AxisFlags y_flags = AxisFlags::Default);
1309
1310 // sets an axis's range limits. If `Condition::Always` is used, the axes limits will be locked
1311 void setup_axis_limits(Axis axis, ClosedInterval<float> data_range, float padding_percentage, Condition = Condition::Once);
1312
1313 // explicitly finalizes plot setup
1314 //
1315 // - once this is called, you cannot call any `plot::setup_*` functions for
1316 // in the current 2D plotting context
1317 // - calling this function is OPTIONAL - the implementation will automatically
1318 // call it on the first setup-locking API call (e.g. `plot::draw_line`)
1319 void setup_finish();
1320
1321 // sets the marker style for the next item only
1322 void set_next_marker_style(
1323 MarkerType = MarkerType::None,
1324 std::optional<float> size = std::nullopt,
1325 std::optional<Color> fill = std::nullopt,
1326 std::optional<float> weight = std::nullopt,
1327 std::optional<Color> outline = std::nullopt
1328 );
1329
1330 // plots a standard 2D line plot
1331 void plot_line(CStringView name, std::span<const Vector2> points);
1332 void plot_line(CStringView name, std::span<const float> y_values, std::optional<ClosedInterval<float>> x_range = std::nullopt);
1333
1334 // returns the plot's rectangle in ui space
1335 //
1336 // must be called between `plot::begin` and `plot::end`
1337 Rect get_plot_ui_rect();
1338
1339 // draws an annotation callout at a chosen point
1340 //
1341 // - clamping keeps annotations in the plot area
1342 // - annotations are always rendered on top of the plot area
1343 namespace detail
1344 {
1345 void draw_annotation_v(Vector2 position_dataspace, const Color& color, Vector2 pixel_offset, bool clamp, CStringView fmt, va_list args);
1346 }
1347 inline void draw_annotation(Vector2 position_dataspace, const Color& color, Vector2 pixel_offset, bool clamp, CStringView fmt, ...)
1348 {
1349 va_list args;
1350 va_start(args, fmt);
1351 detail::draw_annotation_v(position_dataspace, color, pixel_offset, clamp, fmt, args);
1352 va_end(args);
1353 }
1354
1355 // draws a draggable point at `plot_point`, expressed in plot space, in
1356 // the plot area
1357 //
1358 // - returns `true` if the user has interacted with the point. In this
1359 // case, `plot_point` will be updated with user's interaction position
1360 // in plot space.
1361 bool drag_point(
1362 int id,
1363 Vector2d* plot_point,
1364 const Color&,
1365 float size = 4,
1366 DragToolFlags = DragToolFlag::Default
1367 );
1368
1369 // draws a draggable vertical guideline at an x value (plot space) in the
1370 // plot area.
1371 bool drag_line_x(
1372 int id,
1373 double* plot_x,
1374 const Color&,
1375 float thickness = 1,
1376 DragToolFlags = DragToolFlag::Default
1377 );
1378
1379 // draws a draggable horizontal guideline at a y value (plot space) in the
1380 // plot area.
1381 bool drag_line_y(
1382 int id,
1383 double* plot_y,
1384 const Color&,
1385 float thickness = 1,
1386 DragToolFlags = DragToolFlag::Default
1387 );
1388
1389 // draws a tag on the x-axis at the specified x value in plot space
1390 void tag_x(double plot_x, const Color&, bool round = false);
1391
1392 // returns `true` if the plot area in the current plot is hovered
1393 bool is_plot_hovered();
1394
1395 // returns the position of the mouse in plot space
1396 Vector2 get_plot_mouse_position();
1397
1398 // returns the mouse position in the coordinate system of the given axes
1399 Vector2 get_plot_mouse_position(Axis x_axis, Axis y_axis);
1400
1401 // sets up the plot legend
1402 void setup_legend(Location, LegendFlags = LegendFlags::Default);
1403
1404 // begins a popup for a legend entry
1405 bool begin_legend_popup(CStringView label_id, MouseButton = MouseButton::Right);
1406
1407 // ends a popup for a legend entry
1408 void end_legend_popup();
1409 }
1410}
Definition angle.h:25
Definition app.h:45
Definition c_string_view.h:12
Definition camera.h:27
Definition copy_on_upd_ptr.h:22
Definition event.h:13
Definition flags.h:20
Definition rect.h:17
Definition render_texture.h:18
Definition resource_path.h:12
Definition texture2d.h:22
Definition uid.h:14
Definition oscimgui.h:46
void set_base_imgui_ini_config_resource(ResourcePath)
void set_main_font_as_standard_plus_icon_font(ResourcePath main_font_ttf_path, ResourcePath icon_font_ttf_path, ClosedInterval< char16_t > codepoint_range)
Definition oscimgui.h:73
bool on_event(Event &)
Context(Context &&) noexcept=delete
Context(const Context &)=delete
Context(App &, const ContextConfiguration &={})
void on_start_new_frame()
Definition oscimgui.h:615
DrawListAPI(DrawListAPI &&) noexcept=default
DrawListAPI(const DrawListAPI &)=default
Definition oscimgui.h:640
ImDrawList & impl_get_drawlist() final
Definition oscimgui.h:646
DrawListView(ImDrawList *inner_list)
Definition oscimgui.h:642
Definition oscimgui.h:651
ImDrawList & impl_get_drawlist() final
Definition oscimgui.h:663
DrawList(const DrawList &)=delete
DrawList(DrawList &&) noexcept
Definition oscimgui.h:1040
GizmoOperation operation() const
Definition oscimgui.h:1076
std::optional< Transform > draw(Matrix4x4 &model_matrix, const Matrix4x4 &view_matrix, const Matrix4x4 &projection_matrix, const Rect &ui_rect, const GizmoOperationSnappingSteps *snap=nullptr, const AABB *local_bounds=nullptr)
GizmoMode mode() const
Definition oscimgui.h:1078
bool is_over() const
void set_mode(GizmoMode mode)
Definition oscimgui.h:1079
bool is_using() const
bool handle_keyboard_inputs()
bool was_using() const
Definition oscimgui.h:1074
std::optional< Transform > draw_to_foreground(Matrix4x4 &model_matrix, const Matrix4x4 &view_matrix, const Matrix4x4 &projection_matrix, const Rect &ui_rect, const GizmoOperationSnappingSteps *snap=nullptr, const AABB *local_bounds=nullptr)
void set_operation(GizmoOperation operation)
Definition oscimgui.h:1077
void set_tooltip_v(CStringView fmt, va_list)
Definition oscimgui.h:42
bool draw_rgb_color_editor(CStringView label, Color &color)
bool draw_size_t_input(CStringView label, size_t *v, size_t step=1, size_t step_fast=100, TextInputFlags={})
bool is_ctrl_or_super_down()
PanelFlag
Definition oscimgui.h:314
bool draw_image_button(CStringView, const Texture2D &, Vector2 dimensions, const Rect &texture_coordinates)
bool draw_string_input(CStringView label, std::string &edited_string, TextInputFlags={})
bool draw_float3_input(CStringView label, float v[3], const char *format="%.3f", TextInputFlags={})
bool is_item_clicked(MouseButton=MouseButton::Left)
void push_style_color(ColorVar, const Color &)
float get_framerate()
bool begin_listbox(CStringView label)
void draw_image(const Texture2D &texture, std::optional< Vector2 > dimensions=std::nullopt, const Rect &region_uv_coordinates=Rect::from_corners({0.0f, 0.0f}, {1.0f, 1.0f}))
void draw_tooltip_body_only(CStringView)
void begin_tooltip(std::optional< float > wrap_width=std::nullopt)
bool is_key_released(Key)
bool draw_float_circular_slider(CStringView label, float *v, float min, float max, CStringView format="%.3f", SliderFlags={})
void end_tab_bar()
void draw_tooltip_body_only_if_item_hovered(CStringView, HoveredFlags=HoveredFlag::ForTooltip)
void draw_text_column_centered(CStringView)
bool is_mouse_dragging(MouseButton, float lock_threshold=-1.0f)
void push_id(UID)
bool table_column_sort_specs_are_dirty()
TextInputFlag
Definition oscimgui.h:265
void start_new_line()
void apply_dark_theme()
bool table_set_column_index(int column_n)
Rect get_last_drawn_item_screen_rect()
bool begin_popup(CStringView str_id, PanelFlags={})
void end_child_panel()
bool draw_tree_node_ex(CStringView, TreeNodeFlags={})
bool is_panel_hovered(HoveredFlags={})
Rect get_content_region_available_ui_rect()
void set_tooltip(CStringView fmt,...)
Definition oscimgui.h:358
ColumnFlag
Definition oscimgui.h:586
bool draw_float_input(CStringView label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", TextInputFlags={})
Rect get_last_drawn_item_ui_rect()
void enable_dockspace_over_main_window()
bool draw_angle_input(CStringView label, Radians &v)
void end_disabled()
ChildPanelFlag
Definition oscimgui.h:341
bool draw_rgba_color_editor(CStringView label, Color &color)
Vector2 get_item_top_left_ui_position()
Vector2 get_panel_size()
float get_style_alpha()
bool update_polar_camera_from_all_inputs(PolarPerspectiveCamera &, const Rect &viewport_rect, std::optional< AABB > maybe_scene_world_space_aabb)
void draw_text_wrapped(CStringView)
bool begin_tab_bar(CStringView str_id)
void set_next_item_width(float item_width)
void draw_text_centered(CStringView)
bool begin_menu(CStringView sv, bool enabled=true)
Rect get_main_window_workspace_ui_rect()
TreeNodeFlag
Definition oscimgui.h:165
bool draw_menu_item(CStringView label, std::optional< KeyCombination > shortcut={}, bool selected=false, bool enabled=true)
void close_current_popup()
bool draw_invisible_button(CStringView label, Vector2 size={})
ComboFlag
Definition oscimgui.h:299
float get_style_frame_border_size()
void indent(float indent_w=0.0f)
void set_cursor_panel_x(float local_x)
MouseButton
Definition oscimgui.h:228
bool draw_tab_item_button(CStringView label)
bool is_ctrl_down()
void draw_text_disabled_and_panel_centered(CStringView)
bool begin_popup_context_menu(CStringView str_id={}, PopupFlags=PopupFlag::MouseButtonRight)
Vector2 get_cursor_ui_position()
void end_listbox()
void set_num_columns(int count=1, std::optional< CStringView > id=std::nullopt, bool border=true)
TableFlag
Definition oscimgui.h:547
bool begin_main_window_bottom_bar(CStringView)
bool draw_angle_slider(CStringView label, Radians &v, Radians min, Radians max)
bool draw_string_input_with_hint(CStringView label, CStringView hint, std::string &edited_string, TextInputFlags={})
bool is_item_hovered(HoveredFlags={})
float get_font_base_size()
void end_table()
void draw_text(CStringView)
bool should_save_last_drawn_item_value()
void draw_text_bullet_pointed(CStringView)
Vector2 calc_button_size(CStringView)
void draw_dummy(const Vector2 &size)
void set_keyboard_focus_here()
float get_text_line_height_in_current_panel()
std::vector< TableColumnSortSpec > get_table_column_sort_specs()
float get_font_base_size_with_spacing()
Rect get_item_ui_rect()
Vector2 get_style_panel_padding()
void draw_tooltip_description_spacer()
bool draw_button_nobg(CStringView, Vector2 dimensions={0.0f, 0.0f})
Flags< PopupFlag > PopupFlags
Definition oscimgui.h:522
void set_next_panel_size(Vector2 size, Conditional=Conditional::Always)
bool is_mouse_released_without_dragging(MouseButton)
void end_tooltip(std::optional< float > wrap_width=std::nullopt)
Vector2 get_content_region_available()
float get_main_window_workspace_aspect_ratio()
void end_tooltip_nowrap()
void end_menu()
void tree_pop()
void end_combobox()
void draw_same_line_with_vertical_separator()
void end_tab_item()
void pop_style_var(int count=1)
bool draw_angle3_input(CStringView label, Vector< Radians, 3 > &, CStringView format="%.3f")
void table_setup_column(CStringView label, ColumnFlags={}, float init_width_or_weight=0.0f, ID=ID{})
bool update_polar_camera_from_mouse_inputs(PolarPerspectiveCamera &, Vector2 viewport_dimensions)
float get_tree_node_to_label_spacing()
void draw_text_warning(CStringView)
bool begin_table(CStringView str_id, int column, TableFlags={}, const Vector2 &outer_size={}, float inner_width=0.0f)
bool draw_button_centered(CStringView)
void set_cursor_ui_position(Vector2)
void update_camera_from_all_inputs(Camera &, EulerAngles &)
float get_frame_height()
bool is_mouse_down(MouseButton)
void set_next_item_size(Rect)
bool is_mouse_released(MouseButton)
Vector2 get_cursor_start_panel_position()
bool begin_tooltip_nowrap()
bool is_shift_down()
bool is_alt_down()
bool any_of_keys_down(std::span< const Key >)
void draw_vertical_spacer(float num_lines)
void end_menu_bar()
bool draw_checkbox(CStringView label, bool *v)
void pop_item_flag()
void draw_tooltip_header_text(CStringView)
SliderFlag
Definition oscimgui.h:251
Vector2 get_mouse_ui_position()
TabItemFlag
Definition oscimgui.h:205
void draw_help_marker(CStringView header, CStringView description)
bool draw_double_input(CStringView label, double *v, double step=0.0, double step_fast=0.0, const char *format="%.6f", TextInputFlags={})
Vector2 get_style_item_spacing()
void table_setup_scroll_freeze(int cols, int rows)
void draw_progress_bar(float fraction)
void set_next_panel_bg_alpha(float alpha)
bool is_item_hoverable(Rect bounds, ID)
void draw_tooltip(CStringView header, CStringView description={})
void hide_mouse_cursor()
constexpr float gizmo_annotation_offset()
Definition oscimgui.h:1100
bool draw_float_kilogram_input(CStringView label, float &v, float step=0.0f, float step_fast=0.0f, TextInputFlags={})
void set_scroll_y_here()
bool wants_keyboard()
bool begin_tab_item(CStringView label, bool *p_open=nullptr, TabItemFlags={})
bool is_item_deactivated_after_edit()
bool is_mouse_clicked(MouseButton, bool repeat=false)
bool draw_button(CStringView label, const Vector2 &size={})
Vector2 get_style_frame_padding()
void show_mouse_cursor()
float calc_button_width(CStringView)
void next_column()
GizmoMode
Definition oscimgui.h:1025
bool is_mouse_dragging_with_any_button_down()
float get_mouse_wheel_amount()
bool main_window_has_workspace()
void table_headers_row()
void set_cursor_panel_position(Vector2)
bool draw_arrow_down_button(CStringView label)
bool draw_combobox(CStringView label, size_t *current, size_t size, const std::function< CStringView(size_t)> &accessor)
void push_item_flag(ItemFlags flags, bool enabled)
void unindent(float indent_w=0.0f)
bool draw_text_link(CStringView)
bool draw_int_input(CStringView label, int *v, int step=1, int step_fast=100, TextInputFlags={})
DrawListView get_panel_draw_list()
void draw_tooltip_description_text(CStringView)
GizmoOperation
Definition oscimgui.h:1015
StyleVar
Definition oscimgui.h:498
Vector2 get_cursor_panel_position()
bool is_key_down(Key)
bool update_polar_camera_from_keyboard_inputs(PolarPerspectiveCamera &, const Rect &viewport_rect, std::optional< AABB > maybe_scene_world_space_aabb)
bool any_of_keys_pressed(std::span< const Key >)
bool draw_float3_meters_input(CStringView label, Vector3 &, TextInputFlags={})
void draw_text_faded(CStringView)
bool draw_float_meters_slider(CStringView label, float &v, float v_min, float v_max, SliderFlags flags={})
void begin_disabled(bool disabled=true)
bool add_item(Rect bounds, ID)
bool draw_gizmo_mode_selector(Gizmo &)
void set_next_panel_size_constraints(Vector2 size_min, Vector2 size_max)
bool draw_selectable(CStringView label, bool *p_selected)
bool draw_small_button(CStringView label)
ID get_id(std::string_view)
Color get_style_color(ColorVar)
void open_popup(CStringView str_id, PopupFlags={})
void pop_style_color(int count=1)
void draw_text_disabled_and_centered(CStringView)
std::optional< Texture2D > get_font_texture()
ColorVar
Definition oscimgui.h:472
ItemFlag
Definition oscimgui.h:448
Vector2 calc_text_size(CStringView text, bool hide_text_after_double_hash=false)
Color get_color(ColorVar)
void draw_vertical_separator()
bool begin_main_window_top_bar(CStringView label, float height=ui::get_frame_height(), PanelFlags={PanelFlag::NoScrollbar, PanelFlag::NoSavedSettings, PanelFlag::MenuBar})
bool begin_menu_bar()
HittestResult hittest_last_drawn_item()
PopupFlag
Definition oscimgui.h:516
PanelFlags get_minimal_panel_flags()
float get_column_width(int column_index=-1)
bool draw_float_meters_input(CStringView label, float &v, float step=0.0f, float step_fast=0.0f, TextInputFlags={})
bool draw_collapsing_header(CStringView label, TreeNodeFlags={})
bool draw_gizmo_operation_selector(Gizmo &, bool can_translate=true, bool can_rotate=true, bool can_scale=true, CStringView translate_button_text="T", CStringView rotate_button_text="R", CStringView scale_button_text="S")
DataType
Definition oscimgui.h:260
Vector2 get_main_window_workspace_dimensions()
void draw_tooltip_if_item_hovered(CStringView header, CStringView description={}, HoveredFlags=HoveredFlag::ForTooltip)
void end_popup()
bool begin_popup_modal(CStringView name, bool *p_open=nullptr, PanelFlags={})
Flags< PanelFlag > PanelFlags
Definition oscimgui.h:336
SortDirection
Definition oscimgui.h:569
void draw_text_panel_centered(CStringView)
void show_demo_panel()
HoveredFlag
Definition oscimgui.h:416
void set_next_panel_ui_position(Vector2, Conditional=Conditional::Always, Vector2 pivot={})
bool draw_vector3_input(CStringView label, Vector3 &v, const char *format="%.3f", TextInputFlags={})
void draw_separator()
void draw_text_disabled(CStringView)
void pop_id()
void draw_bullet_point()
bool draw_scalar_input(CStringView label, DataType data_type, void *p_data, const void *p_step=nullptr, const void *p_step_fast=nullptr, const char *format=nullptr, TextInputFlags={})
bool draw_float_slider(CStringView label, float *v, float v_min, float v_max, const char *format="%.3f", SliderFlags={})
float get_text_line_height_with_spacing_in_current_panel()
Vector2 get_item_bottom_right_ui_position()
bool is_mouse_in_main_window_workspace()
void end_panel()
bool is_key_pressed(Key, bool repeat=true)
bool begin_combobox(CStringView label, CStringView preview_value, ComboFlags={})
Flags< ChildPanelFlag > ChildPanelFlags
Definition oscimgui.h:346
Conditional
Definition oscimgui.h:401
void table_next_row()
bool begin_child_panel(CStringView str_id, const Vector2 &size={}, ChildPanelFlags child_flags={}, PanelFlags panel_flags={})
float get_cursor_panel_x()
void add_screenshot_annotation_to_last_drawn_item(std::string_view label)
bool begin_panel(CStringView name, bool *p_open=nullptr, PanelFlags={})
void align_text_to_frame_padding()
void pop_item_flags(int n=1)
bool draw_radio_button(CStringView label, bool active)
Vector2 get_style_item_inner_spacing()
void push_style_var(StyleVar, Vector2)
Rect get_main_window_workspace_screen_space_rect()
DrawListView get_foreground_draw_list()
void same_line(float offset_from_start_x=0.0f, float spacing=-1.0f)
void set_next_item_open(bool is_open)
Definition custom_decoration_generator.h:5
constexpr Angle< Rep, Units > clamp(const Angle< Rep, Units > &v, const AngleMin &min, const AngleMax &max)
Definition angle.h:303
Key
Definition key.h:6
constexpr U to(T &&value)
Definition conversion.h:56
Definition aabb.h:14
Definition circle.h:10
Definition closed_interval.h:20
Definition polar_perspective_camera.h:14
Definition oscimgui.h:1033
std::optional< Vector3 > position
Definition oscimgui.h:1036
std::optional< Vector3 > scale
Definition oscimgui.h:1034
std::optional< Radians > rotation
Definition oscimgui.h:1035
Definition oscimgui.h:757
Definition oscimgui.h:235
ID()=default
unsigned int value() const
Definition oscimgui.h:240
ID(unsigned int value)
Definition oscimgui.h:238
Definition oscimgui.h:576