Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any idea when horizontal scroll bar will be available? #246

Closed
nikmes opened this issue Jun 18, 2015 · 8 comments
Closed

Any idea when horizontal scroll bar will be available? #246

nikmes opened this issue Jun 18, 2015 · 8 comments

Comments

@nikmes
Copy link

nikmes commented Jun 18, 2015

No description provided.

@ocornut
Copy link
Owner

ocornut commented Jun 18, 2015

I was actually looking into some of that recently.
It should be quite easy to add.

There's a few problems to take care of, e.g. some clipping optimisations for huge block of texts are skipping on text width calculation. Scrolling is easy and free but calculating accurate size to have a reference point of how big is the contents, can sometimes be costly.

@ocornut
Copy link
Owner

ocornut commented Jul 20, 2015

Note that you can easily hack some form of manual scrolling (without scrollbar) by positioning the cursor.
e.g.

static float x = 0.0f;
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)))
    x -= ImGui::GetIO().DeltaTime * 1000.0f;
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
    x += ImGui::GetIO().DeltaTime * 1000.0f;
ImGui::SetCursorPosX((float)(int)-x);
ImGui::BeginGroup();
...

@nikmes
Copy link
Author

nikmes commented Jul 20, 2015

Thanks! I ll give it a try.

On 20 July 2015 at 03:55, omar [email protected] wrote:

Note that you can easily hack some form of manual scrolling by positioning
the cursor.
e.g.

static float x = 0.0f;if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)))
x -= ImGui::GetIO().DeltaTime * 1000.0f;if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
x += ImGui::GetIO().DeltaTime * 1000.0f;ImGui::SetCursorPosX((float)(int)-x);ImGui::BeginGroup();
...


Reply to this email directly or view it on GitHub
#246 (comment).

Best Regards
Nicholas Messaritis

ocornut added a commit that referenced this issue Aug 30, 2015
… just to remove some syntax noise from the following commit (#246)
ocornut added a commit that referenced this issue Aug 30, 2015
…ntent width via SetNextWindowContentSize() etc (#246)

GetCursorPos, SetCursorPos, GetContentRegionMax,
GetWindowContentRegionMin, GetWindowContentRegionMax are now including
the scrolling amount. It PROBABLY shouldn't break anything for you, but
take note that SetCursorPosX(100.0f) puts you at +100 from the starting
x position which may include scrolling, not at +100 from the window left
side.
ocornut added a commit that referenced this issue Aug 30, 2015
ocornut added a commit that referenced this issue Aug 30, 2015
ocornut added a commit that referenced this issue Aug 30, 2015
@ocornut
Copy link
Owner

ocornut commented Aug 30, 2015

OK pretty much done with that.
The horizontal scrollbar is always off by default and has to be enabled using ImGuiWindowFlags_HorizontalScrollbar.

You can call SetNextWindowContentWidth(width) before Begin() to specify a desired width.
The change had more side-effects than effects, had to change a few things but it may introduce new bugs.

horizontal_scrollbar

horizontal_scrollbar2

@extrawurst
Copy link
Contributor

@ocornut you are amazing... thank you!

@herdigiorgi
Copy link

@ocornut WOW!! Thanks! thanks!

@nikmes
Copy link
Author

nikmes commented Sep 1, 2015

Looks cool. I will upgrade my code tonight :) Thanks a lot

@ocornut ocornut closed this as completed Sep 10, 2015
@nikmes
Copy link
Author

nikmes commented Mar 15, 2016 via email

ocornut added a commit that referenced this issue Jun 12, 2016
ocornut added a commit that referenced this issue Jul 19, 2016
ocornut added a commit that referenced this issue Aug 7, 2017
…bled Horizontal Scrollbar straddle the vertical limit. (#1271, #246)
ocornut added a commit that referenced this issue Aug 29, 2017
f71cdd1  Internal tidying up, moved code to CalcNextScrollFromScrollTargetAndClamp() so it can be reused by upcoming nav code.
c816e6c Fixed SetScrollX() handling of center ratio (which actually wasn't exposed publicly). (#323, #246)
ocornut added a commit that referenced this issue Dec 10, 2017
…tSize(). Kept redirection function (will obsolete). (#246, #519, #1444)
ocornut added a commit that referenced this issue Jan 26, 2018
…is has been here since 65a191c (#246) tho at the time it is possible that SizeContents wasn't calculated as evenly.

Test: auto-resize with: ImGui::Begin("Test", NULL, ImGuiWindowFlags_HorizontalScrollbar); ImGui::Button("##xxx", ImVec2(500,500)); ImGui::End();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants