From e940fe0597052563c9afb2727e82c19bbfa10f5a Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Sun, 2 Jan 2005 20:05:39 +0000 Subject: [PATCH] Fixed button so that it stays depressed when mouse button is down, changed to support click and drag-off, centered button label vertically as Be's version is centered. Still need to add white line below focus line, need to verify the button's value is set at the correct times, need to verify that invoke is being used properly, need to test behavior and drawing when button is disabled. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10561 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Button.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp index a86b4c0cf4..ab66678faa 100644 --- a/src/kits/interface/Button.cpp +++ b/src/kits/interface/Button.cpp @@ -30,6 +30,7 @@ #include #include #include +#include // Project Includes ------------------------------------------------------------ @@ -96,7 +97,7 @@ void BButton::Draw(BRect updateRect) if (IsFocusChanging()) { float x = (bounds.right - StringWidth(Label())) / 2.0f; - float y = bounds.bottom - fh.descent - (IsDefault() ? 6.0f : 3.0f); + float y = bounds.top + ((bounds.Height() - fh.ascent - fh.descent) / 2.0f) + fh.ascent + fh.descent + 1; if (IsFocus()) SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); @@ -186,7 +187,8 @@ void BButton::Draw(BRect updateRect) // Label float x = (bounds.right - StringWidth(Label())) / 2.0f; - float y = bounds.bottom - fh.descent - (IsDefault() ? 8.0f : 5.0f); + float y = bounds.top + ((bounds.Height() - fh.ascent - fh.descent) / 2.0f) + fh.ascent + 1; + if (Value()) { @@ -204,7 +206,7 @@ void BButton::Draw(BRect updateRect) // Focus if (IsFocus()) { - y += 2.0f; + y += fh.descent; SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); StrokeLine(BPoint(x, y), BPoint(x + StringWidth(Label()), y)); } @@ -294,7 +296,7 @@ void BButton::MouseDown(BPoint point) GetMouse(&point, &buttons, true); - bool inside = bounds.Contains(ConvertFromScreen(point)); + bool inside = bounds.Contains(point); if ((Value() == B_CONTROL_ON) != inside) SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);