MacDecorator :
-Draw the text in the titlebar -Fix the buttons (they now are shaded like the DefaultDecorator one, that is, better than in original Mac OS) -Draw the decorator all grey with no buttons when not focused -Fix the border There are some minor bugs left, but basically the decorator is now usable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e5d95b9ded
commit
31aac46f89
@ -6,6 +6,8 @@
|
|||||||
/*! Decorator looking like Mac OS 9 */
|
/*! Decorator looking like Mac OS 9 */
|
||||||
|
|
||||||
|
|
||||||
|
#include "MacDecorator.h"
|
||||||
|
|
||||||
#include <GradientLinear.h>
|
#include <GradientLinear.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@ -15,8 +17,6 @@
|
|||||||
#include "PatternHandler.h"
|
#include "PatternHandler.h"
|
||||||
#include "RGBColor.h"
|
#include "RGBColor.h"
|
||||||
|
|
||||||
#include "MacDecorator.h"
|
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
//#define DEBUG_DECORATOR
|
||||||
#ifdef DEBUG_DECORATOR
|
#ifdef DEBUG_DECORATOR
|
||||||
@ -52,13 +52,107 @@ MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect,
|
|||||||
|
|
||||||
MacDecorator::~MacDecorator()
|
MacDecorator::~MacDecorator()
|
||||||
{
|
{
|
||||||
STRACE("~MacDecorator()\n");
|
STRACE(("~MacDecorator()\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// settitle
|
|
||||||
// fontschanged
|
void
|
||||||
// setlook
|
MacDecorator::SetTitle(const char* string, BRegion* updateRegion)
|
||||||
// setflags
|
{
|
||||||
|
// TODO: we could be much smarter about the update region
|
||||||
|
|
||||||
|
BRect rect = TabRect();
|
||||||
|
|
||||||
|
Decorator::SetTitle(string);
|
||||||
|
|
||||||
|
if (updateRegion == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Decorator::SetTitle may change the TabRect, so we merge the new one
|
||||||
|
BRect updatedRect = TabRect();
|
||||||
|
if (rect.left > updatedRect.left)
|
||||||
|
rect.left = updatedRect.left;
|
||||||
|
if (rect.right < updatedRect.right)
|
||||||
|
rect.right = updatedRect.right;
|
||||||
|
|
||||||
|
rect.bottom++;
|
||||||
|
// the border will look differently when the title is adjacent
|
||||||
|
|
||||||
|
updateRegion->Include(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
// get previous extent
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : does this do anything usefull ?
|
||||||
|
// _UpdateFont(settings);
|
||||||
|
// _InvalidateBitmaps();
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::SetLook(DesktopSettings& settings, window_look look,
|
||||||
|
BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
// TODO: we could be much smarter about the update region
|
||||||
|
|
||||||
|
// get previous extent
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
fLook = look;
|
||||||
|
|
||||||
|
// _UpdateFont(settings);
|
||||||
|
// _InvalidateBitmaps();
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
// TODO: we could be much smarter about the update region
|
||||||
|
|
||||||
|
// get previous extent
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
Decorator::SetFlags(flags, updateRegion);
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL) {
|
||||||
|
BRegion extent;
|
||||||
|
GetFootprint(&extent);
|
||||||
|
updateRegion->Include(&extent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -140,7 +234,7 @@ MacDecorator::Draw()
|
|||||||
// getsizelimits
|
// getsizelimits
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::GetFootprint(BRegion *region)
|
MacDecorator::GetFootprint(BRegion* region)
|
||||||
{
|
{
|
||||||
// This function calculates the decorator's footprint in coordinates
|
// This function calculates the decorator's footprint in coordinates
|
||||||
// relative to the view. This is most often used to set a Window
|
// relative to the view. This is most often used to set a Window
|
||||||
@ -209,19 +303,20 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|
|||||||
void
|
void
|
||||||
MacDecorator::_DoLayout(void)
|
MacDecorator::_DoLayout(void)
|
||||||
{
|
{
|
||||||
|
int32 kDefaultBorderWidth = 6;
|
||||||
STRACE(("MacDecorator: Do Layout\n"));
|
STRACE(("MacDecorator: Do Layout\n"));
|
||||||
|
|
||||||
bool hasTab = false;
|
bool hasTab = false;
|
||||||
|
|
||||||
switch (Look()) {
|
switch (Look()) {
|
||||||
case B_MODAL_WINDOW_LOOK:
|
case B_MODAL_WINDOW_LOOK:
|
||||||
fBorderWidth = 5;
|
fBorderWidth = kDefaultBorderWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_TITLED_WINDOW_LOOK:
|
case B_TITLED_WINDOW_LOOK:
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
hasTab = true;
|
hasTab = true;
|
||||||
fBorderWidth = 5;
|
fBorderWidth = kDefaultBorderWidth;
|
||||||
break;
|
break;
|
||||||
case B_FLOATING_WINDOW_LOOK:
|
case B_FLOATING_WINDOW_LOOK:
|
||||||
hasTab = true;
|
hasTab = true;
|
||||||
@ -238,10 +333,18 @@ MacDecorator::_DoLayout(void)
|
|||||||
fBorderRect=fFrame;
|
fBorderRect=fFrame;
|
||||||
|
|
||||||
if (hasTab) {
|
if (hasTab) {
|
||||||
fBorderRect.top+=19;
|
fBorderRect.InsetBy(-kDefaultBorderWidth, -kDefaultBorderWidth);
|
||||||
|
fBorderRect.top +=3;
|
||||||
|
|
||||||
fTabRect=fFrame;
|
font_height fontHeight;
|
||||||
fTabRect.bottom=fTabRect.top+19;
|
fDrawState.Font().GetHeight(fontHeight);
|
||||||
|
|
||||||
|
// TODO the tab is drawn in a fixed height for now
|
||||||
|
fTabRect.Set(fFrame.left - fBorderWidth,
|
||||||
|
fFrame.top - 20,
|
||||||
|
((fFrame.right - fFrame.left) < 32.0 ?
|
||||||
|
fFrame.left + 32.0 : fFrame.right) + fBorderWidth,
|
||||||
|
fFrame.top);
|
||||||
|
|
||||||
fZoomRect=fTabRect;
|
fZoomRect=fTabRect;
|
||||||
fZoomRect.left=fZoomRect.right-12;
|
fZoomRect.left=fZoomRect.right-12;
|
||||||
@ -295,130 +398,146 @@ MacDecorator::_DrawFrame(BRect invalid)
|
|||||||
case B_DOCUMENT_WINDOW_LOOK:
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
case B_MODAL_WINDOW_LOOK:
|
case B_MODAL_WINDOW_LOOK:
|
||||||
{
|
{
|
||||||
BPoint offset,pt2,topleftpt,toprightpt;
|
if (IsFocus()) {
|
||||||
|
BPoint offset = r.LeftTop();
|
||||||
|
BPoint pt2 = r.LeftBottom();
|
||||||
|
|
||||||
offset=r.LeftTop();
|
// Draw the left side of the frame
|
||||||
pt2=r.LeftBottom();
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
|
offset.x++;
|
||||||
|
pt2.x++;
|
||||||
|
pt2.y--;
|
||||||
|
|
||||||
// Draw the left side of the frame
|
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
offset.x++;
|
||||||
offset.x++;
|
pt2.x++;
|
||||||
pt2.x++;
|
pt2.y--;
|
||||||
pt2.y--;
|
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
pt2.y--;
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
|
offset.x++;
|
||||||
|
pt2.x++;
|
||||||
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
pt2.x++;
|
offset.y+=2;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
BPoint topleftpt=offset;
|
||||||
offset.x++;
|
pt2.x++;
|
||||||
pt2.x++;
|
pt2.y--;
|
||||||
pt2.y--;
|
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
offset.x++;
|
|
||||||
offset.y+=2;
|
|
||||||
topleftpt=offset;
|
|
||||||
pt2.x++;
|
|
||||||
pt2.y--;
|
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
|
||||||
|
|
||||||
|
|
||||||
offset=r.RightTop();
|
offset=r.RightTop();
|
||||||
pt2=r.RightBottom();
|
pt2=r.RightBottom();
|
||||||
|
|
||||||
// Draw the right side of the frame
|
// Draw the right side of the frame
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
||||||
offset.x--;
|
offset.x--;
|
||||||
offset.y+=2;
|
offset.y+=2;
|
||||||
toprightpt=offset;
|
BPoint toprightpt=offset;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
|
|
||||||
// Draw the top side of the frame that is not in the tab
|
// Draw the top side of the frame that is not in the tab
|
||||||
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowercol);
|
offset=r.RightTop();
|
||||||
topleftpt.y--;
|
pt2=r.RightBottom();
|
||||||
toprightpt.x++;
|
|
||||||
toprightpt.y--;
|
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowcol);
|
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowercol);
|
||||||
|
topleftpt.y--;
|
||||||
|
toprightpt.x++;
|
||||||
|
toprightpt.y--;
|
||||||
|
|
||||||
offset=r.RightTop();
|
fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowcol);
|
||||||
pt2=r.RightBottom();
|
|
||||||
|
|
||||||
|
offset=r.LeftBottom();
|
||||||
|
pt2=r.RightBottom();
|
||||||
|
|
||||||
offset=r.LeftBottom();
|
// Draw the bottom side of the frame
|
||||||
pt2=r.RightBottom();
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
|
offset.x++;
|
||||||
|
offset.y--;
|
||||||
|
pt2.x--;
|
||||||
|
pt2.y--;
|
||||||
|
|
||||||
// Draw the bottom side of the frame
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
offset.x++;
|
||||||
offset.x++;
|
offset.y--;
|
||||||
offset.y--;
|
pt2.x--;
|
||||||
pt2.x--;
|
pt2.y--;
|
||||||
pt2.y--;
|
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
||||||
offset.x++;
|
offset.x++;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_midcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
||||||
offset.x++;
|
offset.x+=2;
|
||||||
offset.y--;
|
offset.y--;
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_highcol);
|
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
||||||
offset.x+=2;
|
offset.y--;
|
||||||
offset.y--;
|
pt2.x--;
|
||||||
pt2.x--;
|
pt2.y--;
|
||||||
pt2.y--;
|
} else {
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_lowcol);
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,frame_lowercol);
|
for (int i = 0; i < 4; i++) {
|
||||||
offset.y--;
|
r.InsetBy(1, 1);
|
||||||
pt2.x--;
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_midcol);
|
||||||
pt2.y--;
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_midcol);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_midcol);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.InsetBy(1, 1);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(), frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(), frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(), frame_lowcol);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case B_BORDERED_WINDOW_LOOK:
|
case B_BORDERED_WINDOW_LOOK:
|
||||||
fDrawingEngine->StrokeRect(r, frame_midcol);
|
fDrawingEngine->StrokeRect(r, frame_midcol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// don't draw a border frame
|
// don't draw a border frame
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawTab(BRect invalid)
|
MacDecorator::_DrawTab(BRect invalid)
|
||||||
{
|
{
|
||||||
// If a window has a tab, this will draw it and any buttons which are
|
// If a window has a tab, this will draw it and any buttons which are
|
||||||
@ -426,16 +545,12 @@ MacDecorator::_DrawTab(BRect invalid)
|
|||||||
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect))
|
if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// fDrawState.SetHighColor(frame_lowcol);
|
|
||||||
// fDrawingEngine->StrokeRect(fTabRect,fDrawState.HighColor());
|
|
||||||
|
|
||||||
// UpdateTitle(layer->name->String());
|
|
||||||
BRect rect(fTabRect);
|
BRect rect(fTabRect);
|
||||||
fDrawState.SetHighColor(RGBColor(frame_midcol));
|
fDrawingEngine->SetHighColor(RGBColor(frame_midcol));
|
||||||
fDrawingEngine->FillRect(rect,frame_midcol);
|
fDrawingEngine->FillRect(rect,frame_midcol);
|
||||||
|
|
||||||
|
|
||||||
//if(IsFocus())
|
if(IsFocus())
|
||||||
{
|
{
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
|
||||||
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
|
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
|
||||||
@ -454,7 +569,7 @@ MacDecorator::_DrawTab(BRect invalid)
|
|||||||
// Left side
|
// Left side
|
||||||
|
|
||||||
BPoint offset(fCloseRect.right+5,fCloseRect.top),
|
BPoint offset(fCloseRect.right+5,fCloseRect.top),
|
||||||
pt2(fTabRect.left+textoffset-5,fCloseRect.top);
|
pt2(fTabRect.left+textoffset-5,fCloseRect.top);
|
||||||
fDrawState.SetHighColor(RGBColor(frame_highcol));
|
fDrawState.SetHighColor(RGBColor(frame_highcol));
|
||||||
for(int32 i=0;i<6;i++)
|
for(int32 i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
@ -498,17 +613,24 @@ MacDecorator::_DrawTab(BRect invalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Draw the buttons if we're supposed to
|
// Draw the buttons if we're supposed to
|
||||||
if(!(fFlags & B_NOT_CLOSABLE))
|
if(!(fFlags & B_NOT_CLOSABLE))
|
||||||
_DrawClose(fCloseRect);
|
_DrawClose(fCloseRect);
|
||||||
if(!(fFlags & B_NOT_ZOOMABLE))
|
if(!(fFlags & B_NOT_ZOOMABLE))
|
||||||
_DrawZoom(fZoomRect);
|
_DrawZoom(fZoomRect);
|
||||||
|
} else {
|
||||||
|
// Not focused - Just draw a plain light grey area with the title in the middle
|
||||||
|
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowcol);
|
||||||
|
fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_DrawTitle(fTabRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MacDecorator::_DrawClose(BRect r)
|
MacDecorator::_DrawClose(BRect r)
|
||||||
{
|
{
|
||||||
bool down=GetClose();
|
bool down=GetClose();
|
||||||
@ -518,58 +640,57 @@ MacDecorator::_DrawClose(BRect r)
|
|||||||
|
|
||||||
BPoint offset(r.LeftTop()),pt2(r.RightTop());
|
BPoint offset(r.LeftTop()),pt2(r.RightTop());
|
||||||
|
|
||||||
|
// Topleft dark grey border
|
||||||
pt2.x--;
|
pt2.x--;
|
||||||
fDrawState.SetHighColor(RGBColor(136,136,136));
|
fDrawingEngine->SetHighColor(RGBColor(136,136,136));
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset,pt2);
|
||||||
|
|
||||||
pt2=r.LeftBottom();
|
pt2=r.LeftBottom();
|
||||||
pt2.y--;
|
pt2.y--;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset,pt2);
|
||||||
|
|
||||||
|
// Bottomright white border
|
||||||
offset=r.RightBottom();
|
offset=r.RightBottom();
|
||||||
pt2=r.RightTop();
|
pt2=r.RightTop();
|
||||||
pt2.y++;
|
pt2.y++;
|
||||||
fDrawState.SetHighColor(RGBColor(255,255,255));
|
fDrawingEngine->SetHighColor(RGBColor(255,255,255));
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset,pt2);
|
||||||
|
|
||||||
pt2=r.LeftBottom();
|
pt2=r.LeftBottom();
|
||||||
pt2.x++;
|
pt2.x++;
|
||||||
fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
|
fDrawingEngine->StrokeLine(offset,pt2);
|
||||||
|
|
||||||
|
// Black outline
|
||||||
rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
fDrawState.SetHighColor(RGBColor(0,0,0));
|
fDrawingEngine->SetHighColor(RGBColor(0,0,0));
|
||||||
fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
|
fDrawingEngine->StrokeRect(rect);
|
||||||
|
|
||||||
|
// Double-shaded button
|
||||||
rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
_DrawBlendedRect(fDrawingEngine, rect, down);
|
_DrawBlendedRect(fDrawingEngine, rect, down);
|
||||||
rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
_DrawBlendedRect(fDrawingEngine, rect, !down);
|
_DrawBlendedRect(fDrawingEngine, rect, !down);
|
||||||
|
|
||||||
// rect.top+=4;
|
|
||||||
// rect.left++;
|
|
||||||
// rect.right--;
|
|
||||||
|
|
||||||
// fDrawState.SetHighColor(RGBColor(0,0,0));
|
|
||||||
// fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),&fDrawState,pat_solidhigh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MacDecorator::_DrawTitle(BRect r)
|
void
|
||||||
|
MacDecorator::_DrawTitle(BRect rect)
|
||||||
{
|
{
|
||||||
if(IsFocus())
|
if(IsFocus())
|
||||||
fDrawState.SetHighColor(fFocusTextColor);
|
fDrawingEngine->SetHighColor(fFocusTextColor);
|
||||||
else
|
else
|
||||||
fDrawState.SetHighColor(fNonFocusTextColor);
|
fDrawingEngine->SetHighColor(fNonFocusTextColor);
|
||||||
|
|
||||||
fDrawState.SetLowColor(frame_midcol);
|
fDrawingEngine->SetLowColor(frame_midcol);
|
||||||
|
|
||||||
fTruncatedTitle = Title();
|
fTruncatedTitle = Title();
|
||||||
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
|
||||||
(fZoomRect.left - 5) - (fCloseRect.right + 5));
|
(fZoomRect.left - 5) - (fCloseRect.right + 5));
|
||||||
fTruncatedTitleLength = fTruncatedTitle.Length();
|
fTruncatedTitleLength = fTruncatedTitle.Length();
|
||||||
|
fDrawingEngine->SetFont(fDrawState.Font());
|
||||||
|
|
||||||
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
|
fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
|
||||||
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1)/*,&fDrawState*/);
|
BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -663,25 +784,46 @@ void MacDecorator::_DrawMinimize(BRect r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Draws a framed rectangle with a gradient.
|
void
|
||||||
\param down The rectangle should be drawn recessed or not
|
MacDecorator::_SetColors()
|
||||||
*/
|
{
|
||||||
void
|
_SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MacDecorator::_UpdateFont(DesktopSettings& settings)
|
||||||
|
{
|
||||||
|
ServerFont font;
|
||||||
|
if (fLook == B_FLOATING_WINDOW_LOOK) {
|
||||||
|
settings.GetDefaultPlainFont(font);
|
||||||
|
} else
|
||||||
|
settings.GetDefaultBoldFont(font);
|
||||||
|
|
||||||
|
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||||
|
font.SetSpacing(B_STRING_SPACING);
|
||||||
|
fDrawState.SetFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Draws a rectangle with a gradient.
|
||||||
|
\param down The rectangle should be drawn recessed or not
|
||||||
|
*/
|
||||||
|
void
|
||||||
MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
||||||
bool down/*, bool focus*/)
|
bool down/*, bool focus*/)
|
||||||
{
|
{
|
||||||
// figure out which colors to use
|
// figure out which colors to use
|
||||||
rgb_color startColor, endColor;
|
rgb_color startColor, endColor;
|
||||||
if (down) {
|
if (down) {
|
||||||
startColor = tint_color(fButtonLowColor, B_DARKEN_1_TINT);
|
startColor = fButtonLowColor;
|
||||||
endColor = fButtonLowColor;
|
endColor = frame_highcol;
|
||||||
} else {
|
} else {
|
||||||
startColor = tint_color(fButtonHighColor, B_LIGHTEN_MAX_TINT);
|
startColor = fButtonHighColor;
|
||||||
endColor = fButtonHighColor;
|
endColor = frame_lowercol;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill
|
// fill
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
BGradientLinear gradient;
|
BGradientLinear gradient;
|
||||||
gradient.SetStart(rect.LeftTop());
|
gradient.SetStart(rect.LeftTop());
|
||||||
gradient.SetEnd(rect.RightBottom());
|
gradient.SetEnd(rect.RightBottom());
|
||||||
@ -689,20 +831,9 @@ MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
|
|||||||
gradient.AddColor(endColor, 255);
|
gradient.AddColor(endColor, 255);
|
||||||
|
|
||||||
engine->FillRect(rect, gradient);
|
engine->FillRect(rect, gradient);
|
||||||
|
|
||||||
// outline
|
|
||||||
rect.InsetBy(-1, -1);
|
|
||||||
engine->StrokeRect(rect, tint_color(fTabColor, B_DARKEN_2_TINT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void MacDecorator::_SetColors(void)
|
|
||||||
{
|
|
||||||
_SetFocus();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern "C" float get_decorator_version(void)
|
extern "C" float get_decorator_version(void)
|
||||||
{
|
{
|
||||||
return 1.00;
|
return 1.00;
|
||||||
@ -710,7 +841,7 @@ extern "C" float get_decorator_version(void)
|
|||||||
|
|
||||||
|
|
||||||
extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec,
|
extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec,
|
||||||
window_look loo, uint32 flag)
|
window_look loo, uint32 flag)
|
||||||
{
|
{
|
||||||
return (new MacDecorator(desktopSetting, rec, loo, flag));
|
return (new MacDecorator(desktopSetting, rec, loo, flag));
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,14 @@ public:
|
|||||||
uint32 flags);
|
uint32 flags);
|
||||||
~MacDecorator();
|
~MacDecorator();
|
||||||
|
|
||||||
// void SetTitle(const char* string,
|
void SetTitle(const char* string,
|
||||||
// BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
// void FontsChanged(DesktopSettings& settings,
|
void FontsChanged(DesktopSettings& settings,
|
||||||
// BRegion* updateRegion);
|
BRegion* updateRegion);
|
||||||
// void SetLook(DesktopSettings& settings,
|
void SetLook(DesktopSettings& settings, window_look look,
|
||||||
// BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
// void SetFlags(uint32 flags,
|
void SetFlags(uint32 flags,
|
||||||
// BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
void MoveBy(BPoint offset);
|
void MoveBy(BPoint offset);
|
||||||
void ResizeBy(BPoint offset, BRegion* dirty);
|
void ResizeBy(BPoint offset, BRegion* dirty);
|
||||||
@ -59,20 +59,21 @@ protected:
|
|||||||
void _DrawMinimize(BRect r);
|
void _DrawMinimize(BRect r);
|
||||||
|
|
||||||
// void _SetFocus();
|
// void _SetFocus();
|
||||||
// void _SetColors();
|
void _SetColors();
|
||||||
private:
|
private:
|
||||||
|
void _UpdateFont(DesktopSettings& settings);
|
||||||
void _DrawBlendedRect(DrawingEngine* engine,
|
void _DrawBlendedRect(DrawingEngine* engine,
|
||||||
BRect r, bool down);
|
BRect r, bool down);
|
||||||
|
|
||||||
rgb_color fButtonHighColor;
|
rgb_color fButtonHighColor;
|
||||||
rgb_color fButtonLowColor;
|
rgb_color fButtonLowColor;
|
||||||
rgb_color fTabColor;
|
|
||||||
rgb_color frame_highcol;
|
rgb_color frame_highcol;
|
||||||
rgb_color frame_midcol;
|
rgb_color frame_midcol;
|
||||||
rgb_color frame_lowcol;
|
rgb_color frame_lowcol;
|
||||||
rgb_color frame_lowercol;
|
rgb_color frame_lowercol;
|
||||||
rgb_color fFocusTextColor;
|
rgb_color fFocusTextColor;
|
||||||
rgb_color fNonFocusTextColor;
|
rgb_color fNonFocusTextColor;
|
||||||
|
|
||||||
uint64 solidhigh, solidlow;
|
uint64 solidhigh, solidlow;
|
||||||
|
|
||||||
BString fTruncatedTitle;
|
BString fTruncatedTitle;
|
||||||
|
Loading…
Reference in New Issue
Block a user