summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Thurman <tthurman@gnome.org>2009-10-23 19:51:42 -0400
committerThomas Thurman <tthurman@gnome.org>2009-10-23 19:51:42 -0400
commit894213c5260178132bf708dcd447d418cbf2cc1f (patch)
tree184d316cb6c8caae170a8ae4dde79d82f9cbf927
parent49f7dcf2a74f362f0a7cb6af9f5a1aa009675be8 (diff)
downloadmetacity-894213c5260178132bf708dcd447d418cbf2cc1f.tar.gz
calc aspect ratio of buttons
-rw-r--r--src/ui/theme.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 1bacbcdc..c536c91a 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -639,8 +639,44 @@ cowbell_get_button_width (MetaTheme *theme,
CopperClasses button,
int button_height)
{
- /* stub */
- return button_height;
+ double min_width=0.0, max_width=0.0;
+ double width=0.0, height=0.0;
+ ccss_style_t *style = cowbell_get_current_style (theme, type, flags, button);
+ double aspect_ratio;
+
+ ccss_style_get_double (style, "min-width", &min_width);
+ ccss_style_get_double (style, "max-width", &max_width);
+
+ if (min_width!=0.0 && min_width==max_width)
+ {
+ /* gosh, that was easy. */
+ return (int) min_width;
+ }
+
+ ccss_style_get_double (style, "width", &width);
+ ccss_style_get_double (style, "height", &height);
+
+ if (width==0.0 || height==0.0)
+ {
+ /* They didn't specify a width or height for the button.
+ *
+ * Ultimately I want to stop at this point and check for the
+ * background image, and default to its dimensions. But
+ * for now, let's assume it's square.
+ */
+ aspect_ratio = 1.0;
+
+ /* Warn them. This could be more informative... */
+ g_warning ("Button found with missing width or height");
+ }
+ else
+ {
+ aspect_ratio = width/height;
+ }
+
+ /* FIXME honour min/max width */
+
+ return (int) (width / aspect_ratio);
}
void
@@ -764,9 +800,6 @@ meta_theme_calc_geometry (MetaTheme *theme,
for (i=CC_BUTTON_FIRST; i<=CC_BUTTON_LAST; i++)
{
fgeom->areas[i].height = button_height;
- /* FIXME!! This needs to be worked out from the
- * aspect ratio, BUT for now we are assuming
- * all buttons are square. */
fgeom->areas[i].width = cowbell_get_button_width (theme, type, flags,
i,
button_height);