Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
GUIUtils.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2013-2020 Petr Ohlidal
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include "Application.h"
23#include "GUIManager.h"
24
25namespace RoR {
26
28{
29 ImTextFeeder(ImDrawList* _drawlist, ImVec2 _origin);
30
32 void AddInline(ImU32 color, ImVec2 text_size, const char* text, const char* text_end);
34 void AddWrapped(ImU32 color, float wrap_width, const char* text, const char* text_end);
36 void AddMultiline(ImU32 color, float wrap_width, const char* text, const char* text_end);
38 void AddRectWrapped(ImVec2 size, ImVec2 spacing, float wrap_width, ImVec2& out_rect_min);
39 void NextLine();
40
41 ImDrawList* drawlist = nullptr;
42 ImVec2 cursor;
43 ImVec2 origin;
44 ImVec2 size = ImVec2(0,0);
45 float line_height = 0.f;
46};
47
49void LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed);
50
52void DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle);
53
55ImVec2 DrawColorMarkedText(ImDrawList* drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const& line);
56
57std::string StripColorMarksFromText(std::string const& text);
58
60void ImTextWrappedColorMarked(std::string const& text);
61
62bool DrawGCheckbox(CVar* cvar, const char* label);
63
64void DrawGIntCheck(CVar* cvar, const char* label);
65
66void DrawGIntBox(CVar* cvar, const char* label);
67
68void DrawGIntSlider(CVar* cvar, const char* label, int v_min, int v_max);
69
70void DrawGFloatSlider(CVar* cvar, const char* label, float v_min, float v_max);
71
72void DrawGFloatBox(CVar* cvar, const char* label);
73
74void DrawGTextEdit(CVar* cvar, const char* label, Str<1000>& buf);
75
76bool DrawGCombo(CVar* cvar, const char* label, const char* values);
77
78Ogre::TexturePtr FetchIcon(const char* name);
79
80// Fullscreen drawing helpers
81ImDrawList* GetImDummyFullscreenWindow(const std::string& name = "RoR_TransparentFullscreenWindow");
82bool GetScreenPosFromWorldPos(Ogre::Vector3 const& world_pos, ImVec2& out_screen);
83
84// Helpers for coposing combobox item strings.
85void ImAddItemToComboboxString(std::string& target, std::string const& item);
86void ImTerminateComboboxString(std::string& target);
87
88// Input engine helpers
89void ImDrawEventHighlighted(events input_event);
90bool ImDrawEventHighlightedButton(events input_event, bool* btn_hovered = nullptr, bool* btn_active = nullptr);
91void ImDrawModifierKeyHighlighted(OIS::KeyCode key);
92ImVec2 ImCalcEventHighlightedSize(events input_event);
93
94// Draws button which must be held for a period to report "clicked" - shows a tooltip with countdown progressbar.
95bool ImButtonHoldToConfirm(const std::string& btn_idstr, const bool smallbutton, const float time_limit);
96
97// Returns true if succeeded (needs the text box to have focus).
98bool ImMoveTextInputCursorToEnd(const char* label);
99
101void ImDummyHyperlink(std::string caption);
102void ImHyperlink(std::string url, std::string caption = "", bool tooltip = true);
103
104} // namespace RoR
Central state/object manager and communications hub.
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition CVar.h:53
Wrapper for classic c-string (local buffer) Refresher: strlen() excludes '\0' terminator; strncat() A...
Definition Str.h:36
void ImDrawEventHighlighted(events input_event)
Definition GUIUtils.cpp:446
void ImDummyHyperlink(std::string caption)
Looks and behaves (mouuse cursor) like a hypertext, but doesn't open URL.
Definition GUIUtils.cpp:594
ImVec2 DrawColorMarkedText(ImDrawList *drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const &line)
Draw multiline text with '#rrggbb' color markers. Returns total text size.
Definition GUIUtils.cpp:230
void DrawGFloatBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:336
void DrawGTextEdit(CVar *cvar, const char *label, Str< 1000 > &buf)
Definition GUIUtils.cpp:345
void ImHyperlink(std::string url, std::string caption="", bool tooltip=true)
Full-featured hypertext with tooltip showing full URL.
Definition GUIUtils.cpp:612
ImDrawList * GetImDummyFullscreenWindow(const std::string &name="RoR_TransparentFullscreenWindow")
Definition GUIUtils.cpp:394
bool ImDrawEventHighlightedButton(events input_event, bool *btn_hovered=nullptr, bool *btn_active=nullptr)
Definition GUIUtils.cpp:462
void DrawGIntSlider(CVar *cvar, const char *label, int v_min, int v_max)
Definition GUIUtils.cpp:316
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
Definition GUIUtils.cpp:272
void DrawGIntBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:307
void ImTerminateComboboxString(std::string &target)
Definition GUIUtils.cpp:434
ImVec2 ImCalcEventHighlightedSize(events input_event)
Definition GUIUtils.cpp:505
bool GetScreenPosFromWorldPos(Ogre::Vector3 const &world_pos, ImVec2 &out_screen)
Definition GUIUtils.cpp:578
void DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle)
Add rotated textured quad to ImDrawList, source: https://github.com/ocornut/imgui/issues/1982#issueco...
Definition GUIUtils.cpp:201
void ImAddItemToComboboxString(std::string &target, std::string const &item)
Definition GUIUtils.cpp:412
void ImDrawModifierKeyHighlighted(OIS::KeyCode key)
Definition GUIUtils.cpp:489
void DrawGFloatSlider(CVar *cvar, const char *label, float v_min, float v_max)
Definition GUIUtils.cpp:326
bool DrawGCheckbox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:287
std::string StripColorMarksFromText(std::string const &text)
Definition GUIUtils.cpp:225
void DrawGIntCheck(CVar *cvar, const char *label)
Definition GUIUtils.cpp:298
bool DrawGCombo(CVar *cvar, const char *label, const char *values)
Definition GUIUtils.cpp:361
Ogre::TexturePtr FetchIcon(const char *name)
Definition GUIUtils.cpp:372
void LoadingIndicatorCircle(const char *label, const float indicator_radius, const ImVec4 &main_color, const ImVec4 &backdrop_color, const int circle_count, const float speed)
Draws animated loading spinner.
Definition GUIUtils.cpp:158
bool ImMoveTextInputCursorToEnd(const char *label)
Definition GUIUtils.cpp:556
bool ImButtonHoldToConfirm(const std::string &btn_idstr, const bool smallbutton, const float time_limit)
Definition GUIUtils.cpp:512
Helper for drawing multiline wrapped & colored text.
Definition GUIUtils.h:28
ImVec2 size
Accumulated text size.
Definition GUIUtils.h:44
void AddInline(ImU32 color, ImVec2 text_size, const char *text, const char *text_end)
No wrapping or trimming.
Definition GUIUtils.cpp:42
void AddRectWrapped(ImVec2 size, ImVec2 spacing, float wrap_width, ImVec2 &out_rect_min)
Reserves space for i.e. an image. wrap_width=-1.f disables wrapping.
Definition GUIUtils.cpp:124
void AddWrapped(ImU32 color, float wrap_width, const char *text, const char *text_end)
Wraps entire input. Trims leading blanks on extra lines. wrap_width=-1.f disables wrapping.
Definition GUIUtils.cpp:50
ImDrawList * drawlist
Definition GUIUtils.h:41
void AddMultiline(ImU32 color, float wrap_width, const char *text, const char *text_end)
Wraps substrings separated by blanks. wrap_width=-1.f disables wrapping.
Definition GUIUtils.cpp:78
ImVec2 cursor
Next draw position, screen space.
Definition GUIUtils.h:42
ImVec2 origin
First draw position, screen space.
Definition GUIUtils.h:43