mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +00:00
info: improve sizing
We're now hinting the scrolled window about the content size to avoid empty space + scrolling.
This commit is contained in:
parent
98148dea9d
commit
3d6173aaba
1 changed files with 22 additions and 4 deletions
|
@ -59,6 +59,7 @@ public class MediaInfo.Info : Box
|
||||||
private Notebook subtitle_streams;
|
private Notebook subtitle_streams;
|
||||||
private AspectFrame drawing_frame;
|
private AspectFrame drawing_frame;
|
||||||
private DrawingArea drawing_area;
|
private DrawingArea drawing_area;
|
||||||
|
private ScrolledWindow info_area;
|
||||||
// gstreamer objects
|
// gstreamer objects
|
||||||
private Discoverer dc;
|
private Discoverer dc;
|
||||||
private Pipeline pb;
|
private Pipeline pb;
|
||||||
|
@ -170,21 +171,23 @@ public class MediaInfo.Info : Box
|
||||||
drawing_frame = new AspectFrame (null, 0.5f, 0.5f, 1.25f, false);
|
drawing_frame = new AspectFrame (null, 0.5f, 0.5f, 1.25f, false);
|
||||||
drawing_frame.set_size_request (160, 128);
|
drawing_frame.set_size_request (160, 128);
|
||||||
drawing_frame.set_shadow_type (Gtk.ShadowType.NONE);
|
drawing_frame.set_shadow_type (Gtk.ShadowType.NONE);
|
||||||
|
|
||||||
pack_start (drawing_frame, true, true, 0);
|
pack_start (drawing_frame, true, true, 0);
|
||||||
|
|
||||||
drawing_area = new DrawingArea ();
|
drawing_area = new DrawingArea ();
|
||||||
drawing_area.set_size_request (160, 128);
|
drawing_area.set_size_request (160, 128);
|
||||||
drawing_area.draw.connect (on_drawing_area_draw);
|
drawing_area.draw.connect (on_drawing_area_draw);
|
||||||
|
drawing_area.size_allocate.connect (on_drawing_area_size_allocate);
|
||||||
drawing_area.realize.connect (on_drawing_area_realize);
|
drawing_area.realize.connect (on_drawing_area_realize);
|
||||||
drawing_area.unrealize.connect (on_drawing_area_unrealize);
|
drawing_area.unrealize.connect (on_drawing_area_unrealize);
|
||||||
drawing_frame.add (drawing_area);
|
drawing_frame.add (drawing_area);
|
||||||
|
|
||||||
ScrolledWindow sw = new ScrolledWindow (null, null);
|
info_area = new ScrolledWindow (null, null);
|
||||||
sw.set_policy (PolicyType.NEVER, PolicyType.ALWAYS);
|
info_area.set_policy (PolicyType.NEVER, PolicyType.ALWAYS);
|
||||||
pack_start (sw, true, true, 0);
|
pack_start (info_area, true, true, 0);
|
||||||
|
|
||||||
table = new Table (8, 3, false);
|
table = new Table (8, 3, false);
|
||||||
sw.add_with_viewport (table);
|
info_area.add_with_viewport (table);
|
||||||
|
|
||||||
/* TODO: also use tabs for containers
|
/* TODO: also use tabs for containers
|
||||||
* - this is needed for e.g. mpeg-ts or mp3 inside ape
|
* - this is needed for e.g. mpeg-ts or mp3 inside ape
|
||||||
|
@ -759,6 +762,21 @@ public class MediaInfo.Info : Box
|
||||||
|
|
||||||
// signal handlers
|
// signal handlers
|
||||||
|
|
||||||
|
private void on_drawing_area_size_allocate (Widget widget, Gtk.Allocation frame)
|
||||||
|
{
|
||||||
|
Gtk.Allocation alloc;
|
||||||
|
get_allocation (out alloc);
|
||||||
|
stdout.printf("size_allocate: %d x %d\n", alloc.width, alloc.height);
|
||||||
|
|
||||||
|
Gtk.Requisition requisition;
|
||||||
|
info_area.get_child ().get_preferred_size (null, out requisition);
|
||||||
|
stdout.printf("info_area: %d x %d\n", requisition.width, requisition.height);
|
||||||
|
stdout.printf("video_area: %d x %d\n", frame.width, frame.height);
|
||||||
|
|
||||||
|
int max_h = alloc.height - frame.height;
|
||||||
|
info_area.set_min_content_height (int.min (requisition.height, max_h));
|
||||||
|
}
|
||||||
|
|
||||||
private bool on_drawing_area_draw (Widget widget, Cairo.Context cr)
|
private bool on_drawing_area_draw (Widget widget, Cairo.Context cr)
|
||||||
{
|
{
|
||||||
// redraw if not playing and if there is no video
|
// redraw if not playing and if there is no video
|
||||||
|
|
Loading…
Reference in a new issue