Bring the MacDecorator to compileable and runnable state. I advise you not to use it yet, however.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34753 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2009-12-22 22:50:39 +00:00
parent e0578cf89f
commit facf61e75c
4 changed files with 321 additions and 211 deletions
@@ -19,10 +19,10 @@ class Desktop;
class BeDecorator: public Decorator { class BeDecorator: public Decorator {
public: public:
BeDecorator(DesktopSettings& settings, BeDecorator(DesktopSettings& settings,
BRect frame, BRect frame,
window_look look, window_look look,
uint32 flags); uint32 flags);
virtual ~BeDecorator(); virtual ~BeDecorator();
virtual void SetTitle(const char* string, virtual void SetTitle(const char* string,
+5 -3
View File
@@ -2,10 +2,12 @@ SubDir HAIKU_TOP src add-ons decorators MacDecorator ;
UseFreeTypeHeaders ; UseFreeTypeHeaders ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app ] ;
UsePrivateHeaders [ FDirName servers app ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ;
UsePrivateHeaders app shared interface graphics ;
UseLibraryHeaders agg ;
Addon MacDecorator : Addon MacDecorator :
MacDecorator.cpp MacDecorator.cpp
: be <nogrist>app_server : be <nogrist>app_server $(TARGET_LIBSTDC++)
# libappserver.so
; ;
@@ -1,8 +1,8 @@
#include <Point.h> #include <Point.h>
#include "DisplayDriver.h" #include "DrawingEngine.h"
#include <View.h> #include <View.h>
#include "LayerData.h" //#include "LayerData.h"
#include "ColorUtils.h" //#include "ColorUtils.h"
#include "MacDecorator.h" #include "MacDecorator.h"
#include "RGBColor.h" #include "RGBColor.h"
#include "PatternHandler.h" #include "PatternHandler.h"
@@ -13,8 +13,50 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
MacDecorator::MacDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags) static inline uint8
blend_color_value(uint8 a, uint8 b, float position)
{
int16 delta = (int16)b - a;
int32 value = a + (int32)(position * delta);
if (value > 255)
return 255;
if (value < 0)
return 0;
return (uint8)value;
}
/*!
\brief Function mostly for calculating gradient colors
\param col Start color
\param col2 End color
\param position A floating point number such that 0.0 <= position <= 1.0. 0.0 results in the
start color and 1.0 results in the end color.
\return The blended color. If an invalid position was given, {0,0,0,0} is returned.
*/
static rgb_color
make_blend_color(rgb_color colorA, rgb_color colorB, float position)
{
if (position < 0)
return colorA;
if (position > 1)
return colorB;
rgb_color blendColor;
blendColor.red = blend_color_value(colorA.red, colorB.red, position);
blendColor.green = blend_color_value(colorA.green, colorB.green, position);
blendColor.blue = blend_color_value(colorA.blue, colorB.blue, position);
blendColor.alpha = blend_color_value(colorA.alpha, colorB.alpha, position);
return blendColor;
}
MacDecorator::MacDecorator(DesktopSettings& settings, BRect frame, window_look look, uint32 flags)
: Decorator(settings, frame, look, flags)
{ {
#ifdef DEBUG_DECOR #ifdef DEBUG_DECOR
printf("MacDecorator()\n"); printf("MacDecorator()\n");
@@ -46,7 +88,7 @@ printf("~MacDecorator()\n");
click_type MacDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) click_type MacDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{ {
if(_closerect.Contains(pt)) if(fCloseRect.Contains(pt))
{ {
#ifdef DEBUG_DECOR #ifdef DEBUG_DECOR
@@ -56,7 +98,7 @@ printf("MacDecorator():Clicked() - Close\n");
return DEC_CLOSE; return DEC_CLOSE;
} }
if(_zoomrect.Contains(pt)) if(fZoomRect.Contains(pt))
{ {
#ifdef DEBUG_DECOR #ifdef DEBUG_DECOR
@@ -67,16 +109,18 @@ printf("MacDecorator():Clicked() - Zoom\n");
} }
// Clicking in the tab? // Clicking in the tab?
if(_tabrect.Contains(pt)) if(fTabRect.Contains(pt))
{ {
// Here's part of our window management stuff // Here's part of our window management stuff
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus()) /* TODO This is missing DEC_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return DEC_MOVETOFRONT; return DEC_MOVETOFRONT;
*/
return DEC_DRAG; return DEC_DRAG;
} }
// We got this far, so user is clicking on the border? // We got this far, so user is clicking on the border?
BRect srect(_frame); BRect srect(fFrame);
srect.top+=19; srect.top+=19;
BRect clientrect(srect.InsetByCopy(3,3)); BRect clientrect(srect.InsetByCopy(3,3));
if(srect.Contains(pt) && !clientrect.Contains(pt)) if(srect.Contains(pt) && !clientrect.Contains(pt))
@@ -99,38 +143,38 @@ void MacDecorator::_DoLayout(void)
#ifdef DEBUG_DECOR #ifdef DEBUG_DECOR
printf("MacDecorator()::_DoLayout()\n"); printf("MacDecorator()::_DoLayout()\n");
#endif #endif
_borderrect=_frame; fBorderRect=fFrame;
_borderrect.top+=19; fBorderRect.top+=19;
_tabrect=_frame; fTabRect=fFrame;
_tabrect.bottom=_tabrect.top+19; fTabRect.bottom=fTabRect.top+19;
_zoomrect=_tabrect; fZoomRect=fTabRect;
_zoomrect.left=_zoomrect.right-12; fZoomRect.left=fZoomRect.right-12;
_zoomrect.bottom=_zoomrect.top+12; fZoomRect.bottom=fZoomRect.top+12;
_zoomrect.OffsetBy(-4,4); fZoomRect.OffsetBy(-4,4);
_closerect=_zoomrect; fCloseRect=fZoomRect;
_minimizerect=_zoomrect; fMinimizeRect=fZoomRect;
_closerect.OffsetTo(_tabrect.left+4,_tabrect.top+4); fCloseRect.OffsetTo(fTabRect.left+4,fTabRect.top+4);
_zoomrect.OffsetBy(0-(_zoomrect.Width()+4),0); fZoomRect.OffsetBy(0-(fZoomRect.Width()+4),0);
if(GetTitle() && _driver) if(Title() && fDrawingEngine)
{ {
titlepixelwidth=_driver->StringWidth(GetTitle(),strlen(GetTitle()),&_drawdata); titlepixelwidth=fDrawingEngine->StringWidth(Title(),strlen(Title())/*,&fDrawState*/);
if(titlepixelwidth<(_zoomrect.left-_closerect.right-10)) if(titlepixelwidth<(fZoomRect.left-fCloseRect.right-10))
{ {
// start with offset from closerect.right // start with offset from closerect.right
textoffset=int(((_zoomrect.left-5)-(_closerect.right+5))/2); textoffset=int(((fZoomRect.left-5)-(fCloseRect.right+5))/2);
textoffset-=int(titlepixelwidth/2); textoffset-=int(titlepixelwidth/2);
// now make it the offset from _tabrect.left // now make it the offset from fTabRect.left
textoffset+=int(_closerect.right+5-_tabrect.left); textoffset+=int(fCloseRect.right+5-fTabRect.left);
} }
else else
textoffset=int(_closerect.right)+5; textoffset=int(fCloseRect.right)+5;
} }
else else
{ {
@@ -139,41 +183,77 @@ printf("MacDecorator()::_DoLayout()\n");
} }
} }
void MacDecorator::MoveBy(float x, float y)
{
MoveBy(BPoint(x,y));
}
void MacDecorator::MoveBy(BPoint pt) void MacDecorator::MoveBy(BPoint pt)
{ {
// Move all internal rectangles the appropriate amount // Move all internal rectangles the appropriate amount
_frame.OffsetBy(pt); fFrame.OffsetBy(pt);
_closerect.OffsetBy(pt); fCloseRect.OffsetBy(pt);
_tabrect.OffsetBy(pt); fTabRect.OffsetBy(pt);
_borderrect.OffsetBy(pt); fBorderRect.OffsetBy(pt);
_zoomrect.OffsetBy(pt); fZoomRect.OffsetBy(pt);
_minimizerect.OffsetBy(pt); fMinimizeRect.OffsetBy(pt);
} }
void
MacDecorator::ResizeBy(BPoint pt, BRegion* dirty)
{
// Move all internal rectangles the appropriate amount
fFrame.right += pt.x;
fFrame.bottom += pt.y;
fTabRect.right += pt.x;
fBorderRect.right += pt.x;
fBorderRect.bottom += pt.y;
fZoomRect.OffsetBy(pt.x,0);
fMinimizeRect.OffsetBy(pt.x,0);
// handle invalidation of resize rect
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
BRect realResizeRect;
switch (fLook) {
case B_DOCUMENT_WINDOW_LOOK:
realResizeRect = fResizeRect;
// resize rect at old location
dirty->Include(realResizeRect);
realResizeRect.OffsetBy(pt);
// resize rect at new location
dirty->Include(realResizeRect);
break;
case B_TITLED_WINDOW_LOOK:
case B_FLOATING_WINDOW_LOOK:
case B_MODAL_WINDOW_LOOK:
// resize rect at old location
dirty->Include(fBorderRect);
fBorderRect.OffsetBy(pt);
// resize rect at new location
dirty->Include(fBorderRect);
break;
default:
break;
}
}
// TODO probably some other layouting stuff here
}
void MacDecorator::_DrawTitle(BRect r) void MacDecorator::_DrawTitle(BRect r)
{ {
if(GetFocus()) if(IsFocus())
_drawdata.SetHighColor(textcol); fDrawState.SetHighColor(textcol);
else else
_drawdata.SetHighColor(inactive_textcol); fDrawState.SetHighColor(inactive_textcol);
_drawdata.SetLowColor(frame_midcol); fDrawState.SetLowColor(frame_midcol);
int32 titlecount=_ClipTitle((_zoomrect.left-5)-(_closerect.right+5)); fTruncatedTitle = Title();
BString titlestr=GetTitle(); fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END,
if(titlecount<titlestr.CountChars()) (fZoomRect.left - 5) - (fCloseRect.right + 5));
{ fTruncatedTitleLength = fTruncatedTitle.Length();
titlestr.Truncate(titlecount-1);
titlestr+="..."; fDrawingEngine->DrawString(fTruncatedTitle,fTruncatedTitleLength,
titlecount+=2; BPoint(fTabRect.left+textoffset,fCloseRect.bottom-1)/*,&fDrawState*/);
}
_driver->DrawString(titlestr.String(),titlecount,
BPoint(_tabrect.left+textoffset,_closerect.bottom-1),&_drawdata);
} }
void MacDecorator::GetFootprint(BRegion *region) void MacDecorator::GetFootprint(BRegion *region)
@@ -184,8 +264,8 @@ void MacDecorator::GetFootprint(BRegion *region)
if(!region) if(!region)
return; return;
region->Set(_borderrect); region->Set(fBorderRect);
region->Include(_tabrect); region->Include(fTabRect);
} }
void MacDecorator::Draw(BRect update) void MacDecorator::Draw(BRect update)
@@ -193,12 +273,13 @@ void MacDecorator::Draw(BRect update)
#ifdef DEBUG_DECOR #ifdef DEBUG_DECOR
printf("MacDecorator::Draw(): "); update.PrintToStream(); printf("MacDecorator::Draw(): "); update.PrintToStream();
#endif #endif
/*
// Draw the top view's client area - just a hack :) // Draw the top view's client area - just a hack :)
_driver->FillRect(_borderrect,_colors->document_background); fDrawingEngine->FillRect(fBorderRect,_colors->document_background);
if(_borderrect.Intersects(update)) if(fBorderRect.Intersects(update))
_driver->FillRect(_borderrect,_colors->document_background); fDrawingEngine->FillRect(fBorderRect,_colors->document_background);
*/
_DrawFrame(update); _DrawFrame(update);
_DrawTab(update); _DrawTab(update);
} }
@@ -211,10 +292,10 @@ printf("MacDecorator::Draw()\n");
// Draw the top view's client area - just a hack :) // Draw the top view's client area - just a hack :)
// RGBColor blue(100,100,255); // RGBColor blue(100,100,255);
// _drawdata.SetHighColor(blue); // fDrawState.SetHighColor(blue);
_driver->FillRect(_borderrect,_colors->document_background); // fDrawingEngine->FillRect(fBorderRect,_colors->document_background);
_driver->FillRect(_borderrect,_colors->document_background); // fDrawingEngine->FillRect(fBorderRect,_colors->document_background);
DrawFrame(); DrawFrame();
DrawTab(); DrawTab();
@@ -230,26 +311,26 @@ void MacDecorator::_DrawZoom(BRect r)
BPoint pt(r.LeftTop()),pt2(r.RightTop()); BPoint pt(r.LeftTop()),pt2(r.RightTop());
pt2.x--; pt2.x--;
_drawdata.SetHighColor(RGBColor(136,136,136)); fDrawState.SetHighColor(RGBColor(136,136,136));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt=r.RightBottom(); pt=r.RightBottom();
pt2=r.RightTop(); pt2=r.RightTop();
pt2.y++; pt2.y++;
_drawdata.SetHighColor(RGBColor(255,255,255)); fDrawState.SetHighColor(RGBColor(255,255,255));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.x++; pt2.x++;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawState.SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
DrawBlendedRect(rect,down); DrawBlendedRect(rect,down);
@@ -260,8 +341,8 @@ void MacDecorator::_DrawZoom(BRect r)
rect.left--; rect.left--;
rect.right++; rect.right++;
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawState.SetHighColor(RGBColor(0,0,0));
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),_drawdata.HighColor()); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),fDrawState.HighColor());
} }
void MacDecorator::_DrawClose(BRect r) void MacDecorator::_DrawClose(BRect r)
@@ -274,26 +355,26 @@ void MacDecorator::_DrawClose(BRect r)
BPoint pt(r.LeftTop()),pt2(r.RightTop()); BPoint pt(r.LeftTop()),pt2(r.RightTop());
pt2.x--; pt2.x--;
_drawdata.SetHighColor(RGBColor(136,136,136)); fDrawState.SetHighColor(RGBColor(136,136,136));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt=r.RightBottom(); pt=r.RightBottom();
pt2=r.RightTop(); pt2=r.RightTop();
pt2.y++; pt2.y++;
_drawdata.SetHighColor(RGBColor(255,255,255)); fDrawState.SetHighColor(RGBColor(255,255,255));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.x++; pt2.x++;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawState.SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
DrawBlendedRect(rect,down); DrawBlendedRect(rect,down);
@@ -304,8 +385,8 @@ void MacDecorator::_DrawClose(BRect r)
// rect.left++; // rect.left++;
// rect.right--; // rect.right--;
// _drawdata.SetHighColor(RGBColor(0,0,0)); // fDrawState.SetHighColor(RGBColor(0,0,0));
// _driver->StrokeLine(rect.LeftTop(),rect.RightTop(),&_drawdata,pat_solidhigh); // fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),&fDrawState,pat_solidhigh);
} }
void MacDecorator::_DrawMinimize(BRect r) void MacDecorator::_DrawMinimize(BRect r)
@@ -318,26 +399,26 @@ void MacDecorator::_DrawMinimize(BRect r)
BPoint pt(r.LeftTop()),pt2(r.RightTop()); BPoint pt(r.LeftTop()),pt2(r.RightTop());
pt2.x--; pt2.x--;
_drawdata.SetHighColor(RGBColor(136,136,136)); fDrawState.SetHighColor(RGBColor(136,136,136));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt=r.RightBottom(); pt=r.RightBottom();
pt2=r.RightTop(); pt2=r.RightTop();
pt2.y++; pt2.y++;
_drawdata.SetHighColor(RGBColor(255,255,255)); fDrawState.SetHighColor(RGBColor(255,255,255));
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt2=r.LeftBottom(); pt2=r.LeftBottom();
pt2.x++; pt2.x++;
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawState.SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
rect.InsetBy(1,1); rect.InsetBy(1,1);
DrawBlendedRect(rect,down); DrawBlendedRect(rect,down);
@@ -348,83 +429,83 @@ void MacDecorator::_DrawMinimize(BRect r)
rect.bottom-=4; rect.bottom-=4;
rect.InsetBy(-2,0); rect.InsetBy(-2,0);
_drawdata.SetHighColor(RGBColor(0,0,0)); fDrawState.SetHighColor(RGBColor(0,0,0));
_driver->StrokeRect(rect,_drawdata.HighColor()); fDrawingEngine->StrokeRect(rect,fDrawState.HighColor());
} }
void MacDecorator::_DrawTab(BRect r) void MacDecorator::_DrawTab(BRect r)
{ {
// 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
// in it. // in it.
if(_look==B_NO_BORDER_WINDOW_LOOK) if(fLook==B_NO_BORDER_WINDOW_LOOK)
return; return;
// _drawdata.SetHighColor(frame_lowcol); // fDrawState.SetHighColor(frame_lowcol);
// _driver->StrokeRect(_tabrect,_drawdata.HighColor()); // fDrawingEngine->StrokeRect(fTabRect,fDrawState.HighColor());
// UpdateTitle(layer->name->String()); // UpdateTitle(layer->name->String());
BRect rect(_tabrect); BRect rect(fTabRect);
_drawdata.SetHighColor(RGBColor(frame_midcol)); fDrawState.SetHighColor(RGBColor(frame_midcol));
_driver->FillRect(rect,frame_midcol); fDrawingEngine->FillRect(rect,frame_midcol);
if(GetFocus()) if(IsFocus())
{ {
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
_driver->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
_driver->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol); fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol);
rect.InsetBy(1,1); rect.InsetBy(1,1);
rect.bottom++; rect.bottom++;
_driver->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_highcol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_highcol);
_driver->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_highcol); fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_highcol);
_driver->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol); fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
// Draw the neat little lines on either side of the title if there's room // Draw the neat little lines on either side of the title if there's room
if((_tabrect.left+textoffset)>(_closerect.right+5)) if((fTabRect.left+textoffset)>(fCloseRect.right+5))
{ {
// Left side // Left side
BPoint pt(_closerect.right+5,_closerect.top), BPoint pt(fCloseRect.right+5,fCloseRect.top),
pt2(_tabrect.left+textoffset-5,_closerect.top); pt2(fTabRect.left+textoffset-5,fCloseRect.top);
_drawdata.SetHighColor(RGBColor(frame_highcol)); fDrawState.SetHighColor(RGBColor(frame_highcol));
for(int32 i=0;i<6;i++) for(int32 i=0;i<6;i++)
{ {
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt.y+=2; pt.y+=2;
pt2.y+=2; pt2.y+=2;
} }
pt.Set(_closerect.right+6,_closerect.top+1), pt.Set(fCloseRect.right+6,fCloseRect.top+1),
pt2.Set(_tabrect.left+textoffset-4,_closerect.top+1); pt2.Set(fTabRect.left+textoffset-4,fCloseRect.top+1);
_drawdata.SetHighColor(RGBColor(frame_lowcol)); fDrawState.SetHighColor(RGBColor(frame_lowcol));
for(int32 i=0;i<6;i++) for(int32 i=0;i<6;i++)
{ {
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt.y+=2; pt.y+=2;
pt2.y+=2; pt2.y+=2;
} }
// Right side // Right side
pt.Set(_tabrect.left+textoffset+titlepixelwidth+6,_zoomrect.top), pt.Set(fTabRect.left+textoffset+titlepixelwidth+6,fZoomRect.top),
pt2.Set(_zoomrect.left-6,_zoomrect.top); pt2.Set(fZoomRect.left-6,fZoomRect.top);
if(pt.x<pt2.x) if(pt.x<pt2.x)
{ {
_drawdata.SetHighColor(RGBColor(frame_highcol)); fDrawState.SetHighColor(RGBColor(frame_highcol));
for(int32 i=0;i<6;i++) for(int32 i=0;i<6;i++)
{ {
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt.y+=2; pt.y+=2;
pt2.y+=2; pt2.y+=2;
} }
pt.Set(_tabrect.left+textoffset+titlepixelwidth+7,_zoomrect.top+1), pt.Set(fTabRect.left+textoffset+titlepixelwidth+7,fZoomRect.top+1),
pt2.Set(_zoomrect.left-5,_zoomrect.top+1); pt2.Set(fZoomRect.left-5,fZoomRect.top+1);
_drawdata.SetHighColor(frame_lowcol); fDrawState.SetHighColor(frame_lowcol);
for(int32 i=0;i<6;i++) for(int32 i=0;i<6;i++)
{ {
_driver->StrokeLine(pt,pt2,_drawdata.HighColor()); fDrawingEngine->StrokeLine(pt,pt2,fDrawState.HighColor());
pt.y+=2; pt.y+=2;
pt2.y+=2; pt2.y+=2;
} }
@@ -432,66 +513,72 @@ void MacDecorator::_DrawTab(BRect r)
} }
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
if(!(_flags & B_NOT_CLOSABLE)) if(!(fFlags & B_NOT_CLOSABLE))
_DrawClose(_closerect); _DrawClose(fCloseRect);
if(!(_flags & B_NOT_ZOOMABLE)) if(!(fFlags & B_NOT_ZOOMABLE))
_DrawZoom(_zoomrect); _DrawZoom(fZoomRect);
} }
} }
void MacDecorator::DrawBlendedRect(BRect r, bool down) void MacDecorator::DrawBlendedRect(BRect r, bool down)
{ {
// This bad boy is used to draw a rectangle with a gradient. BRect r1 = r;
// Note that it is not part of the Decorator API - it's specific BRect r2 = r;
// to just the BeDecorator. Called by DrawZoom and DrawClose
// Actually just draws a blended square r1.left += 1.0;
r1.top += 1.0;
rgb_color tmpcol,halfcol, startcol, endcol; r2.bottom -= 1.0;
float rstep,gstep,bstep,i; r2.right -= 1.0;
BRect rect(r); // TODO: replace these with cached versions? does R5 use different colours?
RGBColor tabColorLight = RGBColor(tint_color(tab_col.GetColor32(),B_LIGHTEN_2_TINT));
RGBColor tabColorShadow = RGBColor(tint_color(tab_col.GetColor32(),B_DARKEN_2_TINT));
if(down) int32 w = r.IntegerWidth();
{ int32 h = r.IntegerHeight();
startcol=button_lowcol.GetColor32();
endcol=button_highcol.GetColor32(); RGBColor temprgbcol;
rgb_color halfColor, startColor, endColor;
float rstep, gstep, bstep;
int steps = w < h ? w : h;
if (down) {
startColor = button_lowcol.GetColor32();
endColor = button_highcol.GetColor32();
} else {
startColor = button_highcol.GetColor32();
endColor = button_lowcol.GetColor32();
} }
else
{ halfColor = make_blend_color(startColor, endColor, 0.5);
startcol=button_highcol.GetColor32();
endcol=button_lowcol.GetColor32(); rstep = float(startColor.red - halfColor.red) / steps;
gstep = float(startColor.green - halfColor.green) / steps;
bstep = float(startColor.blue - halfColor.blue) / steps;
for (int32 i = 0; i <= steps; i++) {
temprgbcol.SetColor(uint8(startColor.red - (i * rstep)),
uint8(startColor.green - (i * gstep)),
uint8(startColor.blue - (i * bstep)));
fDrawingEngine->StrokeLine(BPoint(r.left, r.top + i),
BPoint(r.left + i, r.top), temprgbcol);
temprgbcol.SetColor(uint8(halfColor.red - (i * rstep)),
uint8(halfColor.green - (i * gstep)),
uint8(halfColor.blue - (i * bstep)));
fDrawingEngine->StrokeLine(BPoint(r.left + steps, r.top + i),
BPoint(r.left + i, r.top + steps), temprgbcol);
} }
int32 w=rect.IntegerWidth(), h=rect.IntegerHeight();
int steps=(w<h)?w:h;
halfcol=MakeBlendColor(startcol,endcol,0.5);
rstep=float(startcol.red-halfcol.red)/steps; // draw bevelling effect on box
gstep=float(startcol.green-halfcol.green)/steps; fDrawingEngine->StrokeRect(r2, tabColorShadow); // inner dark box
bstep=float(startcol.blue-halfcol.blue)/steps; fDrawingEngine->StrokeRect(r, tabColorShadow); // outer dark box
fDrawingEngine->StrokeRect(r1, tabColorLight); // light box
for(i=0;i<=steps; i++)
{
SetRGBColor(&tmpcol, uint8(startcol.red-(i*rstep)),
uint8(startcol.green-(i*gstep)),
uint8(startcol.blue-(i*bstep)));
_drawdata.SetHighColor(tmpcol);
_driver->StrokeLine(BPoint(rect.left,rect.top+i),
BPoint(rect.left+i,rect.top),_drawdata.HighColor());
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
uint8(halfcol.green-(i*gstep)),
uint8(halfcol.blue-(i*bstep)) );
_drawdata.SetHighColor(tmpcol);
_driver->StrokeLine(BPoint(rect.left+steps,rect.top+i),
BPoint(rect.left+i,rect.top+steps),_drawdata.HighColor());
}
} }
/* /*
@@ -502,78 +589,78 @@ void MacDecorator::_SetColors(void)
*/ */
void MacDecorator::_DrawFrame(BRect rect) void MacDecorator::_DrawFrame(BRect rect)
{ {
if(_look==B_NO_BORDER_WINDOW_LOOK) if(fLook==B_NO_BORDER_WINDOW_LOOK)
return; return;
BRect r=_borderrect; BRect r=fBorderRect;
BPoint pt,pt2,topleftpt,toprightpt; BPoint pt,pt2,topleftpt,toprightpt;
pt=r.LeftTop(); pt=r.LeftTop();
pt2=r.LeftBottom(); pt2=r.LeftBottom();
// Draw the left side of the frame // Draw the left side of the frame
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowercol);
pt.x++; pt.x++;
pt2.x++; pt2.x++;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_highcol); fDrawingEngine->StrokeLine(pt,pt2,frame_highcol);
pt.x++; pt.x++;
pt2.x++; pt2.x++;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x++; pt.x++;
pt2.x++; pt2.x++;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x++; pt.x++;
pt2.x++; pt2.x++;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_lowcol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowcol);
pt.x++; pt.x++;
pt.y+=2; pt.y+=2;
topleftpt=pt; topleftpt=pt;
pt2.x++; pt2.x++;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowercol);
pt=r.RightTop(); pt=r.RightTop();
pt2=r.RightBottom(); pt2=r.RightBottom();
// Draw the right side of the frame // Draw the right side of the frame
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowercol);
pt.x--; pt.x--;
pt2.x--; pt2.x--;
_driver->StrokeLine(pt,pt2,frame_lowcol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowcol);
pt.x--; pt.x--;
pt2.x--; pt2.x--;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x--; pt.x--;
pt2.x--; pt2.x--;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x--; pt.x--;
pt2.x--; pt2.x--;
_driver->StrokeLine(pt,pt2,frame_highcol); fDrawingEngine->StrokeLine(pt,pt2,frame_highcol);
pt.x--; pt.x--;
pt.y+=2; pt.y+=2;
toprightpt=pt; toprightpt=pt;
pt2.x--; pt2.x--;
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,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
_driver->StrokeLine(topleftpt,toprightpt,frame_lowercol); fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowercol);
topleftpt.y--; topleftpt.y--;
toprightpt.x++; toprightpt.x++;
toprightpt.y--; toprightpt.y--;
_driver->StrokeLine(topleftpt,toprightpt,frame_lowcol); fDrawingEngine->StrokeLine(topleftpt,toprightpt,frame_lowcol);
pt=r.RightTop(); pt=r.RightTop();
pt2=r.RightBottom(); pt2=r.RightBottom();
@@ -583,37 +670,37 @@ void MacDecorator::_DrawFrame(BRect rect)
pt2=r.RightBottom(); pt2=r.RightBottom();
// Draw the bottom side of the frame // Draw the bottom side of the frame
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowercol);
pt.x++; pt.x++;
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_lowcol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowcol);
pt.x++; pt.x++;
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x++; pt.x++;
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_midcol); fDrawingEngine->StrokeLine(pt,pt2,frame_midcol);
pt.x++; pt.x++;
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_highcol); fDrawingEngine->StrokeLine(pt,pt2,frame_highcol);
pt.x+=2; pt.x+=2;
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
_driver->StrokeLine(pt,pt2,frame_lowercol); fDrawingEngine->StrokeLine(pt,pt2,frame_lowercol);
pt.y--; pt.y--;
pt2.x--; pt2.x--;
pt2.y--; pt2.y--;
@@ -624,7 +711,9 @@ extern "C" float get_decorator_version(void)
return 1.00; return 1.00;
} }
extern "C" Decorator *instantiate_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
extern "C" Decorator *(instantiate_decorator)(DesktopSettings &desktopSetting, BRect rec,
window_look loo, uint32 flag)
{ {
return (new MacDecorator(rect,wlook,wfeel,wflags)); return (new MacDecorator(desktopSetting, rec, loo, flag));
} }
@@ -2,40 +2,59 @@
#define _MAC_DECORATOR_H_ #define _MAC_DECORATOR_H_
#include "Decorator.h" #include "Decorator.h"
#include "RGBColor.h"
class MacDecorator: public Decorator
{
class MacDecorator: public Decorator {
public: public:
MacDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags); MacDecorator(DesktopSettings& settings,
~MacDecorator(void); BRect frame,
window_look look,
uint32 flags);
~MacDecorator(void);
// SetTitle
// SetLook
// SetFlags
void MoveBy(float x, float y); //void MoveBy(float x, float y);
void MoveBy(BPoint pt); void MoveBy(BPoint pt);
// void ResizeBy(float x, float y); // void ResizeBy(float x, float y);
// void ResizeBy(BPoint pt); void ResizeBy(BPoint pt, BRegion* diirty);
// SetTabLocation
// TabLocation
// SetSettings
// GetSettings
void Draw(BRect r); void Draw(BRect r);
void Draw(void); void Draw(void);
//GetSizeLimits
void GetFootprint(BRegion *region); void GetFootprint(BRegion *region);
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected: protected:
void _DrawClose(BRect r); void _DoLayout(void);
void _DrawFrame(BRect r); void _DrawFrame(BRect r);
void _DrawTab(BRect r); void _DrawTab(BRect r);
void _DrawClose(BRect r);
void _DrawTitle(BRect r); void _DrawTitle(BRect r);
void _DrawZoom(BRect r); void _DrawZoom(BRect r);
void _DrawMinimize(BRect r); void _DrawMinimize(BRect r);
void _DoLayout(void); // SetFocus
// void _SetColors(void); // void _SetColors(void);
void DrawBlendedRect(BRect r, bool down); void DrawBlendedRect(BRect r, bool down);
uint32 taboffset; uint32 taboffset;
private:
RGBColor tab_col; RGBColor tab_col;
RGBColor button_highcol,button_lowcol; RGBColor button_highcol,button_lowcol;
RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_lowercol; RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_lowercol;
RGBColor textcol,inactive_textcol; RGBColor textcol,inactive_textcol;
uint64 solidhigh, solidlow; uint64 solidhigh, solidlow;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bool slidetab; bool slidetab;
int textoffset; int textoffset;
float titlepixelwidth; float titlepixelwidth;