After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646841 - Propose the inclusion of gedit-overlay in gtk+
Propose the inclusion of gedit-overlay in gtk+
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal enhancement
: 3.2
Assigned To: gtk-bugs
gtk-bugs
: 618662 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-04-05 16:35 UTC by Ignacio Casal Quinteiro (nacho)
Modified: 2011-06-14 05:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ignacio Casal Quinteiro (nacho) 2011-04-05 16:35:22 UTC
gedit-overlay is a container similar to gtkfixed but using predefined positions. It is currently used by gedit, nautilus and epiphany and I think it is quite general purpose to be included in gtk+.
You can find it in the gedit repository:
http://git.gnome.org/browse/gedit/tree/gedit/gedit-overlay.c
http://git.gnome.org/browse/gedit/tree/gedit/gedit-overlay.h
http://git.gnome.org/browse/gedit/tree/gedit/gedit-overlay-child.h
http://git.gnome.org/browse/gedit/tree/gedit/gedit-overlay-child.c

Please lemme know if it is fine, or if it needs some modifications etc to get it in, or if you just don't want it and we keep it ourselves.
Comment 1 Javier Jardón (IRC: jjardon) 2011-04-20 12:20:22 UTC
*** Bug 618662 has been marked as a duplicate of this bug. ***
Comment 2 Matthias Clasen 2011-04-29 22:38:34 UTC
Looks certainly interesting. Without playing with this, here are some initial impressions from looking at the code for 5 minutes:

- If we do this, we probably want to make sure it can fully supersede GtkFixed (ie implement static positions, I guess)

- I would prefer to not expose the overlay-child struct, and instead make all the knobs available as child properties

- I think you probably want to allow x/y offsets, at least for stuff placed relative to corners ?

- Do we need z ordering ?

- Should the size request be MAX (main, all children) ?

- Why is this a window widget ?
Comment 3 Ignacio Casal Quinteiro (nacho) 2011-04-30 10:45:50 UTC
(In reply to comment #2)
> Looks certainly interesting. Without playing with this, here are some initial
> impressions from looking at the code for 5 minutes:
> 
> - If we do this, we probably want to make sure it can fully supersede GtkFixed
> (ie implement static positions, I guess)
Do we really want this? See that while GtkFixed is for placing widgets in static positions GeditOverlay is focused on the main widget/relative widget and having some widgets placed in static positions.

> 
> - I would prefer to not expose the overlay-child struct, and instead make all
> the knobs available as child properties
sure, although the reason for the overlay-child was to make the child have a GdkWindow.

> 
> - I think you probably want to allow x/y offsets, at least for stuff placed
> relative to corners ?
> 
makes sense

> - Do we need z ordering ?

Right now the last one added is the one that will be shown over the others. I do not know about any use case for z reodering, should we add it or wait if somebody request it?
> 
> - Should the size request be MAX (main, all children) ?
Not really, we had it like this before and it is not really what we want. The main widget is the one that should request the size and the other widgets shouldn't request more than the main widget. I.e in epiphany or nautilus you don't want the status widget to be bigger than the main widget.

> 
> - Why is this a window widget ?
Good question, when I made it was easier, so I guess I can change it.
Comment 4 Matthias Clasen 2011-05-12 23:43:15 UTC
This was discussed in the gtk team recently: 

https://live.gnome.org/GTK%2B/Meetings?action=AttachFile&do=view&target=20110510.txt

Some of the points that were raised:

- It would be good to have some usage guidelines for an overlay container like this (hig...)

- static placement (ie gtkfixed-like) was seen as relatively uninteresting

- for specifying the placement, would be nice to reuse a pair of GtkAlign values 
  (ie start, center, end for each dimension).
Comment 5 Ignacio Casal Quinteiro (nacho) 2011-05-13 08:27:03 UTC
So I guess I could give it some time to this, some things:
* Should it be GtkOverlay?
* in relation to GtkAlign, do we manage the z dimension?, do we manage it with something else than GtkAlign? do we manage it at all?

I think I will start next week and with the easy parts first, i.e removing the GdkWindow from it, as commented on #comment2
Comment 6 Matthias Clasen 2011-05-16 14:50:46 UTC
I don't think we need to manage z, initially.
Comment 7 Benjamin Otte (Company) 2011-05-18 19:45:39 UTC
(In reply to comment #4)
> - for specifying the placement, would be nice to reuse a pair of GtkAlign
> values 
>   (ie start, center, end for each dimension).
>
Actually, I think it would be awesome to use the actual values of gtk_widget_get_halign() and gtk_widget_get_valign(). Otherwise those values won't do anything...

Another thing I wanted to point out:
The overlay currently underallocates the overlayed child if it is bigger than the parent. This can be seen when shrinking nautilus to its minimum size and opening a directory that causes the loading bar to appear.
Comment 8 Ignacio Casal Quinteiro (nacho) 2011-05-20 14:24:35 UTC
I'll be working on this on my branch:
https://github.com/nacho/gtk-/tree/overlay

I'll let you know when I get the current commented things ready.
Comment 9 Matthias Clasen 2011-05-26 20:06:13 UTC
Some review comments:

api:
- should there be api to get/set the relative widget ?
- maybe keep that out of the constructor ?
- what does gtk_container_add do - it would feel more natural to
  me to make this behave like a bin, with only one slot for regular
  children, and treat the overlays as special slots
- maybe keep offsets out of overlay_add ?
- if there's set_offset, there should be get_offset too
- offset interpretation seems inconsistent (I would have expected
  negative offseets for the end alignment case)
- or maybe do without offsets and use widget margins ?

implementation:
- dispose should drop relative_widget ?
- should require relative_widget to be descendent of main_widget ?
- probably need to queue a resize when relative_widget_is set ?
- not sure main_widget should be a property
- gtk_overlay_size_allocate needs to translate the relative_widget
  allocation to overlay->window coordinates, I think ?
- gtk_overlay_remove leaks the child window
Comment 10 Ignacio Casal Quinteiro (nacho) 2011-05-26 20:21:16 UTC
(In reply to comment #9)
> Some review comments:
> 
> api:
> - should there be api to get/set the relative widget ?
ok
> - maybe keep that out of the constructor ?
ok
> - what does gtk_container_add do - it would feel more natural to
>   me to make this behave like a bin, with only one slot for regular
>   children, and treat the overlays as special slots
so remove the main_widget from construction and set it with gtk_container_add ?
will make more happy glade indeed
> - maybe keep offsets out of overlay_add ?
ok
> - if there's set_offset, there should be get_offset too
> - offset interpretation seems inconsistent (I would have expected
>   negative offseets for the end alignment case)
> - or maybe do without offsets and use widget margins ?
I will implement this with the margins
> 
> implementation:
> - dispose should drop relative_widget ?
well it is suppose to be a child of main_widget
> - should require relative_widget to be descendent of main_widget ?
yes, that's the idea but not sure how to do it, any way to check this?
or should I just go children by children checking?
> - probably need to queue a resize when relative_widget_is set ?
makes sense, yes
> - not sure main_widget should be a property
if we add it with gtk_container_add doesn't look like so
> - gtk_overlay_size_allocate needs to translate the relative_widget
>   allocation to overlay->window coordinates, I think ?
mmm, not sure about this...

> - gtk_overlay_remove leaks the child window
ok

I will tell about when I get things ready. Thanks for the review
Comment 11 Ignacio Casal Quinteiro (nacho) 2011-05-26 22:23:57 UTC
It kinda makes sense to me also, that if we remove the main widget we remove also the other widgets and we set the relative widget to NULL.
What do you think? is this the desired behavior or just set the relative widget to null and we leave the other widgets waiting for another main widget?
Comment 12 Matthias Clasen 2011-06-11 02:48:08 UTC
I've pushed your branch to git.gnome.org, with a bunch of fixes of mine on top.
I think it is very close to merge-ready now, I'll probably do that over the weekend.