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:
parent
2724858b5b
commit
1afd64e8b1
Binary file not shown.
@ -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()
|
||||
|
@ -1,3 +1,7 @@
|
||||
|
||||
#ifndef __LAYER_H__
|
||||
#define __LAYER_H__
|
||||
|
||||
#include <OS.h>
|
||||
#include <Region.h>
|
||||
#include <Rect.h>
|
||||
@ -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
|
@ -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);
|
||||
}
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user