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 <format>
25#include <functional>
26#include <initializer_list>
27#include <optional>
28#include <span>
29#include <string>
30#include <string_view>
31#include <utility>
32
33namespace osc { class App; }
34namespace osc { class Camera; }
35namespace osc { class Event; }
36namespace osc { struct PolarPerspectiveCamera; }
37namespace osc { class RenderTexture; }
38namespace osc { class Texture2D; }
39
40struct ImDrawList;
41
42namespace osc::ui
43{
44 class Context;
45
46 // Represents the runtime configuration of a UI context.
48 public:
50
51 // Sets the resource path to an `imgui.ini` file that acts as the "base" config
52 // when the user doesn't already have one in their user data directory.
54
55 // Sets the UI's main font as a merged combination of a 'standard' font
56 // and an 'icon' font, where the latter contains UTF8-to-glyph mappings
57 // for arbitrary icons.
62 );
63
64 class Impl;
65 private:
66 friend class Context;
67 CopyOnUpdPtr<Impl> impl() const { return impl_; }
68
70 };
71
72 // Represents the top-level UI context that `ui::` functions talk to
73 // when drawing the UI.
74 class Context final {
75 public:
76 // Constructs a global UI context with the given configuration.
77 explicit Context(App&, const ContextConfiguration& = {});
78
79 Context(const Context&) = delete;
81
82 // Shuts down the global UI context.
84
87
88 // Shuts down and constructs this `UiContext` in-place.
89 void reset();
90
91 // Returns true if the UI handled the event.
93
94 // Should be called at the start of each frame (e.g. `Widget::on_draw()`).
96
97 // Should be called at the end of each frame (e.g. the end of `Widget::on_draw()`).
98 void render();
99 private:
100 void init(App&, const CopyOnUpdPtr<ui::ContextConfiguration::Impl>&);
101 void shutdown(App*);
102 };
103
104 // 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)
106
107 void draw_text(std::string_view);
110 {
111 draw_text(std::format(std::move(fmt), std::forward<Args>(args)...));
112 }
113
114 void draw_text_disabled(std::string_view);
115 template<class... Args>
116 void draw_text_disabled(std::format_string<Args...> fmt, Args&&... args)
117 {
118 draw_text_disabled(std::format(std::move(fmt), std::forward<Args>(args)...));
119 }
120
121 void draw_text_wrapped(std::string_view);
122 template<class... Args>
123 void draw_text_wrapped(std::format_string<Args...> fmt, Args&&... args)
124 {
125 draw_text_wrapped(std::format(std::move(fmt), std::forward<Args>(args)...));
126 }
127
130
132
133 enum class TreeNodeFlag : unsigned {
134 None = 0,
135 DefaultOpen = 1<<0,
136 OpenOnArrow = 1<<1, // only open when clicking on the arrow part
137 Leaf = 1<<2, // no collapsing, no arrow (use as a convenience for leaf nodes)
138 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!
139 DrawLinesToNodes = 1<<4,
140 DrawLinesFull = 1<<5,
141 NUM_FLAGS = 6,
142 };
144
146
148
149 void tree_pop();
150
152
153 bool begin_menu(CStringView sv, bool enabled = true);
154 void end_menu();
155
157 CStringView label,
158 std::optional<KeyCombination> shortcut = {},
159 bool selected = false,
160 bool enabled = true
161 );
162
164 CStringView label,
165 std::optional<KeyCombination> shortcut,
166 bool* p_selected,
167 bool enabled = true
168 );
169
172
173 enum class TabItemFlag : unsigned {
174 None = 0,
175 NoReorder = 1<<0, // disable reordering this tab or having another tab cross over this tab
176 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)
177 UnsavedDocument = 1<<2, // display a dot next to the title + (internally) set `ImGuiTabItemFlags_NoAssumedClosure`
178 SetSelected = 1<<3, // trigger flag to programmatically make the tab selected when calling `begin_tab_item`
179 NUM_FLAGS = 4,
180 };
182
183 bool begin_tab_item(CStringView label, bool* p_open = nullptr, TabItemFlags = {});
185
187
188 void set_num_columns(int count = 1, std::optional<CStringView> id = std::nullopt, bool border = true);
189 float get_column_width(int column_index = -1);
191
192 // Places the cursor on the same line as the previous item, with the given
193 // offset/spacing in device-independent pixels.
194 void same_line(float offset_from_start_x = 0.0f, float spacing = -1.0f);
195
196 enum class MouseButton {
197 Left,
198 Right,
199 Middle,
201 };
202
203 struct ID final {
204 public:
205 explicit ID() = default;
206 explicit ID(unsigned int value) : value_{value} {}
207
208 unsigned int value() const { return value_; }
209 private:
210 unsigned int value_ = 0; // defaults to "no ID"
211 };
212
218
219 enum class SliderFlag : unsigned {
220 None = 0,
221 Logarithmic = 1<<0,
222 AlwaysClamp = 1<<1,
223 NoInput = 1<<2,
224 NUM_FLAGS = 3,
225 };
227
228 enum class DataType {
229 Float,
231 };
232
233 enum class TextInputFlag : unsigned {
234 None = 0,
235 ReadOnly = 1<<0,
236 EnterReturnsTrue = 1<<1,
237 NUM_FLAGS = 2,
238 };
240
242 bool draw_selectable(CStringView label, bool selected = false);
243 bool draw_checkbox(CStringView label, bool* v);
244 bool draw_float_slider(CStringView label, float* v, float v_min, float v_max, const char* format = "%.3f", SliderFlags = {});
245 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 = {});
246 bool draw_int_input(CStringView label, int* v, int step = 1, int step_fast = 100, TextInputFlags = {});
247 bool draw_size_t_input(CStringView label, size_t* v, size_t step = 1, size_t step_fast = 100, TextInputFlags = {});
248 bool draw_double_input(CStringView label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", TextInputFlags = {});
249 bool draw_float_input(CStringView label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", TextInputFlags = {});
250 bool draw_float3_input(CStringView label, float v[3], const char* format = "%.3f", TextInputFlags = {});
251 bool draw_vector3_input(CStringView label, Vector3& v, const char* format = "%.3f", TextInputFlags = {});
254 // Draws an interactive button with the given label and with a given size in device-independent pixels.
255 bool draw_button(CStringView label, const Vector2& size = {});
258 // Draws an interactive, but invisible, button with the given label and the given size in device-independent pixels.
262 // Draws an invisible, non-interactive "dummy" element in the UI with the given size in device-independent pixels.
263 void draw_dummy(const Vector2& size);
264 // Draws an invisible, non-interactive "dummy" element that is `num_lines` * text line height high.
266
267 enum class ComboFlag : unsigned {
268 None = 0,
269 NoArrowButton = 1<<0,
270 NUM_FLAGS = 1,
271 };
273
276
279
281
282 enum class PanelFlag : unsigned {
283 None = 0,
284
285 NoMove = 1<<0,
286 NoTitleBar = 1<<1,
287 NoResize = 1<<2,
288 NoSavedSettings = 1<<3,
289 NoScrollbar = 1<<4,
290 NoInputs = 1<<5,
291 NoBackground = 1<<6,
292 NoCollapse = 1<<7,
293 NoDecoration = 1<<8,
294 NoDocking = 1<<9,
295 NoNav = 1<<10,
296
297 MenuBar = 1<<11,
298 AlwaysAutoResize = 1<<12,
299 HorizontalScrollbar = 1<<13,
301
302 NUM_FLAGS = 15,
303 };
305
306 bool begin_panel(CStringView name, bool* p_open = nullptr, PanelFlags = {});
307 void end_panel();
308
309 enum class ChildPanelFlag : unsigned {
310 None = 0,
311 Border = 1<<0,
312 NUM_FLAGS = 1,
313 };
315
316 // Begins a child panel within a parent panel with the given ID, device-independent pixel size, and flags.
317 bool begin_child_panel(CStringView str_id, const Vector2& size = {}, ChildPanelFlags child_flags = {}, PanelFlags panel_flags = {});
319
321
323 template<class... Args>
324 void set_tooltip_fmt(std::format_string<Args...> fmt, Args&&... args)
325 {
326 set_tooltip(std::format(std::move(fmt), std::forward<Args>(args)...));
327 }
328
330
331 // Returns the height of the current frame in device-independent pixels.
333
334 // Returns the size of the content region that's available from the current
335 // cursor position within the current panel in device-independent pixels.
337
338 // Returns the position that the panel cursor started at relative to the top-left
339 // corner of the current panel in device-independent pixels.
341
342 // Returns the current position of the panel cursor relative to the top-left corner
343 // of the current panel in device-independent pixels.
345
346 // Sets the current position of the panel cursor relative to the top-left corner
347 // of the panel in device-independent pixels.
349
350 // Returns the current x position of the panel cursor relative to the left edge
351 // of the current panel in device-independent pixels.
353
354 // Sets the current x position of the panel cursor relative to the left edge of
355 // the current panel in device-independent pixels.
357
358 // Returns the current position of the panel cursor in ui space in device-independent pixels.
360
361 // Sets the current position of the panel cursor in ui space in device-independent pixels.
363
364 enum class Conditional {
365 Always,
366 Once,
367 Appearing,
369 };
370
372
374
376
377 void set_next_panel_bg_alpha(float alpha);
378
379 enum class HoveredFlag : unsigned {
380 None = 0,
381 AllowWhenDisabled = 1<<0,
384 AllowWhenOverlapped = 1<<3,
385 DelayNormal = 1<<4,
386 ForTooltip = 1<<5,
387 RootAndChildPanels = 1<<6,
388 ChildPanels = 1<<7,
389 NUM_FLAGS = 8,
390 };
392
394
395 void begin_disabled(bool disabled = true);
397
400
402 void push_id(int);
403 template<std::integral T> void push_id(T number) { push_id(static_cast<int>(number)); }
404 void push_id(std::string_view);
405 void push_id(const void*);
406
407 void pop_id();
408
409 ID get_id(std::string_view);
410
411 enum class ItemFlag : unsigned {
412 None = 0,
413 Disabled = 1<<0,
414 Inputable = 1<<1,
415 NUM_FLAGS = 2,
416 };
418
419 void set_next_item_size(Rect); // note: ImGui API assumes cursor is located at `p1` already
420 bool add_item(Rect bounds, ID);
421 bool is_item_hoverable(Rect bounds, ID);
422
424
426
427 void indent(float indent_w = 0.0f);
428 void unindent(float indent_w = 0.0f);
429
431 bool is_key_pressed(Key, bool repeat = true);
434
435 enum class ColorVar {
436 Text,
437 Button,
440 FrameBg,
441 PopupBg,
444 CheckMark,
446 PanelBg,
448 };
449
457
460
474
477 void pop_style_var(int count = 1);
478
479 enum class PopupFlag : unsigned {
480 None = 0,
481 MouseButtonLeft = 1<<0,
482 MouseButtonRight = 1<<1,
483 NUM_FLAGS = 2,
484 };
486
490 bool begin_popup_modal(CStringView name, bool* p_open = nullptr, PanelFlags = {});
491 void end_popup();
492
495
498
501
503 void set_next_item_open(bool is_open);
509
510 enum class TableFlag : unsigned {
511 None = 0,
512 BordersInner = 1<<0,
513 BordersInnerV = 1<<1,
514 NoSavedSettings = 1<<2,
515 PadOuterX = 1<<3,
516 Resizable = 1<<4,
517 ScrollY = 1<<5,
518 SizingStretchProp = 1<<6,
519 SizingStretchSame = 1<<7,
520 Sortable = 1<<8,
521 SortTristate = 1<<9,
522 NUM_FLAGS = 10,
523 };
525
529 bool begin_table(CStringView str_id, int column, TableFlags = {}, const Vector2& outer_size = {}, float inner_width = 0.0f);
531
532 enum class SortDirection {
533 None,
534 Ascending,
537 };
538
540 ID column_id{};
541 size_t column_index = 0;
542 size_t sort_order = 0;
543 SortDirection sort_direction = SortDirection::None;
544 };
545
547 std::vector<TableColumnSortSpec> get_table_column_sort_specs();
548
549 enum class ColumnFlag : unsigned {
550 None = 0,
551 NoSort = 1<<0,
552 WidthStretch = 1<<1,
553 NUM_FLAGS = 2,
554 };
556
560 void table_setup_column(CStringView label, ColumnFlags = {}, float init_width_or_weight = 0.0f, ID = ID{});
561 void end_table();
562
564 void pop_style_color(int count = 1);
565
567
572 std::optional<Texture2D> get_font_texture();
573
575
577
579 protected:
580 DrawListAPI() = default;
581 DrawListAPI(const DrawListAPI&) = default;
582 DrawListAPI(DrawListAPI&&) noexcept = default;
583 DrawListAPI& operator=(const DrawListAPI&) = default;
584 DrawListAPI& operator=(DrawListAPI&&) noexcept = default;
585 public:
586 virtual ~DrawListAPI() noexcept = default;
587
588 void add_rect(const Rect& ui_rect, const Color& color, float rounding = 0.0f, float thickness = 1.0f);
589 void add_rect_filled(const Rect& ui_rect, const Color& color, float rounding = 0.0f);
590 void add_circle(const Circle& ui_circle, const Color& color, int num_segments = 0, float thickness = 1.0f);
591 void add_circle_filled(const Circle& ui_circle, const Color& color, int num_segments = 0);
592 void add_text(const Vector2& ui_position, const Color& color, CStringView text);
593 void add_line(const Vector2& ui_start, const Vector2& ui_end, const Color& color, float thickness = 1.0f);
594 void add_triangle_filled(const Vector2 ui_p0, const Vector2& ui_p1, const Vector2& ui_p2, const Color& color);
595 void push_clip_rect(const Rect&, bool intersect_with_currect_clip_rect = false);
596 void pop_clip_rect();
597
598 void render_to(RenderTexture&);
599 private:
600 virtual ImDrawList& impl_get_drawlist() = 0;
601 };
602
603 class DrawListView : public DrawListAPI {
604 public:
605 explicit DrawListView(ImDrawList* inner_list) :
606 inner_list_{inner_list}
607 {}
608 private:
609 ImDrawList& impl_get_drawlist() final { return *inner_list_; }
610
611 ImDrawList* inner_list_;
612 };
613
614 class DrawList final : public DrawListAPI {
615 public:
617 DrawList(const DrawList&) = delete;
618 DrawList(DrawList&&) noexcept;
619 DrawList& operator=(const DrawList&) = delete;
620 DrawList& operator=(DrawList&&) noexcept;
621 ~DrawList() noexcept override;
622
623 operator DrawListView () { return DrawListView{underlying_drawlist_.get()}; }
624
625 private:
626 ImDrawList& impl_get_drawlist() final { return *underlying_drawlist_; }
627
628 std::unique_ptr<ImDrawList> underlying_drawlist_;
629 };
630
633
635
636 // applies "dark" theme to current UI context
638
639 // updates a polar camera's rotation, position, etc. from UI keyboard input state
642 const Rect& viewport_rect,
643 std::optional<AABB> maybe_scene_world_space_aabb
644 );
645
646 // updates a polar camera's rotation, position, etc. from UI input state (all)
649 const Rect& viewport_rect,
650 std::optional<AABB> maybe_scene_world_space_aabb
651 );
652
654 Camera&,
656 );
657
658 // returns the UI content region available in ui space as a `Rect`
660
661 // Draws a texture within the UI.
662 //
663 // - `texture`: the texture to draw within the UI.
664 // - `dimensions`: the dimensions, in device-independent pixels, that the image
665 // should occupy in the UI. Default: `texture.device_independent_dimensions()`.
666 // - `region_uv_coordinates`: texture coordinates in texture space (`(0, 0)` means bottom-left,
667 // `(1, 1)` means top-right) that designate the region within `texture` that should be sampled
668 // to produce the image within the UI (e.g. for cropping, flipping). Default: entire contents
669 // `texture`.
671 const Texture2D& texture,
672 std::optional<Vector2> dimensions = std::nullopt,
673 const Rect& region_uv_coordinates = Rect::from_corners({0.0f, 0.0f}, {1.0f, 1.0f})
674 );
676 const RenderTexture&
677 );
679 const RenderTexture&,
680 Vector2 dimensions
681 );
682
683 // returns the dimensions of a button with the given content
686
689 Vector2 dimensions = {0.0f, 0.0f}
690 );
691
692 // draws a texture within the UI as a clickable button
695 const Texture2D&,
696 Vector2 dimensions,
697 const Rect& texture_coordinates
698 );
701 const Texture2D&,
702 Vector2 dimensions
703 );
704
705 // returns the ui space bounding rectangle of the last-drawn item in
706 // device-independent pixels.
708
709 // returns the screen space bounding rectangle of the last-drawn item
710 // in device-independent pixels.
712
713 // adds a screenshot annotation around the last drawn item to the
714 // application-level annotation collector
715 //
716 // equivalent to: `App::upd().add_main_window_frame_annotation(label, get_last_drawn_item_screen_rect());`
718
719 // hittest the last-drawn item in the UI
720 struct HittestResult final {
721 Rect item_ui_rect = {};
722 bool is_hovered = false;
723 bool is_left_click_released_without_dragging = false;
724 bool is_right_click_released_without_dragging = false;
725 };
728
729 // returns `true` if any scancode in the provided range is currently pressed down
730 bool any_of_keys_down(std::span<const Key>);
731 bool any_of_keys_down(std::initializer_list<const Key>);
732
733 // returns `true` if any scancode in the provided range was pressed down this frame
734 bool any_of_keys_pressed(std::span<const Key>);
735 bool any_of_keys_pressed(std::initializer_list<const Key>);
736
737 // returns true if the user is pressing either left- or right-Ctrl
739
740 // returns `true` if the user is pressing either:
741 //
742 // - left Ctrl
743 // - right Ctrl
744 // - left Super (mac)
745 // - right Super (mac)
747
748 // returns `true` if the user is pressing either left- or right-shift
750
751 // returns `true` if the user is pressing either left- or right-alt
753
754 // returns `true` if the specified mouse button was released without the user dragging
757
758 // returns `true` if the user is dragging their mouse with any button pressed
760
761 // (lower-level tooltip methods: prefer using higher-level 'draw_tooltip(txt)' methods)
762 void begin_tooltip(std::optional<float> wrap_width = std::nullopt);
763 void end_tooltip(std::optional<float> wrap_width = std::nullopt);
764
768
769 // draws an overlay tooltip (content only)
771
772 // draws an overlay tooltip (content only) if the last item is hovered
775 HoveredFlags = HoveredFlag::ForTooltip
776 );
777
778 // draws an overlay tooltip with a header and description
779 void draw_tooltip(CStringView header, CStringView description = {});
780
781 // equivalent to `if (ui::is_item_hovered(flags)) draw_tooltip(header, description);`
783 CStringView header,
784 CStringView description = {},
785 HoveredFlags = HoveredFlag::ForTooltip
786 );
787
788 // draws a help text marker `"(?)"` and display a tooltip when the user hovers over it
789 void draw_help_marker(CStringView header, CStringView description);
790
791 // draws a help text marker `"(?)"` and display a tooltip when the user hovers over it
793
794 // draws a text input that manipulates a `std::string`
796 CStringView label,
797 std::string& edited_string,
798 TextInputFlags = {}
799 );
800
801 // draws a text input that contains `hint` as a placeholder and manipulates a `std::string`
803 CStringView label,
804 CStringView hint,
805 std::string& edited_string,
806 TextInputFlags = {}
807 );
808
809 // behaves like `ui::draw_float_input`, but understood to manipulate the scene scale
811 CStringView label,
812 float& v,
813 float step = 0.0f,
814 float step_fast = 0.0f,
815 TextInputFlags = {}
816 );
817
818 // behaves like `ui::draw_float3_input`, but understood to manipulate the scene scale
820 CStringView label,
821 Vector3&,
822 TextInputFlags = {}
823 );
824
825 // behaves like `ui::draw_float_slider`, but understood to manipulate the scene scale
827 CStringView label,
828 float& v,
829 float v_min,
830 float v_max,
831 SliderFlags flags = {}
832 );
833
834 // behaves like `ui::draw_float_input`, but edits the given value as a mass (kg)
836 CStringView label,
837 float& v,
838 float step = 0.0f,
839 float step_fast = 0.0f,
840 TextInputFlags = {}
841 );
842
843 // behaves like `ui::draw_float_input`, but edits the given angular value in degrees
845 CStringView label,
846 Radians& v
847 );
848
849 // behaves like `ui::draw_float3_input`, but edits the given angular value in degrees
851 CStringView label,
853 CStringView format = "%.3f"
854 );
855
856 // behaves like `ui::draw_float_slider`, but edits the given angular value as degrees
858 CStringView label,
859 Radians& v,
860 Radians min,
861 Radians max
862 );
863
864 // returns "minimal" panel flags (i.e. no title bar, can't move the panel - ideal for images etc.)
866
867 // returns `true` if the area of the main window's workspace is greater than zero.
869
870 // returns a `Rect` that indicates where the current workspace area is in the main
871 // application window
872 //
873 // the returned `Rect` is given in ui space, such that:
874 //
875 // - it's measured in device-independent pixels
876 // - starts in the top-left corner
877 // - ends in the bottom-right corner
879
880 // returns a `Rect` that indicates where the current workspace area is in the main
881 // application window
882 //
883 // the returned `Rect` is given in screen space, such that:
884 //
885 // - it's measured in device-independent pixels
886 // - starts in the bottom-left corner
887 // - ends in the top-right corner
889
890 // returns the dimensions of the current workspace area in device-independent pixels in the
891 // main application window.
893
894 // returns the aspect ratio (width divided by height) of the device-independent pixel dimensions
895 // of the current workspace area in the main application window
897
898 // returns `true` if the user's mouse is within the current workspace area of the main application
899 // window
901
902 // begin a menu that's attached to the top of the main application window, end it with `ui::end_panel()`
904 CStringView label,
905 float height = ui::get_frame_height(),
906 PanelFlags = {PanelFlag::NoScrollbar, PanelFlag::NoSavedSettings, PanelFlag::MenuBar}
907 );
908
909 // begin a menu that's attached to the bottom of the main application window, end it with `ui::end_panel()`
911
912 // behaves like `ui::draw_button`, but is centered on the current line
914
915 // behaves like `ui::draw_text`, but is centered on the current line
917
918 // behaves like `ui::draw_text`, but is vertically and horizontally centered in the remaining content of the current panel
920
921 // behaves like `ui::draw_text`, but with a disabled style and centered on the current line
923
924 // behaves like `ui::draw_text`, but with a disabled style and centered in the remaining content of the current panel
926
927 // behaves like `ui::draw_text`, but centered in the current table column
929
930 // behaves like `ui::draw_text`, but with a faded/muted style
932
933 // behaves like `ui::draw_text`, but with a warning style (e.g. orange)
935
936 // returns `true` if the last drawn item (e.g. an input) should be saved based on heuristics
937 //
938 // - if the item was deactivated (e.g. due to focusing something else), it should be saved
939 // - if there's an active edit and the user presses enter, it should be saved
940 // - if there's an active edit and the user presses tab, it should be saved
942
943 void pop_item_flags(int n = 1);
944
946 CStringView label,
947 size_t* current,
948 size_t size,
949 const std::function<CStringView(size_t)>& accessor
950 );
951
953 CStringView label,
954 size_t* current,
955 std::span<const CStringView> items
956 );
957
960
962 CStringView label,
963 float* v,
964 float min,
965 float max,
966 CStringView format = "%.3f",
967 SliderFlags = {}
968 );
969
970 // updates a polar camera's rotation, position, etc. from UI mouse input state, assuming
971 // the viewport it's connected to has the given device-independent pixel dimensions.
974 Vector2 viewport_dimensions
975 );
976
977 // an operation that a ui `Gizmo` shall perform
978 enum class GizmoOperation : unsigned {
979 None = 0,
980 Translate = 1<<0,
981 Rotate = 1<<1,
982 Scale = 1<<2,
983 NUM_FLAGS = 3,
984 };
986
987 // the mode (coordinate space) that a `Gizmo` presents its manipulations in
988 enum class GizmoMode {
989 Local,
990 World,
991 NUM_OPTIONS,
992 };
993
994 // Represents the step size that the gizmo should stick to when the user is
995 // using a gizmo operation.
997 std::optional<Vector3> scale;
998 std::optional<Radians> rotation;
999 std::optional<Vector3> position;
1000 };
1001
1002 // a UI gizmo that manipulates the given model matrix using user-interactable drag handles, arrows, etc.
1003 class Gizmo final {
1004 public:
1005
1006 // if the user manipulated the gizmo, updates `model_matrix` to match the
1007 // post-manipulation transform and returns a world space transform that
1008 // represents the "difference" added by the user's manipulation. I.e.:
1009 //
1010 // transform_returned * model_matrix_before = model_matrix_after
1011 //
1012 // note: a user-enacted rotation/scale may not happen at the origin, so if
1013 // you're thinking "oh I'm only handling rotation/scaling, so I'll
1014 // ignore the translational part of the transform" then you're in
1015 // for a nasty surprise: T(origin)*R*S*T(-origin)
1016 std::optional<Transform> draw(
1017 Matrix4x4& model_matrix, // edited in-place
1018 const Matrix4x4& view_matrix,
1019 const Matrix4x4& projection_matrix,
1020 const Rect& ui_rect,
1021 const GizmoOperationSnappingSteps* snap = nullptr,
1022 const AABB* local_bounds = nullptr
1023 );
1024
1025 // same as `draw`, but draws to the foreground draw list, rather than the
1026 // draw list of the currently active panel
1027 std::optional<Transform> draw_to_foreground(
1028 Matrix4x4& model_matrix, // edited in-place
1029 const Matrix4x4& view_matrix,
1030 const Matrix4x4& projection_matrix,
1031 const Rect& ui_rect,
1032 const GizmoOperationSnappingSteps* snap = nullptr,
1033 const AABB* local_bounds = nullptr
1034 );
1035
1036 bool is_using() const;
1037 bool was_using() const { return was_using_last_frame_; }
1038 bool is_over() const;
1039 GizmoOperation operation() const { return operation_; }
1040 void set_operation(GizmoOperation operation) { operation_ = operation; }
1041 GizmoMode mode() const { return mode_; }
1042 void set_mode(GizmoMode mode) { mode_ = mode; }
1043
1044 // updates the gizmo based on keyboard inputs (e.g. pressing `G` enables grab mode)
1046 private:
1047 std::optional<Transform> draw_to(
1048 Matrix4x4& model_matrix,
1049 const Matrix4x4& view_matrix,
1050 const Matrix4x4& projection_matrix,
1051 const Rect& ui_rect,
1052 ImDrawList* draw_list,
1054 const AABB* local_bounds
1055 );
1056
1057 UID id_;
1058 GizmoOperation operation_ = GizmoOperation::Translate;
1059 GizmoMode mode_ = GizmoMode::World;
1060 bool was_using_last_frame_ = false;
1061 };
1062
1063 constexpr float gizmo_annotation_offset()
1064 {
1065 return 15.0f;
1066 }
1067
1069 Gizmo&
1070 );
1071
1073 GizmoMode&
1074 );
1075
1077 Gizmo&,
1078 bool can_translate = true,
1079 bool can_rotate = true,
1080 bool can_scale = true,
1081 CStringView translate_button_text = "T",
1082 CStringView rotate_button_text = "R",
1083 CStringView scale_button_text = "S"
1084 );
1085
1088 bool can_translate = true,
1089 bool can_rotate = true,
1090 bool can_scale = true,
1091 CStringView translate_button_text = "T",
1092 CStringView rotate_button_text = "R",
1093 CStringView scale_button_text = "S"
1094 );
1095
1096 // oscar bindings for `ImPlot`
1097 //
1098 // the design/types used here differ from `ImPlot` in order to provide
1099 // consistency with the rest of the `osc` ecosystem
1100 namespace plot
1101 {
1102 enum class PlotFlags {
1103 None = 0,
1104 NoTitle = 1<<0,
1105 NoLegend = 1<<1,
1106 NoMouseText = 1<<2,
1107 NoInputs = 1<<3,
1108 NoMenus = 1<<4,
1109 NoBoxSelect = 1<<5,
1110 NoFrame = 1<<6,
1111
1112 Default = None,
1113 };
1114 constexpr PlotFlags operator|(PlotFlags lhs, PlotFlags rhs)
1115 {
1116 return static_cast<PlotFlags>(std::to_underlying(lhs) | std::to_underlying(rhs));
1117 }
1118 constexpr PlotFlags operator^(PlotFlags lhs, PlotFlags rhs)
1119 {
1120 return static_cast<PlotFlags>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
1121 }
1122 constexpr bool operator&(PlotFlags lhs, PlotFlags rhs)
1123 {
1124 return (std::to_underlying(lhs) & std::to_underlying(rhs)) != 0;
1125 }
1126
1127 enum class PlotStyleVar {
1128 // `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)
1129 FitPadding,
1130
1131 // `Vector2`: padding between the item frame and plot area, labels, or outside legends (i.e. main padding)
1132 PlotPadding,
1133
1134 // `float`: thickness of the border around plot area
1135 PlotBorderSize,
1136
1137 // `Vector2`: text padding around annotation labels
1138 AnnotationPadding,
1139
1140 NUM_OPTIONS
1141 };
1142
1143 enum class PlotColorVar {
1144 // plot line/outline color (defaults to the next unused color in the current colormap)
1145 Line,
1146
1147 // plot area background color (defaults to `ColorVar::PanelBg`)
1148 PlotBackground,
1149
1150 NUM_OPTIONS,
1151 };
1152
1153 enum class Axis {
1154 X1, // enabled by default
1155 Y1, // enabled by default
1156
1157 NUM_OPTIONS,
1158 };
1159
1160 enum class AxisFlags {
1161 None = 0,
1162 NoLabel = 1<<0,
1163 NoGridLines = 1<<1,
1164 NoTickMarks = 1<<2,
1165 NoTickLabels = 1<<3,
1166 NoMenus = 1<<5,
1167 AutoFit = 1<<11,
1168 LockMin = 1<<14,
1169 LockMax = 1<<15,
1170
1171 Default = None,
1172 Lock = LockMin | LockMax,
1173 NoDecorations = NoLabel | NoGridLines | NoTickMarks | NoTickLabels,
1174 };
1175
1176 constexpr AxisFlags operator|(AxisFlags lhs, AxisFlags rhs)
1177 {
1178 return static_cast<AxisFlags>(std::to_underlying(lhs) | std::to_underlying(rhs));
1179 }
1180
1181 enum class Condition {
1182 Always, // unconditional, i.e. the function should always do what is being asked
1183 Once, // only perform the action once per runtime session (only the first call will succeed)
1184 NUM_OPTIONS,
1185 };
1186
1187 enum class MarkerType {
1188 None, // i.e. no marker
1189 Circle,
1190 NUM_OPTIONS,
1191 };
1192
1193 enum class DragToolFlag : uint8_t {
1194 None = 0,
1195 NoFit = 1<<1,
1196 NoInputs = 1<<2,
1197 NUM_FLAGS = 2,
1198
1199 Default = None,
1200 };
1202
1203 enum class Location {
1204 Center,
1205 North,
1206 NorthEast,
1207 East,
1208 SouthEast,
1209 South,
1210 SouthWest,
1211 West,
1212 NorthWest,
1213 NUM_OPTIONS,
1214
1215 Default = Center,
1216 };
1217
1218 enum class LegendFlags {
1219 None = 0,
1220 Outside = 1<<4,
1221
1222 Default = None,
1223 };
1224
1225 constexpr bool operator&(LegendFlags lhs, LegendFlags rhs)
1226 {
1227 return (std::to_underlying(lhs) & std::to_underlying(rhs)) != 0;
1228 }
1229
1230 constexpr LegendFlags operator^(LegendFlags lhs, LegendFlags rhs)
1231 {
1232 return static_cast<LegendFlags>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
1233 }
1234
1235 // draws the plotting demo in its own panel
1236 void show_demo_panel();
1237
1238 // starts a 2D plotting context
1239 //
1240 // - if this function returns `true`, then `plot::end` MUST be called
1241 // - `title` must be unique to the current ID scope/stack
1242 // - `size` is the total size of the plot including axis labels, title, etc.
1243 // you can call `get_plot_screen_rect` after finishing setup to figure out
1244 // the bounds of the plot area (i.e. where the data is)
1245 bool begin(CStringView title, Vector2 size, PlotFlags = PlotFlags::Default);
1246
1247 // ends a 2D plotting context
1248 //
1249 // this must be called if `plot::begin` returns `true`
1250 void end();
1251
1252 // temporarily modifies a style variable of `float` type. Must be paired with `pop_style_var`
1253 void push_style_var(PlotStyleVar, float);
1254
1255 // temporarily modifies a style variable of `Vector2` type. Must be paired with `pop_style_var`
1256 void push_style_var(PlotStyleVar, Vector2);
1257
1258 // undoes `count` temporary style variable modifications that were enacted by `push_style_var`
1259 void pop_style_var(int count = 1);
1260
1261 // temporarily modifies a style color variable. Must be paired with `pop_style_color`
1262 void push_style_color(PlotColorVar, const Color&);
1263
1264 // undoes `count` temporary style color modifications that were enacted by `push_style_color`
1265 void pop_style_color(int count = 1);
1266
1267 // enables an axis or sets the label and/or the flags of an existing axis
1268 void setup_axis(Axis, std::optional<CStringView> label = std::nullopt, AxisFlags = AxisFlags::Default);
1269
1270 // sets the label and/or the flags for the primary X and Y axes (shorthand for two calls to `setup_axis`)
1271 void setup_axes(CStringView x_label, CStringView y_label, AxisFlags x_flags = AxisFlags::Default, AxisFlags y_flags = AxisFlags::Default);
1272
1273 // sets an axis's range limits. If `Condition::Always` is used, the axes limits will be locked
1274 void setup_axis_limits(Axis axis, ClosedInterval<float> data_range, float padding_percentage, Condition = Condition::Once);
1275
1276 // explicitly finalizes plot setup
1277 //
1278 // - once this is called, you cannot call any `plot::setup_*` functions for
1279 // in the current 2D plotting context
1280 // - calling this function is OPTIONAL - the implementation will automatically
1281 // call it on the first setup-locking API call (e.g. `plot::draw_line`)
1282 void setup_finish();
1283
1284 // sets the marker style for the next item only
1285 void set_next_marker_style(
1286 MarkerType = MarkerType::None,
1287 std::optional<float> size = std::nullopt,
1288 std::optional<Color> fill = std::nullopt,
1289 std::optional<float> weight = std::nullopt,
1290 std::optional<Color> outline = std::nullopt
1291 );
1292
1293 // plots a standard 2D line plot
1294 void plot_line(CStringView name, std::span<const Vector2> points);
1295 void plot_line(CStringView name, std::span<const float> y_values, std::optional<ClosedInterval<float>> x_range = std::nullopt);
1296
1297 // returns the plot's rectangle in ui space
1298 //
1299 // must be called between `plot::begin` and `plot::end`
1300 Rect get_plot_ui_rect();
1301
1302 // draws an annotation callout at a chosen point
1303 //
1304 // - clamping keeps annotations in the plot area
1305 // - annotations are always rendered on top of the plot area
1306 namespace detail
1307 {
1308 void draw_annotation_v(Vector2 position_dataspace, const Color& color, Vector2 pixel_offset, bool clamp, CStringView fmt, va_list args);
1309 }
1310 inline void draw_annotation(Vector2 position_dataspace, const Color& color, Vector2 pixel_offset, bool clamp, CStringView fmt, ...)
1311 {
1312 va_list args;
1313 va_start(args, fmt);
1314 detail::draw_annotation_v(position_dataspace, color, pixel_offset, clamp, fmt, args);
1315 va_end(args);
1316 }
1317
1318 // draws a draggable point at `plot_point`, expressed in plot space, in
1319 // the plot area
1320 //
1321 // - returns `true` if the user has interacted with the point. In this
1322 // case, `plot_point` will be updated with user's interaction position
1323 // in plot space.
1324 bool drag_point(
1325 int id,
1326 Vector2d* plot_point,
1327 const Color&,
1328 float size = 4,
1329 DragToolFlags = DragToolFlag::Default
1330 );
1331
1332 // draws a draggable vertical guideline at an x value (plot space) in the
1333 // plot area.
1334 bool drag_line_x(
1335 int id,
1336 double* plot_x,
1337 const Color&,
1338 float thickness = 1,
1339 DragToolFlags = DragToolFlag::Default
1340 );
1341
1342 // draws a draggable horizontal guideline at a y value (plot space) in the
1343 // plot area.
1344 bool drag_line_y(
1345 int id,
1346 double* plot_y,
1347 const Color&,
1348 float thickness = 1,
1349 DragToolFlags = DragToolFlag::Default
1350 );
1351
1352 // draws a tag on the x-axis at the specified x value in plot space
1353 void tag_x(double plot_x, const Color&, bool round = false);
1354
1355 // returns `true` if the plot area in the current plot is hovered
1356 bool is_plot_hovered();
1357
1358 // returns the position of the mouse in plot space
1359 Vector2 get_plot_mouse_position();
1360
1361 // returns the mouse position in the coordinate system of the given axes
1362 Vector2 get_plot_mouse_position(Axis x_axis, Axis y_axis);
1363
1364 // sets up the plot legend
1365 void setup_legend(Location, LegendFlags = LegendFlags::Default);
1366
1367 // begins a popup for a legend entry
1368 bool begin_legend_popup(CStringView label_id, MouseButton = MouseButton::Right);
1369
1370 // ends a popup for a legend entry
1371 void end_legend_popup();
1372 }
1373}
Definition angle.h:26
Definition app.h:45
Definition c_string_view.h:13
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:47
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:74
bool on_event(Event &)
Context(Context &&) noexcept=delete
Context(const Context &)=delete
Context(App &, const ContextConfiguration &={})
void on_start_new_frame()
Definition oscimgui.h:578
DrawListAPI(DrawListAPI &&) noexcept=default
DrawListAPI(const DrawListAPI &)=default
Definition oscimgui.h:603
ImDrawList & impl_get_drawlist() final
Definition oscimgui.h:609
DrawListView(ImDrawList *inner_list)
Definition oscimgui.h:605
Definition oscimgui.h:614
ImDrawList & impl_get_drawlist() final
Definition oscimgui.h:626
DrawList(const DrawList &)=delete
DrawList(DrawList &&) noexcept
Definition oscimgui.h:1003
GizmoOperation operation() const
Definition oscimgui.h:1039
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:1041
bool is_over() const
void set_mode(GizmoMode mode)
Definition oscimgui.h:1042
bool is_using() const
bool handle_keyboard_inputs()
bool was_using() const
Definition oscimgui.h:1037
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:1040
Definition oscimgui.h:43
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:282
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:233
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()
ColumnFlag
Definition oscimgui.h:549
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:309
void draw_text_disabled(std::string_view)
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)
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:133
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:267
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:196
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 draw_text(std::string_view)
void set_num_columns(int count=1, std::optional< CStringView > id=std::nullopt, bool border=true)
TableFlag
Definition oscimgui.h:510
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()
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:485
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 set_tooltip(CStringView text)
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()
void set_tooltip_fmt(std::format_string< Args... > fmt, Args &&... args)
Definition oscimgui.h:324
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:219
Vector2 get_mouse_ui_position()
TabItemFlag
Definition oscimgui.h:173
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:1063
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:988
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:978
StyleVar
Definition oscimgui.h:461
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:435
ItemFlag
Definition oscimgui.h:411
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:479
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:228
void draw_text_wrapped(std::string_view)
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:304
SortDirection
Definition oscimgui.h:532
void draw_text_panel_centered(CStringView)
void show_demo_panel()
HoveredFlag
Definition oscimgui.h:379
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 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:314
Conditional
Definition oscimgui.h:364
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:320
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:996
std::optional< Vector3 > position
Definition oscimgui.h:999
std::optional< Vector3 > scale
Definition oscimgui.h:997
std::optional< Radians > rotation
Definition oscimgui.h:998
Definition oscimgui.h:720
Definition oscimgui.h:203
ID()=default
unsigned int value() const
Definition oscimgui.h:208
ID(unsigned int value)
Definition oscimgui.h:206
Definition oscimgui.h:539