X-Git-Url: https://git.draconx.ca/gitweb/aspectbin.git/blobdiff_plain/7f9cfb4942bdc90c27b9a31d0ffdc9c0b93f2a7b..9b6b5289fb83a20a90aaa3e83b0b43662d650282:/aspectbin.c diff --git a/aspectbin.c b/aspectbin.c index 07fca93..ba3bbda 100644 --- a/aspectbin.c +++ b/aspectbin.c @@ -1,3 +1,22 @@ +/* AspectBin - A GTK+ container for packing with consrained aspect ratio. + * Copyright (C) 2009 Nick Bowler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #include #include "aspectbin.h" @@ -73,7 +92,7 @@ static void aspect_bin_class_init(AspectBinClass *class) PROP_CONSTRAIN, g_param_spec_boolean("constrain", "Constrain", - "Only expand the side to be as large as the body.", + "Try not to place the side beyond the body's edges.", FALSE, G_PARAM_READWRITE)); gtk_container_class_install_child_property(container_class, @@ -295,10 +314,16 @@ aspect_bin_size_allocate(GtkWidget *widget, GtkAllocation *allocation) } asize.y = (allocation->height - asize.height) * abin->body_align + 0.5; - csize.y = (allocation->height - csize.height) * abin->side_align + 0.5; - if (abin->constrain) { - csize.y = MIN(asize.y, allocation->height - csize.height); + if (abin->constrain && csize.height <= asize.height) { + csize.y = asize.y + (asize.height-csize.height) + * abin->side_align + 0.5; + } else if (abin->constrain) { + csize.y = (allocation->height - csize.height) + * abin->body_align + 0.5; + } else { + csize.y = (allocation->height - csize.height) + * abin->side_align + 0.5; } if (abin->body)