Minor tweaks and improvements to the DefaultDecorator
Made toggle for RootLayer debug output Optimization for ViewDriver::CopyRegion with 1-rectangle regions Fixes and tweaks to WinBorder::MouseMoved() Toggled debug output in ServerApp More useful comments in code in general git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4517 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,78 +58,82 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w
|
||||
framecolors[3].SetColor(136,136,136);
|
||||
framecolors[4].SetColor(96,96,96);
|
||||
|
||||
// Set appropriate colors based on the current focus value. In this case, each decorator
|
||||
// defaults to not having the focus.
|
||||
_SetFocus();
|
||||
|
||||
|
||||
// Do initial decorator setup
|
||||
_DoLayout();
|
||||
|
||||
// This flag is used to determine whether or not we're moving the tab
|
||||
slidetab=false;
|
||||
|
||||
// tab_highcol=_colors->window_tab;
|
||||
// tab_lowcol=_colors->window_tab;
|
||||
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator:\n");
|
||||
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator:\n");
|
||||
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
|
||||
#endif
|
||||
}
|
||||
|
||||
DefaultDecorator::~DefaultDecorator(void)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: ~DefaultDecorator()\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: ~DefaultDecorator()\n");
|
||||
#endif
|
||||
|
||||
delete [] framecolors;
|
||||
}
|
||||
|
||||
click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Clicked\n");
|
||||
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y);
|
||||
printf("\tButtons:\n");
|
||||
if(buttons==0)
|
||||
printf("\t\tNone\n");
|
||||
else
|
||||
{
|
||||
if(buttons & B_PRIMARY_MOUSE_BUTTON)
|
||||
printf("\t\tPrimary\n");
|
||||
if(buttons & B_SECONDARY_MOUSE_BUTTON)
|
||||
printf("\t\tSecondary\n");
|
||||
if(buttons & B_TERTIARY_MOUSE_BUTTON)
|
||||
printf("\t\tTertiary\n");
|
||||
}
|
||||
printf("\tModifiers:\n");
|
||||
if(modifiers==0)
|
||||
printf("\t\tNone\n");
|
||||
else
|
||||
{
|
||||
if(modifiers & B_CAPS_LOCK)
|
||||
printf("\t\tCaps Lock\n");
|
||||
if(modifiers & B_NUM_LOCK)
|
||||
printf("\t\tNum Lock\n");
|
||||
if(modifiers & B_SCROLL_LOCK)
|
||||
printf("\t\tScroll Lock\n");
|
||||
if(modifiers & B_LEFT_COMMAND_KEY)
|
||||
printf("\t\t Left Command\n");
|
||||
if(modifiers & B_RIGHT_COMMAND_KEY)
|
||||
printf("\t\t Right Command\n");
|
||||
if(modifiers & B_LEFT_CONTROL_KEY)
|
||||
printf("\t\tLeft Control\n");
|
||||
if(modifiers & B_RIGHT_CONTROL_KEY)
|
||||
printf("\t\tRight Control\n");
|
||||
if(modifiers & B_LEFT_OPTION_KEY)
|
||||
printf("\t\tLeft Option\n");
|
||||
if(modifiers & B_RIGHT_OPTION_KEY)
|
||||
printf("\t\tRight Option\n");
|
||||
if(modifiers & B_LEFT_SHIFT_KEY)
|
||||
printf("\t\tLeft Shift\n");
|
||||
if(modifiers & B_RIGHT_SHIFT_KEY)
|
||||
printf("\t\tRight Shift\n");
|
||||
if(modifiers & B_MENU_KEY)
|
||||
printf("\t\tMenu\n");
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Clicked\n");
|
||||
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y);
|
||||
printf("\tButtons:\n");
|
||||
if(buttons==0)
|
||||
printf("\t\tNone\n");
|
||||
else
|
||||
{
|
||||
if(buttons & B_PRIMARY_MOUSE_BUTTON)
|
||||
printf("\t\tPrimary\n");
|
||||
if(buttons & B_SECONDARY_MOUSE_BUTTON)
|
||||
printf("\t\tSecondary\n");
|
||||
if(buttons & B_TERTIARY_MOUSE_BUTTON)
|
||||
printf("\t\tTertiary\n");
|
||||
}
|
||||
printf("\tModifiers:\n");
|
||||
if(modifiers==0)
|
||||
printf("\t\tNone\n");
|
||||
else
|
||||
{
|
||||
if(modifiers & B_CAPS_LOCK)
|
||||
printf("\t\tCaps Lock\n");
|
||||
if(modifiers & B_NUM_LOCK)
|
||||
printf("\t\tNum Lock\n");
|
||||
if(modifiers & B_SCROLL_LOCK)
|
||||
printf("\t\tScroll Lock\n");
|
||||
if(modifiers & B_LEFT_COMMAND_KEY)
|
||||
printf("\t\t Left Command\n");
|
||||
if(modifiers & B_RIGHT_COMMAND_KEY)
|
||||
printf("\t\t Right Command\n");
|
||||
if(modifiers & B_LEFT_CONTROL_KEY)
|
||||
printf("\t\tLeft Control\n");
|
||||
if(modifiers & B_RIGHT_CONTROL_KEY)
|
||||
printf("\t\tRight Control\n");
|
||||
if(modifiers & B_LEFT_OPTION_KEY)
|
||||
printf("\t\tLeft Option\n");
|
||||
if(modifiers & B_RIGHT_OPTION_KEY)
|
||||
printf("\t\tRight Option\n");
|
||||
if(modifiers & B_LEFT_SHIFT_KEY)
|
||||
printf("\t\tLeft Shift\n");
|
||||
if(modifiers & B_RIGHT_SHIFT_KEY)
|
||||
printf("\t\tRight Shift\n");
|
||||
if(modifiers & B_MENU_KEY)
|
||||
printf("\t\tMenu\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// In checking for hit test stuff, we start with the smallest rectangles the user might
|
||||
// be clicking on and gradually work our way out into larger rectangles.
|
||||
if(_closerect.Contains(pt))
|
||||
return CLICK_CLOSE;
|
||||
|
||||
@@ -143,8 +147,6 @@ else
|
||||
if(_tabrect.Contains(pt))
|
||||
{
|
||||
// Here's part of our window management stuff
|
||||
// if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
|
||||
// return CLICK_MOVETOFRONT;
|
||||
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
||||
return CLICK_MOVETOBACK;
|
||||
return CLICK_DRAG;
|
||||
@@ -168,10 +170,10 @@ else
|
||||
|
||||
void DefaultDecorator::_DoLayout(void)
|
||||
{
|
||||
//debugger("");
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Do Layout\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Do Layout\n");
|
||||
#endif
|
||||
|
||||
// Here we determine the size of every rectangle that we use
|
||||
// internally when we are given the size of the client rectangle.
|
||||
|
||||
@@ -185,6 +187,7 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
// and there *are* apps which do this
|
||||
// borderwidth=3;
|
||||
// break;
|
||||
|
||||
case B_BORDERED_WINDOW_LOOK:
|
||||
case B_TITLED_WINDOW_LOOK:
|
||||
case B_DOCUMENT_WINDOW_LOOK:
|
||||
@@ -194,21 +197,17 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
borderwidth = 0;
|
||||
}
|
||||
|
||||
// Current version simply makes everything fit inside the rect
|
||||
// instead of building around it. This will change.
|
||||
|
||||
// IT did :-)
|
||||
// distance from one item of the tab bar to another. In this case the text and close/zoom rects
|
||||
// distance from one item of the tab bar to another. In this case the text and close/zoom rects
|
||||
textoffset = (_look==B_FLOATING_WINDOW_LOOK) ? 7 : 10;
|
||||
|
||||
// calculate or tab rect
|
||||
// calculate our tab rect
|
||||
_tabrect.Set( _frame.left - borderwidth,
|
||||
_frame.top - borderwidth - 19.0,
|
||||
((_frame.right - _frame.left) < 35.0 ?
|
||||
_frame.left + 35.0 : _frame.right) + borderwidth,
|
||||
_frame.top - (borderwidth-1) );
|
||||
|
||||
// make it text width sensitive
|
||||
// make it text width sensitive
|
||||
if(strlen(GetTitle())>1)
|
||||
{
|
||||
if(_driver)
|
||||
@@ -216,10 +215,10 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
else
|
||||
titlepixelwidth=10;
|
||||
|
||||
int32 tabLength = 14 + // _closerect width
|
||||
int32 tabLength = int32(14 + // _closerect width
|
||||
textoffset + titlepixelwidth + textoffset +
|
||||
14 + // _zoomrect width
|
||||
8; // margins
|
||||
8); // margins
|
||||
int32 tabWidth = (int32)_tabrect.Width();
|
||||
if ( tabLength < tabWidth )
|
||||
_tabrect.right = _tabrect.left + tabLength;
|
||||
@@ -227,7 +226,7 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
else
|
||||
_tabrect.right = _tabrect.left + _tabrect.Width()/2;
|
||||
|
||||
// calculate left/top/right/bottom borders
|
||||
// calculate left/top/right/bottom borders
|
||||
if ( borderwidth != 0 ){
|
||||
_borderrect = _frame.InsetByCopy( -borderwidth, -borderwidth );
|
||||
leftborder.Set( _borderrect.left, _frame.top - borderwidth,
|
||||
@@ -240,7 +239,7 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
_borderrect.right, _borderrect.bottom );
|
||||
}
|
||||
else{
|
||||
// no border ... (?) useful when displaying windows that are just images
|
||||
// no border ... (?) useful when displaying windows that are just images
|
||||
_borderrect = _frame;
|
||||
leftborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
||||
rightborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
||||
@@ -248,89 +247,31 @@ printf("DefaultDecorator: Do Layout\n");
|
||||
bottomborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
||||
}
|
||||
|
||||
// calculate resize rect
|
||||
// calculate resize rect
|
||||
_resizerect.Set( _borderrect.right - 19.0, _borderrect.bottom - 19.0,
|
||||
_borderrect.right, _borderrect.bottom);
|
||||
|
||||
// format tab rect for a floating window - make te rect smaller
|
||||
// format tab rect for a floating window - make the rect smaller
|
||||
if ( _look == B_FLOATING_WINDOW_LOOK ){
|
||||
_tabrect.InsetBy( 0, 2 );
|
||||
_tabrect.OffsetBy( 0, 2 );
|
||||
}
|
||||
|
||||
// calulate close rect based on the tab rectangle
|
||||
// calulate close rect based on the tab rectangle
|
||||
_closerect.Set( _tabrect.left + 4.0, _tabrect.top + 4.0,
|
||||
_tabrect.left + 4.0 + 13.0, _tabrect.top + 4.0 + 13.0 );
|
||||
|
||||
// calulate zoom rect based on the tab rectangle
|
||||
// calulate zoom rect based on the tab rectangle
|
||||
_zoomrect.Set( _tabrect.right - 4.0 - 13.0, _tabrect.top + 4.0,
|
||||
_tabrect.right - 4.0, _tabrect.top + 4.0 + 13.0 );
|
||||
|
||||
// fromat close and zoom rects for a floating window - make rectangles smaller
|
||||
// format close and zoom rects for a floating window - make rectangles smaller
|
||||
if ( _look == B_FLOATING_WINDOW_LOOK ){
|
||||
_closerect.InsetBy( 1, 1 );
|
||||
_zoomrect.InsetBy( 1, 1 );
|
||||
_closerect.OffsetBy( 0, -2 );
|
||||
_zoomrect.OffsetBy( 0, -2 );
|
||||
}
|
||||
// Old version...
|
||||
/*
|
||||
_tabrect=_frame;
|
||||
_resizerect=_frame;
|
||||
_borderrect=_frame;
|
||||
_closerect=_frame;
|
||||
|
||||
|
||||
textoffset=(_look==B_FLOATING_WINDOW_LOOK)?5:7;
|
||||
|
||||
_closerect.left+=(_look==B_FLOATING_WINDOW_LOOK)?2:4;
|
||||
_closerect.top+=(_look==B_FLOATING_WINDOW_LOOK)?6:4;
|
||||
_closerect.right=_closerect.left+10;
|
||||
_closerect.bottom=_closerect.top+10;
|
||||
|
||||
|
||||
_borderrect.top+=19;
|
||||
|
||||
if(borderwidth)
|
||||
{
|
||||
// Set up the border rectangles to handle the window's frame
|
||||
rightborder=leftborder=topborder=bottomborder=_borderrect;
|
||||
|
||||
// We want the rectangles to intersect because of the beveled intersections, so all
|
||||
// that is necessary is to set the short dimension of each side
|
||||
leftborder.right=leftborder.left+borderwidth;
|
||||
rightborder.left=rightborder.right-borderwidth;
|
||||
topborder.bottom=topborder.top+borderwidth;
|
||||
bottomborder.top=bottomborder.bottom-borderwidth;
|
||||
}
|
||||
|
||||
_resizerect.top=_resizerect.bottom-18;
|
||||
_resizerect.left=_resizerect.right-18;
|
||||
|
||||
_tabrect.bottom=_tabrect.top+18;
|
||||
if(strlen(GetTitle())>1)
|
||||
{
|
||||
if(_driver)
|
||||
titlepixelwidth=_driver->StringWidth(GetTitle(),_TitleWidth(), &_layerdata);
|
||||
else
|
||||
titlepixelwidth=10;
|
||||
|
||||
if(_closerect.right+textoffset+titlepixelwidth+35< _frame.Width()-1)
|
||||
_tabrect.right=_tabrect.left+titlepixelwidth;
|
||||
}
|
||||
else
|
||||
_tabrect.right=_tabrect.left+_tabrect.Width()/2;
|
||||
|
||||
if(_look==B_FLOATING_WINDOW_LOOK)
|
||||
_tabrect.top+=4;
|
||||
|
||||
_zoomrect=_tabrect;
|
||||
_zoomrect.top+=(_look==B_FLOATING_WINDOW_LOOK)?2:4;
|
||||
_zoomrect.right-=4;
|
||||
_zoomrect.bottom-=4;
|
||||
_zoomrect.left=_zoomrect.right-10;
|
||||
_zoomrect.bottom=_zoomrect.top+10;
|
||||
*/
|
||||
}
|
||||
|
||||
void DefaultDecorator::MoveBy(float x, float y)
|
||||
@@ -340,9 +281,10 @@ void DefaultDecorator::MoveBy(float x, float y)
|
||||
|
||||
void DefaultDecorator::MoveBy(BPoint pt)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
|
||||
#endif
|
||||
|
||||
// Move all internal rectangles the appropriate amount
|
||||
_frame.OffsetBy(pt);
|
||||
_closerect.OffsetBy(pt);
|
||||
@@ -355,15 +297,14 @@ printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
|
||||
rightborder.OffsetBy(pt);
|
||||
topborder.OffsetBy(pt);
|
||||
bottomborder.OffsetBy(pt);
|
||||
|
||||
// Draw( _borderrect );
|
||||
}
|
||||
|
||||
BRegion * DefaultDecorator::GetFootprint(void)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Get Footprint\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Get Footprint\n");
|
||||
#endif
|
||||
|
||||
// This function calculates the decorator's footprint in coordinates
|
||||
// relative to the layer. This is most often used to set a WinBorder
|
||||
// object's visible region.
|
||||
@@ -380,7 +321,10 @@ BRect DefaultDecorator::SlideTab(float dx, float dy=0){
|
||||
|
||||
void DefaultDecorator::_DrawTitle(BRect r)
|
||||
{
|
||||
printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#endif
|
||||
|
||||
// Designed simply to redraw the title when it has changed on
|
||||
// the client side.
|
||||
_layerdata.highcolor=_colors->window_tab_text;
|
||||
@@ -395,8 +339,15 @@ printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
titlestr+="...";
|
||||
titlecount+=2;
|
||||
}
|
||||
|
||||
// The text position needs tweaked when working as a floating window because the closerect placement
|
||||
// is a little different. If it isn't moved, title placement looks really funky
|
||||
if(_look==B_FLOATING_WINDOW_LOOK)
|
||||
_driver->DrawString(titlestr.String(),titlecount,
|
||||
BPoint(_closerect.right+textoffset,_closerect.bottom-1),&_layerdata);
|
||||
BPoint(_closerect.right+textoffset,_closerect.bottom+1),&_layerdata);
|
||||
else
|
||||
_driver->DrawString(titlestr.String(),titlecount,
|
||||
BPoint(_closerect.right+textoffset,_closerect.bottom),&_layerdata);
|
||||
}
|
||||
|
||||
void DefaultDecorator::_SetFocus(void)
|
||||
@@ -404,40 +355,30 @@ void DefaultDecorator::_SetFocus(void)
|
||||
// SetFocus() performs necessary duties for color swapping and
|
||||
// other things when a window is deactivated or activated.
|
||||
|
||||
// Removed Adi's short-term color hack and replaced with a more palatable substitute for the old,
|
||||
// dark colors
|
||||
if(GetFocus())
|
||||
{
|
||||
// ADI: a temporary hack - the colors were TOO dark
|
||||
// button_highcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
||||
// button_lowcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_DARKEN_2_TINT));
|
||||
button_highcol.SetColor( RGBColor( 255, 255, 0 ) );
|
||||
button_lowcol.SetColor( RGBColor( 234, 181, 0) );
|
||||
button_highcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
||||
button_lowcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_DARKEN_1_TINT));
|
||||
textcol=_colors->window_tab_text;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ADI: a temporary hack - the colors were TOO dark
|
||||
// button_highcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
||||
// button_lowcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_DARKEN_2_TINT));
|
||||
button_highcol.SetColor( RGBColor(234, 181, 0) );
|
||||
button_lowcol.SetColor( RGBColor( 255, 255, 0 ) );
|
||||
button_highcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
||||
button_lowcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_DARKEN_1_TINT));
|
||||
textcol=_colors->inactive_window_tab_text;
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultDecorator::Draw(BRect update)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom);
|
||||
#endif
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom);
|
||||
#endif
|
||||
// We need to draw a few things: the tab, the resize thumb, the borders,
|
||||
// and the buttons
|
||||
|
||||
// Draw the top view's client area - just a hack :)
|
||||
_layerdata.highcolor=_colors->document_background;
|
||||
/*
|
||||
if(_borderrect.Intersects(update))
|
||||
_driver->FillRect(_borderrect & update,&_layerdata,pat_solidhigh);
|
||||
*/
|
||||
_DrawFrame(update);
|
||||
_DrawTab(update);
|
||||
}
|
||||
@@ -447,19 +388,16 @@ void DefaultDecorator::Draw(void)
|
||||
// Easy way to draw everything - no worries about drawing only certain
|
||||
// things
|
||||
|
||||
// Draw the top view's client area - just a hack :)
|
||||
// _layerdata.highcolor=_colors->document_background;
|
||||
|
||||
// _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh);
|
||||
|
||||
_DrawFrame(_borderrect);
|
||||
|
||||
_DrawTab(_tabrect);
|
||||
}
|
||||
|
||||
void DefaultDecorator::_DrawZoom(BRect r)
|
||||
{
|
||||
printf("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#endif
|
||||
|
||||
// If this has been implemented, then the decorator has a Zoom button
|
||||
// which should be drawn based on the state of the member zoomstate
|
||||
BRect zr( r );
|
||||
@@ -476,14 +414,20 @@ printf("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
|
||||
void DefaultDecorator::_DrawClose(BRect r)
|
||||
{
|
||||
printf("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#endif
|
||||
|
||||
// Just like DrawZoom, but for a close button
|
||||
DrawBlendedRect( r, GetClose());
|
||||
}
|
||||
|
||||
void DefaultDecorator::_DrawTab(BRect r)
|
||||
{
|
||||
printf("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
#endif
|
||||
|
||||
// If a window has a tab, this will draw it and any buttons which are
|
||||
// in it.
|
||||
if(_look==B_NO_BORDER_WINDOW_LOOK)
|
||||
|
||||
@@ -398,17 +398,20 @@ void Layer::Invalidate(BRegion& region)
|
||||
All children of the layer also receive this call, so only 1 Invalidate call is
|
||||
needed to set a section as invalid on the screen.
|
||||
*/
|
||||
void Layer::Invalidate(BRect rect)
|
||||
void Layer::Invalidate(const BRect &rect)
|
||||
{
|
||||
// Make our own section dirty and pass it on to any children, if necessary....
|
||||
// YES, WE ARE SHARING DIRT! Mudpies anyone? :D
|
||||
if(TestRectIntersection(Frame(),rect))
|
||||
if(TestRectIntersection(Bounds(),rect))
|
||||
{
|
||||
// Clip the rectangle to the _visible region of the layer
|
||||
if(TestRegionIntersection(_visible,rect))
|
||||
{
|
||||
BRegion reg(*_visible);
|
||||
IntersectRegionWith(®,rect);
|
||||
BRegion rectreg(rect);
|
||||
|
||||
// IntersectRegionWith(®,rect);
|
||||
reg.IntersectWith(&rectreg);
|
||||
if(reg.CountRects()>0)
|
||||
{
|
||||
_is_dirty=true;
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
const char *GetName(void) { return (_name)?_name->String():NULL; }
|
||||
LayerData *GetLayerData(void) { return _layerdata; }
|
||||
|
||||
void Invalidate(BRect rect);
|
||||
void Invalidate(const BRect &rect);
|
||||
void Invalidate(BRegion& region);
|
||||
void RebuildRegions(bool include_children=true);
|
||||
virtual void RequestDraw(const BRect &r);
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//#define DISPLAYDRIVER_TEST_HACK
|
||||
//#define DEBUG_ROOTLAYER
|
||||
|
||||
/*!
|
||||
\brief Sets up internal variables needed by the RootLayer
|
||||
\param rect Frame of the root layer
|
||||
@@ -78,9 +81,12 @@ void RootLayer::RequestDraw(void)
|
||||
// Redraw the base
|
||||
if(_invalid)
|
||||
{
|
||||
#ifdef DEBUG_ROOTLAYER
|
||||
printf("ROOTLAYER: ");
|
||||
_invalid->PrintToStream();
|
||||
printf("===========\n");
|
||||
#endif
|
||||
|
||||
for(int32 i=0; _invalid->CountRects();i++)
|
||||
{
|
||||
if(_invalid->RectAt(i).IsValid())
|
||||
@@ -101,6 +107,7 @@ void RootLayer::RequestDraw(void)
|
||||
}
|
||||
|
||||
_is_dirty=false;
|
||||
|
||||
#ifdef DISPLAYDRIVER_TEST_HACK
|
||||
int8 pattern[8];
|
||||
int8 pattern2[8];
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "LayerData.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define DEBUG_SERVERAPP
|
||||
//#define DEBUG_SERVERAPP
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
|
||||
@@ -212,7 +212,6 @@ void VDView::MouseUp(BPoint pt)
|
||||
|
||||
void VDView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
printf("message received\n");
|
||||
switch(msg->what)
|
||||
{
|
||||
#ifdef ENABLE_INPUT_SERVER_EMULATION
|
||||
@@ -658,10 +657,26 @@ void ViewDriver::CopyRegion(BRegion *src, const BPoint &lefttop)
|
||||
printf("ViewDriver:: CopyRegion not completely tested\n");
|
||||
#endif
|
||||
|
||||
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
|
||||
// Check for cases where the region is only 1 rectangle and call CopyBits in
|
||||
// such a case. While in this particular case CopyBits is not HW-accelerated,
|
||||
// other DisplayDriver derivatives, like AccelerantDriver, can take advantage of
|
||||
// such things, cutting speed significantly in such cases
|
||||
if(src->CountRects()==1)
|
||||
{
|
||||
BRect srect(src->RectAt(0)),drect(src->RectAt(0).OffsetToCopy(lefttop));
|
||||
drawview->CopyBits(srect,drect);
|
||||
drawview->Sync();
|
||||
screenwin->view->Invalidate(srect);
|
||||
screenwin->view->Invalidate(drect);
|
||||
framebuffer->Unlock();
|
||||
screenwin->Unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check for overlap
|
||||
bool overlap=false;
|
||||
|
||||
@@ -675,9 +690,11 @@ printf("ViewDriver:: CopyRegion not completely tested\n");
|
||||
|
||||
if(TestRectIntersection(regframe,src->Frame()) && src->CountRects()>1)
|
||||
overlap=true;
|
||||
|
||||
|
||||
if(overlap)
|
||||
{
|
||||
printf("Overlap\n");
|
||||
|
||||
// If overlap, get the inverse of the region passed to us and save the
|
||||
// inverse region's frame
|
||||
inverse=src->Frame();
|
||||
@@ -1064,9 +1081,6 @@ void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors,
|
||||
drawview->SetHighColor(col);
|
||||
drawview->StrokeLine(pt1,pt2,B_SOLID_HIGH);
|
||||
|
||||
|
||||
printf("\tLine (%.1f,%.1f)-(%.1f,%.1f) in color (%d,%d,%d)\n",pt1.x,pt1.y,pt2.x,pt2.y,
|
||||
col.red,col.green,col.blue);
|
||||
}
|
||||
drawview->Sync();
|
||||
screenwin->view->Invalidate();
|
||||
|
||||
@@ -39,9 +39,12 @@
|
||||
|
||||
// TODO: Document this file completely
|
||||
|
||||
#define DEBUG_WINBORDER
|
||||
// Toggle general function call output
|
||||
//#define DEBUG_WINBORDER
|
||||
|
||||
// toggle
|
||||
//#define DEBUG_WINBORDER_MOUSE
|
||||
#define DEBUG_WINBORDER_CLICK
|
||||
//#define DEBUG_WINBORDER_CLICK
|
||||
|
||||
#ifdef DEBUG_WINBORDER
|
||||
#include <stdio.h>
|
||||
@@ -84,7 +87,9 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
_mbuttons=0;
|
||||
_kmodifiers=0;
|
||||
_win=win;
|
||||
|
||||
if(_win)
|
||||
_frame=_win->_frame;
|
||||
_clientframe=_frame;
|
||||
_mousepos.Set(0,0);
|
||||
_update=false;
|
||||
|
||||
@@ -93,15 +98,15 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
_vresizewin=false;
|
||||
_driver=GetGfxDriver(ActiveScreen());
|
||||
_decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver(ActiveScreen()));
|
||||
// WinBorder must also include the right/left/top/bottom Decorator'
|
||||
// rects - given by _decorator::GetBorderRect() - to be able to draw the borders
|
||||
_frame = _decorator->GetBorderRect();
|
||||
_visible->Set( _frame );
|
||||
_visible->Include( _decorator->GetTabRect() );
|
||||
_full->Set( _frame );
|
||||
_full->Include( _decorator->GetTabRect() );
|
||||
_invalid->Set( _frame );
|
||||
_invalid->Include( _decorator->GetTabRect() );
|
||||
|
||||
// We need to do this because GetFootprint is supposed to generate a new BRegion.
|
||||
// I suppose the call probably ought to be void GetFootprint(BRegion *recipient), but we can
|
||||
// change that later.
|
||||
|
||||
if(_visible)
|
||||
delete _visible;
|
||||
_visible=_decorator->GetFootprint();
|
||||
*_full=*_visible;
|
||||
|
||||
_decorator->SetDriver(_driver);
|
||||
_decorator->SetTitle(name);
|
||||
@@ -147,43 +152,48 @@ void WinBorder::MouseDown(int8 *buffer)
|
||||
{
|
||||
case CLICK_MOVETOBACK:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
|
||||
MakeTopChild();
|
||||
break;
|
||||
}
|
||||
case CLICK_MOVETOFRONT:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToFront\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToFront\n");
|
||||
#endif
|
||||
|
||||
MakeBottomChild();
|
||||
break;
|
||||
}
|
||||
case CLICK_CLOSE:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Close\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Close\n");
|
||||
#endif
|
||||
|
||||
_decorator->SetClose(true);
|
||||
_decorator->DrawClose();
|
||||
break;
|
||||
}
|
||||
case CLICK_ZOOM:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Zoom\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Zoom\n");
|
||||
#endif
|
||||
|
||||
_decorator->SetZoom(true);
|
||||
_decorator->DrawZoom();
|
||||
break;
|
||||
}
|
||||
case CLICK_MINIMIZE:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Minimize\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Minimize\n");
|
||||
#endif
|
||||
|
||||
_decorator->SetMinimize(true);
|
||||
_decorator->DrawMinimize();
|
||||
break;
|
||||
@@ -192,27 +202,30 @@ printf("Click: Minimize\n");
|
||||
{
|
||||
if(buttons==B_PRIMARY_MOUSE_BUTTON)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Drag\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Drag\n");
|
||||
#endif
|
||||
|
||||
MakeBottomChild();
|
||||
set_is_moving_window(true);
|
||||
}
|
||||
|
||||
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: MoveToBack\n");
|
||||
#endif
|
||||
|
||||
MakeTopChild();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLICK_SLIDETAB:
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Slide Tab\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Slide Tab\n");
|
||||
#endif
|
||||
|
||||
set_is_sliding_tab(true);
|
||||
break;
|
||||
}
|
||||
@@ -220,9 +233,10 @@ printf("Click: Slide Tab\n");
|
||||
{
|
||||
if(buttons==B_PRIMARY_MOUSE_BUTTON)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Resize\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("Click: Resize\n");
|
||||
#endif
|
||||
|
||||
set_is_resizing_window(true);
|
||||
}
|
||||
break;
|
||||
@@ -273,9 +287,10 @@ void WinBorder::MouseMoved(int8 *buffer)
|
||||
|
||||
if(is_sliding_tab())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Slide Tab\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Slide Tab\n");
|
||||
#endif
|
||||
|
||||
float dx=pt.x-_mousepos.x;
|
||||
float dy=pt.y-_mousepos.y;
|
||||
|
||||
@@ -295,40 +310,67 @@ printf("ClickMove: Slide Tab\n");
|
||||
|
||||
if(is_moving_window())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Drag\n");
|
||||
#endif
|
||||
//debugger("");
|
||||
// We are moving the window. Because speed is of the essence, we need to handle a lot
|
||||
// of stuff which we might otherwise not need to.
|
||||
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Drag\n");
|
||||
#endif
|
||||
|
||||
// 1) Get deltas
|
||||
float dx=pt.x-_mousepos.x,
|
||||
dy=pt.y-_mousepos.y;
|
||||
|
||||
if(buttons!=0 && (dx!=0 || dy!=0))
|
||||
{
|
||||
BRect oldmoveframe=_win->_frame;
|
||||
_clientframe.OffsetBy(pt);
|
||||
// 2) Offset necessary data members
|
||||
_clientframe.OffsetBy(dx,dy);
|
||||
|
||||
_win->Lock();
|
||||
_win->_frame.OffsetBy(dx,dy);
|
||||
_win->Unlock();
|
||||
|
||||
lock_layers();
|
||||
|
||||
// Move the window decorator's footprint and remove the area occupied
|
||||
// by the new location so we know what areas to invalidate.
|
||||
|
||||
// The original location
|
||||
BRegion *reg=_decorator->GetFootprint();
|
||||
// TODO: we get an error here!!! - this method is untested
|
||||
// TODO: we really need to enable this method to avoid lots of drawings.
|
||||
//_driver->CopyRegion(reg,_win->_frame.LeftTop());
|
||||
|
||||
// The new location
|
||||
BRegion reg2(*reg);
|
||||
reg2.OffsetBy((int32)dx, (int32)dy);
|
||||
|
||||
MoveBy(dx,dy);
|
||||
_decorator->MoveBy(BPoint(dx, dy));
|
||||
|
||||
// 3) quickly move the window
|
||||
_driver->CopyRegion(reg,reg2.Frame().LeftTop());
|
||||
|
||||
// 4) Invalidate only the areas which we can't redraw directly
|
||||
for(int32 i=0; i<reg2.CountRects();i++)
|
||||
reg->Exclude(reg2.RectAt(i));
|
||||
|
||||
// TODO: DW's notes to self
|
||||
// As of right now, dragging the window is extremely slow despite the use
|
||||
// of CopyRegion. The reason is because of the redraw taken. When Invalidate() is
|
||||
// called the RootLayer invalidates things properly for itself, but the area which
|
||||
// should be invalidated for the first of the two windows in my test case is not
|
||||
// made dirty, so the entire first window is redrawn with RequestDraw being
|
||||
// restructured as it is. Additionally, the second window is redrawn for the same reason
|
||||
// when in fact it shouldn't be redrawn at all.
|
||||
|
||||
// Solution:
|
||||
// Figure out what the exact usage of Layer::Invalidate() should be (parent coordinates,
|
||||
// layer's coordinates, etc) and set things right. Secondly, nuke the invalid region
|
||||
// in this call so that when RequestDraw is called, this WinBorder doesn't redraw itself
|
||||
|
||||
_parent->Invalidate(*reg);
|
||||
|
||||
_decorator->MoveBy(BPoint(dx, dy));
|
||||
MoveBy(dx,dy);
|
||||
|
||||
// ADI: what do those do???
|
||||
BRegion reg2(oldmoveframe);
|
||||
reg->OffsetBy((int32)dx, (int32)dy);
|
||||
reg2.Exclude(reg);
|
||||
|
||||
_parent->RebuildRegions();
|
||||
printf("WinBorder: calling parent = %s::RequestDraw()\n", _parent->_name->String());
|
||||
_parent->RequestDraw();
|
||||
|
||||
|
||||
delete reg;
|
||||
unlock_layers();
|
||||
}
|
||||
@@ -337,13 +379,14 @@ printf("ClickMove: Drag\n");
|
||||
|
||||
if(is_resizing_window())
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Resize\n");
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER_CLICK
|
||||
printf("ClickMove: Resize\n");
|
||||
#endif
|
||||
|
||||
float dx=pt.x-_mousepos.x,
|
||||
dy=pt.y-_mousepos.y;
|
||||
if(buttons!=0 && (dx!=0 || dy!=0))
|
||||
{
|
||||
{
|
||||
_clientframe.right+=dx;
|
||||
_clientframe.bottom+=dy;
|
||||
|
||||
@@ -378,9 +421,6 @@ void WinBorder::MouseUp(int8 *buffer)
|
||||
int32 modifiers=*((int32*)index);
|
||||
BPoint pt(x,y);
|
||||
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseUp unimplemented\n",_title->String());
|
||||
#endif
|
||||
|
||||
_mbuttons=0;
|
||||
_kmodifiers=modifiers;
|
||||
@@ -399,6 +439,9 @@ printf("WinBorder %s: MouseUp unimplemented\n",_title->String());
|
||||
_decorator->DrawClose();
|
||||
|
||||
// call close window stuff here
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseUp:CLICK_CLOSE unimplemented\n",_title->String());
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -408,6 +451,9 @@ printf("WinBorder %s: MouseUp unimplemented\n",_title->String());
|
||||
_decorator->DrawZoom();
|
||||
|
||||
// call zoom stuff here
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseUp:CLICK_ZOOM unimplemented\n",_title->String());
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -417,6 +463,9 @@ printf("WinBorder %s: MouseUp unimplemented\n",_title->String());
|
||||
_decorator->DrawMinimize();
|
||||
|
||||
// call minimize stuff here
|
||||
#ifdef DEBUG_WINBORDER_MOUSE
|
||||
printf("WinBorder %s: MouseUp:CLICK_MINIMIZE unimplemented\n",_title->String());
|
||||
#endif
|
||||
|
||||
}
|
||||
default:
|
||||
@@ -438,10 +487,11 @@ void WinBorder::SetFocus(const bool &active)
|
||||
|
||||
void WinBorder::RequestDraw(const BRect &r)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: RequestDraw(BRect)\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: RequestDraw(BRect)\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
|
||||
_decorator->Draw(r);
|
||||
delete _invalid;
|
||||
_invalid = NULL;
|
||||
@@ -449,13 +499,21 @@ PrintToStream();
|
||||
|
||||
void WinBorder::RequestDraw(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s::RequestDraw()\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
_decorator->Draw();
|
||||
delete _invalid;
|
||||
_invalid = NULL;
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s::RequestDraw()\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
|
||||
if(_invalid)
|
||||
{
|
||||
for(int32 i=0;i<_invalid->CountRects();i++)
|
||||
_decorator->Draw(_invalid->RectAt(i));
|
||||
|
||||
delete _invalid;
|
||||
_invalid = NULL;
|
||||
}
|
||||
else
|
||||
_decorator->Draw();
|
||||
}
|
||||
/*
|
||||
void WinBorder::MoveBy(BPoint pt)
|
||||
@@ -476,28 +534,28 @@ void WinBorder::ResizeBy(float x, float y)
|
||||
*/
|
||||
void WinBorder::UpdateColors(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateColors\n",_title->String());
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateColors\n",_title->String());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WinBorder::UpdateDecorator(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateDecorator\n",_title->String());
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateDecorator\n",_title->String());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WinBorder::UpdateFont(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateFont\n",_title->String());
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateFont\n",_title->String());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WinBorder::UpdateScreen(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateScreen\n",_title->String());
|
||||
#endif
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: UpdateScreen\n",_title->String());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -63,9 +63,7 @@ protected:
|
||||
BString *_title;
|
||||
Decorator *_decorator;
|
||||
int32 _flags;
|
||||
// !!! HERE we do have a problem... _frame is also defined in Layer.h
|
||||
// BRect _frame, _clientframe;
|
||||
BRect _clientframe;
|
||||
BRect _clientframe;
|
||||
int32 _mbuttons,_kmodifiers;
|
||||
BPoint _mousepos;
|
||||
bool _update;
|
||||
|
||||
Reference in New Issue
Block a user