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 "RectUtils.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#define USE_VIEW_FILL_HACK
|
#define USE_VIEW_FILL_HACK
|
||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
//#define DEBUG_DECORATOR
|
||||||
@ -355,7 +356,7 @@ printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
|
|||||||
topborder.OffsetBy(pt);
|
topborder.OffsetBy(pt);
|
||||||
bottomborder.OffsetBy(pt);
|
bottomborder.OffsetBy(pt);
|
||||||
|
|
||||||
Draw( _borderrect );
|
// Draw( _borderrect );
|
||||||
}
|
}
|
||||||
|
|
||||||
BRegion * DefaultDecorator::GetFootprint(void)
|
BRegion * DefaultDecorator::GetFootprint(void)
|
||||||
@ -372,6 +373,11 @@ printf("DefaultDecorator: Get Footprint\n");
|
|||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BRect DefaultDecorator::SlideTab(float dx, float dy=0){
|
||||||
|
//return Decorator::SlideTab(dx,dy);
|
||||||
|
return _tabrect;
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultDecorator::_DrawTitle(BRect r)
|
void DefaultDecorator::_DrawTitle(BRect r)
|
||||||
{
|
{
|
||||||
printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
|
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);
|
// _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh);
|
||||||
|
|
||||||
DrawFrame();
|
_DrawFrame(_borderrect);
|
||||||
|
|
||||||
DrawTab();
|
_DrawTab(_tabrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultDecorator::_DrawZoom(BRect r)
|
void DefaultDecorator::_DrawZoom(BRect r)
|
||||||
@ -602,7 +608,8 @@ void DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
// we must clip the lines drawn by this function to the invalid rectangle we are given
|
// we must clip the lines drawn by this function to the invalid rectangle we are given
|
||||||
|
|
||||||
#ifdef USE_VIEW_FILL_HACK
|
#ifdef USE_VIEW_FILL_HACK
|
||||||
_driver->FillRect(_frame,&_layerdata,pat_solidhigh);
|
_layerdata.highcolor = RGBColor( 255, 255, 255 );
|
||||||
|
_driver->FillRect(_frame,&_layerdata,pat_solidhigh);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!borderwidth){
|
if(!borderwidth){
|
||||||
|
@ -36,21 +36,22 @@ public:
|
|||||||
DefaultDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags);
|
DefaultDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags);
|
||||||
~DefaultDecorator(void);
|
~DefaultDecorator(void);
|
||||||
|
|
||||||
void MoveBy(float x, float y);
|
virtual void MoveBy(float x, float y);
|
||||||
void MoveBy(BPoint pt);
|
virtual void MoveBy(BPoint pt);
|
||||||
void Draw(BRect r);
|
virtual void Draw(BRect r);
|
||||||
void Draw(void);
|
virtual void Draw(void);
|
||||||
BRegion *GetFootprint(void);
|
virtual BRegion *GetFootprint(void);
|
||||||
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
|
virtual BRect SlideTab(float dx, float dy);
|
||||||
|
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
|
||||||
protected:
|
protected:
|
||||||
void _DrawClose(BRect r);
|
virtual void _DrawClose(BRect r);
|
||||||
void _DrawFrame(BRect r);
|
virtual void _DrawFrame(BRect r);
|
||||||
void _DrawTab(BRect r);
|
virtual void _DrawTab(BRect r);
|
||||||
void _DrawTitle(BRect r);
|
virtual void _DrawTitle(BRect r);
|
||||||
void _DrawZoom(BRect r);
|
virtual void _DrawZoom(BRect r);
|
||||||
void _DoLayout(void);
|
virtual void _DoLayout(void);
|
||||||
void _SetFocus(void);
|
virtual void _SetFocus(void);
|
||||||
void _SetColors(void);
|
virtual void _SetColors(void);
|
||||||
void DrawBlendedRect(BRect r, bool down);
|
void DrawBlendedRect(BRect r, bool down);
|
||||||
uint32 taboffset;
|
uint32 taboffset;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "PortLink.h"
|
#include "PortLink.h"
|
||||||
#include "TokenHandler.h"
|
#include "TokenHandler.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
#include "RootLayer.h"
|
||||||
|
|
||||||
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
|
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
|
||||||
TokenHandler view_token_handler;
|
TokenHandler view_token_handler;
|
||||||
@ -132,11 +133,19 @@ printf("Layer::AddChild lacks before support\n");
|
|||||||
layer->_parent=this;
|
layer->_parent=this;
|
||||||
if(layer->_visible && layer->_hidecount==0 && _visible)
|
if(layer->_visible && layer->_hidecount==0 && _visible)
|
||||||
{
|
{
|
||||||
// Technically, we could safely take the address of ConvertToParent(BRegion)
|
RootLayer *rl;
|
||||||
// but we don't just to avoid a compiler nag
|
rl = dynamic_cast<RootLayer*>(this);
|
||||||
BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible));
|
if ( rl ){
|
||||||
_visible->Exclude(reg);
|
// RootLayer enters here. It does not need to exclude WinBorder's
|
||||||
delete reg;
|
// 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
|
// we need to change this to a loop for each _lowersibling of the layer
|
||||||
@ -342,7 +351,7 @@ Layer *Layer::FindLayer(int32 token)
|
|||||||
All children of the layer also receive this call, so only 1 Invalidate call is
|
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.
|
needed to set a section as invalid on the screen.
|
||||||
*/
|
*/
|
||||||
void Layer::Invalidate(BRegion region)
|
void Layer::Invalidate(BRegion& region)
|
||||||
{
|
{
|
||||||
int32 i;
|
int32 i;
|
||||||
BRect r;
|
BRect r;
|
||||||
@ -379,6 +388,7 @@ void Layer::Invalidate(BRegion region)
|
|||||||
delete reg;
|
delete reg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -461,7 +471,8 @@ void Layer::RequestDraw(void)
|
|||||||
*/
|
*/
|
||||||
bool Layer::IsDirty(void) const
|
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)
|
void Layer::MoveBy(float x, float y)
|
||||||
{
|
{
|
||||||
BRect oldframe(_frame);
|
|
||||||
_frame.OffsetBy(x,y);
|
_frame.OffsetBy(x,y);
|
||||||
|
|
||||||
|
BRegion oldVisible( *_visible );
|
||||||
|
_visible->OffsetBy( x, y );
|
||||||
|
_full->OffsetBy( x, y );
|
||||||
|
|
||||||
if(_parent)
|
if(_parent)
|
||||||
{
|
{
|
||||||
BRegion *i=new BRegion(oldframe);
|
BRegion exclude(oldVisible);
|
||||||
if(TestRectIntersection(oldframe,_frame))
|
exclude.Exclude(_visible);
|
||||||
i->Exclude(_frame);
|
|
||||||
|
if(_parent->_invalid == NULL)
|
||||||
if(_parent->_invalid==NULL)
|
_parent->_invalid = new BRegion( exclude );
|
||||||
_parent->_invalid=i;
|
|
||||||
else
|
else
|
||||||
{
|
_parent->_invalid->Include( &exclude );
|
||||||
_parent->_invalid->Include(i);
|
|
||||||
delete i;
|
_parent->_is_dirty = true;
|
||||||
}
|
|
||||||
_parent->_is_dirty=true;
|
|
||||||
|
|
||||||
// if _uppersibling is non-NULL, we have other layers which we may have been
|
// 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
|
// covering up. If we did cover up some siblings, they need to be redrawn
|
||||||
for(Layer *sib=_uppersibling;sib!=NULL;sib=sib->_uppersibling)
|
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
|
// The boundaries intersect on screen, so invalidate the area that
|
||||||
// was hidden
|
// 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;
|
sib->_is_dirty=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
LayerData *GetLayerData(void) { return _layerdata; }
|
LayerData *GetLayerData(void) { return _layerdata; }
|
||||||
|
|
||||||
void Invalidate(BRect rect);
|
void Invalidate(BRect rect);
|
||||||
void Invalidate(BRegion region);
|
void Invalidate(BRegion& region);
|
||||||
void RebuildRegions(bool include_children=true);
|
void RebuildRegions(bool include_children=true);
|
||||||
virtual void RequestDraw(const BRect &r);
|
virtual void RequestDraw(const BRect &r);
|
||||||
virtual void RequestDraw(void);
|
virtual void RequestDraw(void);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "PatternHandler.h" // for pattern_union
|
#include "PatternHandler.h" // for pattern_union
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets up internal variables needed by the RootLayer
|
\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)
|
: Layer(rect,layername,B_FOLLOW_NONE,0, NULL)
|
||||||
{
|
{
|
||||||
_driver=gfxdriver;
|
_driver=gfxdriver;
|
||||||
_invalid=new BRegion(Bounds());
|
_invalid->MakeEmpty();
|
||||||
|
_invalid->Include(Bounds());
|
||||||
_is_dirty=true;
|
_is_dirty=true;
|
||||||
_bgcolor=new RGBColor();
|
_bgcolor=new RGBColor();
|
||||||
}
|
}
|
||||||
@ -76,6 +78,9 @@ void RootLayer::RequestDraw(void)
|
|||||||
// Redraw the base
|
// Redraw the base
|
||||||
if(_invalid)
|
if(_invalid)
|
||||||
{
|
{
|
||||||
|
printf("ROOTLAYER: ");
|
||||||
|
_invalid->PrintToStream();
|
||||||
|
printf("===========\n");
|
||||||
for(int32 i=0; _invalid->CountRects();i++)
|
for(int32 i=0; _invalid->CountRects();i++)
|
||||||
{
|
{
|
||||||
if(_invalid->RectAt(i).IsValid())
|
if(_invalid->RectAt(i).IsValid())
|
||||||
@ -92,7 +97,7 @@ void RootLayer::RequestDraw(void)
|
|||||||
for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
|
for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
|
||||||
{
|
{
|
||||||
if(lay->IsDirty())
|
if(lay->IsDirty())
|
||||||
lay->RequestDraw(lay->Bounds());
|
lay->RequestDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
_is_dirty=false;
|
_is_dirty=false;
|
||||||
|
@ -45,9 +45,9 @@ class RootLayer : public Layer
|
|||||||
public:
|
public:
|
||||||
RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver);
|
RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver);
|
||||||
~RootLayer();
|
~RootLayer();
|
||||||
void RequestDraw();
|
virtual void RequestDraw();
|
||||||
void RequestDraw(const BRect &r);
|
virtual void RequestDraw(const BRect &r);
|
||||||
void MoveBy(float x, float y);
|
virtual 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);
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#include "LayerData.h"
|
#include "LayerData.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
//#define DEBUG_SERVERAPP
|
#define DEBUG_SERVERAPP
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
|
@ -665,7 +665,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
|
|||||||
BRegion WindowClipRegion;
|
BRegion WindowClipRegion;
|
||||||
BRegion LayerClipRegion;
|
BRegion LayerClipRegion;
|
||||||
Layer *sibling;
|
Layer *sibling;
|
||||||
int32 numRects;
|
int32 numRects = 0;
|
||||||
|
|
||||||
if ( !msgsize || !msgbuffer )
|
if ( !msgsize || !msgbuffer )
|
||||||
return;
|
return;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
// TODO: Document this file completely
|
// TODO: Document this file completely
|
||||||
|
|
||||||
//#define DEBUG_WINBORDER
|
#define DEBUG_WINBORDER
|
||||||
//#define DEBUG_WINBORDER_MOUSE
|
//#define DEBUG_WINBORDER_MOUSE
|
||||||
#define DEBUG_WINBORDER_CLICK
|
#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
|
// rects - given by _decorator::GetBorderRect() - to be able to draw the borders
|
||||||
_frame = _decorator->GetBorderRect();
|
_frame = _decorator->GetBorderRect();
|
||||||
_visible->Set( _frame );
|
_visible->Set( _frame );
|
||||||
|
_visible->Include( _decorator->GetTabRect() );
|
||||||
_full->Set( _frame );
|
_full->Set( _frame );
|
||||||
|
_full->Include( _decorator->GetTabRect() );
|
||||||
_invalid->Set( _frame );
|
_invalid->Set( _frame );
|
||||||
|
_invalid->Include( _decorator->GetTabRect() );
|
||||||
|
|
||||||
_decorator->SetDriver(_driver);
|
_decorator->SetDriver(_driver);
|
||||||
_decorator->SetTitle(name);
|
_decorator->SetTitle(name);
|
||||||
@ -274,16 +277,17 @@ void WinBorder::MouseMoved(int8 *buffer)
|
|||||||
printf("ClickMove: Slide Tab\n");
|
printf("ClickMove: Slide Tab\n");
|
||||||
#endif
|
#endif
|
||||||
float dx=pt.x-_mousepos.x;
|
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
|
// SlideTab returns how much things were moved, and currently
|
||||||
// supports just the x direction, so get the value so
|
// supports just the x direction, so get the value so
|
||||||
// we can invalidate the proper area.
|
// we can invalidate the proper area.
|
||||||
lock_layers();
|
lock_layers();
|
||||||
_parent->Invalidate(_decorator->SlideTab(dx,0));
|
_parent->Invalidate(_decorator->SlideTab(dx,dy));
|
||||||
_parent->RequestDraw();
|
_parent->RequestDraw();
|
||||||
_decorator->DrawTab();
|
// _decorator->DrawTab();
|
||||||
unlock_layers();
|
unlock_layers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,18 +313,20 @@ printf("ClickMove: Drag\n");
|
|||||||
lock_layers();
|
lock_layers();
|
||||||
BRegion *reg=_decorator->GetFootprint();
|
BRegion *reg=_decorator->GetFootprint();
|
||||||
// TODO: we get an error here!!! - this method is untested
|
// 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());
|
//_driver->CopyRegion(reg,_win->_frame.LeftTop());
|
||||||
|
_parent->Invalidate(*reg);
|
||||||
_decorator->MoveBy(BPoint(dx, dy));
|
|
||||||
|
|
||||||
MoveBy(dx,dy);
|
|
||||||
|
|
||||||
|
_decorator->MoveBy(BPoint(dx, dy));
|
||||||
|
MoveBy(dx,dy);
|
||||||
|
|
||||||
// ADI: what do those do???
|
// ADI: what do those do???
|
||||||
BRegion reg2(oldmoveframe);
|
BRegion reg2(oldmoveframe);
|
||||||
reg->OffsetBy((int32)dx, (int32)dy);
|
reg->OffsetBy((int32)dx, (int32)dy);
|
||||||
reg2.Exclude(reg);
|
reg2.Exclude(reg);
|
||||||
|
|
||||||
_parent->RebuildRegions();
|
_parent->RebuildRegions();
|
||||||
|
printf("WinBorder: calling parent = %s::RequestDraw()\n", _parent->_name->String());
|
||||||
_parent->RequestDraw();
|
_parent->RequestDraw();
|
||||||
|
|
||||||
delete reg;
|
delete reg;
|
||||||
@ -433,17 +439,23 @@ void WinBorder::SetFocus(const bool &active)
|
|||||||
void WinBorder::RequestDraw(const BRect &r)
|
void WinBorder::RequestDraw(const BRect &r)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_WINBORDER
|
#ifdef DEBUG_WINBORDER
|
||||||
printf("WinBorder %s: RequestDraw\n",_title->String());
|
printf("WinBorder %s: RequestDraw(BRect)\n",_title->String());
|
||||||
|
PrintToStream();
|
||||||
#endif
|
#endif
|
||||||
_decorator->Draw(r);
|
_decorator->Draw(r);
|
||||||
|
delete _invalid;
|
||||||
|
_invalid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinBorder::RequestDraw(void)
|
void WinBorder::RequestDraw(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_WINBORDER
|
#ifdef DEBUG_WINBORDER
|
||||||
printf("WinBorder %s::RequestDraw\n",_title->String());
|
printf("WinBorder %s::RequestDraw()\n",_title->String());
|
||||||
|
PrintToStream();
|
||||||
#endif
|
#endif
|
||||||
_decorator->Draw();
|
_decorator->Draw();
|
||||||
|
delete _invalid;
|
||||||
|
_invalid = NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void WinBorder::MoveBy(BPoint pt)
|
void WinBorder::MoveBy(BPoint pt)
|
||||||
|
@ -40,9 +40,9 @@ class WinBorder : public Layer
|
|||||||
public:
|
public:
|
||||||
WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
||||||
const int32 flags, ServerWindow *win);
|
const int32 flags, ServerWindow *win);
|
||||||
~WinBorder(void);
|
virtual ~WinBorder(void);
|
||||||
void RequestDraw(void);
|
virtual void RequestDraw(void);
|
||||||
void RequestDraw(const BRect &r);
|
virtual void RequestDraw(const BRect &r);
|
||||||
// void MoveBy(BPoint pt);
|
// void MoveBy(BPoint pt);
|
||||||
// void MoveBy(float x, float y);
|
// void MoveBy(float x, float y);
|
||||||
// void ResizeBy(BPoint pt);
|
// void ResizeBy(BPoint pt);
|
||||||
|
Loading…
Reference in New Issue
Block a user