[haiku-commits] r35856 - haiku/trunk/src/kits/interface

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 14 Mar 2010 13:54:54 +0100 (CET)

Author: jackburton
Date: 2010-03-14 13:54:53 +0100 (Sun, 14 Mar 2010)
New Revision: 35856
Changeset: http://dev.haiku-os.org/changeset/35856/haiku
Ticket: http://dev.haiku-os.org/ticket/5440

Modified:
   haiku/trunk/src/kits/interface/SeparatorItem.cpp
Log:
Set the preferred height of the separator to be always even, since, and center
the horizontal lines which represents it to the actual bounds. Should fix
#5440.


Modified: haiku/trunk/src/kits/interface/SeparatorItem.cpp
===================================================================
--- haiku/trunk/src/kits/interface/SeparatorItem.cpp    2010-03-14 12:15:52 UTC 
(rev 35855)
+++ haiku/trunk/src/kits/interface/SeparatorItem.cpp    2010-03-14 12:54:53 UTC 
(rev 35856)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2006, Haiku, Inc.
+ * Copyright (c) 2001-2010, Haiku, Inc.
  * Distributed under the terms of the MIT license.
  *
  * Authors:
@@ -68,7 +68,8 @@
                BFont font(be_plain_font);
                if (Menu())
                        Menu()->GetFont(&font);
-               *_height = floorf(font.Size() * 0.8);
+               const float height = floorf((font.Size() * 0.8) / 2) * 2;
+               *_height = max_c(4, height);
        }
 }
 
@@ -84,12 +85,13 @@
        rgb_color oldColor = menu->HighColor();
        rgb_color lowColor = menu->LowColor();
 
+       const float startTop = bounds.top + (floor(bounds.Height())) / 2;
        menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
-       menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
-               BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
+       menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
+               BPoint(bounds.right - 1.0f, startTop));
        menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
-       menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
-               BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
+       menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
+               BPoint(bounds.right - 1.0f, startTop + 1.0f));
 
        menu->SetHighColor(oldColor);
 }


Other related posts: