Make the decorators not crash
This commit is contained in:
@@ -128,25 +128,23 @@ BeDecorator::BeDecorator(DesktopSettings& settings, BRect rect)
|
|||||||
fTabOffset(0),
|
fTabOffset(0),
|
||||||
fWasDoubleClick(false)
|
fWasDoubleClick(false)
|
||||||
{
|
{
|
||||||
_UpdateFont(settings);
|
|
||||||
//SetLook(settings, look);
|
|
||||||
|
|
||||||
fFrameColors = new RGBColor[6];
|
fFrameColors = new RGBColor[6];
|
||||||
fFrameColors[0].SetColor(152, 152, 152);
|
fFrameColors[0].SetColor(152, 152, 152);
|
||||||
fFrameColors[1].SetColor(255, 255, 255);
|
fFrameColors[1].SetColor(255, 255, 255);
|
||||||
fFrameColors[2].SetColor(216, 216, 216);
|
fFrameColors[2].SetColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||||
fFrameColors[3].SetColor(136, 136, 136);
|
fFrameColors[3].SetColor(136, 136, 136);
|
||||||
fFrameColors[4].SetColor(152, 152, 152);
|
fFrameColors[4].SetColor(152, 152, 152);
|
||||||
fFrameColors[5].SetColor(96, 96, 96);
|
fFrameColors[5].SetColor(96, 96, 96);
|
||||||
|
|
||||||
fTabList.AddItem(_AllocateNewTab());
|
fTabColor.SetColor(ui_color(B_WINDOW_TAB_COLOR));
|
||||||
|
fTextColor.SetColor(ui_color(B_WINDOW_TEXT_COLOR));
|
||||||
|
|
||||||
// Set appropriate colors based on the current focus value. In this case,
|
fButtonHighColor.SetColor(tint_color(fTabColor.GetColor32(),
|
||||||
// each decorator defaults to not having the focus.
|
B_LIGHTEN_2_TINT));
|
||||||
_SetFocus(_TabAt(0));
|
fButtonLowColor.SetColor(tint_color(fTabColor.GetColor32(),
|
||||||
|
B_DARKEN_2_TINT));
|
||||||
|
|
||||||
// Do initial decorator setup
|
//_UpdateFont(settings);
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
// TODO: If the decorator was created with a frame too small, it should
|
// TODO: If the decorator was created with a frame too small, it should
|
||||||
// resize itself!
|
// resize itself!
|
||||||
@@ -214,9 +212,11 @@ BeDecorator::Draw(BRect updateRect)
|
|||||||
STRACE(("BeDecorator::Draw(BRect updateRect): "));
|
STRACE(("BeDecorator::Draw(BRect updateRect): "));
|
||||||
updateRect.PrintToStream();
|
updateRect.PrintToStream();
|
||||||
|
|
||||||
|
// We need to draw a few things: the tab, the resize knob, the borders,
|
||||||
|
// and the buttons
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(updateRect & fFrame);
|
_DrawFrame(updateRect);
|
||||||
_DrawTabs(updateRect & fTitleBarRect);
|
_DrawTabs(updateRect & fTitleBarRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ BeDecorator::Draw()
|
|||||||
// things
|
// things
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(fFrame);
|
_DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()));
|
||||||
_DrawTabs(fTitleBarRect);
|
_DrawTabs(fTitleBarRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,10 +837,16 @@ BeDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
|
|||||||
|
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
BeDecorator::Tab* tab = static_cast<BeDecorator::Tab*>(_tab);
|
||||||
|
|
||||||
|
const BRect& tabRect = tab->tabRect;
|
||||||
|
const BRect& closeRect = tab->closeRect;
|
||||||
|
const BRect& zoomRect = tab->zoomRect;
|
||||||
|
|
||||||
fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
||||||
fDrawingEngine->SetHighColor(fTextColor);
|
fDrawingEngine->SetHighColor(fTextColor);
|
||||||
fDrawingEngine->SetLowColor(fTabColor);
|
fDrawingEngine->SetLowColor(fTabColor);
|
||||||
@@ -852,20 +858,22 @@ BeDecorator::_DrawTitle(Decorator::Tab* tab, BRect r)
|
|||||||
|
|
||||||
BPoint titlePos;
|
BPoint titlePos;
|
||||||
if (fTopTab->look != kLeftTitledWindowLook) {
|
if (fTopTab->look != kLeftTitledWindowLook) {
|
||||||
titlePos.x = tab->closeRect.IsValid() ? tab->closeRect.right + fTextOffset
|
titlePos.x = closeRect.IsValid() ? closeRect.right + tab->textOffset
|
||||||
: tab->tabRect.left + fTextOffset;
|
: tabRect.left + tab->textOffset;
|
||||||
titlePos.y = floorf(((tab->tabRect.top + 2.0) + tab->tabRect.bottom
|
titlePos.y = floorf(((tabRect.top + 2.0) + tabRect.bottom
|
||||||
+ fontHeight.ascent + fontHeight.descent) / 2.0
|
+ fontHeight.ascent + fontHeight.descent) / 2.0
|
||||||
- fontHeight.descent + 0.5);
|
- fontHeight.descent + 0.5);
|
||||||
} else {
|
} else {
|
||||||
titlePos.x = floorf(((tab->tabRect.left + 2.0) + tab->tabRect.right
|
titlePos.x = floorf(((tabRect.left + 2.0) + tabRect.right
|
||||||
+ fontHeight.ascent + fontHeight.descent) / 2.0
|
+ fontHeight.ascent + fontHeight.descent) / 2.0
|
||||||
- fontHeight.descent + 0.5);
|
- fontHeight.descent + 0.5);
|
||||||
titlePos.y = tab->zoomRect.IsValid() ? tab->zoomRect.top - fTextOffset
|
titlePos.y = zoomRect.IsValid() ? zoomRect.top - tab->textOffset
|
||||||
: tab->tabRect.bottom - fTextOffset;
|
: tabRect.bottom - tab->textOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength,
|
fDrawingEngine->SetFont(fDrawState.Font());
|
||||||
|
|
||||||
|
fDrawingEngine->DrawString(tab->truncatedTitle.String(), tab->truncatedTitleLength,
|
||||||
titlePos);
|
titlePos);
|
||||||
|
|
||||||
fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
||||||
|
|||||||
@@ -189,12 +189,9 @@ private:
|
|||||||
|
|
||||||
uint32 fTabOffset;
|
uint32 fTabOffset;
|
||||||
float fTabLocation;
|
float fTabLocation;
|
||||||
float fTextOffset;
|
|
||||||
|
|
||||||
float fMinTabSize;
|
float fMinTabSize;
|
||||||
float fMaxTabSize;
|
float fMaxTabSize;
|
||||||
BString fTruncatedTitle;
|
|
||||||
int32 fTruncatedTitleLength;
|
|
||||||
|
|
||||||
bool fWasDoubleClick;
|
bool fWasDoubleClick;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect)
|
|||||||
:
|
:
|
||||||
Decorator(settings, rect)
|
Decorator(settings, rect)
|
||||||
{
|
{
|
||||||
_UpdateFont(settings);
|
|
||||||
|
|
||||||
// common colors to both focus and non focus state
|
// common colors to both focus and non focus state
|
||||||
frame_highcol = (rgb_color){ 255, 255, 255, 255 };
|
frame_highcol = (rgb_color){ 255, 255, 255, 255 };
|
||||||
frame_midcol = (rgb_color){ 216, 216, 216, 255 };
|
frame_midcol = (rgb_color){ 216, 216, 216, 255 };
|
||||||
@@ -62,18 +60,11 @@ WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect)
|
|||||||
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
|
fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
|
||||||
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
|
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
|
||||||
|
|
||||||
fTabList.AddItem(_AllocateNewTab());
|
//_UpdateFont(settings);
|
||||||
|
|
||||||
// Set appropriate colors based on the current focus value. In this case,
|
STRACE(("WinDecorator:\n"));
|
||||||
// each decorator defaults to not having the focus.
|
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
_SetFocus(_TabAt(0));
|
rect.left, rect.top, rect.right, rect.bottom));
|
||||||
|
|
||||||
// Do initial decorator setup
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
textoffset = 5;
|
|
||||||
|
|
||||||
STRACE(("WinDecorator()\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,17 +89,20 @@ WinDecorator::Draw(BRect updateRect)
|
|||||||
STRACE(("WinDecorator::Draw(BRect updateRect): "));
|
STRACE(("WinDecorator::Draw(BRect updateRect): "));
|
||||||
updateRect.PrintToStream();
|
updateRect.PrintToStream();
|
||||||
|
|
||||||
|
// We need to draw a few things: the tab, the resize knob, the borders,
|
||||||
|
// and the buttons
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(updateRect & fFrame);
|
_DrawFrame(fFrame & updateRect);
|
||||||
_DrawTabs(updateRect & fTitleBarRect);
|
_DrawTabs(fTitleBarRect & updateRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WinDecorator::Draw()
|
WinDecorator::Draw()
|
||||||
{
|
{
|
||||||
STRACE(("WinDecorator::Draw()\n"));
|
// Easy way to draw everything - no worries about drawing only certain
|
||||||
|
// things
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
_DrawFrame(fFrame);
|
_DrawFrame(fFrame);
|
||||||
@@ -301,26 +295,28 @@ void
|
|||||||
WinDecorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
|
WinDecorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
|
||||||
{
|
{
|
||||||
const BRect& tabRect = tab->tabRect;
|
const BRect& tabRect = tab->tabRect;
|
||||||
const BRect& closeRect = tab->closeRect;
|
const BRect& minimizeRect = tab->minimizeRect;
|
||||||
const BRect& zoomRect = tab->zoomRect;
|
const BRect& zoomRect = tab->zoomRect;
|
||||||
|
const BRect& closeRect = tab->closeRect;
|
||||||
|
|
||||||
//fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
//fDrawingEngine->SetDrawingMode(B_OP_OVER);
|
||||||
fDrawingEngine->SetHighColor(textcol);
|
fDrawingEngine->SetHighColor(textcol);
|
||||||
fDrawingEngine->SetLowColor(IsFocus(_TabAt(0))
|
fDrawingEngine->SetLowColor(IsFocus(tab)
|
||||||
? fFocusTabColor : fNonFocusTabColor);
|
? fFocusTabColor : fNonFocusTabColor);
|
||||||
|
|
||||||
fTruncatedTitle = Title(_TabAt(0));
|
fTruncatedTitle = Title(tab);
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
||||||
((zoomRect.IsValid() ? zoomRect.left :
|
((minimizeRect.IsValid() ? minimizeRect.left :
|
||||||
|
zoomRect.IsValid() ? zoomRect.left :
|
||||||
closeRect.IsValid() ? closeRect.left : tabRect.right) - 5)
|
closeRect.IsValid() ? closeRect.left : tabRect.right) - 5)
|
||||||
- (tabRect.left + textoffset));
|
- (tabRect.left + 5));
|
||||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||||
fDrawingEngine->SetFont(fDrawState.Font());
|
fDrawingEngine->SetFont(fDrawState.Font());
|
||||||
|
|
||||||
fDrawingEngine->DrawString(fTruncatedTitle, fTruncatedTitleLength,
|
fDrawingEngine->DrawString(fTruncatedTitle, fTruncatedTitleLength,
|
||||||
BPoint(tabRect.left + textoffset,closeRect.bottom - 1));
|
BPoint(tabRect.left + 5, closeRect.bottom - 1));
|
||||||
|
|
||||||
//fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
fDrawingEngine->SetDrawingMode(B_OP_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -480,7 +476,7 @@ WinDecorator::_SetFocus(Decorator::Tab* tab)
|
|||||||
// SetFocus() performs necessary duties for color swapping and
|
// SetFocus() performs necessary duties for color swapping and
|
||||||
// other things when a window is deactivated or activated.
|
// other things when a window is deactivated or activated.
|
||||||
|
|
||||||
if (IsFocus(_TabAt(0))) {
|
if (IsFocus(tab)) {
|
||||||
// tab_highcol.SetColor(100, 100, 255);
|
// tab_highcol.SetColor(100, 100, 255);
|
||||||
// tab_lowcol.SetColor(40, 0, 255);
|
// tab_lowcol.SetColor(40, 0, 255);
|
||||||
tab_highcol = fFocusTabColor;
|
tab_highcol = fFocusTabColor;
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ private:
|
|||||||
int32 fTruncatedTitleLength;
|
int32 fTruncatedTitleLength;
|
||||||
|
|
||||||
bool slidetab;
|
bool slidetab;
|
||||||
int textoffset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ Decorator::IsFocus(int32 tab) const
|
|||||||
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
|
Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
|
||||||
if (decoratorTab == NULL)
|
if (decoratorTab == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return decoratorTab->isFocused;
|
return decoratorTab->isFocused;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user