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

Added option for resize grip in the lower left corner of a window. #822

Closed
wants to merge 1 commit into from
Closed

Conversation

amc522
Copy link
Contributor

@amc522 amc522 commented Sep 9, 2016

The lower left grip is disabled by default and can be added to the window with one of the following two window flags

  • ImGuiWindowFlags_ResizeLowerLeft
  • ImGuiWindowFlags_ResizeLowerLeftAndRight

@ocornut
Copy link
Owner

ocornut commented Sep 10, 2016

May I ask why did you want it specifically in that corner?(To understand your use case.

I wanted to add the possibility to resize from any corners and any border. Especially any-border is necessary when using e.g. docking types of facilities.

For both things the problem is mostly a visual/rendering problem.

  1. We obviously don't want to add the same resizing visual in every corner it would be noisy.

  2. For resizing on one axis from the window borders: we need suitable visuals considering that windows don't have borders and few bindings honor the mouse cursor change requests. If we were guaranteed that bindings honored the mouse cursor changes then we could get away without visual feedback and we'd need that. So it is a little tricky because we don't want an overly obnoxious hovering feedback.

  3. The patch adds too much code as it duplicate (and more) existing code. But probably adding support for 4 four corners will force us making the code shorter rather than duplicating it, but it should be a healthy thing to look into.

  4. I am also concerned about adding too many flags, so those should be designed better. If the visual feedback aren't annoying then in theory we can enable all of them all the time.
    It feels like some could be part of the Style and not per-window flag.

@amc522
Copy link
Contributor Author

amc522 commented Sep 10, 2016

First, this is my first time using dear imgui, and so so far it's been exactly what I'm looking for.

I currently have imgui windows docked on the upper left and upper right sides of my application. And I want to have the ability to resize those windows away from the sides and top of the application. Adding in a lower left grip seemed like an non-intrusive addition that matched the current style and layout of the windows. That being said, like you, I would prefer having the ability to resize from any corner or side of the window.

  1. If you want to keep the same style of grip, possibly the default visual would have the grips invisible until the mouse hovers over them. This is not unlike what happens in traditional windowing systems when the mouse changes icons when hovering over a resize area.

  2. I agree that changing mouse icons isn't necessarily a universal solution for imgui. From my understanding, a lot of games and rendering applications use imgui as a UI for development and debugging. Most of those applications probably don't want to have to worry about dealing with mouse icon changes. I think we should try the approach of having grips 'appear' when the mouse is hovering in the resize area. For resizing strictly vertically and horizontally, how about adding a border (a visible grip) on the side that currently has the mouse hovering over it. Doesn't have to be large, just a couple pixels wide.

  3. I agree that adding general support for all corners and sides from the ground up will make the code cleaner.

  4. I designed the flags the way I did because I didn't want to change the current default behavior. If the default behavior had either all sides and corners resizable or no sides and corners resizable, the flags could be more succinct. Something like:

  • ImGuiWindowFlag_ResizeN
  • ImGuiWindowFlag_ResizeS
  • ImGuiWindowFlag_ResizeE
  • ImGuiWindowFlag_ResizeW
  • ImGuiWindowFlag_ResizeNE = ImGuiWindowFlag_ResizeN | ImGuiWindowFlag_ResizeE
  • ImGuiWindowFlag_ResizeSE = ImGuiWindowFlag_ResizeS | ImGuiWindowFlag_ResizeE
  • ImGuiWindowFlag_ResizeNW = ImGuiWindowFlag_ResizeN | ImGuiWindowFlag_ResizeW
  • ImGuiWindowFlag_ResizeSW = ImGuiWindowFlag_ResizeS | ImGuiWindowFlag_ResizeW

That way any combination of corners and sides could be enabled or disabled. I did see that you have ImGuiMouseCursor_ResizeNWSE not really being used anywhere, and that you had the inklings of adding this type of support in the future.

If you don't like the flags approach and you want to go the style route, that could work as well. My bias is that in my use case, the resize style would not be global, but per window. I could definitely push and pop the style per window. Either way, I think it works.


I'll take some time this weekend to prototype a solution, see how it turns out. Would you like me to keep committing and commenting to this pull request? Or would you rather me open a new pull request that is more specific to adding full resize functionality and can be used for testing, iterating, and commenting?

@rokups
Copy link
Contributor

rokups commented Aug 13, 2017

This would be very useful for panel windows that are permanently docked at some edge of the window. Though flags should definitely be combinable as ImGuiWindowFlags_ResizeLowerLeft + ImGuiWindowFlags_ResizeLowerLeftAndRight hardly makes sense. What if i want to have resize handle at the right corner when panel-window is docked at the left?

Any chance to see this merged?

@ocornut
Copy link
Owner

ocornut commented Aug 14, 2017

Any chance to see this merged?

The four points I have highlighted still stand. The PR isn't mergeable as is but I agree we will need this feature. I suspect that the desirable answer will be that by default every window is resizable from all 4 corners and 4 border. This will probably have to wait until an official Docking extension is implemented.

I'll keep 1) and 2) in mind as I am looking at styles at the moment.

ocornut added a commit that referenced this pull request Dec 6, 2017
… any of the 4 corners (only 2 corners enabled). (#822)
ocornut added a commit that referenced this pull request Dec 6, 2017
…eFromAnySide is set. (#822) The interaction is currently unsatisfying because we can only reach a window from its inner rectangle (because of HoveredWindow filtering).
ocornut added a commit that referenced this pull request Dec 6, 2017
ocornut added a commit that referenced this pull request Dec 6, 2017
… any of the 4 corners (only 2 corners enabled). (#822)
ocornut added a commit that referenced this pull request Dec 6, 2017
…eFromAnySide is set. (#822) The interaction is currently unsatisfying because we can only reach a window from its inner rectangle (because of HoveredWindow filtering).
ocornut added a commit that referenced this pull request Dec 6, 2017
ocornut added a commit that referenced this pull request Dec 11, 2017
@ocornut
Copy link
Owner

ocornut commented Dec 11, 2017

@amc522 @rokups
This feature has been implemented with a new ImGuiWindowFlags_ResizeFromAnySide flag which also support resizing from borders.

However, two things:

For the border your backend/binding needs to honor mouse cursor requests otherwise you won't have visual feedback on hovering borders.

    ImGuiMouseCursor_ResizeNS,          // Unused
    ImGuiMouseCursor_ResizeEW,          // When hovering over a column
    ImGuiMouseCursor_ResizeNESW,        // When hovering over the bottom-left corner of a window
    ImGuiMouseCursor_ResizeNWSE,        // When hovering over the bottom-right corner of a window

I haven't got around to get all the backend to support mouse cursor and I think in the meanwhile this will stay a non-default flag.

For resizing from the border it currently requires the mouse to be inside the window which is a little unsatisfactory. This should be improved.

Closing this as the initial PR feature is supported. Added the point (2) in the todo list.

@ocornut ocornut closed this Dec 11, 2017
@amc522
Copy link
Contributor Author

amc522 commented Dec 11, 2017

Thank you so much for implementing this! Can't wait to try it out.

ocornut added a commit that referenced this pull request Jan 11, 2018
… window DrawList main clipping rectangle. Sane (and required for viewport code). (#822, #1542)
ocornut added a commit that referenced this pull request Jan 11, 2018
…dle manual resize (grip, border, gamepad) before setting up window DrawList main clipping rectangle. Sane (and required for viewport code). (#822, #1542)
ocornut added a commit that referenced this pull request Aug 1, 2018
… io.OptCursorBlink to io.ConfigCursorBlink, io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. (#1427, #1495, #822, #473, #650)

Demo: Exposed flags in Demo.
ocornut added a commit that referenced this pull request Oct 2, 2018
…a flag) extends the hit region of root floating windows outside the window, making it easier to resize windows. Resize grips are also extended accordingly so there are no discontinuity when hovering between borders and corners. (#1495, #822, #2110)
ocornut added a commit that referenced this pull request Jan 23, 2019
…low the rounded corners. Border rendering moved to RenderOuterBorders so it can be called in a different order for docking. (#1495, #822)
ocornut added a commit that referenced this pull request Jan 23, 2019
…low the rounded corners. Border rendering moved to RenderOuterBorders so it can be called in a different order for docking. (#1495, #822)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants