From 9563d722ea57b648f64264ce43e8d4ce83e141c3 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Fri, 7 Nov 2014 22:53:18 -0500
Subject: [PATCH] BToolbar: Allow the toolbar's orientation to be set by its
creator.
I already made this patch in Heidi's clone of BToolbar. Adding it here
allows me to drop Heidi's version altogether.
I also relicensed the header file at the permission of Stephan. The .cpp
file still lists him as author and copyright holder.
---
headers/private/shared/Toolbar.h | 9 ++++++---
src/kits/shared/Toolbar.cpp | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/headers/private/shared/Toolbar.h b/headers/private/shared/Toolbar.h
index d14eaec..130a6bf 100644
a
|
b
|
|
1 | 1 | /* |
2 | | * Copyright 2011 Stephan Aßmus <superstippi@gmx.de> |
3 | | * All rights reserved. Distributed under the terms of the MIT license. |
| 2 | * Copyright 2011-2014, Haiku, Inc. All rights reserved. |
| 3 | * Distributed under the terms of the MIT License. |
4 | 4 | */ |
5 | 5 | #ifndef _TOOLBAR_H |
6 | 6 | #define _TOOLBAR_H |
… |
… |
namespace BPrivate {
|
14 | 14 | |
15 | 15 | class BToolbar : public BGroupView { |
16 | 16 | public: |
17 | | BToolbar(BRect frame); |
| 17 | BToolbar(BRect frame, |
| 18 | orientation ont = B_HORIZONTAL); |
18 | 19 | virtual ~BToolbar(); |
19 | 20 | |
20 | 21 | virtual void Hide(); |
… |
… |
private:
|
41 | 42 | void _AddView(BView* view); |
42 | 43 | BButton* _FindButton(uint32 command) const; |
43 | 44 | void _HideToolTips() const; |
| 45 | |
| 46 | orientation fOrientation; |
44 | 47 | }; |
45 | 48 | |
46 | 49 | } // namespace BPrivate |
diff --git a/src/kits/shared/Toolbar.cpp b/src/kits/shared/Toolbar.cpp
index 4c9fbf5..0d6b791 100644
a
|
b
|
LockableButton::MouseDown(BPoint point)
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | | BToolbar::BToolbar(BRect frame) |
| 47 | BToolbar::BToolbar(BRect frame, orientation ont) |
48 | 48 | : |
49 | | BGroupView(B_HORIZONTAL) |
| 49 | BGroupView(ont), |
| 50 | fOrientation(ont) |
50 | 51 | { |
51 | 52 | float inset = ceilf(be_control_look->DefaultItemSpacing() / 2); |
52 | 53 | GroupLayout()->SetInsets(inset, 0, inset, 0); |
… |
… |
BToolbar::AddAction(BMessage* message, BHandler* target,
|
105 | 106 | void |
106 | 107 | BToolbar::AddSeparator() |
107 | 108 | { |
108 | | _AddView(new BSeparatorView(B_VERTICAL, B_PLAIN_BORDER)); |
| 109 | orientation ont = (fOrientation == B_HORIZONTAL) ? |
| 110 | B_VERTICAL : B_HORIZONTAL; |
| 111 | _AddView(new BSeparatorView(ont, B_PLAIN_BORDER)); |
109 | 112 | } |
110 | 113 | |
111 | 114 | |