From X512 <danger_mail@xxxxxxx>:
X512 has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2316 ;)
Change subject: SeparatorItem: support horizontal layout
......................................................................
SeparatorItem: support horizontal layout
This is required for BMenuBar based toolbars.
Fixes #15785.
Change-Id: I8d108694b481e408e5c56e23a697c8e7829343dc
---
M headers/os/interface/Menu.h
M src/kits/interface/SeparatorItem.cpp
2 files changed, 34 insertions(+), 16 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/16/2316/1
diff --git a/headers/os/interface/Menu.h b/headers/os/interface/Menu.h
index 2960e3e..3fede3d 100644
--- a/headers/os/interface/Menu.h
+++ b/headers/os/interface/Menu.h
@@ -172,6 +172,7 @@
private:
friend class BMenuBar;
+ friend class BSeparatorItem;
friend class BPrivate::MenuPrivate;
friend status_t _init_interface_kit_();
friend status_t set_menu_info(menu_info* info);
diff --git a/src/kits/interface/SeparatorItem.cpp
b/src/kits/interface/SeparatorItem.cpp
index ef4abf7..a520bb3 100644
--- a/src/kits/interface/SeparatorItem.cpp
+++ b/src/kits/interface/SeparatorItem.cpp
@@ -62,16 +62,24 @@
void
BSeparatorItem::GetContentSize(float* _width, float* _height)
{
- if (_width != NULL)
- *_width = 2.0;
+ if (Menu() != NULL && Menu()->Layout() == B_ITEMS_IN_ROW) {
+ if (_width != NULL)
+ *_width = 2.0;
- if (_height != NULL) {
- BFont font(be_plain_font);
- if (Menu() != NULL)
- Menu()->GetFont(&font);
+ if (_height != NULL)
+ *_height = 2.0;
+ } else {
+ if (_width != NULL)
+ *_width = 2.0;
- const float height = floorf((font.Size() * 0.8) / 2) * 2;
- *_height = max_c(4, height);
+ if (_height != NULL) {
+ BFont font(be_plain_font);
+ if (Menu() != NULL)
+ Menu()->GetFont(&font);
+
+ const float height = floorf((font.Size() * 0.8) / 2) *
2;
+ *_height = max_c(4, height);
+ }
}
}
@@ -87,14 +95,23 @@
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, startTop),
- BPoint(bounds.right - 1.0f, startTop));
- menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
- menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
- BPoint(bounds.right - 1.0f, startTop + 1.0f));
-
+ if (menu->Layout() == B_ITEMS_IN_ROW) {
+ const float startLeft = bounds.left + (floor(bounds.Width())) /
2;
+ menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
+ menu->StrokeLine(BPoint(startLeft, bounds.top + 1.0f),
+ BPoint(startLeft, bounds.bottom - 1.0f));
+ menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
+ menu->StrokeLine(BPoint(startLeft + 1.0f, bounds.top + 1.0f),
+ BPoint(startLeft + 1.0f, bounds.bottom - 1.0f));
+ } else {
+ 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, startTop),
+ BPoint(bounds.right - 1.0f, startTop));
+ menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
+ menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
+ BPoint(bounds.right - 1.0f, startTop + 1.0f));
+ }
menu->SetHighColor(oldColor);
}
--
To view, visit https://review.haiku-os.org/c/haiku/+/2316
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I8d108694b481e408e5c56e23a697c8e7829343dc
Gerrit-Change-Number: 2316
Gerrit-PatchSet: 1
Gerrit-Owner: X512 <danger_mail@xxxxxxx>
Gerrit-MessageType: newchange