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.
|
||||
*
|
||||
* Authors:
|
||||
@@ -7,8 +7,8 @@
|
||||
* John Scipione, [email protected]
|
||||
*
|
||||
* Corresponds to:
|
||||
* headers/os/interface/TabView.h hrev45377
|
||||
* src/kits/interface/TabView.cpp hrev45377
|
||||
* headers/os/interface/TabView.h hrev54500
|
||||
* src/kits/interface/TabView.cpp hrev54500
|
||||
*/
|
||||
|
||||
|
||||
@@ -27,33 +27,45 @@
|
||||
Tab position flags
|
||||
|
||||
\since BeOS R3
|
||||
|
||||
\deprecated This should not be used anymore.
|
||||
\sa BTab::DrawTab()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\var tab_position B_TAB_FIRST
|
||||
|
||||
First tab in the tab view.
|
||||
The first tab in the tab view.
|
||||
|
||||
\since BeOS R3
|
||||
|
||||
\deprecated This should not be used anymore.
|
||||
\sa BTab::DrawTab()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\var tab_position B_TAB_FRONT
|
||||
|
||||
Front most tab in the tab view.
|
||||
The selected tab in the tab view.
|
||||
|
||||
\since BeOS R3
|
||||
|
||||
\deprecated This should not be used anymore.
|
||||
\sa BTab::DrawTab()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
||||
\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,
|
||||
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
|
||||
tab itself. The \a position of the tab may affect how the tab is rendered
|
||||
-- for example the frontmost tab may have a different appearance than the
|
||||
other tabs.
|
||||
This method draws the tab, then draws the tab's title by calling
|
||||
DrawLabel(). The \a position of the tab may affect how the tab is
|
||||
rendered -- for example the first tab may have a differene appearance
|
||||
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 frame The frame rectangle to draw in.
|
||||
\param position May affect how the tab is rendered. Choices include:
|
||||
- \c B_TAB_FIRST
|
||||
- \c B_TAB_FRONT
|
||||
- \c B_TAB_ANY
|
||||
\param full Whether or not to completely draw the tab, no longer used.
|
||||
- \c B_TAB_FIRST The first tab
|
||||
- \c B_TAB_FRONT The selected or active tab
|
||||
- \c B_TAB_ANY Tab that is not first or front
|
||||
\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
|
||||
*/
|
||||
@@ -484,7 +503,7 @@
|
||||
|
||||
/*!
|
||||
\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
|
||||
*/
|
||||
@@ -727,3 +746,11 @@
|
||||
|
||||
\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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user