preview: fix minimal size

We need some minial size, otherwise we can enlarge, but not shrink the window.
This commit is contained in:
Stefan Sauer 2013-09-04 09:16:47 +02:00
parent 449342ba30
commit a432c367e7
2 changed files with 15 additions and 11 deletions

View file

@ -147,6 +147,7 @@ public class MediaInfo.Info : Box
// add widgets // add widgets
preview = new Preview (); preview = new Preview ();
preview.draw.connect (on_preview_draw); preview.draw.connect (on_preview_draw);
preview.size_allocate.connect (on_preview_size_allocate);
pack_start (preview, false, false, 0); pack_start (preview, false, false, 0);
info_area = new ScrolledWindow (null, null); info_area = new ScrolledWindow (null, null);
@ -718,9 +719,9 @@ public class MediaInfo.Info : Box
// signal handlers // signal handlers
/* private void on_preview_size_allocate (Widget widget, Gtk.Allocation box)
private void on_size_allocate (Widget widget, Gtk.Allocation box)
{ {
/*
Gtk.Allocation alloc; Gtk.Allocation alloc;
get_allocation (out alloc); get_allocation (out alloc);
debug ("size_allocate: %d x %d", alloc.width, alloc.height); debug ("size_allocate: %d x %d", alloc.width, alloc.height);
@ -728,13 +729,12 @@ public class MediaInfo.Info : Box
Gtk.Requisition requisition; Gtk.Requisition requisition;
info_area.get_child ().get_preferred_size (null, out requisition); info_area.get_child ().get_preferred_size (null, out requisition);
debug ("info_area: %d x %d", requisition.width, requisition.height); debug ("info_area: %d x %d", requisition.width, requisition.height);
int frame_height = (int)(box.width / video_ratio); debug ("video_area: %d x %d", box.width, box.height);
debug ("video_area: %d x %d", box.width, frame_height);
int max_h = alloc.height - frame_height; int max_h = alloc.height - box.height;
info_area.set_min_content_height (int.min (requisition.height, max_h)); info_area.set_min_content_height (int.min (requisition.height, max_h));
*/
} }
*/
private bool on_preview_draw (Widget widget, Cairo.Context cr) private bool on_preview_draw (Widget widget, Cairo.Context cr)
{ {

View file

@ -67,7 +67,8 @@ public class MediaInfo.Preview : DrawingArea {
public override void get_preferred_width (out int minimal_width, out int natural_width) { public override void get_preferred_width (out int minimal_width, out int natural_width) {
if (ratio != 0.0) { if (ratio != 0.0) {
minimal_width = natural_width = (int)(alloc_height * ratio); minimal_width = 16;
natural_width = (int)(alloc_height * ratio);
} else { } else {
minimal_width = natural_width = 0; minimal_width = natural_width = 0;
} }
@ -76,7 +77,8 @@ public class MediaInfo.Preview : DrawingArea {
public override void get_preferred_height (out int minimal_height, out int natural_height) { public override void get_preferred_height (out int minimal_height, out int natural_height) {
if (ratio != 0.0) { if (ratio != 0.0) {
minimal_height = natural_height = (int)(alloc_width / ratio); minimal_height = 12;
natural_height = (int)(alloc_width / ratio);
} else { } else {
minimal_height = natural_height = 0; minimal_height = natural_height = 0;
} }
@ -85,7 +87,8 @@ public class MediaInfo.Preview : DrawingArea {
public override void get_preferred_width_for_height (int height, out int minimal_width, out int natural_width) { public override void get_preferred_width_for_height (int height, out int minimal_width, out int natural_width) {
if (ratio != 0.0) { if (ratio != 0.0) {
minimal_width = natural_width = (int)(height * ratio); minimal_width = 16;
natural_width = (int)(height * ratio);
} else { } else {
minimal_width = natural_width = 0; minimal_width = natural_width = 0;
} }
@ -94,7 +97,8 @@ public class MediaInfo.Preview : DrawingArea {
public override void get_preferred_height_for_width (int width, out int minimal_height, out int natural_height) { public override void get_preferred_height_for_width (int width, out int minimal_height, out int natural_height) {
if (ratio != 0.0) { if (ratio != 0.0) {
minimal_height = natural_height = (int)(width / ratio); minimal_height = 12;
natural_height = (int)(width / ratio);
} else { } else {
minimal_height = natural_height = 0; minimal_height = natural_height = 0;
} }
@ -106,7 +110,7 @@ public class MediaInfo.Preview : DrawingArea {
alloc_width = alloc.width; alloc_width = alloc.width;
alloc_height = alloc.height; alloc_height = alloc.height;
debug ("alloc w,h: %d,%d", alloc_width, alloc_height); debug ("alloc w,h: %d,%d", alloc_width, alloc_height);
} }
public override bool draw (Cairo.Context cr) { public override bool draw (Cairo.Context cr) {