cycfi / elements

Elements C++ GUI library
http://cycfi.github.io/elements/
3.07k stars 232 forks source link

[Feature Request] Resizable child windows #419

Open Arcnor opened 1 month ago

Arcnor commented 1 month ago

Currently child windows cannot be resized, only moved and/or closed. My assumption is that a resizeable "trait" (sorry if that's not the right term!) can be added, similar to the moveable one.

djowel commented 1 month ago

My assumption is that a resizeable "trait" (sorry if that's not the right term!) can be added, similar to the moveable one.

Yes, that is correct.

djowel commented 1 month ago

I'm working on this.

djowel commented 1 month ago

Ah, then minimize/maximize have to be added.

djowel commented 1 month ago

Implemented now in master and skia_2024 branches.

Arcnor commented 1 month ago

I've finally tested this, seems to work mostly ok, although (and talking about the "Child Windows" example) depending on how far into the window the mouse cursor is, it either resizes the window or triggers the scrollbar behavior (when talking about the bottom/right areas) / moves the window (when talking about the top area), but the mouse cursor is still the resize one.

There is probably a difference between the area that triggers the cursor change and the area that actually effects the resizing behavior.

djowel commented 1 month ago

I've finally tested this, seems to work mostly ok, although (and talking about the "Child Windows" example) depending on how far into the window the mouse cursor is, it either resizes the window or triggers the scrollbar behavior (when talking about the bottom/right areas) / moves the window (when talking about the top area), but the mouse cursor is still the resize one.

There is probably a difference between the area that triggers the cursor change and the area that actually effects the resizing behavior.

Right! Good observation. The active areas overlap. What I should do is move the resize area outside the scroll bar's active area. I'll see what I can do!

djowel commented 1 month ago

Try it now. master and skia_2024

djowel commented 1 month ago

Need more cursors. I added two cursors for the corner sizing (north-to-east and south-to-west) for the Mac, example:

Screenshot 2024-07-14 at 1 24 07 PM

I also fixed the correct "sizing" cursors on the Mac.

If you can add the switches for setting these new cursors for GTK and Windows, that would be great. If not, I'll have this open and get back to it later. See:

void set_cursor(cursor_type type)

in base_view.cpp

Arcnor commented 1 month ago

Awesome. I actually noticed that corners were missing as well, but didn't want to bother you anymore 🙂.

I'll check and test Windows corner cursors (it's IDC_SIZENWSE and IDC_SIZENESW there), will also check GTK docs but not sure I'll be able to test the implementation, will let you know.

Arcnor commented 1 month ago

So I've implemented and tested Windows, the corner cursor seems to need a bit of tinkering. The area in which the cursor appear seems to be very small, and also the cursor can go from "h cursor" -> "diagonal cursor" -> "h cursor" (for example) when slowly panning the cursor from the right side of the window until you get to the corner. Same with the "v cursor".

As for GTK3 I'm having a bit of a hard time finding the diagonal cursor. I see there should be one on this image (although this might be GTK2?):

However, I can't find any diagonal cursors on the docs: https://docs.gtk.org/gdk3/enum.CursorType.html

djowel commented 1 month ago

So I've implemented and tested Windows, the corner cursor seems to need a bit of tinkering. The area in which the cursor appear seems to be very small, and also the cursor can go from "h cursor" -> "diagonal cursor" -> "h cursor" (for example) when slowly panning the cursor from the right side of the window until you get to the corner. Same with the "v cursor".

For sure. Right now the margin is just 5px. You are welcome to make some adjustments.

djowel commented 1 month ago

Did some refactoring and renames.

djowel commented 1 month ago

I'm going to move this to a feature branch (resizable_window and resizable_window_skia) until it is complete.

djowel commented 1 month ago

Done. This is moved to the resizable_window and resizable_window_skia branches now.