Geogram Version 1.9.6-rc
A programming library of geometric algorithms
Loading...
Searching...
No Matches
imgui_ext.h
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef GEOGRAM_GFX_IMGUI_EXT
41#define GEOGRAM_GFX_IMGUI_EXT
42
44#include <string>
45
46#ifdef GEO_COMPILER_GCC_FAMILY
47#pragma GCC diagnostic push
48#pragma GCC diagnostic ignored "-Wsign-conversion"
49#ifdef GEO_COMPILER_CLANG
50#pragma GCC diagnostic ignored "-Wunknown-warning-option"
51#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
52#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic"
53#endif
54#endif
55
56#include <geogram_gfx/third_party/imgui/imgui.h>
57#include <geogram_gfx/third_party/imgui/misc/cpp/imgui_stdlib.h>
58
59#if defined(GEO_COMPILER_GCC_FAMILY)
60#pragma GCC diagnostic pop
61#endif
62
63
69namespace GEO {
75 enum { geo_imgui_string_length = 4096 };
76
77 namespace FileSystem {
78 class Node;
79 }
80}
81
82typedef int ImGuiExtFileDialogFlags;
83
84
85enum ImGuiExtFileDialogFlags_ {
86 ImGuiExtFileDialogFlags_Load = 1,
87 ImGuiExtFileDialogFlags_Save = 2
88};
89
90
91namespace ImGui {
92
100 float GEOGRAM_GFX_API scaling();
101
109 void GEOGRAM_GFX_API set_scaling(float x);
110
120 bool GEOGRAM_GFX_API ColorEdit3WithPalette(
121 const char* label, float* color
122 );
123
133 bool GEOGRAM_GFX_API ColorEdit4WithPalette(
134 const char* label, float* color
135 );
136
148 void GEOGRAM_GFX_API OpenFileDialog(
149 const char* label,
150 const char* extensions,
151 const char* filename,
152 ImGuiExtFileDialogFlags flags,
153 GEO::FileSystem::Node* root = nullptr
154 );
155
166 bool GEOGRAM_GFX_API FileDialog(
167 const char* label,
168 char* filename, size_t filename_buff_len
169 );
170
174 inline bool MenuItem(
175 const std::string& name, const char* shortcut,
176 bool* p_selected = nullptr, bool enabled = true
177 ) {
178 return ImGui::MenuItem(name.c_str(), shortcut, p_selected, enabled);
179 }
180
184 inline bool MenuItem(
185 const std::string& name, const char* shortcut = nullptr,
186 bool selected = false, bool enabled = true
187 ) {
188 return ImGui::MenuItem(name.c_str(), shortcut, selected, enabled);
189 }
190
194 inline bool BeginMenu(const std::string& name) {
195 return ImGui::BeginMenu(name.c_str());
196 }
197
201 inline bool Button(const std::string& name) {
202 return ImGui::Button(name.c_str());
203 }
204
212 void GEOGRAM_GFX_API Tooltip(const char* str);
213
221 inline void Tooltip(const std::string& s) {
222 Tooltip(s.c_str());
223 }
224
229 void GEOGRAM_GFX_API EnableTooltips();
230
235 void GEOGRAM_GFX_API DisableTooltips();
236
237
241 bool GEOGRAM_GFX_API SimpleButton(const char* label);
242
246 bool GEOGRAM_GFX_API SimpleButton(const char* label, const ImVec2& size);
247
251 inline bool SimpleButton(const std::string& label) {
252 return SimpleButton(label.c_str());
253 }
254
259 void GEOGRAM_GFX_API CenteredText(const char* text);
260
261}
262
263#endif
A Node in a FileSystem.
Definition file_system.h:69
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition defs.h:55
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
Definition basic.h:55