Skip to content

Commit ee59d7a

Browse files
committed
Merge branch 'features/viewport_in_master' into docking (WIP need adding code for new ImGuiViewportFlags values)
# Conflicts: # imgui.cpp # imgui.h # imgui_demo.cpp # imgui_internal.h # imgui_widgets.cpp
2 parents 3607c42 + f14042c commit ee59d7a

File tree

6 files changed

+221
-134
lines changed

6 files changed

+221
-134
lines changed

.github/workflows/build.yml

+122-79
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: build
22

33
on:
4-
push: {}
5-
pull_request: {}
4+
push:
5+
pull_request:
66
schedule:
77
- cron: '0 9 * * *'
88

@@ -12,21 +12,19 @@ jobs:
1212
env:
1313
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
1414
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
15-
# Until gh-actions allow us to use env variables inside other env variables (because we need %GITHUB_WORKSPACE%) we have to use relative path to imgui/examples/example_name directory.
16-
SDL2_DIR: ..\..\SDL2-devel-2.0.10-VC\SDL2-2.0.10\
17-
VULKAN_SDK: ..\..\vulkan-sdk-1.1.121.2\
1815
steps:
19-
- uses: actions/checkout@v1
20-
with:
21-
fetch-depth: 1
16+
- uses: actions/checkout@v2
2217

2318
- name: Install Dependencies
2419
shell: powershell
2520
run: |
2621
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip"
2722
Expand-Archive -Path SDL2-devel-2.0.10-VC.zip
23+
echo "SDL2_DIR=$(pwd)\SDL2-devel-2.0.10-VC\SDL2-2.0.10\" >>${env:GITHUB_ENV}
24+
2825
Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
2926
Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
27+
echo "VULKAN_SDK=$(pwd)\vulkan-sdk-1.1.121.2\" >>${env:GITHUB_ENV}
3028
3129
- name: Fix Projects
3230
shell: powershell
@@ -55,31 +53,41 @@ jobs:
5553
- name: Build example_null (single file build)
5654
shell: bash
5755
run: |
58-
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
59-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
60-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
56+
cat > example_single_file.cpp <<'EOF'
57+
58+
#define IMGUI_IMPLEMENTATION
59+
#include "misc/single_file/imgui_single_file.h"
60+
#include "examples/example_null/main.cpp"
61+
62+
EOF
6163
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
6264
6365
- name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS)
6466
shell: bash
6567
run: |
66-
echo '#define IMGUI_DISABLE_WIN32_FUNCTIONS' > example_single_file.cpp
67-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
68-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
69-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
68+
cat > example_single_file.cpp <<'EOF'
69+
70+
#define IMGUI_DISABLE_WIN32_FUNCTIONS
71+
#define IMGUI_IMPLEMENTATION
72+
#include "misc/single_file/imgui_single_file.h"
73+
#include "examples/example_null/main.cpp"
74+
75+
EOF
7076
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
7177
7278
- name: Build example_null (as DLL)
7379
shell: cmd
7480
run: |
7581
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
82+
7683
echo #ifdef _EXPORT > example_single_file.cpp
7784
echo # define IMGUI_API __declspec(dllexport) >> example_single_file.cpp
7885
echo #else >> example_single_file.cpp
7986
echo # define IMGUI_API __declspec(dllimport) >> example_single_file.cpp
8087
echo #endif >> example_single_file.cpp
8188
echo #define IMGUI_IMPLEMENTATION >> example_single_file.cpp
8289
echo #include "misc/single_file/imgui_single_file.h" >> example_single_file.cpp
90+
8391
cl.exe /D_USRDLL /D_WINDLL /D_EXPORT /I. example_single_file.cpp /LD /FeImGui.dll /link
8492
cl.exe /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
8593
@@ -183,9 +191,7 @@ jobs:
183191
Linux:
184192
runs-on: ubuntu-20.04
185193
steps:
186-
- uses: actions/checkout@v1
187-
with:
188-
fetch-depth: 1
194+
- uses: actions/checkout@v2
189195

190196
- name: Install Dependencies
191197
run: |
@@ -219,82 +225,118 @@ jobs:
219225
220226
- name: Build example_null (single file build)
221227
run: |
222-
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
223-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
224-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
228+
cat > example_single_file.cpp <<'EOF'
229+
230+
#define IMGUI_IMPLEMENTATION
231+
#include "misc/single_file/imgui_single_file.h"
232+
#include "examples/example_null/main.cpp"
233+
234+
EOF
225235
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
226236
227237
- name: Build example_null (with ImWchar32)
228238
run: |
229-
echo '#define IMGUI_USE_WCHAR32' > example_single_file.cpp
230-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
231-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
232-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
239+
cat > example_single_file.cpp <<'EOF'
240+
241+
#define IMGUI_USE_WCHAR32
242+
#define IMGUI_IMPLEMENTATION
243+
#include "misc/single_file/imgui_single_file.h"
244+
#include "examples/example_null/main.cpp"
245+
246+
EOF
233247
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
234248
235249
- name: Build example_null (with large ImDrawIdx)
236250
run: |
237-
echo '#define ImDrawIdx unsigned int' > example_single_file.cpp
238-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
239-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
240-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
251+
cat > example_single_file.cpp <<'EOF'
252+
253+
#define ImDrawIdx unsigned int
254+
#define IMGUI_IMPLEMENTATION
255+
#include "misc/single_file/imgui_single_file.h"
256+
#include "examples/example_null/main.cpp"
257+
258+
EOF
241259
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
242260
243261
- name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
244262
run: |
245-
echo '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' > example_single_file.cpp
246-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
247-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
248-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
263+
cat > example_single_file.cpp <<'EOF'
264+
265+
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
266+
#define IMGUI_IMPLEMENTATION
267+
#include "misc/single_file/imgui_single_file.h"
268+
#include "examples/example_null/main.cpp"
269+
270+
EOF
249271
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
250272
251273
- name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW)
252274
run: |
253-
echo '#define IMGUI_DISABLE_DEMO_WINDOWS' > example_single_file.cpp
254-
echo '#define IMGUI_DISABLE_METRICS_WINDOW' >> example_single_file.cpp
255-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
256-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
257-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
275+
cat > example_single_file.cpp <<'EOF'
276+
277+
#define IMGUI_DISABLE_DEMO_WINDOWS
278+
#define IMGUI_DISABLE_METRICS_WINDOW
279+
#define IMGUI_IMPLEMENTATION
280+
#include "misc/single_file/imgui_single_file.h"
281+
#include "examples/example_null/main.cpp"
282+
283+
EOF
258284
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
259285
260286
- name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS)
261287
run: |
262-
echo '#define IMGUI_DISABLE_FILE_FUNCTIONS' > example_single_file.cpp
263-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
264-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
265-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
288+
cat > example_single_file.cpp <<'EOF'
289+
290+
#define IMGUI_DISABLE_FILE_FUNCTIONS
291+
#define IMGUI_IMPLEMENTATION
292+
#include "misc/single_file/imgui_single_file.h"
293+
#include "examples/example_null/main.cpp"
294+
295+
EOF
266296
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
267297
268298
- name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR)
269299
run: |
270-
echo '#define IMGUI_USE_BGRA_PACKED_COLOR' > example_single_file.cpp
271-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
272-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
273-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
300+
cat > example_single_file.cpp <<'EOF'
301+
302+
#define IMGUI_USE_BGRA_PACKED_COLOR
303+
#define IMGUI_IMPLEMENTATION
304+
#include "misc/single_file/imgui_single_file.h"
305+
#include "examples/example_null/main.cpp"
306+
307+
EOF
274308
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
275309
276310
- name: Build example_null (with IM_VEC2_CLASS_EXTRA and IM_VEC4_CLASS_EXTRA)
277311
run: |
278-
echo 'struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };' > example_single_file.cpp
279-
echo 'struct MyVec4 { float x; float y; float z; float w;' >> example_single_file.cpp
280-
echo 'MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };' >> example_single_file.cpp
281-
echo '#define IM_VEC2_CLASS_EXTRA \' >> example_single_file.cpp
282-
echo ' ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \' >> example_single_file.cpp
283-
echo ' operator MyVec2() const { return MyVec2(x, y); }' >> example_single_file.cpp
284-
echo '#define IM_VEC4_CLASS_EXTRA \' >> example_single_file.cpp
285-
echo ' ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \' >> example_single_file.cpp
286-
echo ' operator MyVec4() const { return MyVec4(x, y, z, w); }' >> example_single_file.cpp
287-
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
288-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
289-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
312+
cat > example_single_file.cpp <<'EOF'
313+
314+
struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };
315+
struct MyVec4 { float x; float y; float z; float w;
316+
MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };
317+
#define IM_VEC2_CLASS_EXTRA \
318+
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
319+
operator MyVec2() const { return MyVec2(x, y); }
320+
#define IM_VEC4_CLASS_EXTRA \
321+
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
322+
operator MyVec4() const { return MyVec4(x, y, z, w); }
323+
#define IMGUI_IMPLEMENTATION
324+
#include "misc/single_file/imgui_single_file.h"
325+
#include "examples/example_null/main.cpp"
326+
327+
EOF
290328
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
291329
292330
- name: Build example_null (without c++ runtime, Clang)
293331
run: |
294-
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
295-
echo '#define IMGUI_DISABLE_DEMO_WINDOWS' >> example_single_file.cpp
296-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
297-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
332+
cat > example_single_file.cpp <<'EOF'
333+
334+
#define IMGUI_IMPLEMENTATION
335+
#define IMGUI_DISABLE_DEMO_WINDOWS
336+
#include "misc/single_file/imgui_single_file.h"
337+
#include "examples/example_null/main.cpp"
338+
339+
EOF
298340
clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
299341
300342
- name: Build example_glfw_opengl2
@@ -314,30 +356,35 @@ jobs:
314356
MacOS:
315357
runs-on: macOS-latest
316358
steps:
317-
- uses: actions/checkout@v1
318-
with:
319-
fetch-depth: 1
359+
- uses: actions/checkout@v2
320360

321361
- name: Install Dependencies
322362
run: |
323-
brew install glfw3
324-
brew install sdl2
363+
brew install glfw3 sdl2
325364
326365
- name: Build example_null (extra warnings, clang 64-bit)
327366
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
328367

329368
- name: Build example_null (single file build)
330369
run: |
331-
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
332-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
333-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
370+
cat > example_single_file.cpp <<'EOF'
371+
372+
#define IMGUI_IMPLEMENTATION
373+
#include "misc/single_file/imgui_single_file.h"
374+
#include "examples/example_null/main.cpp"
375+
376+
EOF
334377
clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
335378
336379
- name: Build example_null (without c++ runtime)
337380
run: |
338-
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
339-
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
340-
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
381+
cat > example_single_file.cpp <<'EOF'
382+
383+
#define IMGUI_IMPLEMENTATION
384+
#include "misc/single_file/imgui_single_file.h"
385+
#include "examples/example_null/main.cpp"
386+
387+
EOF
341388
clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
342389
343390
- name: Build example_glfw_opengl2
@@ -369,9 +416,7 @@ jobs:
369416
iOS:
370417
runs-on: macOS-latest
371418
steps:
372-
- uses: actions/checkout@v1
373-
with:
374-
fetch-depth: 1
419+
- uses: actions/checkout@v2
375420

376421
- name: Build example_apple_metal
377422
run: |
@@ -381,9 +426,7 @@ jobs:
381426
Emscripten:
382427
runs-on: ubuntu-18.04
383428
steps:
384-
- uses: actions/checkout@v1
385-
with:
386-
fetch-depth: 1
429+
- uses: actions/checkout@v2
387430

388431
- name: Install Dependencies
389432
run: |

docs/CHANGELOG.txt

+18-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ Breaking Changes:
124124

125125
Other Changes:
126126

127+
- Viewports Added ImGui::GetMainViewport() as a way to get the bounds and work area of the host display. (#3789, #1542)
128+
- In 'master' branch or without multi-viewports feature enabled:
129+
- GetMainViewport()->Pos is always == (0,0)
130+
- GetMainViewport()->Size is always == io.DisplaySize
131+
- In 'docking' branch and with the multi-viewports feature enabled:
132+
- GetMainViewport() will return information from your host Platform Window.
133+
- In the future, we will support a "no main viewport" mode and this may return bounds of your main monitor.
134+
- For forward compatibility with multi-viewports/multi-monitors:
135+
- Code using (0,0) as a way to signify "upper-left of the host window" should use GetMainViewport()->Pos.
136+
- Code using io.DisplaySize as a way to signify "size of the host window" should use GetMainViewport()->Size.
137+
- We are also exposing a work area in ImGuiViewport ('WorkPos', 'WorkSize' vs 'Pos', 'Size' for full area):
138+
- For a Platform Window, the work area is generally the full area minus space used by menu-bars.
139+
- For a Platform Monitor, the work area is generally the full area minus space used by task-bars.
140+
- All of this has been the case in 'docking' branch for a long time. What we've done is merely merging
141+
a small chunk of the multi-viewport logic into 'master' to standardize some concepts ahead of time.
127142
- Tables: Fixed PopItemWidth() or multi-components items not restoring per-colum ItemWidth correctly. (#3760)
128143
- Window: Fixed minor title bar text clipping issue when FramePadding is small/zero and there are no
129144
close button in the window. (#3731)
@@ -152,7 +167,9 @@ Other Changes:
152167
Would lead to a buffer read overflow.
153168
- ImDrawList: Clarified PathArcTo() need for a_min <= a_max with an assert.
154169
- ImDrawList: Fixed PathArcToFast() handling of a_min > a_max.
155-
- Demo: Added 'Examples->Fullscreen Window' demo. (#3789)
170+
- Metrics: Backported "Viewports" debug visualizer from 'docking' branch.
171+
- Demo: Added 'Examples->Fullscreen Window' demo using GetMainViewport() values. (#3789)
172+
- Demo: 'Simple Overlay' demo now moves under main menu-bar (if any) using GetMainViewport()'s work area.
156173
- Backends: Win32: Dynamically loading XInput DLL instead of linking with it, facilite compiling with
157174
old WindowSDK versions or running on Windows 7. (#3646, #3645, #3248, #2716) [@Demonese]
158175
- Backends: Vulkan: Add support for custom Vulkan function loader and VK_NO_PROTOTYPES. (#3759, #3227) [@Hossein-Noroozpour]

0 commit comments

Comments
 (0)