RigsofRods
Soft-body Physics Simulation
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 
25 namespace RoR {
26 
27 struct ImTextFeeder
28 {
29  ImTextFeeder(ImDrawList* _drawlist, ImVec2 _origin): drawlist(_drawlist), origin(_origin), cursor(_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);
37  void NextLine();
38 
39  ImDrawList* drawlist;
40  ImVec2 cursor;
41  ImVec2 origin;
42  ImVec2 size = ImVec2(0,0);
43 };
44 
46 void LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, const int circle_count, const float speed);
47 
49 void DrawImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle);
50 
52 ImVec2 DrawColorMarkedText(ImDrawList* drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const& line);
53 
54 std::string StripColorMarksFromText(std::string const& text);
55 
57 void ImTextWrappedColorMarked(std::string const& text);
58 
59 bool DrawGCheckbox(CVar* cvar, const char* label);
60 
61 void DrawGIntCheck(CVar* cvar, const char* label);
62 
63 void DrawGIntBox(CVar* cvar, const char* label);
64 
65 void DrawGIntSlider(CVar* cvar, const char* label, int v_min, int v_max);
66 
67 void DrawGFloatSlider(CVar* cvar, const char* label, float v_min, float v_max);
68 
69 void DrawGFloatBox(CVar* cvar, const char* label);
70 
71 void DrawGTextEdit(CVar* cvar, const char* label, Str<1000>& buf);
72 
73 void DrawGCombo(CVar* cvar, const char* label, const char* values);
74 
75 Ogre::TexturePtr FetchIcon(const char* name);
76 
77 ImDrawList* GetImDummyFullscreenWindow();
78 
79 // Helpers for coposing combobox item strings.
80 void ImAddItemToComboboxString(std::string& target, std::string const& item);
81 void ImTerminateComboboxString(std::string& target);
82 
83 // Input engine helpers
84 void ImDrawEventHighlighted(events input_event);
85 void ImDrawModifierKeyHighlighted(OIS::KeyCode key);
86 
87 // Draws button which must be held for a period to report "clicked" - shows a tooltip with countdown progressbar.
88 bool ImButtonHoldToConfirm(const std::string& btn_idstr, const bool smallbutton, const float time_limit);
89 
90 } // namespace RoR
RoR::ImTextWrappedColorMarked
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
Definition: GUIUtils.cpp:245
RoR::ImAddItemToComboboxString
void ImAddItemToComboboxString(std::string &target, std::string const &item)
Definition: GUIUtils.cpp:373
RoR::StripColorMarksFromText
std::string StripColorMarksFromText(std::string const &text)
Definition: GUIUtils.cpp:198
RoR::DrawGFloatSlider
void DrawGFloatSlider(CVar *cvar, const char *label, float v_min, float v_max)
Definition: GUIUtils.cpp:299
RoR::FetchIcon
Ogre::TexturePtr FetchIcon(const char *name)
Definition: GUIUtils.cpp:343
RoR::ImTextFeeder::cursor
ImVec2 cursor
Next draw position, screen space.
Definition: GUIUtils.h:40
RoR::ImTextFeeder::AddMultiline
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:70
RoR::DrawGCombo
void DrawGCombo(CVar *cvar, const char *label, const char *values)
Definition: GUIUtils.cpp:334
RoR::DrawGTextEdit
void DrawGTextEdit(CVar *cvar, const char *label, Str< 1000 > &buf)
Definition: GUIUtils.cpp:318
RoR::DrawGIntBox
void DrawGIntBox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:280
RoR::ImTextFeeder::size
ImVec2 size
Accumulated text size.
Definition: GUIUtils.h:42
RoR::DrawColorMarkedText
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:203
RoR::ImDrawModifierKeyHighlighted
void ImDrawModifierKeyHighlighted(OIS::KeyCode key)
Definition: GUIUtils.cpp:424
RoR::ImTextFeeder::AddInline
void AddInline(ImU32 color, ImVec2 text_size, const char *text, const char *text_end)
No wrapping or trimming.
Definition: GUIUtils.cpp:34
RoR::DrawGFloatBox
void DrawGFloatBox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:309
RoR::ImTextFeeder::NextLine
void NextLine()
Definition: GUIUtils.cpp:116
RoR::DrawGIntSlider
void DrawGIntSlider(CVar *cvar, const char *label, int v_min, int v_max)
Definition: GUIUtils.cpp:289
RoR::ImTextFeeder
Helper for drawing multiline wrapped & colored text.
Definition: GUIUtils.h:27
GUIManager.h
RoR::Str< 1000 >
RoR::GetImDummyFullscreenWindow
ImDrawList * GetImDummyFullscreenWindow()
Definition: GUIUtils.cpp:355
RoR::ImButtonHoldToConfirm
bool ImButtonHoldToConfirm(const std::string &btn_idstr, const bool smallbutton, const float time_limit)
Definition: GUIUtils.cpp:440
Application.h
Central state/object manager and communications hub.
RoR::DrawGIntCheck
void DrawGIntCheck(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:271
RoR::CVar
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition: CVar.h:52
RoR::ImTextFeeder::AddWrapped
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:42
RoR::ImTextFeeder::ImTextFeeder
ImTextFeeder(ImDrawList *_drawlist, ImVec2 _origin)
Definition: GUIUtils.h:29
RoR::ImTextFeeder::origin
ImVec2 origin
First draw position, screen space.
Definition: GUIUtils.h:41
RoR::ImTerminateComboboxString
void ImTerminateComboboxString(std::string &target)
Definition: GUIUtils.cpp:395
RoR::DrawGCheckbox
bool DrawGCheckbox(CVar *cvar, const char *label)
Definition: GUIUtils.cpp:260
RoR::ImDrawEventHighlighted
void ImDrawEventHighlighted(events input_event)
Definition: GUIUtils.cpp:407
RoR::events
events
Definition: InputEngine.h:74
RoR::ImTextFeeder::drawlist
ImDrawList * drawlist
Definition: GUIUtils.h:39
RoR::LoadingIndicatorCircle
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:131
RoR
Definition: AppContext.h:36
RoR::DrawImageRotated
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:174