Skip to content

Commit

Permalink
gui: Update to use latest patched ImGui
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaZulberti committed Sep 10, 2023
1 parent 3ee9213 commit 0663632
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/gui/flat.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GUI_H=gui/gui.h\
gui/api.h\
gui/api.hh\
gui/hotkey.hh\
gui/imconfig_user.h\
gui/widget_draw.hh\
gui/widget_filebrowser.hh\
gui/widget_filteredlist.hh\
Expand All @@ -38,12 +39,13 @@ GUI_H=gui/gui.h\
pipe/graph-traverse.inc\
pipe/graph-history.h\
pipe/graph-defaults.h
GUI_CFLAGS=$(VKDT_GLFW_CFLAGS) -I../ext/imgui -I../ext/imgui/backends/
GUI_CFLAGS=$(VKDT_GLFW_CFLAGS) -I../ext/imgui -I../ext/imgui/backends/ -DIMGUI_USER_CONFIG=\"gui/imconfig_user.h\"
GUI_LDFLAGS=-ldl $(VKDT_GLFW_LDFLAGS) -lm -lstdc++ -rdynamic

ifeq ($(VKDT_USE_FREETYPE),1)
GUI_CFLAGS+=$(shell pkg-config --cflags freetype2) -DVKDT_USE_FREETYPE=1
GUI_LDFLAGS+=$(shell pkg-config --libs freetype2)
GUI_O+=../ext/imgui/misc/freetype/imgui_freetype.o
endif
ifeq ($(VKDT_USE_PENTABLET),1)
GUI_CFLAGS+=-DVKDT_USE_PENTABLET=1
Expand Down
2 changes: 1 addition & 1 deletion src/gui/hotkey.hh
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ namespace ImHotKey
{
uint16_t *k = hotkey[editingHotkey].key + scanCodeCount-1;
k[0] = i + ImGuiKey_NamedKey_BEGIN;
if(k[0] >= ImGuiKey_ModCtrl)
if(k[0] >= ImGuiMod_Ctrl)
{ // swap control/mod to beginning
uint16_t tmp = hotkey[editingHotkey].key[0];
hotkey[editingHotkey].key[0] = k[0];
Expand Down
12 changes: 12 additions & 0 deletions src/gui/imconfig_user.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.

//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
#define IMGUI_USE_WCHAR32

#if VKDT_USE_FREETYPE == 1
#define IMGUI_ENABLE_FREETYPE
#endif
3 changes: 2 additions & 1 deletion src/gui/imnodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "imnodes_internal.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include "imgui.h"
#include "imgui_internal.h"

// Check minimum ImGui version
#define MINIMUM_COMPATIBLE_IMGUI_VERSION 17400
Expand Down
2 changes: 2 additions & 0 deletions src/gui/imnodes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <stddef.h>

#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui.h"

#ifdef IMNODES_USER_CONFIG
Expand Down
2 changes: 1 addition & 1 deletion src/gui/imnodes_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "imnodes.h"

#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>

#include <limits.h>
Expand Down
14 changes: 5 additions & 9 deletions src/gui/render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@ extern "C" {
#include "pipe/graph-history.h"
#include "api.h"
}

#include "render.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui.h"
#include "imgui_impl_vulkan.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_vulkan.h"

#include "imnodes.h"
#include "widget_draw.hh"
#include "render_view.hh"
#if VKDT_USE_FREETYPE == 1
#include "misc/freetype/imgui_freetype.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsubobject-linkage"
#include "misc/freetype/imgui_freetype.cpp" // come on gcc, this is clearly not a header!
#pragma GCC diagnostic pop
#endif
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

Expand Down Expand Up @@ -157,7 +154,6 @@ extern "C" void dt_gui_init_fonts()
ImFontConfig* font_config = (ImFontConfig*)&io.Fonts->ConfigData[n];
font_config->RasterizerMultiply = 1.0f;
}
ImGuiFreeType::BuildFontAtlas(io.Fonts, flags); // same flags
#endif

{ // upload Fonts, use any command queue
Expand Down
10 changes: 6 additions & 4 deletions src/gui/render_nodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ void render_nodes_right_panel()
dsp[d] == dt_token("main") && nodes.dual_monitor;
char title[20] = {0};
snprintf(title, sizeof(title), "nodes %" PRItkn, dt_token_str(dsp[d]));
if(popout) ImGui::Begin(title, 0, ImGuiWindowFlags_SecondMonitor);
else ImGui::BeginChild(title, ImVec2(0.975*ImGui::GetWindowSize().x,
MIN(ImGui::GetWindowSize().y, ImGui::GetWindowSize().x*2.0f/3.0f)));
// FIXME
// if(popout) ImGui::Begin(title, 0, ImGuiWindowFlags_SecondMonitor);
// else
ImGui::BeginChild(title, ImVec2(0.975*ImGui::GetWindowSize().x,
MIN(ImGui::GetWindowSize().y, ImGui::GetWindowSize().x*2.0f/3.0f)));

if(dsp[d] == dt_token("main"))
dt_image(&vkdt.wstate.img_widget, out, 1, 1);
Expand Down Expand Up @@ -483,7 +485,7 @@ void render_nodes()
int mc0 = sid&0x1f, mc1 = eid&0x1f;

int err = 0;
if(ImGui::IsKeyDown(ImGuiKey_ModShift))
if(ImGui::IsKeyDown(ImGuiMod_Shift))
err = dt_module_feedback_with_history(g, mi0, mc0, mi1, mc1);
else
err = dt_module_connect_with_history(g, mi0, mc0, mi1, mc1);
Expand Down

0 comments on commit 0663632

Please sign in to comment.