From 1295205cd4871b29eef8ae633ee7f19b18e92ac9 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Apr 2019 22:27:45 +0200 Subject: [PATCH 1/4] Examples: Vulkan: Fixed warnings. (#2480) --- examples/example_glfw_vulkan/main.cpp | 3 ++- examples/example_sdl_vulkan/main.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index 43abd3e7..e0c062af 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -108,6 +108,7 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count) // Create Vulkan Instance without any debug feature err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); check_vk_result(err); + IM_UNUSED(g_DebugReport); #endif } @@ -142,7 +143,7 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count) break; } free(queues); - IM_ASSERT(g_QueueFamily != -1); + IM_ASSERT(g_QueueFamily != (uint32_t)-1); } // Create Logical Device (with 1 queue) diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index ad789462..812d0988 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -100,6 +100,7 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count) // Create Vulkan Instance without any debug feature err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); check_vk_result(err); + IM_UNUSED(g_DebugReport); #endif } @@ -134,7 +135,7 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count) break; } free(queues); - IM_ASSERT(g_QueueFamily != -1); + IM_ASSERT(g_QueueFamily != (uint32_t)-1); } // Create Logical Device (with 1 queue) From 42423d5ea484898fde42e9703035ea5dfaabab50 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Apr 2019 23:02:07 +0200 Subject: [PATCH 2/4] Examples: Makefile: Tweaks so they are more consistent with each others. Added -g./opt/local includes for MacPorts on Mac OS X. (#297) --- examples/example_glfw_opengl2/Makefile | 35 ++++++++++++++---------- examples/example_glfw_opengl3/Makefile | 30 +++++++++++---------- examples/example_glut_opengl2/Makefile | 37 ++++++++++++++------------ examples/example_sdl_opengl2/Makefile | 35 +++++++++++++++--------- examples/example_sdl_opengl3/Makefile | 25 +++++++++-------- 5 files changed, 93 insertions(+), 69 deletions(-) diff --git a/examples/example_glfw_opengl2/Makefile b/examples/example_glfw_opengl2/Makefile index 482b0e5d..3649b717 100644 --- a/examples/example_glfw_opengl2/Makefile +++ b/examples/example_glfw_opengl2/Makefile @@ -19,39 +19,46 @@ SOURCES = main.cpp SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_opengl2.cpp SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) - UNAME_S := $(shell uname -s) +CXXFLAGS = -I../ -I../../ +CXXFLAGS += -g -Wall -Wformat +LIBS = + +##--------------------------------------------------------------------- +## BUILD FLAGS PER PLATFORM +##--------------------------------------------------------------------- ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS = -lGL `pkg-config --static --libs glfw3` + LIBS += -lGL `pkg-config --static --libs glfw3` - CXXFLAGS = -I../ -I../../ `pkg-config --cflags glfw3` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += `pkg-config --cflags glfw3` CFLAGS = $(CXXFLAGS) endif ifeq ($(UNAME_S), Darwin) #APPLE ECHO_MESSAGE = "Mac OS X" - LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo - #LIBS += -L/usr/local/lib -lglfw3 - LIBS += -L/usr/local/lib -lglfw + LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo + LIBS += -L/usr/local/lib -L/opt/local/lib + #LIBS += -lglfw3 + LIBS += -lglfw - CXXFLAGS = -I../ -I../../ -I/usr/local/include - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I/usr/local/include -I/opt/local/include CFLAGS = $(CXXFLAGS) endif ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) - ECHO_MESSAGE = "Windows" - LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32 + ECHO_MESSAGE = "MinGW" + LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 - CXXFLAGS = -I../ -I../../ -I../libs/gl3w `pkg-config --cflags glfw3` - CXXFLAGS += -Wall -Wformat - CFLAGS = $(CXXFLAGS) + CXXFLAGS += -I../libs/gl3w `pkg-config --cflags glfw3` + CFLAGS = $(CXXFLAGS) endif +##--------------------------------------------------------------------- +## BUILD RULES +##--------------------------------------------------------------------- %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< diff --git a/examples/example_glfw_opengl3/Makefile b/examples/example_glfw_opengl3/Makefile index a9c7007f..e8cf4614 100644 --- a/examples/example_glfw_opengl3/Makefile +++ b/examples/example_glfw_opengl3/Makefile @@ -21,13 +21,17 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) +CXXFLAGS = -I../ -I../../ +CXXFLAGS += -g -Wall -Wformat +LIBS = + ##--------------------------------------------------------------------- ## OPENGL LOADER ##--------------------------------------------------------------------- ## Using OpenGL loader: gl3w [default] SOURCES += ../libs/gl3w/GL/gl3w.c -CXXFLAGS = -I../libs/gl3w +CXXFLAGS += -I../libs/gl3w ## Using OpenGL loader: glew ## (This assumes a system-wide installation) @@ -44,31 +48,29 @@ CXXFLAGS = -I../libs/gl3w ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS = -lGL `pkg-config --static --libs glfw3` + LIBS += -lGL `pkg-config --static --libs glfw3` - CXXFLAGS += -I../ -I../../ `pkg-config --cflags glfw3` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += `pkg-config --cflags glfw3` CFLAGS = $(CXXFLAGS) endif ifeq ($(UNAME_S), Darwin) #APPLE ECHO_MESSAGE = "Mac OS X" - LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo - #LIBS += -L/usr/local/lib -lglfw3 - LIBS += -L/usr/local/lib -lglfw + LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo + LIBS += -L/usr/local/lib -L/opt/local/lib + #LIBS += -lglfw3 + LIBS += -lglfw - CXXFLAGS += -I../ -I../../ -I/usr/local/include - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I/usr/local/include -I/opt/local/include CFLAGS = $(CXXFLAGS) endif ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) - ECHO_MESSAGE = "Windows" - LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32 + ECHO_MESSAGE = "MinGW" + LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 - CXXFLAGS += -I../ -I../../ `pkg-config --cflags glfw3` - CXXFLAGS += -Wall -Wformat - CFLAGS = $(CXXFLAGS) + CXXFLAGS += `pkg-config --cflags glfw3` + CFLAGS = $(CXXFLAGS) endif ##--------------------------------------------------------------------- diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile index 25ddc43a..c381c0c9 100644 --- a/examples/example_glut_opengl2/Makefile +++ b/examples/example_glut_opengl2/Makefile @@ -1,6 +1,6 @@ # # Cross Platform Makefile -# Compatible with Ubuntu 14.04.1 and Mac OS X +# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X # # Linux: # apt-get install freeglut3-dev @@ -10,41 +10,44 @@ #CXX = clang++ EXE = example_glut_opengl2 -SOURCES = main.cpp +SOURCES = main.cpp SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) - UNAME_S := $(shell uname -s) +CXXFLAGS = -I../ -I../../ +CXXFLAGS += -g -Wall -Wformat +LIBS = + +##--------------------------------------------------------------------- +## BUILD FLAGS PER PLATFORM +##--------------------------------------------------------------------- ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS = -lGL -lglut - - CXXFLAGS = -I ../ -I../.. - CXXFLAGS += -Wall -Wformat + LIBS += -lGL -lglut CFLAGS = $(CXXFLAGS) endif ifeq ($(UNAME_S), Darwin) #APPLE ECHO_MESSAGE = "Mac OS X" - LIBS = -framework OpenGL -framework GLUT + LIBS += -framework OpenGL -framework GLUT + LIBS += -L/usr/local/lib -L/opt/local/lib - CXXFLAGS = -I .. -I../.. - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I/usr/local/include -I/opt/local/include CFLAGS = $(CXXFLAGS) endif ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) - ECHO_MESSAGE = "Windows" - LIBS = -lgdi32 -lopengl32 -limm32 -lglut - - CXXFLAGS = -I ../ -I../../ - CXXFLAGS += -Wall -Wformat - CFLAGS = $(CXXFLAGS) + ECHO_MESSAGE = "MinGW" + LIBS += -lgdi32 -lopengl32 -limm32 -lglut + CFLAGS = $(CXXFLAGS) endif +##--------------------------------------------------------------------- +## BUILD RULES +##--------------------------------------------------------------------- %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< diff --git a/examples/example_sdl_opengl2/Makefile b/examples/example_sdl_opengl2/Makefile index 4a948aa4..ce29a249 100644 --- a/examples/example_sdl_opengl2/Makefile +++ b/examples/example_sdl_opengl2/Makefile @@ -15,40 +15,49 @@ #CXX = clang++ EXE = example_sdl_opengl2 -SOURCES = main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp +SOURCES = main.cpp +SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) - UNAME_S := $(shell uname -s) +CXXFLAGS = -I../ -I../../ +CXXFLAGS += -g -Wall -Wformat +LIBS = + +##--------------------------------------------------------------------- +## BUILD FLAGS PER PLATFORM +##--------------------------------------------------------------------- ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS = -lGL -ldl `sdl2-config --libs` + LIBS += -lGL -ldl `sdl2-config --libs` - CXXFLAGS = -I ../ -I../../ `sdl2-config --cflags` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += `sdl2-config --cflags` CFLAGS = $(CXXFLAGS) endif ifeq ($(UNAME_S), Darwin) #APPLE ECHO_MESSAGE = "Mac OS X" - LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` + LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` + LIBS += -L/usr/local/lib -L/opt/local/lib - CXXFLAGS = -I ../ -I../../ -I/usr/local/include `sdl2-config --cflags` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += `sdl2-config --cflags` + CXXFLAGS += -I/usr/local/include -I/opt/local/include CFLAGS = $(CXXFLAGS) endif ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) - ECHO_MESSAGE = "Windows" - LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` + ECHO_MESSAGE = "MinGW" + LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` - CXXFLAGS = -I ../ -I../../ `pkg-config --cflags sdl2` - CXXFLAGS += -Wall -Wformat - CFLAGS = $(CXXFLAGS) + CXXFLAGS += `pkg-config --cflags sdl2` + CFLAGS = $(CXXFLAGS) endif +##--------------------------------------------------------------------- +## BUILD RULES +##--------------------------------------------------------------------- %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< diff --git a/examples/example_sdl_opengl3/Makefile b/examples/example_sdl_opengl3/Makefile index 69874119..76601a1b 100644 --- a/examples/example_sdl_opengl3/Makefile +++ b/examples/example_sdl_opengl3/Makefile @@ -21,13 +21,17 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) +CXXFLAGS = -I../ -I../../ +CXXFLAGS += -g -Wall -Wformat +LIBS = + ##--------------------------------------------------------------------- ## OPENGL LOADER ##--------------------------------------------------------------------- ## Using OpenGL loader: gl3w [default] SOURCES += ../libs/gl3w/GL/gl3w.c -CXXFLAGS = -I../libs/gl3w +CXXFLAGS += -I../libs/gl3w ## Using OpenGL loader: glew ## (This assumes a system-wide installation) @@ -44,28 +48,27 @@ CXXFLAGS = -I../libs/gl3w ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS = -lGL -ldl `sdl2-config --libs` + LIBS += -lGL -ldl `sdl2-config --libs` - CXXFLAGS = -I../ -I../../ -I../libs/gl3w `sdl2-config --cflags` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags` CFLAGS = $(CXXFLAGS) endif ifeq ($(UNAME_S), Darwin) #APPLE ECHO_MESSAGE = "Mac OS X" - LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` + LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` + LIBS += -L/usr/local/lib -L/opt/local/lib - CXXFLAGS = -I../ -I../../ -I../libs/gl3w -I/usr/local/include `sdl2-config --cflags` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags` + CXXFLAGS += -I/usr/local/include -I/opt/local/include CFLAGS = $(CXXFLAGS) endif ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) - ECHO_MESSAGE = "Windows" - LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` + ECHO_MESSAGE = "MinGW" + LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` - CXXFLAGS = -I../ -I../../ -I../libs/gl3w `pkg-config --cflags sdl2` - CXXFLAGS += -Wall -Wformat + CXXFLAGS += -I../libs/gl3w `pkg-config --cflags sdl2` CFLAGS = $(CXXFLAGS) endif From b53630813ecaf7791045a63cb53b3034289427d0 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Apr 2019 23:45:21 +0200 Subject: [PATCH 3/4] Internals: Tweak ItemSize calls. Added todo items. --- docs/TODO.txt | 1 + imgui_widgets.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index 24525947..66fd9459 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -34,6 +34,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - scrolling/style: shadows on scrollable areas to denote that there is more contents - drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering. + - drawlist: add calctextsize func to facilitate consistent code from user pov - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack. - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command). - drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d6d5ac84..ec393963 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -642,7 +642,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu const ImGuiID id = window->GetID(str_id); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); const float default_size = GetFrameHeight(); - ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); + ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); if (!ItemAdd(bb, id)) return false; @@ -1040,8 +1040,9 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over const ImGuiStyle& style = g.Style; ImVec2 pos = window->DC.CursorPos; - ImRect bb(pos, pos + CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f)); - ItemSize(bb, style.FramePadding.y); + ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f); + ImRect bb(pos, pos + size); + ItemSize(size, style.FramePadding.y); if (!ItemAdd(bb, 0)) return; @@ -1114,7 +1115,7 @@ void ImGui::Dummy(const ImVec2& size) return; const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - ItemSize(bb); + ItemSize(size); ItemAdd(bb, 0); } @@ -5260,7 +5261,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl ImVec2 pos = window->DC.CursorPos; pos.y += window->DC.CurrentLineTextBaseOffset; ImRect bb_inner(pos, pos + size); - ItemSize(bb_inner); + ItemSize(size); // Fill horizontal space. ImVec2 window_padding = window->WindowPadding; From 1391904fd23a4367ec80a042bd32044e63c2da84 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 8 Apr 2019 17:27:17 +0200 Subject: [PATCH 4/4] Internals: Selectable: Added ImGuiSelectableFlags_AllowItemOverlap in imgui_internal.h (~ #684, #2341) --- imgui_internal.h | 3 ++- imgui_widgets.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui_internal.h b/imgui_internal.h index bcbaec6a..4bf703d9 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -344,7 +344,8 @@ enum ImGuiSelectableFlagsPrivate_ ImGuiSelectableFlags_NoHoldingActiveID = 1 << 10, ImGuiSelectableFlags_PressedOnClick = 1 << 11, ImGuiSelectableFlags_PressedOnRelease = 1 << 12, - ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13 + ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13, + ImGuiSelectableFlags_AllowItemOverlap = 1 << 14 }; enum ImGuiSeparatorFlags_ diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index ec393963..ad3126cd 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5308,6 +5308,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl if (flags & ImGuiSelectableFlags_PressedOnRelease) button_flags |= ImGuiButtonFlags_PressedOnRelease; if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled; if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; + if (flags & ImGuiSelectableFlags_AllowItemOverlap) button_flags |= ImGuiButtonFlags_AllowItemOverlap; + if (flags & ImGuiSelectableFlags_Disabled) selected = false; @@ -5323,6 +5325,9 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl if (pressed) MarkItemEdited(id); + if (flags & ImGuiSelectableFlags_AllowItemOverlap) + SetItemAllowOverlap(); + // Render if (hovered || selected) {