Browse Source

imgui: switch to the docking branch.

This branch seems pretty stable, and it lets us get rid of some
legacy code about extensions.
legacy
Sam Hocevar 6 years ago
parent
commit
7f9de5d554
3 changed files with 3 additions and 93 deletions
  1. +1
    -1
      src/3rdparty/imgui
  2. +2
    -67
      src/lolimgui.cpp
  3. +0
    -25
      src/lolimgui.h

+ 1
- 1
src/3rdparty/imgui

@@ -1 +1 @@
Subproject commit 76e31bd51a4d045505a3f40d01cad734d7b2b4e0
Subproject commit 1d3862b6b3fad2cf7b2e934b95d5710f38632b32

+ 2
- 67
src/lolimgui.cpp View File

@@ -13,8 +13,6 @@


#include <lol/engine-internal.h> #include <lol/engine-internal.h>


#include "imgui_internal.h" // needed for GImGui in GetMainMenuBarHeight()

#include <cstdio> #include <cstdio>
#include <string> #include <string>


@@ -24,70 +22,7 @@


using namespace lol; using namespace lol;


//Imgui extension ---------------------------------------------------------------------------------
namespace ImGui
{
IMGUI_API void SetNextWindowDockingAndSize(const ImVec2& size, ImGuiSetDock dock, const ImVec2& padding, ImGuiCond cond)
{
SetNextWindowDockingAndSize(size, dock, ImVec4(vec2(padding).xyxy), cond);
}
IMGUI_API void SetNextWindowDockingAndSize(const ImVec2& size, ImGuiSetDock dock, const ImVec4& padding, ImGuiCond cond)
{
vec4 pdg = padding;
vec2 vsz = vec2(Video::GetSize());
vec2 ctr = pdg.xy + (((vsz - pdg.zw) - pdg.xy) * .5f);
vec2 pos = vec2();

switch (dock)
{
case ImGuiSetDock_Center: pos = vec2(ctr.x - (size.x * .5f), ctr.y - (size.y * .5f)); break;
case ImGuiSetDock_Top: pos = vec2(ctr.x - (size.x * .5f), pdg.y); break;
case ImGuiSetDock_TopRight: pos = vec2(vsz.x - (size.x + pdg.z), pdg.y); break;
case ImGuiSetDock_Right: pos = vec2(vsz.x - (size.x + pdg.z), ctr.y - (size.y * .5f)); break;
case ImGuiSetDock_BottomRight: pos = vec2(vsz.x - (size.x + pdg.z), vsz.y - (size.y + pdg.w)); break;
case ImGuiSetDock_Bottom: pos = vec2(ctr.x - (size.x * .5f), vsz.y - (size.y + pdg.w)); break;
case ImGuiSetDock_BottomLeft: pos = vec2(pdg.x, vsz.y - (size.y + pdg.w)); break;
case ImGuiSetDock_Left: pos = vec2(pdg.x, ctr.y - (size.y * .5f)); break;
case ImGuiSetDock_TopLeft: pos = vec2(pdg.x, pdg.y); break;
}

ImGui::SetNextWindowPos(pos, cond);
ImGui::SetNextWindowSize(size, cond);
}

IMGUI_API void SetNextWindowDocking(ImGuiSetDock dock, const ImVec2& padding, ImGuiCond cond)
{
SetNextWindowDocking(dock, ImVec4(vec2(padding).xyxy), cond);
}
IMGUI_API void SetNextWindowDocking(ImGuiSetDock dock, const ImVec4& padding, ImGuiCond cond)
{
vec2 vsz = vec2(Video::GetSize());
vec2 size = vec2();
vec2 pos = vec2();
vec4 pdg = padding;

switch (dock)
{
case ImGuiSetDock_Center: size = vsz - vec2(pdg.x + pdg.z, pdg.y + pdg.w); break;
case ImGuiSetDock_Top: size = vec2(vsz.x - (pdg.x + pdg.z), vsz.y *.5f - pdg.y); break;
case ImGuiSetDock_TopRight: size = vec2(vsz.x *.5f - pdg.z, vsz.y *.5f - pdg.y); break;
case ImGuiSetDock_Right: size = vec2(vsz.x *.5f - pdg.z, vsz.y - (pdg.y + pdg.w)); break;
case ImGuiSetDock_BottomRight: size = vec2(vsz.x *.5f - pdg.z, vsz.y *.5f - pdg.w); break;
case ImGuiSetDock_Bottom: size = vec2(vsz.x - (pdg.x + pdg.z), vsz.y *.5f - pdg.w); break;
case ImGuiSetDock_BottomLeft: size = vec2(vsz.x *.5f - pdg.x, vsz.y *.5f - pdg.w); break;
case ImGuiSetDock_Left: size = vec2(vsz.x *.5f - pdg.x, vsz.y - (pdg.y + pdg.w)); break;
case ImGuiSetDock_TopLeft: size = vec2(vsz.x *.5f - pdg.x, vsz.y *.5f - pdg.y); break;
}

SetNextWindowDockingAndSize(size, dock, padding, cond);
}

IMGUI_API float GetMainMenuBarHeight()
{
ImGuiContext& g = *GImGui;
return g.FontBaseSize + g.Style.FramePadding.y * 2.0f;
}
}
static LolImGui* g_lolimgui = nullptr;


//LolImGui ---------------------------------------------------------------------------------------- //LolImGui ----------------------------------------------------------------------------------------
#define Line(s) ((s) + "\n") #define Line(s) ((s) + "\n")
@@ -162,6 +97,7 @@ LolImGui::LolImGui()
//# undef KB //# undef KB


} }

LolImGui::~LolImGui() LolImGui::~LolImGui()
{ {
ImGui::GetIO().Fonts->TexID = nullptr; ImGui::GetIO().Fonts->TexID = nullptr;
@@ -175,7 +111,6 @@ LolImGui::~LolImGui()
} }


//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
LolImGui* g_lolimgui = nullptr;
void LolImGui::Init() void LolImGui::Init()
{ {
Ticker::Ref(g_lolimgui = new LolImGui()); Ticker::Ref(g_lolimgui = new LolImGui());


+ 0
- 25
src/lolimgui.h View File

@@ -35,31 +35,6 @@
#undef IM_VEC2_CLASS_EXTRA #undef IM_VEC2_CLASS_EXTRA
#undef IM_VEC4_CLASS_EXTRA #undef IM_VEC4_CLASS_EXTRA


//Imgui extension ---------------------------------------------------------------------------------
typedef int ImGuiSetDock; // condition flags for Set*() // enum ImGuiCond_

enum ImGuiSetDock_
{
ImGuiSetDock_Center,
ImGuiSetDock_Top,
ImGuiSetDock_TopRight,
ImGuiSetDock_Right,
ImGuiSetDock_BottomRight,
ImGuiSetDock_Bottom,
ImGuiSetDock_BottomLeft,
ImGuiSetDock_Left,
ImGuiSetDock_TopLeft,
};

namespace ImGui
{
IMGUI_API void SetNextWindowDockingAndSize(const ImVec2& size, ImGuiSetDock dock, const ImVec2& padding, ImGuiCond cond = 0);
IMGUI_API void SetNextWindowDockingAndSize(const ImVec2& size, ImGuiSetDock dock, const ImVec4& padding = ImVec4(0, 0, 0, 0), ImGuiCond cond = 0);
IMGUI_API void SetNextWindowDocking(ImGuiSetDock dock, const ImVec2& padding, ImGuiCond cond = 0);
IMGUI_API void SetNextWindowDocking(ImGuiSetDock dock, const ImVec4& padding = ImVec4(0, 0, 0, 0), ImGuiCond cond = 0);
IMGUI_API float GetMainMenuBarHeight();
}

//LolImGui ---------------------------------------------------------------------------------------- //LolImGui ----------------------------------------------------------------------------------------
namespace lol namespace lol
{ {


Loading…
Cancel
Save