From 1afd64e8b14c72141e45931243c09f49ec9a9735 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Sat, 28 May 2005 08:51:09 +0000 Subject: [PATCH] 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 --- .../servers/app/newClipping/Clipping.proj | Bin 12050 -> 12308 bytes src/tests/servers/app/newClipping/Layer.cpp | 28 +++++++++++++++++- src/tests/servers/app/newClipping/Layer.h | 26 ++++++++++++---- src/tests/servers/app/newClipping/MyView.cpp | 16 +++++----- src/tests/servers/app/newClipping/main.cpp | 27 ++++++++++------- 5 files changed, 71 insertions(+), 26 deletions(-) diff --git a/src/tests/servers/app/newClipping/Clipping.proj b/src/tests/servers/app/newClipping/Clipping.proj index 97cd05f8f890ebf482aece372d2b66d6233105de..980b922c996e9c114116e3d5e7c2585003033e5a 100644 GIT binary patch delta 303 zcmbOfHzk3?*VDz7fx&=hBgYOlmK(NG4U-q}I&NlVKcd3OHu;pc33JU`)y<4Le2kK3 z85p<=7#J8>fS4JG85)4tX~yn%lQndEJ%Wqea)5jVAZB1-WMJ@1%uNNd1b~<)JTuQJ zzbGZONH2rIEi=auD7K7&K~@q-g8&nVXaHiT85^Df4O5%^TQ^_w63`})bs&Ilotm5y mL;`M)5RlIYw`X#?t{@?TxG$$q-&3T~M>hCs1p3=Gm6fHVjoD|7@ZoGQ7T Sfq|VJB8ei)3N~i7ekK6w1|P-% diff --git a/src/tests/servers/app/newClipping/Layer.cpp b/src/tests/servers/app/newClipping/Layer.cpp index cad4723332..ac7191b8d2 100644 --- a/src/tests/servers/app/newClipping/Layer.cpp +++ b/src/tests/servers/app/newClipping/Layer.cpp @@ -41,7 +41,7 @@ Layer::~Layer() } } -void Layer::ConvertToScreen2(BRect* rect) +void Layer::ConvertToScreen2(BRect* rect) const { MyView *view = GetRootLayer(); 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 { if (fView) @@ -422,6 +435,11 @@ void Layer::ScrollBy(float dx, float dy) ScrolledByHook(dx, dy); } +void Layer::GetWantedRegion(BRegion ®) +{ + set_user_regions(reg); +} + void Layer::set_user_regions(BRegion ®) { // 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 // what they could. 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() diff --git a/src/tests/servers/app/newClipping/Layer.h b/src/tests/servers/app/newClipping/Layer.h index 6c4b5c8235..9fa65b1ab6 100644 --- a/src/tests/servers/app/newClipping/Layer.h +++ b/src/tests/servers/app/newClipping/Layer.h @@ -1,3 +1,7 @@ + +#ifndef __LAYER_H__ +#define __LAYER_H__ + #include #include #include @@ -22,6 +26,9 @@ public: void Hide(); void Show(); + void Invalidate( const BRegion &invalid, + const Layer *startFrom = NULL); + virtual void MovedByHook(float dx, float dy) { } virtual void ResizedByHook(float dx, float dy, bool automatic) { } virtual void ScrolledByHook(float dx, float dy) { } @@ -31,16 +38,16 @@ public: Layer* VirtualUpperSibling() const; Layer* VirtualLowerSibling() const; - void Invalidate( const BRegion &invalid, - const Layer *startFrom = NULL); void RebuildVisibleRegions( const BRegion &invalid, const Layer *startFrom); - void ConvertToScreen2(BRect* rect); + void ConvertToScreen2(BRect* rect) const; + void ConvertToScreen2(BRegion* reg) const; MyView* GetRootLayer() const; void SetRootLayer(MyView* view) { fView = view; } BRegion* Visible() { return &fVisible; } BRegion* FullVisible() { return &fFullVisible; } + void GetWantedRegion(BRegion ®); BRect Frame() const { return fFrame; } BRect Bounds() const { BRect r(fFrame); @@ -49,14 +56,20 @@ public: const char* Name() const { return fName; } Layer* Parent() const { return fParent; } void PrintToStream() const; + bool IsTopLayer() const { return fView? true: false; } rgb_color HighColor() const { return fColor; } void rebuild_visible_regions(const BRegion &invalid, const BRegion &parentLocalVisible, const Layer *startFrom); +protected: + rgb_color fColor; + private: - void set_user_regions(BRegion ®); + virtual void operate_on_visible(BRegion ®ion); + virtual void set_user_regions(BRegion ®); + void clear_visible_regions(); void resize_layer_frame_by(float x, float y); void resize_redraw_more_regions(BRegion &redraw); @@ -68,7 +81,6 @@ private: BRect fFrame; BPoint fOrigin; uint32 fResizeMode; - rgb_color fColor; Layer* fBottom; Layer* fUpper; @@ -79,5 +91,7 @@ private: uint32 fFlags; bool fHidden; - MyView* fView; + MyView* fView; }; + +#endif \ No newline at end of file diff --git a/src/tests/servers/app/newClipping/MyView.cpp b/src/tests/servers/app/newClipping/MyView.cpp index b7699f2a7a..ecaf58c43a 100644 --- a/src/tests/servers/app/newClipping/MyView.cpp +++ b/src/tests/servers/app/newClipping/MyView.cpp @@ -50,13 +50,11 @@ Layer* MyView::FindLayer(Layer *lay, const char *bytes) const void MyView::CopyRegion(BRegion *reg, float dx, float dy) { + // Yes... in this sandbox app, do a redraw. wind->Lock(); -// ConstrainClippingRegion(&r); -// CopyBits(Bounds(), Bounds().OffsetByCopy(dx, dy)); - // TODO: properly do that! - // LAME, I know! - CopyBits(reg->Frame(), reg->Frame().OffsetByCopy(dx, dy)); -// ConstrainClippingRegion(NULL); + ConstrainClippingRegion(reg); + DrawSubTree(topLayer); + Flush(); wind->Unlock(); } @@ -93,9 +91,9 @@ void MyView::DrawSubTree(Layer* lay) } ConstrainClippingRegion(lay->Visible()); SetHighColor(lay->HighColor()); - BRect temp = lay->Bounds(); - lay->ConvertToScreen2(&temp); - FillRect(temp); + BRegion reg; + lay->GetWantedRegion(reg); + FillRect(reg.Frame()); Flush(); ConstrainClippingRegion(NULL); } \ No newline at end of file diff --git a/src/tests/servers/app/newClipping/main.cpp b/src/tests/servers/app/newClipping/main.cpp index bf94b9c268..31e7d4a675 100644 --- a/src/tests/servers/app/newClipping/main.cpp +++ b/src/tests/servers/app/newClipping/main.cpp @@ -10,6 +10,7 @@ #include "MyView.h" #include "Layer.h" +#include "WinBorder.h" #define ApplicationSignature "application/x-vnd.generic-SkeletonApplication" @@ -80,17 +81,23 @@ bool clsMainWindow::QuitRequested() void clsMainWindow::test1() { Layer *topLayer = fView->topLayer; -// Layer *parent; rgb_color c; - BRect temp; c.red = rand()/256; c.green = rand()/256; c.blue = rand()/256; - Layer *lay1 = new Layer(BRect(20,20,300,220), "lay1", B_FOLLOW_NONE, 0, c); - topLayer->AddLayer(lay1); - +// Layer *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.green = rand()/256; c.blue = rand()/256; @@ -107,9 +114,9 @@ void clsMainWindow::test1() 0, c); lay2->AddLayer(lay3); - temp = lay1->Bounds(); - lay1->ConvertToScreen2(&temp); - topLayer->RebuildVisibleRegions(BRegion(temp), lay1); + BRegion temp; + wb1->GetWantedRegion(temp); + topLayer->RebuildVisibleRegions(temp, wb1); wind->Lock(); fView->Invalidate(); @@ -128,7 +135,7 @@ void clsMainWindow::test1() lay2->ResizeBy(-45, -55); -/* + snooze(2000000); lay1->ScrollBy(0,50); @@ -144,7 +151,7 @@ void clsMainWindow::test1() snooze(2000000); lay1->Invalidate(BRect(0,0,500,500)); -*/ + } int main()