Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
v1.80 should be a nice release - they are adding in the tables.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@rrraptor , thanks. although i also decided not to use the docking features as of now as i need fixed size windows (or at least fixed minimum size, which i did not see how to make), let's see when docking becomes part of the main branch.
i'm not sure i get what happens on the video, but looks cool. : )
Im trying to make it work with gideros scale modes (letterbox and etc). So if application window scales up or down, mouse position calculates correctly.
Spent whole day trying to make dockbuilder work and here is the result:
Code:
-- flags to emulate fullscreen windowlocal window_flags = ImGui.WindowFlags_NoTitleBar | ImGui.WindowFlags_NoCollapse | ImGui.WindowFlags_NoResize | ImGui.WindowFlags_NoMove | ImGui.WindowFlags_NoBringToFrontOnFocus | ImGui.WindowFlags_NoNavFocus
EditorScene = Core.class(Sprite)function EditorScene:init()
self.imgui = ImGui.new()
self:addChild(self.imgui)local IO = self.imgui:getIO()
IO:setIniFilename(nil)-- disable INI file
IO:addConfigFlags(ImGui.ConfigFlags_DockingEnable)
self:addEventListener("enterFrame", self.drawGUI, self)end--function EditorScene:drawGUI(e)local UI = self.imgui
UI:newFrame(e)local dockspace_id = UI:getID("root")if(not UI:dockBuilderCheckNode(dockspace_id))then-- called once
self:createDock(UI, dockspace_id)endlocal IO = self.imgui:getIO()
UI:setNextWindowPos(0, 0)
UI:setNextWindowSize(IO:getDisplaySize())
UI:pushStyleVar(ImGui.StyleVar_WindowRounding, 0)
UI:pushStyleVar(ImGui.StyleVar_WindowBorderSize, 0)
UI:pushStyleVar(ImGui.StyleVar_WindowPadding, 0, 0)
UI:beginWindow("DockSpace Demo", nil, window_flags)
UI:popStyleVar(3)
UI:dockSpace(dockspace_id, 0, 0)
UI:endWindow()if(UI:beginWindow("Log", nil))then
UI:value("Random", math.random())end
UI:endWindow()if(UI:beginWindow("Properties", nil))thenend
UI:endWindow()if(UI:beginWindow("Grid", nil))thenend
UI:endWindow()
UI:render()
UI:endFrame()end--function EditorScene:createDock(UI, dockspace_id)
UI:dockBuilderRemoveNode(dockspace_id)-- clear existing layout
UI:dockBuilderAddNode(dockspace_id)-- add empty node-- split main node into 2 (left and right node), return left panel id AND modified dockspace idlocal dock_id_left,_,dockspace_id= UI:dockBuilderSplitNode(dockspace_id, ImGui.Dir_Left, 0.2, nil, dockspace_id)-- split right node into 2, return bottom panel idlocal dock_id_bottom = UI:dockBuilderSplitNode(dockspace_id, ImGui.Dir_Down, 0.2, nil, dockspace_id)-- split right node into 2 (but in different direction), return top panel idlocal dock_id_top = UI:dockBuilderSplitNode(dockspace_id, ImGui.Dir_Up, 0.7, nil, dockspace_id)
UI:dockBuilderDockWindow("Log", dock_id_bottom)
UI:dockBuilderDockWindow("Grid", dock_id_up)
UI:dockBuilderDockWindow("Properties", dock_id_prop)
UI:dockBuilderFinish(dockspace_id)end
Also, Ive noticed this:
ini file contains imgui window settings. You can disable it like I did ( IO:setIniFilename(nil) ). But I want to make it so it will be stored somewhere in gideros documents folder ("|D|imgui.ini" or something like that). Same for .log file ( ImGui:logToFile() )
I guess it won't work if you put your imgui sprite inside another sprite with its own transform. Ideally you would want to retrieve mouse coordinate in logical stage space such as what Gideros reports in lua, then perform th equivalent of globalToLocal on your sprite. The latter is easy if you have a lua context, but I am not sure to get the former directly from gideros, without having to mimic it like you do.
I guess it won't work if you put your imgui sprite inside another sprite with its own transform. Ideally you would want to retrieve mouse coordinate in logical stage space such as what Gideros reports in lua, then perform th equivalent of globalToLocal on your sprite. The latter is easy if you have a lua context, but I am not sure to get the former directly from gideros, without having to mimic it like you do.
Well I can do something like
auto curr = proxy;while(curr){
curr->matrix().transformPoint(x, y, newX, newY);
curr = curr->parent();}
That would do localToGlobal transform while you want the opposite, but yes that's the idea, or just call globalToLocal lua function. Also avoid using "auto" as I am not sure all compilers (I mean for each platform) support C++11.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
is there anything missing or is it ready to work with? i'm enthusiastic about rebuilding my gui with imgui, just i lack the time so it will come a bit later. in any case i hope in next gideros release we will have an imgui plugin we can depend on. thanks again for it, it is amazing
is there anything missing or is it ready to work with?
Missing drag&drop functions and maybe something else... File functions works, so you can use this:
local IO = self.imgui:getIO()
IO:setLogFilename("|D|imgui_log.txt")-- "%temp%\gideros\ProjectName\documents\imgui_log.txt" on windows
self.imgui:logToFile()
self.imgui:logText("Hello world")
self.imgui:logFinish()
local dockNode = UI:dockBuilderGetNode(dock_id_top)-- OKlocal tabBar = dockNode:getTabBar()-- OKlocal t = tabBar:getTabs()-- OK
tabBar:getTabName(t[1])-- sometimes this line works ok, sometimes it leads to a crush
So I added new function:
int TabBar_GetTab(lua_State* L)// retruns single tab instance by index
{
Binder binder(L);
ImGuiTabBar* tabBar = static_cast<ImGuiTabBar*>(binder.getInstance("ImGuiTabBar", 1));
int count = tabBar->Tabs.Size;
int index = luaL_checkinteger(L, 2) - 1;
LUA_ASSERT(L, index >=0&& index <= count, "Tab index is out of bounds.");
binder.pushInstance("ImGuiTabItem", &tabBar->Tabs[index]);return1;}
in lua:
local dockNode = UI:dockBuilderGetNode(dock_id_top)local tabBar = dockNode:getTabBar()local tab0 = tabBar:getTab(1)local tab1 = tabBar:getTab(2)print(tabBar:getTabName(tab0))-- always OKprint(tabBar:getTabName(tab1))-- always OK
@hgy29 one more question Do I need to free memory in the "destroyImGui" function (called when imgui instance garbage collected)? Delete proxy, delete event listener and etc.
Comments
https://www.w3schools.com/JSREF/event_ctrlkey.asp
and
https://www.w3schools.com/JSREF/event_key_ctrlkey.asp
Edit:
Also this:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState
getModifierState seems supported on all the browsers:
https://www.w3schools.com/JSREF/event_key_getmodifierstate.asp
https://deluxepixel.com
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://github.com/ocornut/imgui/releases/tag/v1.79
Ill update my binding later
Likes: keszegh, MoKaLux, SinisterSoft
https://deluxepixel.com
Im dropping docking branch support for now.
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
Likes: rrraptor
Fragmenter - animated loop machine and IKONOMIKON - the memory game
@hgy29 can you help with that?)
I did it this way:
added event listener for "applicationResize"
And when I calculate mouse position:
Is it OK or there is a better solution?
Code:
Also, Ive noticed this:
ini file contains imgui window settings.
You can disable it like I did ( IO:setIniFilename(nil) ). But I want to make it so it will be stored somewhere in gideros documents folder ("|D|imgui.ini" or something like that). Same for .log file ( ImGui:logToFile() )
Likes: MoKaLux
Anyways, I can take code from here. https://github.com/gideros/gideros/blob/2e4aa2fd3550a7c4d2da9a5d9ac755bfe68d4eae/2dsg/sprite.cpp#L696
https://github.com/MultiPain/Gideros_examples/tree/master/ImGuiDockingDemo
P.S. Grid by itself is gideros Sprite object.
Likes: keszegh, MoKaLux, SinisterSoft
Likes: MoKaLux
https://deluxepixel.com
Fragmenter - animated loop machine and IKONOMIKON - the memory game
File functions works, so you can use this:
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
Can you help a bit?)
I have a function that returns a table of "ImGuiTabItem" instances.
EDIT: if lua_setintfield is the same as defined here https://github.com/hgy29/gideros/blob/master/plugins/imgui/source/Common/imgui_bindings.cpp#L3767, then it should work well in theory, so it may be something else after all
Do I need to free memory in the "destroyImGui" function (called when imgui instance garbage collected)? Delete proxy, delete event listener and etc.
Example from demo:
Code in lua:
Likes: MoKaLux, SinisterSoft, antix