BeControlLook: Fix app integration drawing issues
Update BTab::DrawTab() to pass the current index, the index of the selected tab, and the index of the first and last tabs into BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab(). This allows you to draw tabs differently in your BTab or BControlLook subclass in many different circumstances. Modify BControlLook API to add indexes to DrawActiveTab() and DrawInactiveTab() like so: void DrawActiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); void DrawInactiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); These extra indexes are not used by HaikuControlLook which relies only on if the tab is active or inactive to draw. Add IndexOf(BTab* tab) method to BTabView and document it to get the index of the current tab in BTab::DrawTab(). Also add a warning in the BTabView::DrawTab() method not to use the position and full parameters anymore, use BTabView::IndexOf(), BTabView::Selection(), and BTabView::TabCount() to get the info you need. Using a dynamic_cast to a BTabView in BeControlLook to determine if the view is derived from a BTabView didn't work in the case of WebPositive. Furthermore, WebPositive does custom tab drawing which needed to be updated for alternative control look. These index parameters passed from BTab to BeControlLook allow us to draw the tab like BeOS without relying on a dynamic_cast to BTabView to get the info. Reproduce the functionality described above for BTab in WebPositive's custom tabs. Eliminate no longer needed code in favor of using indexes. Update WebPositive custom tabs to use BControlLook::DrawTabFrame() instead of BControlLook::DrawInactiveTab() matching the update made in BTabView. In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive doesn't draw any tab background, so it expects this work to be done for it. Eliminate hasFrames variable from WebPositive. Rename TabSelected(index) to UpdateSelection(index) in WebPositive to better reflect its purpose. Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more selectively. Only draw border if left border is set for top and bottom tabs or top border is set for left and right tabs. Undo no longer needed frame manipulation border drawing workaround in HaikuControlLook::DrawTabFrame(). Draw scroll bar triangle without using DrawArrowShape(). Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in BOutlineListView and menus distinctly from how it draws arrows in scroll bars. Draw our distinct arrows in DrawSrollBarButtons() instead. This fixes overflow of time edit up-down arrows in Clock prefs and the collapse-expand arrow in Deskbar not being vertically centered. In DrawBorders() only inset if we actually draw the border. Fix alignment issues with DrawSliderThumb dots for example in MediaPlayer volume knobs. Draw using line arrays calling AddLine instead of StrokeLine in several places. DrawMenuBar() extends to draw final pixel which eliminates an extra lines at the end of menu bars. Truncate button labels better fixing a few issues for example keymap keyboard layout button labels. Button insets has been updated a bit to fix drawing issues with buttons missing a border. Using a dynamic_cast to a BButton to determine if a view is a button in BeControlLook didn't work in the case of the keymap label. Look for B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel() to draw the label inverted on click. Pass the B_FLAT flag from Keymap keys when drawing using BControlLook so that the label is inverted. Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
186dc96ef6
commit
7c095f4709
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014 Haiku, Inc. All rights reserved.
|
* Copyright 2014-2020 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* John Scipione, [email protected]
|
* John Scipione, [email protected]
|
||||||
*
|
*
|
||||||
* Corresponds to:
|
* Corresponds to:
|
||||||
* headers/os/interface/TabView.h hrev45377
|
* headers/os/interface/TabView.h hrev54500
|
||||||
* src/kits/interface/TabView.cpp hrev45377
|
* src/kits/interface/TabView.cpp hrev54500
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -27,33 +27,45 @@
|
|||||||
Tab position flags
|
Tab position flags
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
|
|
||||||
|
\deprecated This should not be used anymore.
|
||||||
|
\sa BTab::DrawTab()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\var tab_position B_TAB_FIRST
|
\var tab_position B_TAB_FIRST
|
||||||
|
|
||||||
First tab in the tab view.
|
The first tab in the tab view.
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
|
|
||||||
|
\deprecated This should not be used anymore.
|
||||||
|
\sa BTab::DrawTab()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\var tab_position B_TAB_FRONT
|
\var tab_position B_TAB_FRONT
|
||||||
|
|
||||||
Front most tab in the tab view.
|
The selected tab in the tab view.
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
|
|
||||||
|
\deprecated This should not be used anymore.
|
||||||
|
\sa BTab::DrawTab()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\var tab_position B_TAB_ANY
|
\var tab_position B_TAB_ANY
|
||||||
|
|
||||||
Any tab in the tab view.
|
Any tab in the tab view that is not the first or selected tab.
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
|
|
||||||
|
\deprecated This should not be used anymore.
|
||||||
|
\sa BTab::DrawTab()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -239,20 +251,27 @@
|
|||||||
/*!
|
/*!
|
||||||
\fn void BTab::DrawTab(BView* owner, BRect frame, tab_position position,
|
\fn void BTab::DrawTab(BView* owner, BRect frame, tab_position position,
|
||||||
bool full)
|
bool full)
|
||||||
\brief Draws the tab.
|
\brief Draws the tab and label according to \a position and \a full.
|
||||||
|
|
||||||
This method draws the tab's title by calling DrawLabel(), then draws the
|
This method draws the tab, then draws the tab's title by calling
|
||||||
tab itself. The \a position of the tab may affect how the tab is rendered
|
DrawLabel(). The \a position of the tab may affect how the tab is
|
||||||
-- for example the frontmost tab may have a different appearance than the
|
rendered -- for example the first tab may have a differene appearance
|
||||||
other tabs.
|
than the other tabs. You may override this method to draw tabs
|
||||||
|
differently in your BTab subclass.
|
||||||
|
|
||||||
\param owner The view that owns the tab.
|
\param owner The view that owns the tab.
|
||||||
\param frame The frame rectangle to draw in.
|
\param frame The frame rectangle to draw in.
|
||||||
\param position May affect how the tab is rendered. Choices include:
|
\param position May affect how the tab is rendered. Choices include:
|
||||||
- \c B_TAB_FIRST
|
- \c B_TAB_FIRST The first tab
|
||||||
- \c B_TAB_FRONT
|
- \c B_TAB_FRONT The selected or active tab
|
||||||
- \c B_TAB_ANY
|
- \c B_TAB_ANY Tab that is not first or front
|
||||||
\param full Whether or not to completely draw the tab, no longer used.
|
\param full Whether or not to completely draw the tab. All tabs were full
|
||||||
|
except for the tab before the selected tab on BeOS R5.
|
||||||
|
|
||||||
|
\warning The \a position and \a full parameters should no longer be used.
|
||||||
|
This information can be gathered from BTabView by calling the
|
||||||
|
BTabView::IndexOf(), BTabView::Selection(), and
|
||||||
|
BTabView::CountTabs() methods.
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
*/
|
*/
|
||||||
@@ -484,7 +503,7 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int32 BTabView::Selection() const
|
\fn int32 BTabView::Selection() const
|
||||||
\brief Returns the currently selected tab's index.
|
\brief Returns the index of the selected tab or -1 if not found.
|
||||||
|
|
||||||
\since BeOS R3
|
\since BeOS R3
|
||||||
*/
|
*/
|
||||||
@@ -727,3 +746,11 @@
|
|||||||
|
|
||||||
\since Haiku R1
|
\since Haiku R1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn int32 BTabView::IndexOf(Tab* tab) const
|
||||||
|
\brief Returns the index of \a tab or -1 if not found.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|||||||
@@ -294,12 +294,16 @@ public:
|
|||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER) = 0;
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0) = 0;
|
||||||
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER) = 0;
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0) = 0;
|
||||||
|
|
||||||
virtual void DrawSplitter(BView* view, BRect& rect,
|
virtual void DrawSplitter(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ private:
|
|||||||
|
|
||||||
BTab& operator=(const BTab&);
|
BTab& operator=(const BTab&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 _Borders(BView* owner, BRect frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool fEnabled;
|
bool fEnabled;
|
||||||
bool fSelected;
|
bool fSelected;
|
||||||
@@ -180,6 +183,8 @@ public:
|
|||||||
int32 CountTabs() const;
|
int32 CountTabs() const;
|
||||||
BView* ViewForTab(int32 tabIndex) const;
|
BView* ViewForTab(int32 tabIndex) const;
|
||||||
|
|
||||||
|
int32 IndexOf(BTab* tab) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FBC padding and forbidden methods
|
// FBC padding and forbidden methods
|
||||||
virtual void _ReservedTabView3();
|
virtual void _ReservedTabView3();
|
||||||
|
|||||||
@@ -241,12 +241,16 @@ public:
|
|||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER);
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0);
|
||||||
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER);
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0);
|
||||||
|
|
||||||
virtual void DrawSplitter(BView* view, BRect& rect,
|
virtual void DrawSplitter(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
|
|||||||
@@ -466,9 +466,83 @@ BeControlLook::DrawScrollBarButton(BView* view, BRect rect,
|
|||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
view->FillRect(rect);
|
view->FillRect(rect);
|
||||||
|
|
||||||
|
// draw button triangle
|
||||||
|
// don't use DrawArrowShape because we use that to draw arrows differently
|
||||||
|
// in menus and outline list view
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
rect.OffsetBy(-3, -3);
|
rect.OffsetBy(-3, -3);
|
||||||
DrawArrowShape(view, rect, updateRect, base, direction, flags, B_NO_TINT);
|
|
||||||
|
BPoint tri1, tri2, tri3;
|
||||||
|
BPoint off1, off2, off3;
|
||||||
|
BRect r(rect.left, rect.top, rect.left + 14, rect.top + 14);
|
||||||
|
rgb_color lightenmax = tint_color(base, B_LIGHTEN_MAX_TINT);
|
||||||
|
rgb_color light, dark, arrow, arrow2;
|
||||||
|
|
||||||
|
switch(direction) {
|
||||||
|
case B_LEFT_ARROW:
|
||||||
|
tri1.Set(r.left + 3, floorf((r.top + r.bottom) / 2));
|
||||||
|
tri2.Set(r.right - 4, r.top + 4);
|
||||||
|
tri3.Set(r.right - 4, r.bottom - 4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case B_RIGHT_ARROW:
|
||||||
|
tri1.Set(r.left + 4, r.bottom - 4);
|
||||||
|
tri2.Set(r.left + 4, r.top + 4);
|
||||||
|
tri3.Set(r.right - 3, floorf((r.top + r.bottom) / 2));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_UP_ARROW:
|
||||||
|
tri1.Set(r.left + 4, r.bottom - 4);
|
||||||
|
tri2.Set(floorf((r.left + r.right) / 2), r.top + 3);
|
||||||
|
tri3.Set(r.right - 4, r.bottom - 4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
tri1.Set(r.left + 4, r.top + 4);
|
||||||
|
tri2.Set(r.right - 4, r.top + 4);
|
||||||
|
tri3.Set(floorf((r.left + r.right) / 2), r.bottom - 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
r.InsetBy(1, 1);
|
||||||
|
|
||||||
|
float tint = B_NO_TINT;
|
||||||
|
if (!isEnabled)
|
||||||
|
tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
|
||||||
|
|
||||||
|
view->SetHighColor(tint_color(base, tint));
|
||||||
|
view->MovePenTo(B_ORIGIN);
|
||||||
|
view->SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
|
view->SetHighColor(tint_color(base, tint));
|
||||||
|
|
||||||
|
if (isEnabled) {
|
||||||
|
arrow2 = light = tint_color(base, B_DARKEN_2_TINT);
|
||||||
|
dark = tint_color(base, B_DARKEN_3_TINT);
|
||||||
|
arrow = tint_color(base, B_DARKEN_MAX_TINT);
|
||||||
|
} else
|
||||||
|
arrow = arrow2 = light = dark = tint_color(base, B_DARKEN_1_TINT);
|
||||||
|
|
||||||
|
// white triangle offset by 1px
|
||||||
|
off1.Set(tri1.x + 1, tri1.y + 1);
|
||||||
|
off2.Set(tri2.x + 1, tri2.y + 1);
|
||||||
|
off3.Set(tri3.x + 1, tri3.y + 1);
|
||||||
|
|
||||||
|
// draw white triangle
|
||||||
|
view->BeginLineArray(3);
|
||||||
|
view->AddLine(off2, off3, lightenmax);
|
||||||
|
view->AddLine(off1, off3, lightenmax);
|
||||||
|
view->AddLine(off1, off2, lightenmax);
|
||||||
|
view->EndLineArray();
|
||||||
|
|
||||||
|
// draw triangle on top
|
||||||
|
view->BeginLineArray(3);
|
||||||
|
view->AddLine(tri2, tri3, dark);
|
||||||
|
view->AddLine(tri1, tri3, dark);
|
||||||
|
view->AddLine(tri1, tri2, arrow2);
|
||||||
|
view->EndLineArray();
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
@@ -673,80 +747,61 @@ void
|
|||||||
BeControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
|
BeControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 direction, uint32 flags, float tint)
|
const rgb_color& base, uint32 direction, uint32 flags, float tint)
|
||||||
{
|
{
|
||||||
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
|
return;
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
bool isEnabled = (flags & B_DISABLED) == 0;
|
rgb_color fill = tint_color(base, 1.074); // 200
|
||||||
|
rgb_color stroke = tint_color(base, 1.629); // 80
|
||||||
BPoint tri1, tri2, tri3;
|
|
||||||
BPoint off1, off2, off3;
|
|
||||||
BRect r(rect.left, rect.top, rect.left + 14, rect.top + 14);
|
|
||||||
rgb_color lightenmax = tint_color(base, B_LIGHTEN_MAX_TINT);
|
|
||||||
rgb_color light, dark, arrow, arrow2;
|
|
||||||
|
|
||||||
switch(direction) {
|
switch(direction) {
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
tri1.Set(r.left + 3, floorf((r.top + r.bottom) / 2));
|
view->SetHighColor(fill);
|
||||||
tri2.Set(r.right - 4, r.top + 4);
|
view->FillTriangle(rect.LeftTop() + BPoint(4, 6),
|
||||||
tri3.Set(r.right - 4, r.bottom - 4);
|
rect.LeftTop() + BPoint(8, 2),
|
||||||
|
rect.LeftTop() + BPoint(8, 10));
|
||||||
|
view->SetHighColor(stroke);
|
||||||
|
view->StrokeTriangle(rect.LeftTop() + BPoint(4, 6),
|
||||||
|
rect.LeftTop() + BPoint(8, 2),
|
||||||
|
rect.LeftTop() + BPoint(8, 10));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
tri1.Set(r.left + 4, r.bottom - 4);
|
view->SetHighColor(fill);
|
||||||
tri2.Set(r.left + 4, r.top + 4);
|
view->FillTriangle(rect.LeftTop() + BPoint(4, 2),
|
||||||
tri3.Set(r.right - 3, floorf((r.top + r.bottom) / 2));
|
rect.LeftTop() + BPoint(4, 10),
|
||||||
|
rect.LeftTop() + BPoint(8, 6));
|
||||||
|
view->SetHighColor(stroke);
|
||||||
|
view->StrokeTriangle(rect.LeftTop() + BPoint(4, 2),
|
||||||
|
rect.LeftTop() + BPoint(4, 10),
|
||||||
|
rect.LeftTop() + BPoint(8, 6));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
tri1.Set(r.left + 4, r.bottom - 4);
|
view->SetHighColor(fill);
|
||||||
tri2.Set(floorf((r.left + r.right) / 2), r.top + 3);
|
view->FillTriangle(rect.LeftTop() + BPoint(6, 4),
|
||||||
tri3.Set(r.right - 4, r.bottom - 4);
|
rect.LeftTop() + BPoint(2, 8),
|
||||||
|
rect.LeftTop() + BPoint(10, 8));
|
||||||
|
view->SetHighColor(stroke);
|
||||||
|
view->StrokeTriangle(rect.LeftTop() + BPoint(6, 4),
|
||||||
|
rect.LeftTop() + BPoint(2, 8),
|
||||||
|
rect.LeftTop() + BPoint(10, 8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_DOWN_ARROW:
|
case B_DOWN_ARROW:
|
||||||
tri1.Set(r.left + 4, r.top + 4);
|
view->SetHighColor(fill);
|
||||||
tri2.Set(r.right - 4, r.top + 4);
|
view->FillTriangle(rect.LeftTop() + BPoint(2, 4),
|
||||||
tri3.Set(floorf((r.left + r.right) / 2), r.bottom - 3);
|
rect.LeftTop() + BPoint(10, 4),
|
||||||
|
rect.LeftTop() + BPoint(6, 8));
|
||||||
|
view->SetHighColor(stroke);
|
||||||
|
view->StrokeTriangle(rect.LeftTop() + BPoint(2, 4),
|
||||||
|
rect.LeftTop() + BPoint(10, 4),
|
||||||
|
rect.LeftTop() + BPoint(6, 8));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.InsetBy(1, 1);
|
|
||||||
|
|
||||||
if (!isEnabled)
|
|
||||||
tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
|
|
||||||
|
|
||||||
view->SetHighColor(tint_color(base, tint));
|
|
||||||
view->MovePenTo(B_ORIGIN);
|
|
||||||
view->SetDrawingMode(B_OP_OVER);
|
|
||||||
|
|
||||||
view->SetHighColor(tint_color(base, tint));
|
|
||||||
|
|
||||||
if (isEnabled) {
|
|
||||||
arrow2 = light = tint_color(base, B_DARKEN_2_TINT);
|
|
||||||
dark = tint_color(base, B_DARKEN_3_TINT);
|
|
||||||
arrow = tint_color(base, B_DARKEN_MAX_TINT);
|
|
||||||
} else
|
|
||||||
arrow = arrow2 = light = dark = tint_color(base, B_DARKEN_1_TINT);
|
|
||||||
|
|
||||||
// white triangle offset by 1px
|
|
||||||
off1.Set(tri1.x + 1, tri1.y + 1);
|
|
||||||
off2.Set(tri2.x + 1, tri2.y + 1);
|
|
||||||
off3.Set(tri3.x + 1, tri3.y + 1);
|
|
||||||
|
|
||||||
// draw white triangle
|
|
||||||
view->BeginLineArray(3);
|
|
||||||
view->AddLine(off2, off3, lightenmax);
|
|
||||||
view->AddLine(off1, off3, lightenmax);
|
|
||||||
view->AddLine(off1, off2, lightenmax);
|
|
||||||
view->EndLineArray();
|
|
||||||
|
|
||||||
// draw triangle on top
|
|
||||||
view->BeginLineArray(3);
|
|
||||||
view->AddLine(tri2, tri3, dark);
|
|
||||||
view->AddLine(tri1, tri3, dark);
|
|
||||||
view->AddLine(tri1, tri2, arrow2);
|
|
||||||
view->EndLineArray();
|
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,7 +823,7 @@ BeControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
|
|||||||
rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
|
rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
|
||||||
rgb_color darken1 = tint_color(base, B_DARKEN_1_TINT);
|
rgb_color darken1 = tint_color(base, B_DARKEN_1_TINT);
|
||||||
|
|
||||||
view->BeginLineArray(5);
|
view->BeginLineArray(3);
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), lighten2);
|
view->AddLine(rect.LeftTop(), rect.RightTop(), lighten2);
|
||||||
// left bottom pixel is base color
|
// left bottom pixel is base color
|
||||||
view->AddLine(rect.LeftTop(), rect.LeftBottom() - BPoint(0, 1),
|
view->AddLine(rect.LeftTop(), rect.LeftBottom() - BPoint(0, 1),
|
||||||
@@ -818,7 +873,6 @@ BeControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
|
|||||||
rect.InsetBy(2, 2);
|
rect.InsetBy(2, 2);
|
||||||
|
|
||||||
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
|
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
|
||||||
rgb_color darken4 = tint_color(base, B_DARKEN_4_TINT);
|
|
||||||
|
|
||||||
// draw left and top side and top right corner
|
// draw left and top side and top right corner
|
||||||
view->BeginLineArray(3);
|
view->BeginLineArray(3);
|
||||||
@@ -1009,31 +1063,33 @@ BeControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
|
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
|
||||||
rgb_color darkenmax = tint_color(base, B_DARKEN_MAX_TINT);
|
rgb_color darkenmax = tint_color(base, B_DARKEN_MAX_TINT);
|
||||||
|
|
||||||
view->SetHighColor(darken1);
|
view->BeginLineArray(9);
|
||||||
view->StrokeLine(BPoint(rect.left, rect.top),
|
|
||||||
BPoint(rect.left + 1, rect.top));
|
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom),
|
|
||||||
BPoint(rect.left + 1, rect.bottom));
|
|
||||||
view->StrokeLine(BPoint(rect.right - 1, rect.top),
|
|
||||||
BPoint(rect.right, rect.top));
|
|
||||||
|
|
||||||
view->SetHighColor(darken2);
|
view->AddLine(BPoint(rect.left, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.left + 1, rect.top),
|
BPoint(rect.left + 1, rect.top), darken1);
|
||||||
BPoint(rect.right - 1, rect.top));
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom - 1),
|
BPoint(rect.left + 1, rect.bottom), darken1);
|
||||||
BPoint(rect.left, rect.top + 1));
|
view->AddLine(BPoint(rect.right - 1, rect.top),
|
||||||
|
BPoint(rect.right, rect.top), darken1);
|
||||||
|
|
||||||
view->SetHighColor(lightenmax);
|
view->AddLine(BPoint(rect.left + 1, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.left + 1, rect.bottom),
|
BPoint(rect.right - 1, rect.top), darken2);
|
||||||
BPoint(rect.right, rect.bottom));
|
view->AddLine(BPoint(rect.left, rect.bottom - 1),
|
||||||
view->StrokeLine(BPoint(rect.right, rect.top + 1));
|
BPoint(rect.left, rect.top + 1), darken2);
|
||||||
|
|
||||||
|
view->AddLine(BPoint(rect.left + 1, rect.bottom),
|
||||||
|
BPoint(rect.right, rect.bottom), lightenmax);
|
||||||
|
view->AddLine(BPoint(rect.right, rect.top + 1),
|
||||||
|
BPoint(rect.right, rect.bottom), lightenmax);
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
|
|
||||||
view->SetHighColor(darkenmax);
|
view->AddLine(BPoint(rect.left, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom),
|
BPoint(rect.left, rect.bottom), darkenmax);
|
||||||
BPoint(rect.left, rect.top));
|
view->AddLine(BPoint(rect.left, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.right, rect.top));
|
BPoint(rect.right, rect.top), darkenmax);
|
||||||
|
|
||||||
|
view->EndLineArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1045,20 +1101,21 @@ BeControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
|
rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
|
||||||
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
|
rgb_color dark = tint_color(base, 1.333); // 144
|
||||||
rgb_color darken3 = tint_color(base, B_DARKEN_3_TINT);
|
rgb_color darker = tint_color(base, 1.444); // 120
|
||||||
rgb_color darkenmax = tint_color(base, B_DARKEN_MAX_TINT);
|
rgb_color darkenmax = tint_color(base, B_DARKEN_MAX_TINT);
|
||||||
|
|
||||||
|
view->BeginLineArray(14);
|
||||||
|
|
||||||
// outline
|
// outline
|
||||||
view->SetHighColor(darken3);
|
view->AddLine(BPoint(rect.left, rect.bottom - 2),
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom - 2),
|
BPoint(rect.left, rect.top + 1), darker);
|
||||||
BPoint(rect.left, rect.top + 1));
|
view->AddLine(BPoint(rect.left + 1, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.left + 1, rect.top),
|
BPoint(rect.right - 2, rect.top), darker);
|
||||||
BPoint(rect.right - 2, rect.top));
|
view->AddLine(BPoint(rect.right, rect.top + 2),
|
||||||
view->StrokeLine(BPoint(rect.right, rect.top + 2),
|
BPoint(rect.right, rect.bottom - 1), darker);
|
||||||
BPoint(rect.right, rect.bottom - 1));
|
view->AddLine(BPoint(rect.left + 2, rect.bottom),
|
||||||
view->StrokeLine(BPoint(rect.left + 2, rect.bottom),
|
BPoint(rect.right - 1, rect.bottom), darker);
|
||||||
BPoint(rect.right - 1, rect.bottom));
|
|
||||||
|
|
||||||
// first bevel
|
// first bevel
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
@@ -1066,46 +1123,51 @@ BeControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect
|
|||||||
view->SetHighColor(lighten2);
|
view->SetHighColor(lighten2);
|
||||||
view->FillRect(rect);
|
view->FillRect(rect);
|
||||||
|
|
||||||
view->SetHighColor(darkenmax);
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom),
|
BPoint(rect.right - 1, rect.bottom), darkenmax);
|
||||||
BPoint(rect.right - 1, rect.bottom));
|
view->AddLine(BPoint(rect.right, rect.bottom - 1),
|
||||||
view->StrokeLine(BPoint(rect.right, rect.bottom - 1),
|
BPoint(rect.right, rect.top), darkenmax);
|
||||||
BPoint(rect.right, rect.top));
|
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
|
|
||||||
// second bevel and center dots
|
// second bevel and center dots
|
||||||
view->SetHighColor(darken2);
|
view->SetHighColor(dark);
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom),
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
BPoint(rect.right, rect.bottom));
|
BPoint(rect.right, rect.bottom), dark);
|
||||||
view->StrokeLine(BPoint(rect.right, rect.top));
|
view->AddLine(BPoint(rect.right, rect.top),
|
||||||
|
BPoint(rect.right, rect.bottom), dark);
|
||||||
|
|
||||||
|
// center dots
|
||||||
|
float hCenter = rect.Width() / 2;
|
||||||
|
float vMiddle = rect.Height() / 2;
|
||||||
if (orientation == B_HORIZONTAL) {
|
if (orientation == B_HORIZONTAL) {
|
||||||
view->StrokeLine(BPoint(rect.left + 6, rect.top + 2),
|
view->AddLine(BPoint(rect.left + hCenter, rect.top + 1),
|
||||||
BPoint(rect.left + 6, rect.top + 2));
|
BPoint(rect.left + hCenter, rect.top + 1), dark);
|
||||||
view->StrokeLine(BPoint(rect.left + 6, rect.top + 4),
|
view->AddLine(BPoint(rect.left + hCenter, rect.top + 3),
|
||||||
BPoint(rect.left + 6, rect.top + 4));
|
BPoint(rect.left + hCenter, rect.top + 3), dark);
|
||||||
view->StrokeLine(BPoint(rect.left + 6, rect.top + 6),
|
view->AddLine(BPoint(rect.left + hCenter, rect.top + 5),
|
||||||
BPoint(rect.left + 6, rect.top + 6));
|
BPoint(rect.left + hCenter, rect.top + 5), dark);
|
||||||
} else {
|
} else {
|
||||||
view->StrokeLine(BPoint(rect.left + 2, rect.top + 6),
|
view->AddLine(BPoint(rect.left + 1, rect.top + vMiddle),
|
||||||
BPoint(rect.left + 2, rect.top + 6));
|
BPoint(rect.left + 1, rect.top + vMiddle), dark);
|
||||||
view->StrokeLine(BPoint(rect.left + 4, rect.top + 6),
|
view->AddLine(BPoint(rect.left + 3, rect.top + vMiddle),
|
||||||
BPoint(rect.left + 4, rect.top + 6));
|
BPoint(rect.left + 3, rect.top + vMiddle), dark);
|
||||||
view->StrokeLine(BPoint(rect.left + 6, rect.top + 6),
|
view->AddLine(BPoint(rect.left + 5, rect.top + vMiddle - 1),
|
||||||
BPoint(rect.left + 6, rect.top + 6));
|
BPoint(rect.left + 5, rect.top + vMiddle), dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
view->StrokeLine(BPoint(rect.right + 1, rect.bottom + 1),
|
view->AddLine(BPoint(rect.right + 1, rect.bottom + 1),
|
||||||
BPoint(rect.right + 1, rect.bottom + 1));
|
BPoint(rect.right + 1, rect.bottom + 1), dark);
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
|
|
||||||
// third bevel
|
// third bevel
|
||||||
view->SetHighColor(base);
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
view->StrokeLine(BPoint(rect.left, rect.bottom),
|
BPoint(rect.right, rect.bottom), base);
|
||||||
BPoint(rect.right, rect.bottom));
|
view->AddLine(BPoint(rect.right, rect.top),
|
||||||
view->StrokeLine(BPoint(rect.right, rect.top));
|
BPoint(rect.right, rect.bottom), base);
|
||||||
|
|
||||||
|
view->EndLineArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1275,6 +1337,9 @@ BeControlLook::DrawTabFrame(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
const rgb_color& base, uint32 flags, uint32 borders,
|
const rgb_color& base, uint32 flags, uint32 borders,
|
||||||
border_style borderStyle, uint32 side)
|
border_style borderStyle, uint32 side)
|
||||||
{
|
{
|
||||||
|
view->SetHighColor(base);
|
||||||
|
view->FillRect(rect);
|
||||||
|
|
||||||
rgb_color lightenmax = tint_color(base, B_LIGHTEN_MAX_TINT);
|
rgb_color lightenmax = tint_color(base, B_LIGHTEN_MAX_TINT);
|
||||||
|
|
||||||
view->BeginLineArray(1);
|
view->BeginLineArray(1);
|
||||||
@@ -1309,7 +1374,7 @@ BeControlLook::DrawTabFrame(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
void
|
void
|
||||||
BeControlLook::DrawActiveTab(BView* view, BRect& rect,
|
BeControlLook::DrawActiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders, uint32 side)
|
uint32 borders, uint32 side, int32, int32, int32, int32)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
@@ -1531,11 +1596,15 @@ BeControlLook::DrawActiveTab(BView* view, BRect& rect,
|
|||||||
void
|
void
|
||||||
BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
uint32 borders, uint32 side)
|
uint32 borders, uint32 side, int32 index, int32 selected,
|
||||||
|
int32 first, int32 last)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool isFirst = index == first;
|
||||||
|
bool isFull = index != selected - 1;
|
||||||
|
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
// set clipping constraints to updateRect plus 2px extra
|
// set clipping constraints to updateRect plus 2px extra
|
||||||
@@ -1551,16 +1620,12 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
view->SetHighColor(darkenmax);
|
view->SetHighColor(darkenmax);
|
||||||
view->SetLowColor(base);
|
view->SetLowColor(base);
|
||||||
|
|
||||||
BTabView* tabView = dynamic_cast<BTabView*>(view);
|
|
||||||
if (tabView == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
view->BeginLineArray(12);
|
view->BeginLineArray(12);
|
||||||
|
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case BTabView::kLeftSide:
|
case BTabView::kLeftSide:
|
||||||
// only draw if first tab is unselected
|
// only draw if first tab is unselected
|
||||||
if (updateRect == tabView->TabFrame(0)) {
|
if (isFirst) {
|
||||||
// before going left
|
// before going left
|
||||||
view->AddLine(BPoint(rect.right - 1, rect.top - 1),
|
view->AddLine(BPoint(rect.right - 1, rect.top - 1),
|
||||||
BPoint(rect.right - 1, rect.top - 1), lightenmax);
|
BPoint(rect.right - 1, rect.top - 1), lightenmax);
|
||||||
@@ -1593,7 +1658,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
BPoint(rect.right - 4, rect.bottom - 1), darken4);
|
BPoint(rect.right - 4, rect.bottom - 1), darken4);
|
||||||
|
|
||||||
// only draw if not before selected tab
|
// only draw if not before selected tab
|
||||||
if (updateRect != tabView->TabFrame(tabView->Selection() - 1)) {
|
if (isFull) {
|
||||||
// after going right
|
// after going right
|
||||||
view->AddLine(BPoint(rect.right - 3, rect.bottom),
|
view->AddLine(BPoint(rect.right - 3, rect.bottom),
|
||||||
BPoint(rect.right - 2, rect.bottom), darken4);
|
BPoint(rect.right - 2, rect.bottom), darken4);
|
||||||
@@ -1604,7 +1669,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
|
|
||||||
case BTabView::kRightSide:
|
case BTabView::kRightSide:
|
||||||
// only draw if first tab is unselected
|
// only draw if first tab is unselected
|
||||||
if (updateRect == tabView->TabFrame(0)) {
|
if (isFirst) {
|
||||||
// before going right
|
// before going right
|
||||||
view->AddLine(BPoint(rect.left - 1, rect.top - 1),
|
view->AddLine(BPoint(rect.left - 1, rect.top - 1),
|
||||||
BPoint(rect.left - 1, rect.top - 1), lightenmax);
|
BPoint(rect.left - 1, rect.top - 1), lightenmax);
|
||||||
@@ -1637,7 +1702,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
BPoint(rect.left - 4, rect.bottom - 1), darken4);
|
BPoint(rect.left - 4, rect.bottom - 1), darken4);
|
||||||
|
|
||||||
// only draw if not before selected tab
|
// only draw if not before selected tab
|
||||||
if (updateRect != tabView->TabFrame(tabView->Selection() - 1)) {
|
if (isFull) {
|
||||||
// after going left
|
// after going left
|
||||||
view->AddLine(BPoint(rect.left - 3, rect.bottom),
|
view->AddLine(BPoint(rect.left - 3, rect.bottom),
|
||||||
BPoint(rect.left - 2, rect.bottom), darken4);
|
BPoint(rect.left - 2, rect.bottom), darken4);
|
||||||
@@ -1649,7 +1714,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
default:
|
default:
|
||||||
case BTabView::kTopSide:
|
case BTabView::kTopSide:
|
||||||
// only draw if first tab is unselected
|
// only draw if first tab is unselected
|
||||||
if (updateRect == tabView->TabFrame(0)) {
|
if (isFirst) {
|
||||||
// before going up
|
// before going up
|
||||||
view->AddLine(BPoint(rect.left - 1, rect.bottom - 1),
|
view->AddLine(BPoint(rect.left - 1, rect.bottom - 1),
|
||||||
BPoint(rect.left - 1, rect.bottom - 1), lightenmax);
|
BPoint(rect.left - 1, rect.bottom - 1), lightenmax);
|
||||||
@@ -1682,7 +1747,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
BPoint(rect.right - 1, rect.bottom - 4), darken4);
|
BPoint(rect.right - 1, rect.bottom - 4), darken4);
|
||||||
|
|
||||||
// only draw if not before selected tab
|
// only draw if not before selected tab
|
||||||
if (updateRect != tabView->TabFrame(tabView->Selection() - 1)) {
|
if (isFull) {
|
||||||
// after going down
|
// after going down
|
||||||
view->AddLine(BPoint(rect.right, rect.bottom - 3),
|
view->AddLine(BPoint(rect.right, rect.bottom - 3),
|
||||||
BPoint(rect.right, rect.bottom - 2), darken4);
|
BPoint(rect.right, rect.bottom - 2), darken4);
|
||||||
@@ -1693,7 +1758,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
|
|
||||||
case BTabView::kBottomSide:
|
case BTabView::kBottomSide:
|
||||||
// only draw if first tab is unselected
|
// only draw if first tab is unselected
|
||||||
if (updateRect == tabView->TabFrame(0)) {
|
if (isFirst) {
|
||||||
// before going down
|
// before going down
|
||||||
view->AddLine(BPoint(rect.left - 1, rect.top - 1),
|
view->AddLine(BPoint(rect.left - 1, rect.top - 1),
|
||||||
BPoint(rect.left - 1, rect.top - 1), lightenmax);
|
BPoint(rect.left - 1, rect.top - 1), lightenmax);
|
||||||
@@ -1726,7 +1791,7 @@ BeControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
|||||||
BPoint(rect.right - 1, rect.top - 4), darken4);
|
BPoint(rect.right - 1, rect.top - 4), darken4);
|
||||||
|
|
||||||
// only draw if not before selected tab
|
// only draw if not before selected tab
|
||||||
if (updateRect != tabView->TabFrame(tabView->Selection() - 1)) {
|
if (isFull) {
|
||||||
// after going up
|
// after going up
|
||||||
view->AddLine(BPoint(rect.right, rect.top - 3),
|
view->AddLine(BPoint(rect.right, rect.top - 3),
|
||||||
BPoint(rect.right, rect.top - 2), darken4);
|
BPoint(rect.right, rect.top - 2), darken4);
|
||||||
@@ -1876,68 +1941,89 @@ BeControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
|
|||||||
BRegion clipping(updateRect);
|
BRegion clipping(updateRect);
|
||||||
view->ConstrainClippingRegion(&clipping);
|
view->ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
rgb_color lightColor = tint_color(base, B_LIGHTEN_MAX_TINT);
|
rgb_color lightColor;
|
||||||
rgb_color shadowColor = tint_color(base, B_DARKEN_3_TINT);
|
rgb_color shadowColor;
|
||||||
if (base.Brightness() > 128) {
|
if (base.Brightness() > 128) {
|
||||||
lightColor = tint_color(base, B_DARKEN_2_TINT);
|
lightColor = tint_color(base, B_DARKEN_2_TINT);
|
||||||
shadowColor = tint_color(base, B_LIGHTEN_2_TINT);
|
shadowColor = tint_color(base, B_LIGHTEN_2_TINT);
|
||||||
|
} else {
|
||||||
|
lightColor = tint_color(base, B_LIGHTEN_MAX_TINT);
|
||||||
|
shadowColor = tint_color(base, B_DARKEN_3_TINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view->BeginLineArray(8);
|
||||||
|
|
||||||
if (borderStyle == B_FANCY_BORDER) {
|
if (borderStyle == B_FANCY_BORDER) {
|
||||||
rect.left++;
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
rect.top++;
|
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
|
||||||
view->EndLineArray();
|
|
||||||
|
|
||||||
rect.OffsetBy(-1, -1);
|
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
|
||||||
view->EndLineArray();
|
|
||||||
} else if (borderStyle == B_PLAIN_BORDER) {
|
|
||||||
rect.left++;
|
rect.left++;
|
||||||
rect.top++;
|
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
|
||||||
view->EndLineArray();
|
|
||||||
|
|
||||||
rect.OffsetBy(-1, -1);
|
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
|
||||||
view->EndLineArray();
|
|
||||||
}
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
||||||
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
||||||
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
||||||
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
} else if (borderStyle == B_PLAIN_BORDER) {
|
||||||
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
||||||
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
||||||
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
||||||
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
||||||
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view->EndLineArray();
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
@@ -1967,31 +2053,42 @@ BeControlLook::DrawRaisedBorder(BView* view, BRect& rect,
|
|||||||
shadowColor = tint_color(base, 1.07);
|
shadowColor = tint_color(base, 1.07);
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.left++;
|
view->BeginLineArray(8);
|
||||||
rect.top++;
|
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
|
||||||
view->EndLineArray();
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
|
||||||
rect.OffsetBy(-1, -1);
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
|
||||||
if ((borders & B_RIGHT_BORDER) != 0)
|
rect.top++;
|
||||||
|
}
|
||||||
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0)
|
rect.right--;
|
||||||
|
}
|
||||||
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
|
||||||
|
rect.bottom--;
|
||||||
|
}
|
||||||
|
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
@@ -2029,43 +2126,54 @@ BeControlLook::DrawTextControlBorder(BView* view, BRect& rect,
|
|||||||
bevelLight = isEnabled ? lightenmax : lighten1;
|
bevelLight = isEnabled ? lightenmax : lighten1;
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
view->BeginLineArray(4);
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), bevelShadow);
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), bevelShadow);
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), bevelShadow);
|
view->AddLine(rect.LeftTop(), rect.RightTop(), bevelShadow);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
if ((borders & B_RIGHT_BORDER) != 0) {
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(),
|
view->AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(),
|
||||||
bevelLight);
|
bevelLight);
|
||||||
|
rect.right--;
|
||||||
}
|
}
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0) {
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightBottom(), BPoint(rect.right, rect.top + 1),
|
view->AddLine(rect.RightBottom(), BPoint(rect.right, rect.top + 1),
|
||||||
bevelLight);
|
bevelLight);
|
||||||
|
rect.bottom--;
|
||||||
}
|
}
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
|
|
||||||
// second bevel
|
// second bevel
|
||||||
|
|
||||||
if (isEnabled && isFocused) {
|
if (isEnabled && isFocused) {
|
||||||
view->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
view->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||||
view->StrokeRect(rect);
|
view->StrokeRect(rect);
|
||||||
|
rect.InsetBy(1, 1);
|
||||||
} else {
|
} else {
|
||||||
bevelShadow = isEnabled ? darken4 : darken2;
|
bevelShadow = isEnabled ? darken4 : darken2;
|
||||||
bevelLight = base;
|
bevelLight = base;
|
||||||
|
|
||||||
view->BeginLineArray(4);
|
view->BeginLineArray(4);
|
||||||
if ((borders & B_LEFT_BORDER) != 0)
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftBottom(), rect.LeftTop(), bevelShadow);
|
view->AddLine(rect.LeftBottom(), rect.LeftTop(), bevelShadow);
|
||||||
if ((borders & B_TOP_BORDER) != 0)
|
rect.left++;
|
||||||
|
}
|
||||||
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(rect.LeftTop(), rect.RightTop(), bevelShadow);
|
view->AddLine(rect.LeftTop(), rect.RightTop(), bevelShadow);
|
||||||
|
rect.top++;
|
||||||
|
}
|
||||||
if ((borders & B_RIGHT_BORDER) != 0) {
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(),
|
view->AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(),
|
||||||
bevelLight);
|
bevelLight);
|
||||||
|
rect.right--;
|
||||||
}
|
}
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0) {
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(rect.RightBottom(), BPoint(rect.right, rect.top + 1),
|
view->AddLine(rect.RightBottom(), BPoint(rect.right, rect.top + 1),
|
||||||
bevelLight);
|
bevelLight);
|
||||||
|
rect.bottom--;
|
||||||
}
|
}
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
}
|
}
|
||||||
@@ -2111,6 +2219,8 @@ BeControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
|
|||||||
{
|
{
|
||||||
view->PushState();
|
view->PushState();
|
||||||
|
|
||||||
|
bool isButton = (flags & B_FLAT) != 0 || (flags & B_HOVER) != 0
|
||||||
|
|| (flags & B_DEFAULT_BUTTON) != 0;
|
||||||
bool isEnabled = (flags & B_DISABLED) == 0;
|
bool isEnabled = (flags & B_DISABLED) == 0;
|
||||||
bool isActivated = (flags & B_ACTIVATED) != 0;
|
bool isActivated = (flags & B_ACTIVATED) != 0;
|
||||||
|
|
||||||
@@ -2222,7 +2332,7 @@ BeControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rgb_color invertedIfClicked = color;
|
rgb_color invertedIfClicked = color;
|
||||||
if (isEnabled && isActivated && dynamic_cast<BButton*>(view) != NULL) {
|
if (isButton && isEnabled && isActivated) {
|
||||||
// only for enabled and activated buttons
|
// only for enabled and activated buttons
|
||||||
invertedIfClicked.red = 255 - invertedIfClicked.red;
|
invertedIfClicked.red = 255 - invertedIfClicked.red;
|
||||||
invertedIfClicked.green = 255 - invertedIfClicked.green;
|
invertedIfClicked.green = 255 - invertedIfClicked.green;
|
||||||
@@ -2283,7 +2393,7 @@ BeControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
|
|||||||
BFont font;
|
BFont font;
|
||||||
view->GetFont(&font);
|
view->GetFont(&font);
|
||||||
|
|
||||||
font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
|
font.TruncateString(&truncatedLabel, B_TRUNCATE_MIDDLE, availableWidth);
|
||||||
width += ceilf(font.StringWidth(truncatedLabel.String()));
|
width += ceilf(font.StringWidth(truncatedLabel.String()));
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
@@ -2316,10 +2426,10 @@ BeControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
|
|||||||
float y = location.y + ceilf(fontHeight.descent);
|
float y = location.y + ceilf(fontHeight.descent);
|
||||||
view->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
view->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||||
view->StrokeLine(BPoint(x, y),
|
view->StrokeLine(BPoint(x, y),
|
||||||
BPoint(x + view->StringWidth(label), y));
|
BPoint(x + view->StringWidth(truncatedLabel.String()), y));
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawLabel(view, label, base, flags, location, textColor);
|
DrawLabel(view, truncatedLabel.String(), base, flags, location, textColor);
|
||||||
|
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
@@ -2525,25 +2635,27 @@ BeControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
// dark border
|
// dark border
|
||||||
view->BeginLineArray(4);
|
view->BeginLineArray(4);
|
||||||
if ((borders & B_LEFT_BORDER) != 0) {
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left, rect.bottom - 1),
|
view->AddLine(BPoint(rect.left, rect.top + 1),
|
||||||
BPoint(rect.left, rect.top + 1), dark2BorderColor);
|
BPoint(rect.left, rect.bottom - 1), dark2BorderColor);
|
||||||
|
rect.left++;
|
||||||
}
|
}
|
||||||
if ((borders & B_TOP_BORDER) != 0) {
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.top),
|
view->AddLine(BPoint(rect.left, rect.top),
|
||||||
BPoint(rect.right - 1, rect.top), dark2BorderColor);
|
BPoint(rect.right - 1, rect.top), dark2BorderColor);
|
||||||
|
rect.top++;
|
||||||
}
|
}
|
||||||
if ((borders & B_RIGHT_BORDER) != 0) {
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.right, rect.top + 1),
|
view->AddLine(BPoint(rect.right, rect.top),
|
||||||
BPoint(rect.right, rect.bottom - 1), dark2BorderColor);
|
BPoint(rect.right, rect.bottom - 1), dark2BorderColor);
|
||||||
|
rect.right--;
|
||||||
}
|
}
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0) {
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.bottom),
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
BPoint(rect.right - 1, rect.bottom), dark2BorderColor);
|
BPoint(rect.right, rect.bottom), dark2BorderColor);
|
||||||
|
rect.bottom--;
|
||||||
}
|
}
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
|
|
||||||
// bevel
|
// bevel
|
||||||
view->SetHighColor(darken1);
|
view->SetHighColor(darken1);
|
||||||
view->StrokeRect(rect);
|
view->StrokeRect(rect);
|
||||||
@@ -2559,25 +2671,27 @@ BeControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
// dark border
|
// dark border
|
||||||
view->BeginLineArray(4);
|
view->BeginLineArray(4);
|
||||||
if ((borders & B_LEFT_BORDER) != 0) {
|
if ((borders & B_LEFT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left, rect.bottom - 1),
|
view->AddLine(BPoint(rect.left, rect.top + 1),
|
||||||
BPoint(rect.left, rect.top + 1), darken1);
|
BPoint(rect.left, rect.bottom - 1), darken1);
|
||||||
|
rect.left++;
|
||||||
}
|
}
|
||||||
if ((borders & B_TOP_BORDER) != 0) {
|
if ((borders & B_TOP_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.top),
|
view->AddLine(BPoint(rect.left, rect.top),
|
||||||
BPoint(rect.right - 1, rect.top), darken1);
|
BPoint(rect.right - 1, rect.top), darken1);
|
||||||
|
rect.top++;
|
||||||
}
|
}
|
||||||
if ((borders & B_RIGHT_BORDER) != 0) {
|
if ((borders & B_RIGHT_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.right, rect.top + 1),
|
view->AddLine(BPoint(rect.right, rect.top),
|
||||||
BPoint(rect.right, rect.bottom - 1), darken1);
|
BPoint(rect.right, rect.bottom - 1), darken1);
|
||||||
|
rect.right--;
|
||||||
}
|
}
|
||||||
if ((borders & B_BOTTOM_BORDER) != 0) {
|
if ((borders & B_BOTTOM_BORDER) != 0) {
|
||||||
view->AddLine(BPoint(rect.left + 1, rect.bottom),
|
view->AddLine(BPoint(rect.left, rect.bottom),
|
||||||
BPoint(rect.right - 1, rect.bottom), darken1);
|
BPoint(rect.right, rect.bottom), darken1);
|
||||||
|
rect.bottom--;
|
||||||
}
|
}
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
|
|
||||||
// fill
|
// fill
|
||||||
view->SetHighColor(lighten1);
|
view->SetHighColor(lighten1);
|
||||||
view->FillRect(rect);
|
view->FillRect(rect);
|
||||||
@@ -2585,10 +2699,8 @@ BeControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
|||||||
rect.InsetBy(3, 3);
|
rect.InsetBy(3, 3);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if not default button, add a 1px base color border
|
// if not default button, inset top and bottom by 1px
|
||||||
view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
rect.InsetBy(1, 0);
|
||||||
view->StrokeRect(rect);
|
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stroke frame to draw four corners, then write on top
|
// stroke frame to draw four corners, then write on top
|
||||||
|
|||||||
@@ -222,12 +222,16 @@ public:
|
|||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER);
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0);
|
||||||
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
virtual void DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base, uint32 flags = 0,
|
const rgb_color& base, uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS,
|
uint32 borders = B_ALL_BORDERS,
|
||||||
uint32 side = B_TOP_BORDER);
|
uint32 side = B_TOP_BORDER,
|
||||||
|
int32 index = 0, int32 selected = -1,
|
||||||
|
int32 first = 0, int32 last = 0);
|
||||||
|
|
||||||
virtual void DrawSplitter(BView* view, BRect& rect,
|
virtual void DrawSplitter(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
|
|||||||
@@ -75,44 +75,48 @@ TabContainerView::MessageReceived(BMessage* message)
|
|||||||
void
|
void
|
||||||
TabContainerView::Draw(BRect updateRect)
|
TabContainerView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
|
// draw tab frame
|
||||||
|
BRect rect(Bounds());
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
BRect frame(Bounds());
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
|
| BControlLook::B_BOTTOM_BORDER;
|
||||||
|
be_control_look->DrawTabFrame(this, rect, updateRect, base, 0,
|
||||||
|
borders, B_NO_BORDER);
|
||||||
|
|
||||||
// Draw empty area before first tab.
|
// draw tabs on top of frame
|
||||||
uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER;
|
|
||||||
BRect leftFrame(frame.left, frame.top, kLeftTabInset, frame.bottom);
|
|
||||||
be_control_look->DrawInactiveTab(this, leftFrame, updateRect, base, 0,
|
|
||||||
borders);
|
|
||||||
|
|
||||||
// Draw all tabs, keeping track of where they end.
|
|
||||||
BGroupLayout* layout = GroupLayout();
|
BGroupLayout* layout = GroupLayout();
|
||||||
int32 count = layout->CountItems() - 1;
|
int32 count = layout->CountItems() - 1;
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(layout->ItemAt(i));
|
||||||
layout->ItemAt(i));
|
if (item == NULL || !item->IsVisible())
|
||||||
if (!item || !item->IsVisible())
|
|
||||||
continue;
|
continue;
|
||||||
item->Parent()->Draw(updateRect);
|
item->Parent()->Draw(item->Frame());
|
||||||
frame.left = item->Frame().right + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw empty area after last tab.
|
|
||||||
be_control_look->DrawInactiveTab(this, frame, updateRect, base, 0, borders);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabContainerView::MouseDown(BPoint where)
|
TabContainerView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
|
if (Window() == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BMessage* currentMessage = Window()->CurrentMessage();
|
||||||
|
if (currentMessage == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
if (Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) != B_OK)
|
if (currentMessage->FindInt32("buttons", (int32*)&buttons) != B_OK)
|
||||||
buttons = B_PRIMARY_MOUSE_BUTTON;
|
buttons = B_PRIMARY_MOUSE_BUTTON;
|
||||||
|
|
||||||
uint32 clicks;
|
uint32 clicks;
|
||||||
if (Window()->CurrentMessage()->FindInt32("clicks", (int32*)&clicks) != B_OK)
|
if (currentMessage->FindInt32("clicks", (int32*)&clicks) != B_OK)
|
||||||
clicks = 1;
|
clicks = 1;
|
||||||
|
|
||||||
fMouseDown = true;
|
fMouseDown = true;
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||||
if (fLastMouseEventTab)
|
|
||||||
|
if (fLastMouseEventTab != NULL)
|
||||||
fLastMouseEventTab->MouseDown(where, buttons);
|
fLastMouseEventTab->MouseDown(where, buttons);
|
||||||
else {
|
else {
|
||||||
if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
|
if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
|
||||||
@@ -168,10 +172,11 @@ void
|
|||||||
TabContainerView::AddTab(const char* label, int32 index)
|
TabContainerView::AddTab(const char* label, int32 index)
|
||||||
{
|
{
|
||||||
TabView* tab;
|
TabView* tab;
|
||||||
if (fController)
|
if (fController != NULL)
|
||||||
tab = fController->CreateTabView();
|
tab = fController->CreateTabView();
|
||||||
else
|
else
|
||||||
tab = new TabView();
|
tab = new TabView();
|
||||||
|
|
||||||
tab->SetLabel(label);
|
tab->SetLabel(label);
|
||||||
AddTab(tab, index);
|
AddTab(tab, index);
|
||||||
}
|
}
|
||||||
@@ -185,23 +190,22 @@ TabContainerView::AddTab(TabView* tab, int32 index)
|
|||||||
if (index == -1)
|
if (index == -1)
|
||||||
index = GroupLayout()->CountItems() - 1;
|
index = GroupLayout()->CountItems() - 1;
|
||||||
|
|
||||||
bool hasFrames = fController != NULL && fController->HasFrames();
|
tab->Update();
|
||||||
bool isFirst = index == 0 && hasFrames;
|
|
||||||
bool isLast = index == GroupLayout()->CountItems() - 1 && hasFrames;
|
|
||||||
bool isFront = fSelectedTab == NULL;
|
|
||||||
tab->Update(isFirst, isLast, isFront);
|
|
||||||
|
|
||||||
GroupLayout()->AddItem(index, tab->LayoutItem());
|
GroupLayout()->AddItem(index, tab->LayoutItem());
|
||||||
|
|
||||||
if (isFront)
|
if (fSelectedTab == NULL)
|
||||||
SelectTab(tab);
|
SelectTab(tab);
|
||||||
|
|
||||||
|
bool isLast = index == GroupLayout()->CountItems() - 1;
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
TabLayoutItem* item
|
TabLayoutItem* item
|
||||||
= dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
|
= dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->Parent()->SetIsLast(false);
|
item->Parent()->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetFirstVisibleTabIndex(MaxFirstVisibleTabIndex());
|
SetFirstVisibleTabIndex(MaxFirstVisibleTabIndex());
|
||||||
_ValidateTabVisibility();
|
_ValidateTabVisibility();
|
||||||
}
|
}
|
||||||
@@ -212,8 +216,7 @@ TabContainerView::RemoveTab(int32 index)
|
|||||||
{
|
{
|
||||||
TabLayoutItem* item
|
TabLayoutItem* item
|
||||||
= dynamic_cast<TabLayoutItem*>(GroupLayout()->RemoveItem(index));
|
= dynamic_cast<TabLayoutItem*>(GroupLayout()->RemoveItem(index));
|
||||||
|
if (item == NULL)
|
||||||
if (!item)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BRect dirty(Bounds());
|
BRect dirty(Bounds());
|
||||||
@@ -225,27 +228,22 @@ TabContainerView::RemoveTab(int32 index)
|
|||||||
fLastMouseEventTab = NULL;
|
fLastMouseEventTab = NULL;
|
||||||
|
|
||||||
// Update tabs after or before the removed tab.
|
// Update tabs after or before the removed tab.
|
||||||
bool hasFrames = fController != NULL && fController->HasFrames();
|
|
||||||
item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index));
|
item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index));
|
||||||
if (item) {
|
if (item != NULL) {
|
||||||
// This tab is behind the removed tab.
|
// This tab is behind the removed tab.
|
||||||
TabView* tab = item->Parent();
|
TabView* tab = item->Parent();
|
||||||
tab->Update(index == 0 && hasFrames,
|
tab->Update();
|
||||||
index == GroupLayout()->CountItems() - 2 && hasFrames,
|
|
||||||
tab == fSelectedTab);
|
|
||||||
if (removedTab == fSelectedTab) {
|
if (removedTab == fSelectedTab) {
|
||||||
fSelectedTab = NULL;
|
fSelectedTab = NULL;
|
||||||
SelectTab(tab);
|
SelectTab(tab);
|
||||||
} else if (fController && tab == fSelectedTab)
|
} else if (fController != NULL && tab == fSelectedTab)
|
||||||
fController->TabSelected(index);
|
fController->UpdateSelection(index);
|
||||||
} else {
|
} else {
|
||||||
// The removed tab was the last tab.
|
// The removed tab was the last tab.
|
||||||
item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
|
item = dynamic_cast<TabLayoutItem*>(GroupLayout()->ItemAt(index - 1));
|
||||||
if (item) {
|
if (item != NULL) {
|
||||||
TabView* tab = item->Parent();
|
TabView* tab = item->Parent();
|
||||||
tab->Update(index == 0 && hasFrames,
|
tab->Update();
|
||||||
index == GroupLayout()->CountItems() - 2 && hasFrames,
|
|
||||||
tab == fSelectedTab);
|
|
||||||
if (removedTab == fSelectedTab) {
|
if (removedTab == fSelectedTab) {
|
||||||
fSelectedTab = NULL;
|
fSelectedTab = NULL;
|
||||||
SelectTab(tab);
|
SelectTab(tab);
|
||||||
@@ -265,8 +263,9 @@ TabContainerView::TabAt(int32 index) const
|
|||||||
{
|
{
|
||||||
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
||||||
GroupLayout()->ItemAt(index));
|
GroupLayout()->ItemAt(index));
|
||||||
if (item)
|
if (item != NULL)
|
||||||
return item->Parent();
|
return item->Parent();
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +273,9 @@ TabContainerView::TabAt(int32 index) const
|
|||||||
int32
|
int32
|
||||||
TabContainerView::IndexOf(TabView* tab) const
|
TabContainerView::IndexOf(TabView* tab) const
|
||||||
{
|
{
|
||||||
|
if (tab == NULL || GroupLayout() == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return GroupLayout()->IndexOfItem(tab->LayoutItem());
|
return GroupLayout()->IndexOfItem(tab->LayoutItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +286,7 @@ TabContainerView::SelectTab(int32 index)
|
|||||||
TabView* tab = NULL;
|
TabView* tab = NULL;
|
||||||
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
||||||
GroupLayout()->ItemAt(index));
|
GroupLayout()->ItemAt(index));
|
||||||
if (item)
|
if (item != NULL)
|
||||||
tab = item->Parent();
|
tab = item->Parent();
|
||||||
|
|
||||||
SelectTab(tab);
|
SelectTab(tab);
|
||||||
@@ -297,15 +299,16 @@ TabContainerView::SelectTab(TabView* tab)
|
|||||||
if (tab == fSelectedTab)
|
if (tab == fSelectedTab)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fSelectedTab)
|
// update old selected tab
|
||||||
fSelectedTab->SetIsFront(false);
|
if (fSelectedTab != NULL)
|
||||||
|
fSelectedTab->Update();
|
||||||
|
|
||||||
fSelectedTab = tab;
|
fSelectedTab = tab;
|
||||||
|
|
||||||
if (fSelectedTab)
|
// update new selected tab
|
||||||
fSelectedTab->SetIsFront(true);
|
if (fSelectedTab != NULL)
|
||||||
|
fSelectedTab->Update();
|
||||||
|
|
||||||
if (fController != NULL) {
|
|
||||||
int32 index = -1;
|
int32 index = -1;
|
||||||
if (fSelectedTab != NULL)
|
if (fSelectedTab != NULL)
|
||||||
index = GroupLayout()->IndexOfItem(tab->LayoutItem());
|
index = GroupLayout()->IndexOfItem(tab->LayoutItem());
|
||||||
@@ -313,16 +316,16 @@ TabContainerView::SelectTab(TabView* tab)
|
|||||||
if (!tab->LayoutItem()->IsVisible())
|
if (!tab->LayoutItem()->IsVisible())
|
||||||
SetFirstVisibleTabIndex(index);
|
SetFirstVisibleTabIndex(index);
|
||||||
|
|
||||||
fController->TabSelected(index);
|
if (fController != NULL)
|
||||||
}
|
fController->UpdateSelection(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabContainerView::SetTabLabel(int32 tabIndex, const char* label)
|
TabContainerView::SetTabLabel(int32 index, const char* label)
|
||||||
{
|
{
|
||||||
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
TabLayoutItem* item = dynamic_cast<TabLayoutItem*>(
|
||||||
GroupLayout()->ItemAt(tabIndex));
|
GroupLayout()->ItemAt(index));
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class TabContainerView : public BGroupView {
|
|||||||
public:
|
public:
|
||||||
class Controller {
|
class Controller {
|
||||||
public:
|
public:
|
||||||
virtual void TabSelected(int32 tabIndex) = 0;
|
virtual void UpdateSelection(int32 index) = 0;
|
||||||
virtual bool HasFrames() = 0;
|
virtual bool HasFrames() = 0;
|
||||||
virtual TabView* CreateTabView() = 0;
|
virtual TabView* CreateTabView() = 0;
|
||||||
virtual void DoubleClickOutsideTabs() = 0;
|
virtual void DoubleClickOutsideTabs() = 0;
|
||||||
@@ -49,6 +49,16 @@ public:
|
|||||||
|
|
||||||
int32 IndexOf(TabView* tab) const;
|
int32 IndexOf(TabView* tab) const;
|
||||||
|
|
||||||
|
int32 FirstTabIndex() { return 0; };
|
||||||
|
int32 LastTabIndex()
|
||||||
|
{ return GroupLayout() == NULL ? -1
|
||||||
|
: GroupLayout()->CountItems() - 1; };
|
||||||
|
int32 SelectedTabIndex()
|
||||||
|
{ return fSelectedTab == NULL ? -1
|
||||||
|
: IndexOf(fSelectedTab); };
|
||||||
|
|
||||||
|
TabView* SelectedTab() { return fSelectedTab; };
|
||||||
|
|
||||||
void SelectTab(int32 tabIndex);
|
void SelectTab(int32 tabIndex);
|
||||||
void SelectTab(TabView* tab);
|
void SelectTab(TabView* tab);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <AbstractLayoutItem.h>
|
#include <AbstractLayoutItem.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -67,19 +69,20 @@ public:
|
|||||||
uint32 flags = be_control_look->Flags(this);
|
uint32 flags = be_control_look->Flags(this);
|
||||||
uint32 borders = BControlLook::B_TOP_BORDER
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER;
|
| BControlLook::B_BOTTOM_BORDER;
|
||||||
be_control_look->DrawInactiveTab(this, bounds, updateRect, base,
|
be_control_look->DrawTabFrame(this, bounds, updateRect, base,
|
||||||
0, borders);
|
0, borders, B_NO_BORDER);
|
||||||
if (IsEnabled()) {
|
if (IsEnabled()) {
|
||||||
rgb_color button = tint_color(base, 1.07);
|
rgb_color button = tint_color(base, 1.07);
|
||||||
be_control_look->DrawButtonBackground(this, bounds, updateRect,
|
be_control_look->DrawButtonBackground(this, bounds, updateRect,
|
||||||
button, flags, 0);
|
button, flags, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds.left = (bounds.left + bounds.right) / 2 - 6;
|
BRect symbolRect(bounds);
|
||||||
bounds.top = (bounds.top + bounds.bottom) / 2 - 6;
|
symbolRect.left = (symbolRect.left + symbolRect.right) / 2 - 6;
|
||||||
bounds.right = bounds.left + 12;
|
symbolRect.top = (symbolRect.top + symbolRect.bottom) / 2 - 6;
|
||||||
bounds.bottom = bounds.top + 12;
|
symbolRect.right = symbolRect.left + 12;
|
||||||
DrawSymbol(bounds, updateRect, base);
|
symbolRect.bottom = symbolRect.top + 12;
|
||||||
|
DrawSymbol(symbolRect, updateRect, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
|
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
|
||||||
@@ -237,28 +240,36 @@ public:
|
|||||||
|
|
||||||
virtual void MessageReceived(BMessage* message)
|
virtual void MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
if (fTabContainerView == NULL)
|
||||||
|
return BGroupView::MessageReceived(message);
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_SCROLL_TABS_LEFT:
|
case MSG_SCROLL_TABS_LEFT:
|
||||||
fTabContainerView->SetFirstVisibleTabIndex(
|
fTabContainerView->SetFirstVisibleTabIndex(
|
||||||
fTabContainerView->FirstVisibleTabIndex() - 1);
|
fTabContainerView->FirstVisibleTabIndex() - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SCROLL_TABS_RIGHT:
|
case MSG_SCROLL_TABS_RIGHT:
|
||||||
fTabContainerView->SetFirstVisibleTabIndex(
|
fTabContainerView->SetFirstVisibleTabIndex(
|
||||||
fTabContainerView->FirstVisibleTabIndex() + 1);
|
fTabContainerView->FirstVisibleTabIndex() + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_OPEN_TAB_MENU:
|
case MSG_OPEN_TAB_MENU:
|
||||||
{
|
{
|
||||||
BPopUpMenu* tabMenu = new BPopUpMenu("tab menu", true, false);
|
BPopUpMenu* tabMenu = new BPopUpMenu("tab menu", true, false);
|
||||||
int tabCount = fTabContainerView->GetLayout()->CountItems();
|
int tabCount = fTabContainerView->GetLayout()->CountItems();
|
||||||
for (int i = 0; i < tabCount; i++) {
|
for (int i = 0; i < tabCount; i++) {
|
||||||
TabView* tab = fTabContainerView->TabAt(i);
|
TabView* tab = fTabContainerView->TabAt(i);
|
||||||
if (tab) {
|
if (tab != NULL) {
|
||||||
BMenuItem* item = new BMenuItem(tab->Label(), NULL);
|
BMenuItem* item = new(std::nothrow)
|
||||||
|
BMenuItem(tab->Label(), NULL);
|
||||||
|
if (item != NULL) {
|
||||||
tabMenu->AddItem(item);
|
tabMenu->AddItem(item);
|
||||||
if (tab->IsFront())
|
if (i == fTabContainerView->SelectedTabIndex())
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Force layout to get the final menu size. InvalidateLayout()
|
// Force layout to get the final menu size. InvalidateLayout()
|
||||||
// did not seem to work here.
|
// did not seem to work here.
|
||||||
@@ -284,6 +295,7 @@ public:
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BGroupView::MessageReceived(message);
|
BGroupView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -341,10 +353,7 @@ public:
|
|||||||
|
|
||||||
virtual void Draw(BRect updateRect)
|
virtual void Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
// draw nothing
|
||||||
rgb_color base = LowColor();
|
|
||||||
be_control_look->DrawInactiveTab(this, bounds, updateRect,
|
|
||||||
base, 0, BControlLook::B_TOP_BORDER);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -355,7 +364,7 @@ public:
|
|||||||
|
|
||||||
virtual ~TabManagerController();
|
virtual ~TabManagerController();
|
||||||
|
|
||||||
virtual void TabSelected(int32 index)
|
virtual void UpdateSelection(int32 index)
|
||||||
{
|
{
|
||||||
fManager->SelectTab(index);
|
fManager->SelectTab(index);
|
||||||
}
|
}
|
||||||
@@ -379,6 +388,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (fCurrentToolTip == text)
|
if (fCurrentToolTip == text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fCurrentToolTip = text;
|
fCurrentToolTip = text;
|
||||||
fManager->GetTabContainerView()->HideToolTip();
|
fManager->GetTabContainerView()->HideToolTip();
|
||||||
fManager->GetTabContainerView()->SetToolTip(
|
fManager->GetTabContainerView()->SetToolTip(
|
||||||
@@ -426,8 +436,8 @@ public:
|
|||||||
|
|
||||||
virtual BSize MaxSize();
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
virtual void DrawContents(BView* owner, BRect frame, const BRect& updateRect,
|
virtual void DrawContents(BView* owner, BRect frame,
|
||||||
bool isFirst, bool isLast, bool isFront);
|
const BRect& updateRect);
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where, uint32 buttons);
|
virtual void MouseDown(BPoint where, uint32 buttons);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
@@ -437,8 +447,7 @@ public:
|
|||||||
void SetIcon(const BBitmap* icon);
|
void SetIcon(const BBitmap* icon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _DrawCloseButton(BView* owner, BRect& frame, const BRect& updateRect,
|
void _DrawCloseButton(BView* owner, BRect& frame, const BRect& updateRect);
|
||||||
bool isFirst, bool isLast, bool isFront);
|
|
||||||
BRect _CloseRectFrame(BRect frame) const;
|
BRect _CloseRectFrame(BRect frame) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -485,13 +494,12 @@ WebTabView::MaxSize()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
|
WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect)
|
||||||
bool isFirst, bool isLast, bool isFront)
|
|
||||||
{
|
{
|
||||||
if (fController->CloseButtonsAvailable())
|
if (fController->CloseButtonsAvailable())
|
||||||
_DrawCloseButton(owner, frame, updateRect, isFirst, isLast, isFront);
|
_DrawCloseButton(owner, frame, updateRect);
|
||||||
|
|
||||||
if (fIcon) {
|
if (fIcon != NULL) {
|
||||||
BRect iconBounds(0, 0, kIconSize - 1, kIconSize - 1);
|
BRect iconBounds(0, 0, kIconSize - 1, kIconSize - 1);
|
||||||
// clip to icon bounds, if they are smaller
|
// clip to icon bounds, if they are smaller
|
||||||
if (iconBounds.Contains(fIcon->Bounds()))
|
if (iconBounds.Contains(fIcon->Bounds()))
|
||||||
@@ -523,7 +531,7 @@ WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
|
|||||||
frame.left = frame.left + kIconSize + kIconInset * 2;
|
frame.left = frame.left + kIconSize + kIconInset * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, isFront);
|
TabView::DrawContents(owner, frame, updateRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -602,8 +610,9 @@ WebTabView::_CloseRectFrame(BRect frame) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
|
void
|
||||||
const BRect& updateRect, bool isFirst, bool isLast, bool isFront)
|
WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
|
||||||
|
const BRect& updateRect)
|
||||||
{
|
{
|
||||||
BRect closeRect = _CloseRectFrame(frame);
|
BRect closeRect = _CloseRectFrame(frame);
|
||||||
frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();
|
frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();
|
||||||
@@ -615,7 +624,10 @@ void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
|
|||||||
|
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
float tint = B_DARKEN_1_TINT;
|
float tint = B_DARKEN_1_TINT;
|
||||||
if (!IsFront()) {
|
|
||||||
|
float isFront = ContainerView()->SelectedTab()
|
||||||
|
== static_cast<TabView*>(this);
|
||||||
|
if (!isFront) {
|
||||||
base = tint_color(base, tint);
|
base = tint_color(base, tint);
|
||||||
tint *= 1.02;
|
tint *= 1.02;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
|
#include <TabView.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "TabContainerView.h"
|
#include "TabContainerView.h"
|
||||||
@@ -36,7 +37,7 @@ TabView::TabView()
|
|||||||
TabView::~TabView()
|
TabView::~TabView()
|
||||||
{
|
{
|
||||||
// The layout item is deleted for us by the layout which contains it.
|
// The layout item is deleted for us by the layout which contains it.
|
||||||
if (!fContainerView)
|
if (fContainerView == NULL)
|
||||||
delete fLayoutItem;
|
delete fLayoutItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,60 +71,55 @@ void
|
|||||||
TabView::Draw(BRect updateRect)
|
TabView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
BRect frame(fLayoutItem->Frame());
|
BRect frame(fLayoutItem->Frame());
|
||||||
if (fIsFront) {
|
|
||||||
// Extend the front tab outward left/right in order to merge
|
|
||||||
// the frames of adjacent tabs.
|
|
||||||
if (!fIsFirst)
|
|
||||||
frame.left--;
|
|
||||||
if (!fIsLast)
|
|
||||||
frame.right++;
|
frame.right++;
|
||||||
}
|
|
||||||
frame.bottom++;
|
frame.bottom++;
|
||||||
|
|
||||||
DrawBackground(fContainerView, frame, updateRect, fIsFirst, fIsLast,
|
int32 index = fContainerView->IndexOf(this);
|
||||||
fIsFront);
|
|
||||||
|
|
||||||
if (fIsFront) {
|
// make room for tail of last tab
|
||||||
|
bool isLast = index == fContainerView->LastTabIndex();
|
||||||
|
if (isLast)
|
||||||
|
frame.right -= 2;
|
||||||
|
|
||||||
|
DrawBackground(fContainerView, frame, updateRect);
|
||||||
|
|
||||||
|
bool isFront = index == fContainerView->SelectedTabIndex();
|
||||||
|
if (isFront)
|
||||||
frame.top += 3.0f;
|
frame.top += 3.0f;
|
||||||
if (!fIsFirst)
|
else
|
||||||
frame.left++;
|
|
||||||
if (!fIsLast)
|
|
||||||
frame.right--;
|
|
||||||
} else
|
|
||||||
frame.top += 6.0f;
|
frame.top += 6.0f;
|
||||||
|
|
||||||
float spacing = be_control_look->DefaultLabelSpacing();
|
float spacing = be_control_look->DefaultLabelSpacing();
|
||||||
frame.InsetBy(spacing, spacing / 2);
|
frame.InsetBy(spacing, spacing / 2);
|
||||||
DrawContents(fContainerView, frame, updateRect, fIsFirst, fIsLast,
|
DrawContents(fContainerView, frame, updateRect);
|
||||||
fIsFront);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabView::DrawBackground(BView* owner, BRect frame, const BRect& updateRect,
|
TabView::DrawBackground(BView* owner, BRect frame, const BRect& updateRect)
|
||||||
bool isFirst, bool isLast, bool isFront)
|
|
||||||
{
|
{
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
uint32 flags = 0;
|
||||||
uint32 borders = BControlLook::B_TOP_BORDER
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER;
|
| BControlLook::B_BOTTOM_BORDER;
|
||||||
|
|
||||||
if (isFirst)
|
int32 index = fContainerView->IndexOf(this);
|
||||||
borders |= BControlLook::B_LEFT_BORDER;
|
int32 selected = fContainerView->SelectedTabIndex();
|
||||||
if (isLast)
|
int32 first = fContainerView->FirstTabIndex();
|
||||||
borders |= BControlLook::B_RIGHT_BORDER;
|
int32 last = fContainerView->LastTabIndex();
|
||||||
if (isFront) {
|
|
||||||
be_control_look->DrawActiveTab(owner, frame, updateRect, base,
|
if (index == selected) {
|
||||||
0, borders);
|
be_control_look->DrawActiveTab(owner, frame, updateRect, base, flags,
|
||||||
|
borders, BControlLook::B_TOP_BORDER, index, selected, first, last);
|
||||||
} else {
|
} else {
|
||||||
be_control_look->DrawInactiveTab(owner, frame, updateRect, base,
|
be_control_look->DrawInactiveTab(owner, frame, updateRect, base, flags,
|
||||||
0, borders);
|
borders, BControlLook::B_TOP_BORDER, index, selected, first, last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
|
TabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect)
|
||||||
bool isFirst, bool isLast, bool isFront)
|
|
||||||
{
|
{
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
be_control_look->DrawLabel(owner, fLabel.String(), frame, updateRect,
|
be_control_look->DrawLabel(owner, fLabel.String(), frame, updateRect,
|
||||||
@@ -151,35 +147,8 @@ TabView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TabView::SetIsFront(bool isFront)
|
TabView::Update()
|
||||||
{
|
{
|
||||||
Update(fIsFirst, fIsLast, isFront);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
TabView::IsFront() const
|
|
||||||
{
|
|
||||||
return fIsFront;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TabView::SetIsLast(bool isLast)
|
|
||||||
{
|
|
||||||
Update(fIsFirst, isLast, fIsFront);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TabView::Update(bool isFirst, bool isLast, bool isFront)
|
|
||||||
{
|
|
||||||
if (fIsFirst == isFirst && fIsLast == isLast && fIsFront == isFront)
|
|
||||||
return;
|
|
||||||
fIsFirst = isFirst;
|
|
||||||
fIsLast = isLast;
|
|
||||||
fIsFront = isFront;
|
|
||||||
|
|
||||||
fLayoutItem->InvalidateContainer();
|
fLayoutItem->InvalidateContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +179,7 @@ TabView::SetLabel(const char* label)
|
|||||||
{
|
{
|
||||||
if (fLabel == label)
|
if (fLabel == label)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fLabel = label;
|
fLabel = label;
|
||||||
fLayoutItem->InvalidateLayout();
|
fLayoutItem->InvalidateLayout();
|
||||||
}
|
}
|
||||||
@@ -339,8 +309,8 @@ void
|
|||||||
TabLayoutItem::InvalidateContainer(BRect frame)
|
TabLayoutItem::InvalidateContainer(BRect frame)
|
||||||
{
|
{
|
||||||
// Invalidate more than necessary, to help the TabContainerView
|
// Invalidate more than necessary, to help the TabContainerView
|
||||||
// redraw the parts outside any tabs...
|
// redraw the parts outside any tabs... need 2px
|
||||||
frame.bottom++;
|
frame.bottom += 2;
|
||||||
frame.right++;
|
frame.right += 2;
|
||||||
fParent->ContainerView()->Invalidate(frame);
|
fParent->ContainerView()->Invalidate(frame);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,26 +28,20 @@ public:
|
|||||||
|
|
||||||
void Draw(BRect updateRect);
|
void Draw(BRect updateRect);
|
||||||
virtual void DrawBackground(BView* owner, BRect frame,
|
virtual void DrawBackground(BView* owner, BRect frame,
|
||||||
const BRect& updateRect, bool isFirst,
|
const BRect& updateRect);
|
||||||
bool isLast, bool isFront);
|
|
||||||
virtual void DrawContents(BView* owner, BRect frame,
|
virtual void DrawContents(BView* owner, BRect frame,
|
||||||
const BRect& updateRect, bool isFirst,
|
const BRect& updateRect);
|
||||||
bool isLast, bool isFront);
|
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where, uint32 buttons);
|
virtual void MouseDown(BPoint where, uint32 buttons);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage);
|
const BMessage* dragMessage);
|
||||||
|
|
||||||
void SetIsFront(bool isFront);
|
virtual void Update();
|
||||||
bool IsFront() const;
|
|
||||||
void SetIsLast(bool isLast);
|
|
||||||
virtual void Update(bool isFirst, bool isLast,
|
|
||||||
bool isFront);
|
|
||||||
|
|
||||||
BLayoutItem* LayoutItem() const;
|
BLayoutItem* LayoutItem() const;
|
||||||
void SetContainerView(
|
|
||||||
TabContainerView* containerView);
|
void SetContainerView(TabContainerView* view);
|
||||||
TabContainerView* ContainerView() const;
|
TabContainerView* ContainerView() const;
|
||||||
|
|
||||||
void SetLabel(const char* label);
|
void SetLabel(const char* label);
|
||||||
@@ -63,10 +57,6 @@ private:
|
|||||||
TabLayoutItem* fLayoutItem;
|
TabLayoutItem* fLayoutItem;
|
||||||
|
|
||||||
BString fLabel;
|
BString fLabel;
|
||||||
|
|
||||||
bool fIsFirst;
|
|
||||||
bool fIsLast;
|
|
||||||
bool fIsFront;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1635,33 +1635,23 @@ HaikuControlLook::DrawTabFrame(BView* view, BRect& rect,
|
|||||||
if (side == BTabView::kTopSide || side == BTabView::kBottomSide) {
|
if (side == BTabView::kTopSide || side == BTabView::kBottomSide) {
|
||||||
// draw an inactive tab frame behind all tabs
|
// draw an inactive tab frame behind all tabs
|
||||||
borders = B_TOP_BORDER | B_BOTTOM_BORDER;
|
borders = B_TOP_BORDER | B_BOTTOM_BORDER;
|
||||||
if (borderStyle == B_NO_BORDER) {
|
if (borderStyle != B_NO_BORDER)
|
||||||
// removes left border that is an artifact of DrawInactiveTab()
|
|
||||||
rect.left -= 1;
|
|
||||||
} else
|
|
||||||
borders |= B_LEFT_BORDER | B_RIGHT_BORDER;
|
borders |= B_LEFT_BORDER | B_RIGHT_BORDER;
|
||||||
|
|
||||||
// DrawInactiveTab draws 2px border
|
// DrawInactiveTab draws 2px border
|
||||||
// draw a little wider tab frame to align B_PLAIN_BORDER with it
|
// draw tab frame wider to align B_PLAIN_BORDER with it
|
||||||
if (borderStyle == B_PLAIN_BORDER) {
|
if (borderStyle == B_PLAIN_BORDER)
|
||||||
rect.left -= 1;
|
rect.InsetBy(-1, 0);
|
||||||
rect.right += 1;
|
|
||||||
}
|
|
||||||
} else if (side == BTabView::kLeftSide || side == BTabView::kRightSide) {
|
} else if (side == BTabView::kLeftSide || side == BTabView::kRightSide) {
|
||||||
// draw an inactive tab frame behind all tabs
|
// draw an inactive tab frame behind all tabs
|
||||||
borders = B_LEFT_BORDER | B_RIGHT_BORDER;
|
borders = B_LEFT_BORDER | B_RIGHT_BORDER;
|
||||||
if (borderStyle == B_NO_BORDER) {
|
if (borderStyle != B_NO_BORDER)
|
||||||
// removes top border that is an artifact of DrawInactiveTab()
|
|
||||||
rect.top -= 1;
|
|
||||||
} else
|
|
||||||
borders |= B_TOP_BORDER | B_BOTTOM_BORDER;
|
borders |= B_TOP_BORDER | B_BOTTOM_BORDER;
|
||||||
|
|
||||||
// DrawInactiveTab draws 2px border
|
// DrawInactiveTab draws 2px border
|
||||||
// draw a little wider tab frame to align B_PLAIN_BORDER with it
|
// draw tab frame wider to align B_PLAIN_BORDER with it
|
||||||
if (borderStyle == B_PLAIN_BORDER) {
|
if (borderStyle == B_PLAIN_BORDER)
|
||||||
rect.top -= 1;
|
rect.InsetBy(0, -1);
|
||||||
rect.bottom += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawInactiveTab(view, rect, rect, base, 0, borders, side);
|
DrawInactiveTab(view, rect, rect, base, 0, borders, side);
|
||||||
@@ -1669,8 +1659,9 @@ HaikuControlLook::DrawTabFrame(BView* view, BRect& rect,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HaikuControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
HaikuControlLook::DrawActiveTab(BView* view, BRect& rect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders, uint32 side)
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
|
uint32 borders, uint32 side, int32, int32, int32, int32)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
@@ -1848,8 +1839,9 @@ HaikuControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRec
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HaikuControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
|
HaikuControlLook::DrawInactiveTab(BView* view, BRect& rect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders, uint32 side)
|
const BRect& updateRect, const rgb_color& base, uint32 flags,
|
||||||
|
uint32 borders, uint32 side, int32, int32, int32, int32)
|
||||||
{
|
{
|
||||||
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
return;
|
return;
|
||||||
@@ -1886,18 +1878,22 @@ HaikuControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateR
|
|||||||
|
|
||||||
BRect background = rect;
|
BRect background = rect;
|
||||||
switch (side) {
|
switch (side) {
|
||||||
|
default:
|
||||||
case B_TOP_BORDER:
|
case B_TOP_BORDER:
|
||||||
rect.top += 4;
|
rect.top += 4;
|
||||||
background.bottom = rect.top;
|
background.bottom = rect.top;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BOTTOM_BORDER:
|
case B_BOTTOM_BORDER:
|
||||||
rect.bottom -= 4;
|
rect.bottom -= 4;
|
||||||
background.top = rect.bottom;
|
background.top = rect.bottom;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_LEFT_BORDER:
|
case B_LEFT_BORDER:
|
||||||
rect.left += 4;
|
rect.left += 4;
|
||||||
background.right = rect.left;
|
background.right = rect.left;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_RIGHT_BORDER:
|
case B_RIGHT_BORDER:
|
||||||
rect.right -= 4;
|
rect.right -= 4;
|
||||||
background.left = rect.right;
|
background.left = rect.right;
|
||||||
@@ -1915,23 +1911,21 @@ HaikuControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateR
|
|||||||
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
||||||
frameShadowColor, borders);
|
frameShadowColor, borders);
|
||||||
|
|
||||||
|
if ((side == B_TOP_BORDER || side == B_BOTTOM_BORDER)
|
||||||
|
&& (borders & B_LEFT_BORDER) != 0) {
|
||||||
if (rect.IsValid()) {
|
if (rect.IsValid()) {
|
||||||
if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
|
|
||||||
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
||||||
bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
|
bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
|
||||||
} else if (side == B_LEFT_BORDER || side == B_RIGHT_BORDER) {
|
} else if ((B_LEFT_BORDER & ~borders) != 0)
|
||||||
|
rect.left++;
|
||||||
|
} else if ((side == B_LEFT_BORDER || side == B_RIGHT_BORDER)
|
||||||
|
&& (borders & B_TOP_BORDER) != 0) {
|
||||||
|
if (rect.IsValid()) {
|
||||||
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
||||||
bevelLightColor, bevelLightColor, B_TOP_BORDER & ~borders);
|
bevelLightColor, bevelLightColor, B_TOP_BORDER & ~borders);
|
||||||
}
|
} else if ((B_TOP_BORDER & ~borders) != 0)
|
||||||
} else {
|
|
||||||
if (side == B_TOP_BORDER || side == B_BOTTOM_BORDER) {
|
|
||||||
if ((B_LEFT_BORDER & ~borders) != 0)
|
|
||||||
rect.left++;
|
|
||||||
} else if (side == B_LEFT_BORDER || side == B_RIGHT_BORDER) {
|
|
||||||
if ((B_TOP_BORDER & ~borders) != 0)
|
|
||||||
rect.top++;
|
rect.top++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
view->FillRect(rect, fillGradient);
|
view->FillRect(rect, fillGradient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,10 +316,42 @@ BTab::DrawLabel(BView* owner, BRect frame)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTab::DrawTab(BView* owner, BRect frame, tab_position position, bool full)
|
BTab::DrawTab(BView* owner, BRect frame, tab_position, bool)
|
||||||
|
{
|
||||||
|
if (fTabView == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
uint32 flags = 0;
|
||||||
|
uint32 borders = _Borders(owner, frame);
|
||||||
|
|
||||||
|
int32 index = fTabView->IndexOf(this);
|
||||||
|
int32 selected = fTabView->Selection();
|
||||||
|
int32 first = 0;
|
||||||
|
int32 last = fTabView->CountTabs() - 1;
|
||||||
|
|
||||||
|
if (index == selected) {
|
||||||
|
be_control_look->DrawActiveTab(owner, frame, frame, base, flags,
|
||||||
|
borders, fTabView->TabSide(), index, selected, first, last);
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawInactiveTab(owner, frame, frame, base, flags,
|
||||||
|
borders, fTabView->TabSide(), index, selected, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawLabel(owner, frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BTab private methods
|
||||||
|
|
||||||
|
|
||||||
|
uint32
|
||||||
|
BTab::_Borders(BView* owner, BRect frame)
|
||||||
{
|
{
|
||||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
uint32 borders = 0;
|
uint32 borders = 0;
|
||||||
|
if (owner == NULL || fTabView == NULL)
|
||||||
|
return borders;
|
||||||
|
|
||||||
if (fTabView->TabSide() == BTabView::kTopSide
|
if (fTabView->TabSide() == BTabView::kTopSide
|
||||||
|| fTabView->TabSide() == BTabView::kBottomSide) {
|
|| fTabView->TabSide() == BTabView::kBottomSide) {
|
||||||
borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER;
|
borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER;
|
||||||
@@ -340,15 +372,7 @@ BTab::DrawTab(BView* owner, BRect frame, tab_position position, bool full)
|
|||||||
borders |= BControlLook::B_BOTTOM_BORDER;
|
borders |= BControlLook::B_BOTTOM_BORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position == B_TAB_FRONT) {
|
return borders;
|
||||||
be_control_look->DrawActiveTab(owner, frame, frame, no_tint, 0,
|
|
||||||
borders, fTabView->TabSide());
|
|
||||||
} else {
|
|
||||||
be_control_look->DrawInactiveTab(owner, frame, frame, no_tint, 0,
|
|
||||||
borders, fTabView->TabSide());
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawLabel(owner, frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -921,9 +945,9 @@ BTabView::DrawTabs()
|
|||||||
activeTabFrame = tabFrame;
|
activeTabFrame = tabFrame;
|
||||||
|
|
||||||
TabAt(i)->DrawTab(this, tabFrame,
|
TabAt(i)->DrawTab(this, tabFrame,
|
||||||
i == fSelection ? B_TAB_FRONT :
|
i == fSelection ? B_TAB_FRONT
|
||||||
(i == 0) ? B_TAB_FIRST : B_TAB_ANY,
|
: (i == 0) ? B_TAB_FIRST : B_TAB_ANY,
|
||||||
i + 1 != fSelection);
|
i != fSelection - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect tabsBounds;
|
BRect tabsBounds;
|
||||||
@@ -1348,6 +1372,21 @@ BTabView::ViewForTab(int32 tabIndex) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BTabView::IndexOf(BTab* tab) const
|
||||||
|
{
|
||||||
|
if (tab != NULL) {
|
||||||
|
int32 tabCount = CountTabs();
|
||||||
|
for (int32 index = 0; index < tabCount; index++) {
|
||||||
|
if (TabAt(index) == tab)
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTabView::_InitObject(bool layouted, button_width width)
|
BTabView::_InitObject(bool layouted, button_width width)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -699,6 +699,9 @@ void
|
|||||||
KeyboardLayoutView::_DrawKeyButton(BView* view, BRect& rect, BRect updateRect,
|
KeyboardLayoutView::_DrawKeyButton(BView* view, BRect& rect, BRect updateRect,
|
||||||
rgb_color base, rgb_color background, bool pressed)
|
rgb_color base, rgb_color background, bool pressed)
|
||||||
{
|
{
|
||||||
|
uint32 flags = pressed ? BControlLook::B_ACTIVATED : 0;
|
||||||
|
flags |= BControlLook::B_FLAT;
|
||||||
|
|
||||||
be_control_look->DrawButtonFrame(view, rect, updateRect, 4.0f, base,
|
be_control_look->DrawButtonFrame(view, rect, updateRect, 4.0f, base,
|
||||||
background, pressed ? BControlLook::B_ACTIVATED : 0);
|
background, pressed ? BControlLook::B_ACTIVATED : 0);
|
||||||
be_control_look->DrawButtonBackground(view, rect, updateRect, 4.0f,
|
be_control_look->DrawButtonBackground(view, rect, updateRect, 4.0f,
|
||||||
@@ -731,6 +734,9 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
|||||||
|
|
||||||
_SetFontSize(view, keyKind);
|
_SetFontSize(view, keyKind);
|
||||||
|
|
||||||
|
uint32 flags = pressed ? BControlLook::B_ACTIVATED : 0;
|
||||||
|
flags |= BControlLook::B_FLAT;
|
||||||
|
|
||||||
if (secondDeadKey)
|
if (secondDeadKey)
|
||||||
base = kSecondDeadKeyColor;
|
base = kSecondDeadKeyColor;
|
||||||
else if (deadKey > 0 && isDeadKeyEnabled)
|
else if (deadKey > 0 && isDeadKeyEnabled)
|
||||||
@@ -743,7 +749,8 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
|||||||
|
|
||||||
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
|
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
|
||||||
be_control_look->DrawLabel(view, text, rect, updateRect,
|
be_control_look->DrawLabel(view, text, rect, updateRect,
|
||||||
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &keyLabelColor);
|
base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE),
|
||||||
|
&keyLabelColor);
|
||||||
} else if (key->shape == kEnterKeyShape) {
|
} else if (key->shape == kEnterKeyShape) {
|
||||||
BRect topLeft = rect;
|
BRect topLeft = rect;
|
||||||
BRect topRight = rect;
|
BRect topRight = rect;
|
||||||
@@ -769,35 +776,29 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
|||||||
|
|
||||||
// draw top left corner
|
// draw top left corner
|
||||||
be_control_look->DrawButtonFrame(view, topLeft, updateRect,
|
be_control_look->DrawButtonFrame(view, topLeft, updateRect,
|
||||||
4.0f, 0.0f, 4.0f, 0.0f, base, background,
|
4.0f, 0.0f, 4.0f, 0.0f, base, background, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
|
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER);
|
| BControlLook::B_BOTTOM_BORDER);
|
||||||
be_control_look->DrawButtonBackground(view, topLeft, updateRect,
|
be_control_look->DrawButtonBackground(view, topLeft, updateRect,
|
||||||
4.0f, 0.0f, 4.0f, 0.0f, base,
|
4.0f, 0.0f, 4.0f, 0.0f, base, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
|
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER);
|
| BControlLook::B_BOTTOM_BORDER);
|
||||||
|
|
||||||
// draw top right corner
|
// draw top right corner
|
||||||
be_control_look->DrawButtonFrame(view, topRight, updateRect,
|
be_control_look->DrawButtonFrame(view, topRight, updateRect,
|
||||||
0.0f, 4.0f, 0.0f, 0.0f, base, background,
|
0.0f, 4.0f, 0.0f, 0.0f, base, background, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
|
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
|
||||||
be_control_look->DrawButtonBackground(view, topRight, updateRect,
|
be_control_look->DrawButtonBackground(view, topRight, updateRect,
|
||||||
0.0f, 4.0f, 0.0f, 0.0f, base,
|
0.0f, 4.0f, 0.0f, 0.0f, base, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
|
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
|
||||||
|
|
||||||
// draw bottom right corner
|
// draw bottom right corner
|
||||||
be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
|
be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
|
||||||
0.0f, 0.0f, 4.0f, 4.0f, base, background,
|
0.0f, 0.0f, 4.0f, 4.0f, base, background, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
|
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER);
|
| BControlLook::B_BOTTOM_BORDER);
|
||||||
be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
|
be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
|
||||||
0.0f, 0.0f, 4.0f, 4.0f, base,
|
0.0f, 0.0f, 4.0f, 4.0f, base, flags,
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0,
|
|
||||||
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
|
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
|
||||||
| BControlLook::B_BOTTOM_BORDER);
|
| BControlLook::B_BOTTOM_BORDER);
|
||||||
|
|
||||||
@@ -811,15 +812,15 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
|||||||
// draw the button background
|
// draw the button background
|
||||||
BRect bgRect = rect.InsetByCopy(2, 2);
|
BRect bgRect = rect.InsetByCopy(2, 2);
|
||||||
be_control_look->DrawButtonBackground(view, bgRect, updateRect,
|
be_control_look->DrawButtonBackground(view, bgRect, updateRect,
|
||||||
4.0f, 4.0f, 0.0f, 4.0f, base,
|
4.0f, 4.0f, 0.0f, 4.0f, base, flags);
|
||||||
pressed ? BControlLook::B_ACTIVATED : 0);
|
|
||||||
|
|
||||||
rect.left = bottomLeft.right;
|
rect.left = bottomLeft.right;
|
||||||
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
|
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
|
||||||
|
|
||||||
// draw the button label
|
// draw the button label
|
||||||
be_control_look->DrawLabel(view, text, rect, updateRect,
|
be_control_look->DrawLabel(view, text, rect, updateRect,
|
||||||
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &keyLabelColor);
|
base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE),
|
||||||
|
&keyLabelColor);
|
||||||
|
|
||||||
// reset the clipping region
|
// reset the clipping region
|
||||||
view->ConstrainClippingRegion(NULL);
|
view->ConstrainClippingRegion(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user