Refactor BeDecorator
This commit is contained in:
@@ -93,39 +93,6 @@ BeDecorator::~BeDecorator()
|
|||||||
// #pragma mark - Public methods
|
// #pragma mark - Public methods
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Updates the decorator in the rectangular area \a updateRect.
|
|
||||||
|
|
||||||
The default version updates all areas which intersect the frame and tab.
|
|
||||||
|
|
||||||
\param updateRect The rectangular area to update.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
BeDecorator::Draw(BRect updateRect)
|
|
||||||
{
|
|
||||||
STRACE(("BeDecorator::Draw(BRect updateRect): "));
|
|
||||||
updateRect.PrintToStream();
|
|
||||||
|
|
||||||
// We need to draw a few things: the tab, the resize knob, the borders,
|
|
||||||
// and the buttons
|
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
|
||||||
|
|
||||||
_DrawFrame(updateRect);
|
|
||||||
_DrawTabs(updateRect & fTitleBarRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BeDecorator::Draw()
|
|
||||||
{
|
|
||||||
// Easy way to draw everything - no worries about drawing only certain
|
|
||||||
// things
|
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
|
||||||
|
|
||||||
_DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()));
|
|
||||||
_DrawTabs(fTitleBarRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! Returns the frame colors for the specified decorator component.
|
/*! Returns the frame colors for the specified decorator component.
|
||||||
|
|
||||||
The meaning of the color array elements depends on the specified component.
|
The meaning of the color array elements depends on the specified component.
|
||||||
@@ -139,7 +106,7 @@ void
|
|||||||
BeDecorator::GetComponentColors(Component component, uint8 highlight,
|
BeDecorator::GetComponentColors(Component component, uint8 highlight,
|
||||||
ComponentColors _colors, Decorator::Tab* _tab)
|
ComponentColors _colors, Decorator::Tab* _tab)
|
||||||
{
|
{
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case COMPONENT_TAB:
|
case COMPONENT_TAB:
|
||||||
if (tab && tab->buttonFocus) {
|
if (tab && tab->buttonFocus) {
|
||||||
@@ -286,7 +253,7 @@ BeDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -BorderWidth()))) {
|
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
ComponentColors colors;
|
ComponentColors colors;
|
||||||
_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
|
_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
|
||||||
|
|
||||||
@@ -307,7 +274,7 @@ BeDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// right
|
// right
|
||||||
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -BorderWidth()))) {
|
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
ComponentColors colors;
|
ComponentColors colors;
|
||||||
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
|
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
|
||||||
|
|
||||||
@@ -343,7 +310,7 @@ BeDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -BorderWidth()))) {
|
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
ComponentColors colors;
|
ComponentColors colors;
|
||||||
_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
|
_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
|
||||||
|
|
||||||
@@ -374,7 +341,7 @@ BeDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// right
|
// right
|
||||||
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -BorderWidth()))) {
|
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
|
||||||
ComponentColors colors;
|
ComponentColors colors;
|
||||||
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
|
_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
|
||||||
|
|
||||||
@@ -482,6 +449,14 @@ BeDecorator::_DrawFrame(BRect invalid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Actually draws the tab
|
||||||
|
|
||||||
|
This function is called when the tab itself needs drawn. Other items,
|
||||||
|
like the window title or buttons, should not be drawn here.
|
||||||
|
|
||||||
|
\param tab The \a tab to update.
|
||||||
|
\param invalid The area of the \a tab to update.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
BeDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
|
BeDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
|
||||||
{
|
{
|
||||||
@@ -545,16 +520,26 @@ BeDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
|
|||||||
|
|
||||||
_DrawTitle(tab, tabRect);
|
_DrawTitle(tab, tabRect);
|
||||||
|
|
||||||
DrawButtons(tab, invalid);
|
_DrawButtons(tab, invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Actually draws the title
|
||||||
|
|
||||||
|
The main tasks for this function are to ensure that the decorator draws
|
||||||
|
the title only in its own area and drawing the title itself.
|
||||||
|
Using B_OP_COPY for drawing the title is recommended because of the marked
|
||||||
|
performance hit of the other drawing modes, but it is not a requirement.
|
||||||
|
|
||||||
|
\param _tab The \a tab to update.
|
||||||
|
\param r area of the title to update.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
BeDecorator::_DrawTitle(Decorator::Tab* _tab, BRect r)
|
BeDecorator::_DrawTitle(Decorator::Tab* _tab, BRect r)
|
||||||
{
|
{
|
||||||
STRACE(("_DrawTitle(%f, %f, %f, %f)\n", r.left, r.top, r.right, r.bottom));
|
STRACE(("_DrawTitle(%f, %f, %f, %f)\n", r.left, r.top, r.right, r.bottom));
|
||||||
|
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
|
||||||
|
|
||||||
const BRect& tabRect = tab->tabRect;
|
const BRect& tabRect = tab->tabRect;
|
||||||
const BRect& closeRect = tab->closeRect;
|
const BRect& closeRect = tab->closeRect;
|
||||||
@@ -596,13 +581,22 @@ BeDecorator::_DrawTitle(Decorator::Tab* _tab, BRect r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Actually draws the close button
|
||||||
|
|
||||||
|
Unless a subclass has a particularly large button, it is probably
|
||||||
|
unnecessary to check the update rectangle.
|
||||||
|
|
||||||
|
\param _tab The \a tab to update.
|
||||||
|
\param direct Draw without double buffering.
|
||||||
|
\param rect The area of the button to update.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
BeDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
|
BeDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
|
||||||
{
|
{
|
||||||
STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
|
STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
|
||||||
rect.bottom));
|
rect.bottom));
|
||||||
|
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
|
||||||
|
|
||||||
int32 index = (tab->buttonFocus ? 0 : 1) + (tab->closePressed ? 0 : 2);
|
int32 index = (tab->buttonFocus ? 0 : 1) + (tab->closePressed ? 0 : 2);
|
||||||
ServerBitmap* bitmap = tab->closeBitmaps[index];
|
ServerBitmap* bitmap = tab->closeBitmaps[index];
|
||||||
@@ -616,13 +610,22 @@ BeDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Actually draws the zoom button
|
||||||
|
|
||||||
|
Unless a subclass has a particularly large button, it is probably
|
||||||
|
unnecessary to check the update rectangle.
|
||||||
|
|
||||||
|
\param _tab The \a tab to update.
|
||||||
|
\param direct Draw without double buffering.
|
||||||
|
\param rect The area of the button to update.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
BeDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
|
BeDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
|
||||||
{
|
{
|
||||||
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
|
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
|
||||||
rect.bottom));
|
rect.bottom));
|
||||||
|
|
||||||
TabDecorator::Tab* tab = static_cast<TabDecorator::Tab*>(_tab);
|
Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
|
||||||
int32 index = (tab->buttonFocus ? 0 : 1) + (tab->zoomPressed ? 0 : 2);
|
int32 index = (tab->buttonFocus ? 0 : 1) + (tab->zoomPressed ? 0 : 2);
|
||||||
ServerBitmap* bitmap = tab->zoomBitmaps[index];
|
ServerBitmap* bitmap = tab->zoomBitmaps[index];
|
||||||
if (bitmap == NULL) {
|
if (bitmap == NULL) {
|
||||||
@@ -635,6 +638,13 @@ BeDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BeDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
|
||||||
|
{
|
||||||
|
// This decorator doesn't have this button
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BeDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
|
BeDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
|
||||||
float* _size, float* _inset) const
|
float* _size, float* _inset) const
|
||||||
|
|||||||
@@ -35,21 +35,22 @@ public:
|
|||||||
BeDecorator(DesktopSettings& settings, BRect frame);
|
BeDecorator(DesktopSettings& settings, BRect frame);
|
||||||
virtual ~BeDecorator();
|
virtual ~BeDecorator();
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
|
||||||
virtual void Draw();
|
|
||||||
|
|
||||||
virtual void GetComponentColors(Component component,
|
virtual void GetComponentColors(Component component,
|
||||||
uint8 highlight, ComponentColors _colors,
|
uint8 highlight, ComponentColors _colors,
|
||||||
Decorator::Tab* tab = NULL);
|
Decorator::Tab* tab = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _DrawFrame(BRect rect);
|
virtual void _DrawFrame(BRect rect);
|
||||||
|
|
||||||
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
|
virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
|
||||||
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
|
virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
|
||||||
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
virtual void _DrawClose(Decorator::Tab* tab, bool direct,
|
||||||
BRect rect);
|
BRect rect);
|
||||||
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
|
||||||
BRect rect);
|
BRect rect);
|
||||||
|
virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
|
||||||
|
BRect rect);
|
||||||
|
|
||||||
virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
|
virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
|
||||||
float* offset, float* size,
|
float* offset, float* size,
|
||||||
float* inset) const;
|
float* inset) const;
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ Addon BeDecorator :
|
|||||||
BeDecorator.cpp
|
BeDecorator.cpp
|
||||||
: be <nogrist>app_server $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++)
|
: be <nogrist>app_server $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++)
|
||||||
: resources.rdef
|
: resources.rdef
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
resource("be:decor:info") message('deco') {
|
resource("be:decor:info") message('deco') {
|
||||||
"name" = "Classic BeOS",
|
"name" = "Classic BeOS",
|
||||||
"authors" = "DarkWyrm, Stephan Aßmus, Clemens Zeidler",
|
"authors" = "DarkWyrm, Stephan Aßmus, Clemens Zeidler",
|
||||||
"short_descr" = "Basic appearance of the classic BeOS.",
|
"short_descr" = "Classic appearance of the BeOS",
|
||||||
"long_descr" = "",
|
"long_descr" = "",
|
||||||
"lic_url" = "",
|
"lic_url" = "",
|
||||||
"lic_name" = "MIT",
|
"lic_name" = "MIT",
|
||||||
"support_url" = "http://www.haiku-os.org/",
|
"support_url" = "http://www.haiku-os.org/",
|
||||||
float "version" = 1.0
|
float "version" = 1.1
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user