Author Topic: horizontal scrollbar ImGui  (Read 537 times)



0 Members and 1 Guest are viewing this topic.

stakov999

  • Newbie
  • *
  • Posts: 8
    • View Profile
horizontal scrollbar ImGui
« on: March 20, 2018, 12:29:57 AM »
Dear all,

I'm currently meeting a problem with Imgui.
To explain shortly : i'm drawing an array (like an Excel array) with something like :
Code: [Select]
for line=1,10 do
  gh_imgui.columns(10,1)
  for col=1,10 do
     gh_imgui.button("button",20,20)
     gh_imgui.column_next()
  end
end

With that method, if the array is horizontally larger than the current window, the buttons are automatically resized so that they fit in the window.
Which is weird because if it's bigger than the vertical size of the window, then it calls the scrollbar to go up/down.
I'd like to call a scrollbar like this, but horizontally. Do you think it would be possible with any GeexLab function ?

Thanking you in advance

Regards
Stakov

JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1440
    • View Profile
    • Geeks3D.com
Re: horizontal scrollbar ImGui
« Reply #1 on: March 20, 2018, 03:48:18 PM »
Yes it's weird indeed. Vertical and horizontal scrollbars are enabled. I will look at ImGui functions, maybe it's a bug in GeeXLab. I let you know.

JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1440
    • View Profile
    • Geeks3D.com
Re: horizontal scrollbar ImGui
« Reply #2 on: March 20, 2018, 07:09:30 PM »
I found the way to enable horizontal scrollbar. Just define a new constant window_horizontal_scrollbar with value 2048 and use it in window flags:

Code: [Select]
local pos_size_flag_always = 1
local window_no_save_settings = 256
local window_horizontal_scrollbar = 2048

local window_flags = window_no_save_settings | window_horizontal_scrollbar

local is_open = gh_imgui.window_begin("myWindow", 200, 400, 0, 0, window_flags, pos_size_flag_always, pos_size_flag_always)
...
...

By default, the vertical scrollbar is enabled and the horizontal scrollbar is disabled.

stakov999

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: horizontal scrollbar ImGui
« Reply #3 on: March 21, 2018, 02:47:24 PM »
It's now working, thank you !
There were two reasons of the issue : one you solved with allowing horizontal scrollbar, and the other one is that gh_imgui.columns automatically resizes the columns so they fit in the window.
I builded my own column array with a simple loop and "same line" statement.

Thanks