Now, a window properly displays and moves across screen. Yupyyy! That was possible before... but now the new window is drawn arround the rect passed by BWindow. I also made some changes in update mechanim of Winborder/Layer/RootLayer.
also made some methods virtual 'cause I think DW forgot about that! It's normal, app_server is SOOOO big! :-) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4489 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
072a83e4b9
commit
67f4247f6c
@ -35,6 +35,7 @@
|
||||
#include "RectUtils.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define USE_VIEW_FILL_HACK
|
||||
|
||||
//#define DEBUG_DECORATOR
|
||||
@ -355,7 +356,7 @@ printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
|
||||
topborder.OffsetBy(pt);
|
||||
bottomborder.OffsetBy(pt);
|
||||
|
||||
Draw( _borderrect );
|
||||
// Draw( _borderrect );
|
||||
}
|
||||
|
||||
BRegion * DefaultDecorator::GetFootprint(void)
|
||||
@ -372,6 +373,11 @@ printf("DefaultDecorator: Get Footprint\n");
|
||||
return reg;
|
||||
}
|
||||
|
||||
BRect DefaultDecorator::SlideTab(float dx, float dy=0){
|
||||
//return Decorator::SlideTab(dx,dy);
|
||||
return _tabrect;
|
||||
}
|
||||
|
||||
void DefaultDecorator::_DrawTitle(BRect r)
|
||||
{
|
||||
printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
||||
@ -446,9 +452,9 @@ void DefaultDecorator::Draw(void)
|
||||
|
||||
// _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh);
|
||||
|
||||
DrawFrame();
|
||||
_DrawFrame(_borderrect);
|
||||
|
||||
DrawTab();
|
||||
_DrawTab(_tabrect);
|
||||
}
|
||||
|
||||
void DefaultDecorator::_DrawZoom(BRect r)
|
||||
@ -602,6 +608,7 @@ void DefaultDecorator::_DrawFrame(BRect invalid)
|
||||
// we must clip the lines drawn by this function to the invalid rectangle we are given
|
||||
|
||||
#ifdef USE_VIEW_FILL_HACK
|
||||
_layerdata.highcolor = RGBColor( 255, 255, 255 );
|
||||
_driver->FillRect(_frame,&_layerdata,pat_solidhigh);
|
||||
#endif
|
||||
|
||||
|
@ -36,21 +36,22 @@ public:
|
||||
DefaultDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags);
|
||||
~DefaultDecorator(void);
|
||||
|
||||
void MoveBy(float x, float y);
|
||||
void MoveBy(BPoint pt);
|
||||
void Draw(BRect r);
|
||||
void Draw(void);
|
||||
BRegion *GetFootprint(void);
|
||||
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void MoveBy(BPoint pt);
|
||||
virtual void Draw(BRect r);
|
||||
virtual void Draw(void);
|
||||
virtual BRegion *GetFootprint(void);
|
||||
virtual BRect SlideTab(float dx, float dy);
|
||||
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
|
||||
protected:
|
||||
void _DrawClose(BRect r);
|
||||
void _DrawFrame(BRect r);
|
||||
void _DrawTab(BRect r);
|
||||
void _DrawTitle(BRect r);
|
||||
void _DrawZoom(BRect r);
|
||||
void _DoLayout(void);
|
||||
void _SetFocus(void);
|
||||
void _SetColors(void);
|
||||
virtual void _DrawClose(BRect r);
|
||||
virtual void _DrawFrame(BRect r);
|
||||
virtual void _DrawTab(BRect r);
|
||||
virtual void _DrawTitle(BRect r);
|
||||
virtual void _DrawZoom(BRect r);
|
||||
virtual void _DoLayout(void);
|
||||
virtual void _SetFocus(void);
|
||||
virtual void _SetColors(void);
|
||||
void DrawBlendedRect(BRect r, bool down);
|
||||
uint32 taboffset;
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "PortLink.h"
|
||||
#include "TokenHandler.h"
|
||||
#include "RectUtils.h"
|
||||
#include "RootLayer.h"
|
||||
|
||||
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
|
||||
TokenHandler view_token_handler;
|
||||
@ -132,12 +133,20 @@ printf("Layer::AddChild lacks before support\n");
|
||||
layer->_parent=this;
|
||||
if(layer->_visible && layer->_hidecount==0 && _visible)
|
||||
{
|
||||
RootLayer *rl;
|
||||
rl = dynamic_cast<RootLayer*>(this);
|
||||
if ( rl ){
|
||||
// RootLayer enters here. It does not need to exclude WinBorder's
|
||||
// visible area!
|
||||
}
|
||||
else{
|
||||
// Technically, we could safely take the address of ConvertToParent(BRegion)
|
||||
// but we don't just to avoid a compiler nag
|
||||
BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible));
|
||||
_visible->Exclude(reg);
|
||||
delete reg;
|
||||
}
|
||||
}
|
||||
|
||||
// we need to change this to a loop for each _lowersibling of the layer
|
||||
if(_bottomchild)
|
||||
@ -342,7 +351,7 @@ Layer *Layer::FindLayer(int32 token)
|
||||
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(BRegion region)
|
||||
void Layer::Invalidate(BRegion& region)
|
||||
{
|
||||
int32 i;
|
||||
BRect r;
|
||||
@ -379,6 +388,7 @@ void Layer::Invalidate(BRegion region)
|
||||
delete reg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -461,7 +471,8 @@ void Layer::RequestDraw(void)
|
||||
*/
|
||||
bool Layer::IsDirty(void) const
|
||||
{
|
||||
return (!_invalid)?true:false;
|
||||
//return (!_invalid)?true:false;
|
||||
return _is_dirty;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -614,33 +625,40 @@ uint32 Layer::CountChildren(void)
|
||||
*/
|
||||
void Layer::MoveBy(float x, float y)
|
||||
{
|
||||
BRect oldframe(_frame);
|
||||
_frame.OffsetBy(x,y);
|
||||
|
||||
BRegion oldVisible( *_visible );
|
||||
_visible->OffsetBy( x, y );
|
||||
_full->OffsetBy( x, y );
|
||||
|
||||
if(_parent)
|
||||
{
|
||||
BRegion *i=new BRegion(oldframe);
|
||||
if(TestRectIntersection(oldframe,_frame))
|
||||
i->Exclude(_frame);
|
||||
BRegion exclude(oldVisible);
|
||||
exclude.Exclude(_visible);
|
||||
|
||||
if(_parent->_invalid==NULL)
|
||||
_parent->_invalid=i;
|
||||
if(_parent->_invalid == NULL)
|
||||
_parent->_invalid = new BRegion( exclude );
|
||||
else
|
||||
{
|
||||
_parent->_invalid->Include(i);
|
||||
delete i;
|
||||
}
|
||||
_parent->_is_dirty=true;
|
||||
_parent->_invalid->Include( &exclude );
|
||||
|
||||
_parent->_is_dirty = true;
|
||||
|
||||
// if _uppersibling is non-NULL, we have other layers which we may have been
|
||||
// covering up. If we did cover up some siblings, they need to be redrawn
|
||||
for(Layer *sib=_uppersibling;sib!=NULL;sib=sib->_uppersibling)
|
||||
{
|
||||
if(TestRectIntersection(oldframe,sib->_frame))
|
||||
BRegion exclude2(oldVisible);
|
||||
exclude2.Exclude(sib->_visible);
|
||||
|
||||
if( exclude2.CountRects() != 0 )
|
||||
{
|
||||
// The boundaries intersect on screen, so invalidate the area that
|
||||
// was hidden
|
||||
sib->Invalidate(oldframe & sib->_frame);
|
||||
// a new region, becase we do not want to modify 'oldVisible'
|
||||
BRegion exclude3(oldVisible);
|
||||
exclude3.IntersectWith(sib->_visible);
|
||||
|
||||
sib->Invalidate( exclude3 );
|
||||
sib->_is_dirty=true;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
LayerData *GetLayerData(void) { return _layerdata; }
|
||||
|
||||
void Invalidate(BRect rect);
|
||||
void Invalidate(BRegion region);
|
||||
void Invalidate(BRegion& region);
|
||||
void RebuildRegions(bool include_children=true);
|
||||
virtual void RequestDraw(const BRect &r);
|
||||
virtual void RequestDraw(void);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "PatternHandler.h" // for pattern_union
|
||||
#include "ServerConfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*!
|
||||
\brief Sets up internal variables needed by the RootLayer
|
||||
@ -44,7 +45,8 @@ RootLayer::RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver
|
||||
: Layer(rect,layername,B_FOLLOW_NONE,0, NULL)
|
||||
{
|
||||
_driver=gfxdriver;
|
||||
_invalid=new BRegion(Bounds());
|
||||
_invalid->MakeEmpty();
|
||||
_invalid->Include(Bounds());
|
||||
_is_dirty=true;
|
||||
_bgcolor=new RGBColor();
|
||||
}
|
||||
@ -76,6 +78,9 @@ void RootLayer::RequestDraw(void)
|
||||
// Redraw the base
|
||||
if(_invalid)
|
||||
{
|
||||
printf("ROOTLAYER: ");
|
||||
_invalid->PrintToStream();
|
||||
printf("===========\n");
|
||||
for(int32 i=0; _invalid->CountRects();i++)
|
||||
{
|
||||
if(_invalid->RectAt(i).IsValid())
|
||||
@ -92,7 +97,7 @@ void RootLayer::RequestDraw(void)
|
||||
for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
|
||||
{
|
||||
if(lay->IsDirty())
|
||||
lay->RequestDraw(lay->Bounds());
|
||||
lay->RequestDraw();
|
||||
}
|
||||
|
||||
_is_dirty=false;
|
||||
|
@ -45,9 +45,9 @@ class RootLayer : public Layer
|
||||
public:
|
||||
RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver);
|
||||
~RootLayer();
|
||||
void RequestDraw();
|
||||
void RequestDraw(const BRect &r);
|
||||
void MoveBy(float x, float y);
|
||||
virtual void RequestDraw();
|
||||
virtual void RequestDraw(const BRect &r);
|
||||
virtual void MoveBy(float x, float y);
|
||||
void MoveBy(BPoint pt);
|
||||
void ResizeBy(float x, float y);
|
||||
void ResizeBy(BPoint pt);
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include "LayerData.h"
|
||||
#include "Utils.h"
|
||||
|
||||
//#define DEBUG_SERVERAPP
|
||||
#define DEBUG_SERVERAPP
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
|
@ -665,7 +665,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
|
||||
BRegion WindowClipRegion;
|
||||
BRegion LayerClipRegion;
|
||||
Layer *sibling;
|
||||
int32 numRects;
|
||||
int32 numRects = 0;
|
||||
|
||||
if ( !msgsize || !msgbuffer )
|
||||
return;
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
// TODO: Document this file completely
|
||||
|
||||
//#define DEBUG_WINBORDER
|
||||
#define DEBUG_WINBORDER
|
||||
//#define DEBUG_WINBORDER_MOUSE
|
||||
#define DEBUG_WINBORDER_CLICK
|
||||
|
||||
@ -97,8 +97,11 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
// 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() );
|
||||
|
||||
_decorator->SetDriver(_driver);
|
||||
_decorator->SetTitle(name);
|
||||
@ -274,16 +277,17 @@ void WinBorder::MouseMoved(int8 *buffer)
|
||||
printf("ClickMove: Slide Tab\n");
|
||||
#endif
|
||||
float dx=pt.x-_mousepos.x;
|
||||
float dy=pt.y-_mousepos.y;
|
||||
|
||||
if(dx!=0)
|
||||
if(dx != 0 || dy != 0)
|
||||
{
|
||||
// SlideTab returns how much things were moved, and currently
|
||||
// supports just the x direction, so get the value so
|
||||
// we can invalidate the proper area.
|
||||
lock_layers();
|
||||
_parent->Invalidate(_decorator->SlideTab(dx,0));
|
||||
_parent->Invalidate(_decorator->SlideTab(dx,dy));
|
||||
_parent->RequestDraw();
|
||||
_decorator->DrawTab();
|
||||
// _decorator->DrawTab();
|
||||
unlock_layers();
|
||||
}
|
||||
}
|
||||
@ -309,10 +313,11 @@ printf("ClickMove: Drag\n");
|
||||
lock_layers();
|
||||
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());
|
||||
_parent->Invalidate(*reg);
|
||||
|
||||
_decorator->MoveBy(BPoint(dx, dy));
|
||||
|
||||
MoveBy(dx,dy);
|
||||
|
||||
// ADI: what do those do???
|
||||
@ -321,6 +326,7 @@ printf("ClickMove: Drag\n");
|
||||
reg2.Exclude(reg);
|
||||
|
||||
_parent->RebuildRegions();
|
||||
printf("WinBorder: calling parent = %s::RequestDraw()\n", _parent->_name->String());
|
||||
_parent->RequestDraw();
|
||||
|
||||
delete reg;
|
||||
@ -433,17 +439,23 @@ void WinBorder::SetFocus(const bool &active)
|
||||
void WinBorder::RequestDraw(const BRect &r)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s: RequestDraw\n",_title->String());
|
||||
printf("WinBorder %s: RequestDraw(BRect)\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
_decorator->Draw(r);
|
||||
delete _invalid;
|
||||
_invalid = NULL;
|
||||
}
|
||||
|
||||
void WinBorder::RequestDraw(void)
|
||||
{
|
||||
#ifdef DEBUG_WINBORDER
|
||||
printf("WinBorder %s::RequestDraw\n",_title->String());
|
||||
printf("WinBorder %s::RequestDraw()\n",_title->String());
|
||||
PrintToStream();
|
||||
#endif
|
||||
_decorator->Draw();
|
||||
delete _invalid;
|
||||
_invalid = NULL;
|
||||
}
|
||||
/*
|
||||
void WinBorder::MoveBy(BPoint pt)
|
||||
|
@ -40,9 +40,9 @@ class WinBorder : public Layer
|
||||
public:
|
||||
WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
||||
const int32 flags, ServerWindow *win);
|
||||
~WinBorder(void);
|
||||
void RequestDraw(void);
|
||||
void RequestDraw(const BRect &r);
|
||||
virtual ~WinBorder(void);
|
||||
virtual void RequestDraw(void);
|
||||
virtual void RequestDraw(const BRect &r);
|
||||
// void MoveBy(BPoint pt);
|
||||
// void MoveBy(float x, float y);
|
||||
// void ResizeBy(BPoint pt);
|
||||
|
Loading…
Reference in New Issue
Block a user