Added some support for WinBorders. support B_DOCUMENT_WINDOW_LOOK remains to implemented as the border in this case overlaps the white view area with the resize box
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12860 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Binary file not shown.
@@ -41,7 +41,7 @@ Layer::~Layer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::ConvertToScreen2(BRect* rect)
|
void Layer::ConvertToScreen2(BRect* rect) const
|
||||||
{
|
{
|
||||||
MyView *view = GetRootLayer();
|
MyView *view = GetRootLayer();
|
||||||
if (view)
|
if (view)
|
||||||
@@ -54,6 +54,19 @@ void Layer::ConvertToScreen2(BRect* rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer::ConvertToScreen2(BRegion* reg) const
|
||||||
|
{
|
||||||
|
MyView *view = GetRootLayer();
|
||||||
|
if (view)
|
||||||
|
if (fParent)
|
||||||
|
{
|
||||||
|
reg->OffsetBy(-fOrigin.x, -fOrigin.y);
|
||||||
|
reg->OffsetBy(fFrame.left, fFrame.top);
|
||||||
|
|
||||||
|
fParent->ConvertToScreen2(reg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MyView* Layer::GetRootLayer() const
|
MyView* Layer::GetRootLayer() const
|
||||||
{
|
{
|
||||||
if (fView)
|
if (fView)
|
||||||
@@ -422,6 +435,11 @@ void Layer::ScrollBy(float dx, float dy)
|
|||||||
ScrolledByHook(dx, dy);
|
ScrolledByHook(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer::GetWantedRegion(BRegion ®)
|
||||||
|
{
|
||||||
|
set_user_regions(reg);
|
||||||
|
}
|
||||||
|
|
||||||
void Layer::set_user_regions(BRegion ®)
|
void Layer::set_user_regions(BRegion ®)
|
||||||
{
|
{
|
||||||
// OPT: maybe we should have all these cached in a 'fFull' member
|
// OPT: maybe we should have all these cached in a 'fFull' member
|
||||||
@@ -525,6 +543,14 @@ void Layer::rebuild_visible_regions(const BRegion &invalid,
|
|||||||
// the visible region of this layer is what left after all its children took
|
// the visible region of this layer is what left after all its children took
|
||||||
// what they could.
|
// what they could.
|
||||||
fVisible.Include(&common);
|
fVisible.Include(&common);
|
||||||
|
|
||||||
|
// we don't need this ATM
|
||||||
|
//operate_on_visible(fVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::operate_on_visible(BRegion ®)
|
||||||
|
{
|
||||||
|
// Empty Hook function
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::clear_visible_regions()
|
void Layer::clear_visible_regions()
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef __LAYER_H__
|
||||||
|
#define __LAYER_H__
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
@@ -22,6 +26,9 @@ public:
|
|||||||
void Hide();
|
void Hide();
|
||||||
void Show();
|
void Show();
|
||||||
|
|
||||||
|
void Invalidate( const BRegion &invalid,
|
||||||
|
const Layer *startFrom = NULL);
|
||||||
|
|
||||||
virtual void MovedByHook(float dx, float dy) { }
|
virtual void MovedByHook(float dx, float dy) { }
|
||||||
virtual void ResizedByHook(float dx, float dy, bool automatic) { }
|
virtual void ResizedByHook(float dx, float dy, bool automatic) { }
|
||||||
virtual void ScrolledByHook(float dx, float dy) { }
|
virtual void ScrolledByHook(float dx, float dy) { }
|
||||||
@@ -31,16 +38,16 @@ public:
|
|||||||
Layer* VirtualUpperSibling() const;
|
Layer* VirtualUpperSibling() const;
|
||||||
Layer* VirtualLowerSibling() const;
|
Layer* VirtualLowerSibling() const;
|
||||||
|
|
||||||
void Invalidate( const BRegion &invalid,
|
|
||||||
const Layer *startFrom = NULL);
|
|
||||||
void RebuildVisibleRegions( const BRegion &invalid,
|
void RebuildVisibleRegions( const BRegion &invalid,
|
||||||
const Layer *startFrom);
|
const Layer *startFrom);
|
||||||
void ConvertToScreen2(BRect* rect);
|
void ConvertToScreen2(BRect* rect) const;
|
||||||
|
void ConvertToScreen2(BRegion* reg) const;
|
||||||
MyView* GetRootLayer() const;
|
MyView* GetRootLayer() const;
|
||||||
void SetRootLayer(MyView* view) { fView = view; }
|
void SetRootLayer(MyView* view) { fView = view; }
|
||||||
|
|
||||||
BRegion* Visible() { return &fVisible; }
|
BRegion* Visible() { return &fVisible; }
|
||||||
BRegion* FullVisible() { return &fFullVisible; }
|
BRegion* FullVisible() { return &fFullVisible; }
|
||||||
|
void GetWantedRegion(BRegion ®);
|
||||||
|
|
||||||
BRect Frame() const { return fFrame; }
|
BRect Frame() const { return fFrame; }
|
||||||
BRect Bounds() const { BRect r(fFrame);
|
BRect Bounds() const { BRect r(fFrame);
|
||||||
@@ -49,14 +56,20 @@ public:
|
|||||||
const char* Name() const { return fName; }
|
const char* Name() const { return fName; }
|
||||||
Layer* Parent() const { return fParent; }
|
Layer* Parent() const { return fParent; }
|
||||||
void PrintToStream() const;
|
void PrintToStream() const;
|
||||||
|
bool IsTopLayer() const { return fView? true: false; }
|
||||||
|
|
||||||
rgb_color HighColor() const { return fColor; }
|
rgb_color HighColor() const { return fColor; }
|
||||||
|
|
||||||
void rebuild_visible_regions(const BRegion &invalid,
|
void rebuild_visible_regions(const BRegion &invalid,
|
||||||
const BRegion &parentLocalVisible,
|
const BRegion &parentLocalVisible,
|
||||||
const Layer *startFrom);
|
const Layer *startFrom);
|
||||||
|
protected:
|
||||||
|
rgb_color fColor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_user_regions(BRegion ®);
|
virtual void operate_on_visible(BRegion ®ion);
|
||||||
|
virtual void set_user_regions(BRegion ®);
|
||||||
|
|
||||||
void clear_visible_regions();
|
void clear_visible_regions();
|
||||||
void resize_layer_frame_by(float x, float y);
|
void resize_layer_frame_by(float x, float y);
|
||||||
void resize_redraw_more_regions(BRegion &redraw);
|
void resize_redraw_more_regions(BRegion &redraw);
|
||||||
@@ -68,7 +81,6 @@ private:
|
|||||||
BRect fFrame;
|
BRect fFrame;
|
||||||
BPoint fOrigin;
|
BPoint fOrigin;
|
||||||
uint32 fResizeMode;
|
uint32 fResizeMode;
|
||||||
rgb_color fColor;
|
|
||||||
|
|
||||||
Layer* fBottom;
|
Layer* fBottom;
|
||||||
Layer* fUpper;
|
Layer* fUpper;
|
||||||
@@ -81,3 +93,5 @@ private:
|
|||||||
|
|
||||||
MyView* fView;
|
MyView* fView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -50,13 +50,11 @@ Layer* MyView::FindLayer(Layer *lay, const char *bytes) const
|
|||||||
|
|
||||||
void MyView::CopyRegion(BRegion *reg, float dx, float dy)
|
void MyView::CopyRegion(BRegion *reg, float dx, float dy)
|
||||||
{
|
{
|
||||||
|
// Yes... in this sandbox app, do a redraw.
|
||||||
wind->Lock();
|
wind->Lock();
|
||||||
// ConstrainClippingRegion(&r);
|
ConstrainClippingRegion(reg);
|
||||||
// CopyBits(Bounds(), Bounds().OffsetByCopy(dx, dy));
|
DrawSubTree(topLayer);
|
||||||
// TODO: properly do that!
|
Flush();
|
||||||
// LAME, I know!
|
|
||||||
CopyBits(reg->Frame(), reg->Frame().OffsetByCopy(dx, dy));
|
|
||||||
// ConstrainClippingRegion(NULL);
|
|
||||||
wind->Unlock();
|
wind->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +91,9 @@ void MyView::DrawSubTree(Layer* lay)
|
|||||||
}
|
}
|
||||||
ConstrainClippingRegion(lay->Visible());
|
ConstrainClippingRegion(lay->Visible());
|
||||||
SetHighColor(lay->HighColor());
|
SetHighColor(lay->HighColor());
|
||||||
BRect temp = lay->Bounds();
|
BRegion reg;
|
||||||
lay->ConvertToScreen2(&temp);
|
lay->GetWantedRegion(reg);
|
||||||
FillRect(temp);
|
FillRect(reg.Frame());
|
||||||
Flush();
|
Flush();
|
||||||
ConstrainClippingRegion(NULL);
|
ConstrainClippingRegion(NULL);
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "MyView.h"
|
#include "MyView.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
|
#include "WinBorder.h"
|
||||||
|
|
||||||
#define ApplicationSignature "application/x-vnd.generic-SkeletonApplication"
|
#define ApplicationSignature "application/x-vnd.generic-SkeletonApplication"
|
||||||
|
|
||||||
@@ -80,17 +81,23 @@ bool clsMainWindow::QuitRequested()
|
|||||||
void clsMainWindow::test1()
|
void clsMainWindow::test1()
|
||||||
{
|
{
|
||||||
Layer *topLayer = fView->topLayer;
|
Layer *topLayer = fView->topLayer;
|
||||||
// Layer *parent;
|
|
||||||
|
|
||||||
rgb_color c;
|
rgb_color c;
|
||||||
BRect temp;
|
|
||||||
|
|
||||||
c.red = rand()/256;
|
c.red = rand()/256;
|
||||||
c.green = rand()/256;
|
c.green = rand()/256;
|
||||||
c.blue = rand()/256;
|
c.blue = rand()/256;
|
||||||
Layer *lay1 = new Layer(BRect(20,20,300,220), "lay1", B_FOLLOW_NONE, 0, c);
|
// Layer *lay1
|
||||||
topLayer->AddLayer(lay1);
|
// = new Layer(BRect(20,20,300,220), "lay1", B_FOLLOW_NONE, 0, c);
|
||||||
|
// = new WinBorder(BRect(20,20,300,220), "lay1", B_FOLLOW_NONE, 0, c);
|
||||||
|
// topLayer->AddLayer(lay1);
|
||||||
|
// ------
|
||||||
|
WinBorder *wb1 = new WinBorder(BRect(20,20,300,220), "wb1", B_FOLLOW_NONE, 0, c);
|
||||||
|
topLayer->AddLayer(wb1);
|
||||||
|
Layer *lay1
|
||||||
|
= new Layer(BRect(0,0,280,200), "lay1", B_FOLLOW_NONE, 0, c);
|
||||||
|
wb1->AddLayer(lay1);
|
||||||
|
// ------
|
||||||
c.red = rand()/256;
|
c.red = rand()/256;
|
||||||
c.green = rand()/256;
|
c.green = rand()/256;
|
||||||
c.blue = rand()/256;
|
c.blue = rand()/256;
|
||||||
@@ -107,9 +114,9 @@ void clsMainWindow::test1()
|
|||||||
0, c);
|
0, c);
|
||||||
lay2->AddLayer(lay3);
|
lay2->AddLayer(lay3);
|
||||||
|
|
||||||
temp = lay1->Bounds();
|
BRegion temp;
|
||||||
lay1->ConvertToScreen2(&temp);
|
wb1->GetWantedRegion(temp);
|
||||||
topLayer->RebuildVisibleRegions(BRegion(temp), lay1);
|
topLayer->RebuildVisibleRegions(temp, wb1);
|
||||||
|
|
||||||
wind->Lock();
|
wind->Lock();
|
||||||
fView->Invalidate();
|
fView->Invalidate();
|
||||||
@@ -128,7 +135,7 @@ void clsMainWindow::test1()
|
|||||||
|
|
||||||
lay2->ResizeBy(-45, -55);
|
lay2->ResizeBy(-45, -55);
|
||||||
|
|
||||||
/*
|
|
||||||
snooze(2000000);
|
snooze(2000000);
|
||||||
|
|
||||||
lay1->ScrollBy(0,50);
|
lay1->ScrollBy(0,50);
|
||||||
@@ -144,7 +151,7 @@ void clsMainWindow::test1()
|
|||||||
snooze(2000000);
|
snooze(2000000);
|
||||||
|
|
||||||
lay1->Invalidate(BRect(0,0,500,500));
|
lay1->Invalidate(BRect(0,0,500,500));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
Reference in New Issue
Block a user