File ImGuiDockspace.h

Defines

IMGUI_DEFINE_MATH_OPERATORS
namespace Gsage

Typedefs

typedef std::shared_ptr<Dock> DockPtr

Enums

enum DockSlotPreviewStyle

Values:

DockSlotPreviewFill = 0
DockSlotPreviewOutline = 1
enum ImGuiDockFlags

Values:

ImGuiDock_NoTitleBar = 1 << 0
ImGuiDock_NoResize = 1 << 1
class Dock

Public Types

enum Layout

Values:

None = 0
Vertical = 1
Horizontal = 2
enum Location

Values:

Unspecified = 10
Left = 1
Right = Left ^ 1
Top = 3
Bottom = Top ^ 1
Tab = 5
Root = 6

Public Functions

Dock(const char *label, const ImGuiDockspaceStyle &mStyle)
virtual ~Dock()
void reset()

Called when dock is detached

void activateOther()

Activate any other tab if there is one Descending order is preferable

bool isContainer() const

Check if dock is container should have any children present

bool hasBothChildren() const

Check if container has both children open

bool bothChildrenVisible() const

Check if both children are visible

void updateChildren()

Update children in container

Update dimensions, positions and draw splits

void setDimensions(ImVec2 pos, ImVec2 size)

Update dock dimensions

Parameters
  • pos: Position

  • size: Size

float getRatio() const

Get first dock scale ratio

void setRatio(float ratio)

Set first dock scale ratio

Parameters
  • ratio: from 0 to 1

const ImVec2 &getPosition() const

Get position

const ImVec2 &getSize() const

Get size

bool getOpened() const

Check if dock is opened

bool anyTabOpen() const

Check if this tab or any next tab is open

void setOpened(bool value)

Change opened state for dock

Parameters
  • value:

bool getActive() const

Check if dock is active (tab wise)

void setActive(bool value)

Set dock as active

Parameters
  • value:

bool visible() const

Check if the dock should be drawn

bool docked() const

Is docked to anything

void addChild(DockPtr child)

Add child to location defined in child itself

Parameters
  • child: DockPtr

void addChildAt(DockPtr child, Location location)

Add child to container at location

Parameters
  • child: DockPtr

  • location: Location

void removeChildAt(Location location)

Remove child from location

Parameters
  • location: Location

DockPtr getChildAt(Location location)

Get child at specified location

DockPtr getChildAt(int index)

Get child at specified index

Dock::Layout getLayout() const

Get dock layout

Dock::Location getLocation() const

Get dock location

DockPtr getParent()

Get dock parent

DockPtr getNextTab()

Get next tab

DockPtr getPreviousTab()

Get previous tab

const char *getLabel() const

Get dock label

const char *getTitle() const

Get dock title

const ImRect &getBoundingRect() const

Get bounding rect

float calculateRatio(Dock::Layout layout, const ImVec2 &containerSize)

Calculate ratio for the dock, basing on dock location

Parameters
  • container: destination container

Private Functions

int locationToIndex(Location location) const

Private Members

char *mLabel
char *mTitle
ImVec2 mPos
ImVec2 mSize
ImRect mBounds
DockPtr mChildren[2]
DockPtr mNextTab
DockPtr mPreviousTab
DockPtr mParent
Layout mLayout
Location mLocation
bool mActive
bool mOpened
bool mRendered
bool mResized
bool mDirty
float mRatio
int mFlags
const ImGuiDockspaceStyle &mStyle

Friends

friend Gsage::ImGuiDockspace
friend Gsage::ImGuiDockspaceRenderer
class ImGuiDockspace
#include <ImGuiDockspace.h>

Imgui dockspace

Public Functions

ImGuiDockspace()
ImGuiDockspace(const ImGuiDockspaceStyle &style)
virtual ~ImGuiDockspace()
ImGuiDockspaceState getState()

Get dockspace state

Return

current ImGuiDockspaceState

void setState(ImGuiDockspaceState state)

Set dockspace state

Parameters

void setDimensions(ImVec2 pos, ImVec2 size)

Update dockspace position and dimensions

Parameters
  • pos: Position

  • size: Size

void updateLayout()

Update layout

bool dockTo(const char *label, DockPtr dock, Dock::Location location)

Dock window

Parameters
  • label: parent dock label

  • location: location to dock to

bool undock(DockPtr dock, bool destroy = false)

Undock dock from any kind of container

Parameters
  • dock: DockPtr

  • destroy: removes dock object completely, clearing the dock state

bool undock(const char *label, bool destroy = false)

Undock dock from any kind of container

Parameters
  • label: dock label

  • destroy: removes dock object completely, clearing the dock state

DockPtr getRootDock()

Get root dock

DockPtr getDock(const char *label)

Get window state calculated by updateLayout call

Parameters
  • label: identifies window uniquely

DockPtr getDock(const std::string &label)

ImGuiDockspace::getDock

DockPtr createDock(const char *label, bool opened = true, bool active = true)

Create new dock

Parameters
  • label: dock label

void addChild(DockPtr container, DockPtr child)

Add child dock to container

Parameters
  • container:

  • child:

void reset()

Reset dockspace, remove all docks

DockPtr getDockAt(const ImVec2 &position)

Get dock under mouse position

Parameters
  • ImVec2: position

Private Types

typedef std::map<std::string, DockPtr> Docks
typedef std::map<Dock::Location, Dock::Layout> LocationToLayout

Private Members

ImGuiDockspaceStyle mStyle
Docks mDocks
LocationToLayout mLocationToLayout
DockPtr mRootDock
ImVec2 mSize

Friends

friend Gsage::ImGuiDockspaceRenderer
class ImGuiDockspaceRenderer
#include <ImGuiDockspace.h>

Dockspace for ImGUI.

Provides alternate methods for Begin and End. Docked view should be surrounded by BeginDock and EndDock methods.

local flags = 0
local active, open = imgui.BeginDockOpen("test", true, flags)
if active and open then
  -- render some view here
  imgui.TextWrapped("Hello World!")
end
imgui.EndDock()

Saving and loading dockspace state:

-- save dock state (will get lua table)
local savedState = imgui.GetDockState()

...

-- restore dock state
imgui.SetDockState(savedState)

Public Functions

ImGuiDockspaceRenderer()
ImGuiDockspaceRenderer(const ImGuiDockspaceStyle &style)
virtual ~ImGuiDockspaceRenderer()
bool activateDock(const char *label)

Activate dock

Return

true if succeed

Parameters

void beginWorkspace(ImVec2 pos, ImVec2 size)

Must be called before rendering all windows

bool begin(const char *label, bool *opened, ImGuiWindowFlags windowFlags)

Begin rendering

Parameters
  • label: Window label

  • opened: Pointer to bool

  • windowFlags: additional window flags

bool begin(const char *label, const char *title, bool *opened, ImGuiWindowFlags windowFlags, int dockFlags)

Begin rendering

Parameters
  • label: Window label

  • opened: Pointer to bool

  • windowFlags: additional window flags

  • dockFlags: additional dock flags

bool begin(const char *label, const char *title, bool *opened, ImGuiWindowFlags windowFlags)

Begin rendering

Parameters
  • label: Window label

  • title: Actual window name

  • opened: Pointer to bool

  • windowFlags: additional window flags

void end()

End rendering

void endWorkspace(bool cleanup = false)

Must be called after rendering all windows

Parameters
  • cleanup: do cleanup of docks that were not rendered this time

ImGuiDockspaceState getState()

Get workspace state

void setState(const ImGuiDockspaceState &state)

Set workspace state

Parameters
  • state:

Private Types

enum EndCommand

Values:

End_None = 0
End_Child = 1
End_Window = 2
typedef std::map<std::string, bool> Windows

Private Functions

bool tabbar(DockPtr dock, bool closeButton)
void title(DockPtr dock)
void dockWindows()
void splitters()
void handleDragging()
bool dockSlots(DockPtr destDock, const ImRect &rect, const std::vector<Dock::Location> &locations)

Private Members

ImGuiDockspace mDockspace
ImGuiDockspaceStyle mStyle
EndCommand mEndCommand
ImVec2 mPos
ImVec2 mSize
bool mPopClipRect
Windows mDockableWindows
DockPtr mDraggedDock
bool mStateWasUpdated
struct ImGuiDockspaceState

Public Types

typedef std::map<std::string, Dockstate> Docks

Public Members

Docks docks
ImVec2 size
struct Dockstate

Public Functions

Dockstate()
Dockstate(DockPtr dock)
virtual ~Dockstate()

Public Members

float ratio
std::string children[2]
std::string next
std::string prev
std::string parent
Dock::Layout layout
Dock::Location location
bool active
bool opened
struct ImGuiDockspaceStyle

Public Members

float splitterThickness
float tabbarHeight
float tabbarTextMargin
float tabbarPadding
float windowRounding
ImU32 windowBGColor
ImU32 tabInactiveColor
ImU32 tabActiveColor
ImU32 tabHoveredColor
ImU32 textColor
ImU32 splitterHoveredColor
ImU32 splitterNormalColor
ImU32 dockSlotHoveredColor
ImU32 dockSlotNormalColor
DockSlotPreviewStyle dockSlotPreview