inkyblackness / imgui-go

Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible to use input field elements without the simluated window?

airtonix opened this issue · comments

I have a screen for a game where the user enters parameters for the level creation.

I don't want the draggable window, is it possible to just render the ui elements without it?

Hi there, thank you for your question.
All elements are bound to a window region, even if you didn't specify one. Because in this case, Dear ImGui uses a "default" window.

If the core issue is that the window should not be draggable, use the window creation flag WindowFlagsNoMove. If you want to avoid the section to look like a window with a title bar, you can also specify WindowFlagsNoTitleBar.
To completely hide the fact that there's a window, there's also WindowFlagsNoBackground.

If you are curious for more, there are many more flags, see here:

imgui-go/Window.go

Lines 22 to 82 in 44567f2

const (
// WindowFlagsNone default = 0.
WindowFlagsNone WindowFlags = 0
// WindowFlagsNoTitleBar disables title-bar.
WindowFlagsNoTitleBar WindowFlags = 1 << 0
// WindowFlagsNoResize disables user resizing with the lower-right grip.
WindowFlagsNoResize WindowFlags = 1 << 1
// WindowFlagsNoMove disables user moving the window.
WindowFlagsNoMove WindowFlags = 1 << 2
// WindowFlagsNoScrollbar disables scrollbars. Window can still scroll with mouse or programmatically.
WindowFlagsNoScrollbar WindowFlags = 1 << 3
// WindowFlagsNoScrollWithMouse disables user vertically scrolling with mouse wheel. On child window, mouse wheel
// will be forwarded to the parent unless NoScrollbar is also set.
WindowFlagsNoScrollWithMouse WindowFlags = 1 << 4
// WindowFlagsNoCollapse disables user collapsing window by double-clicking on it.
WindowFlagsNoCollapse WindowFlags = 1 << 5
// WindowFlagsAlwaysAutoResize resizes every window to its content every frame.
WindowFlagsAlwaysAutoResize WindowFlags = 1 << 6
// WindowFlagsNoBackground disables drawing background color (WindowBg, etc.) and outside border. Similar as using
// SetNextWindowBgAlpha(0.0f).
WindowFlagsNoBackground WindowFlags = 1 << 7
// WindowFlagsNoSavedSettings will never load/save settings in .ini file.
WindowFlagsNoSavedSettings WindowFlags = 1 << 8
// WindowFlagsNoMouseInputs disables catching mouse, hovering test with pass through.
WindowFlagsNoMouseInputs WindowFlags = 1 << 9
// WindowFlagsMenuBar has a menu-bar.
WindowFlagsMenuBar WindowFlags = 1 << 10
// WindowFlagsHorizontalScrollbar allows horizontal scrollbar to appear (off by default). You may use
// SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo
// in the "Horizontal Scrolling" section.
WindowFlagsHorizontalScrollbar WindowFlags = 1 << 11
// WindowFlagsNoFocusOnAppearing disables taking focus when transitioning from hidden to visible state.
WindowFlagsNoFocusOnAppearing WindowFlags = 1 << 12
// WindowFlagsNoBringToFrontOnFocus disables bringing window to front when taking focus. e.g. clicking on it or
// programmatically giving it focus.
WindowFlagsNoBringToFrontOnFocus WindowFlags = 1 << 13
// WindowFlagsAlwaysVerticalScrollbar always shows vertical scrollbar, even if ContentSize.y < Size.y .
WindowFlagsAlwaysVerticalScrollbar WindowFlags = 1 << 14
// WindowFlagsAlwaysHorizontalScrollbar always shows horizontal scrollbar, even if ContentSize.x < Size.x .
WindowFlagsAlwaysHorizontalScrollbar WindowFlags = 1 << 15
// WindowFlagsAlwaysUseWindowPadding ensures child windows without border uses style.WindowPadding (ignored by
// default for non-bordered child windows, because more convenient).
WindowFlagsAlwaysUseWindowPadding WindowFlags = 1 << 16
// WindowFlagsNoNavInputs has no gamepad/keyboard navigation within the window.
WindowFlagsNoNavInputs WindowFlags = 1 << 18
// WindowFlagsNoNavFocus has no focusing toward this window with gamepad/keyboard navigation
// (e.g. skipped by CTRL+TAB).
WindowFlagsNoNavFocus WindowFlags = 1 << 19
// WindowFlagsUnsavedDocument appends '*' to title without affecting the ID, as a convenience to avoid using the
// ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one
// frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
WindowFlagsUnsavedDocument WindowFlags = 1 << 20
// WindowFlagsNoNav combines WindowFlagsNoNavInputs and WindowFlagsNoNavFocus.
WindowFlagsNoNav = WindowFlagsNoNavInputs | WindowFlagsNoNavFocus
// WindowFlagsNoDecoration combines WindowFlagsNoTitleBar, WindowFlagsNoResize, WindowFlagsNoScrollbar and
// WindowFlagsNoCollapse.
WindowFlagsNoDecoration = WindowFlagsNoTitleBar | WindowFlagsNoResize | WindowFlagsNoScrollbar | WindowFlagsNoCollapse
// WindowFlagsNoInputs combines WindowFlagsNoMouseInputs, WindowFlagsNoNavInputs and WindowFlagsNoNavFocus.
WindowFlagsNoInputs = WindowFlagsNoMouseInputs | WindowFlagsNoNavInputs | WindowFlagsNoNavFocus
)

Nah, for asthetic reasons i dont want any window at all, just the input elements.