- moving and resizing is new performed only with the primary mouse button
- by holding the secondary mouse button pressed one can draw random lines so you can see what regions are invalidated durring a move, resize or scroll operation - clicking the third mouse button issues a redraw, WITHOUT a region rebuild action (this is to force a redraw because the window does not redraw itself, I've been lazy :-) - playing with the mouse wheel results in the layer under mouse cursor being scrolled on the y-axis. - fixed redraw and copyRegion of this sandbox app. They work correctly now. - TODO: fix a clipping bug which appears when moving a layer arround. --This line, and those below, will be ignored-- M newClipping/MyView.cpp M newClipping/main.cpp M newClipping/MyView.h M newClipping/Layer.cpp M newClipping/Clipping.proj git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12895 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
38b2e6ccbe
commit
a332730df7
Binary file not shown.
@ -355,11 +355,14 @@ void Layer::ResizeBy(float dx, float dy)
|
|||||||
|
|
||||||
void Layer::MoveBy(float dx, float dy)
|
void Layer::MoveBy(float dx, float dy)
|
||||||
{
|
{
|
||||||
fFrame.Set(fFrame.left+dx, fFrame.top+dy, fFrame.right+dx, fFrame.bottom+dy);
|
if (dx == 0.0f && dy == 0.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// fFrame.Set(fFrame.left+dx, fFrame.top+dy, fFrame.right+dx, fFrame.bottom+dy);
|
||||||
|
fFrame.OffsetBy(dx, dy);
|
||||||
|
|
||||||
// call hook function
|
// call hook function
|
||||||
if (dx != 0.0f || dy != 0.0f)
|
MovedByHook(dx, dy);
|
||||||
MovedByHook(dx, dy);
|
|
||||||
|
|
||||||
if (!IsVisuallyHidden() && GetRootLayer())
|
if (!IsVisuallyHidden() && GetRootLayer())
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ MyView::MyView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
|
|||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
fTracking = false;
|
fTracking = false;
|
||||||
fIsResize = false;
|
fIsResize = false;
|
||||||
|
fIs2ndButton= false;
|
||||||
fMovingLayer = NULL;
|
fMovingLayer = NULL;
|
||||||
|
|
||||||
rgb_color col;
|
rgb_color col;
|
||||||
@ -49,27 +50,41 @@ Layer* MyView::FindLayer(Layer *lay, BPoint &where) const
|
|||||||
|
|
||||||
void MyView::MouseDown(BPoint where)
|
void MyView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
fTracking = true;
|
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||||
|
int32 buttons;
|
||||||
|
Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||||
fLastPos = where;
|
fLastPos = where;
|
||||||
fMovingLayer = FindLayer(topLayer, where);
|
if (buttons == B_PRIMARY_MOUSE_BUTTON)
|
||||||
if (fMovingLayer == topLayer)
|
|
||||||
fMovingLayer = NULL;
|
|
||||||
if (fMovingLayer)
|
|
||||||
{
|
{
|
||||||
BRect bounds(fMovingLayer->Bounds());
|
fTracking = true;
|
||||||
fMovingLayer->ConvertToScreen2(&bounds);
|
fMovingLayer = FindLayer(topLayer, where);
|
||||||
BRect resizeRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom);
|
if (fMovingLayer == topLayer)
|
||||||
if (resizeRect.Contains(where))
|
fMovingLayer = NULL;
|
||||||
fIsResize = true;
|
if (fMovingLayer)
|
||||||
else
|
{
|
||||||
fIsResize = false;
|
BRect bounds(fMovingLayer->Bounds());
|
||||||
|
fMovingLayer->ConvertToScreen2(&bounds);
|
||||||
|
BRect resizeRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom);
|
||||||
|
if (resizeRect.Contains(where))
|
||||||
|
fIsResize = true;
|
||||||
|
else
|
||||||
|
fIsResize = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (buttons == B_SECONDARY_MOUSE_BUTTON)
|
||||||
|
{
|
||||||
|
fIs2ndButton = true;
|
||||||
|
}
|
||||||
|
else if (buttons == B_TERTIARY_MOUSE_BUTTON)
|
||||||
|
{
|
||||||
|
DrawSubTree(topLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyView::MouseUp(BPoint where)
|
void MyView::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
fTracking = false;
|
fTracking = false;
|
||||||
|
fIs2ndButton = false;
|
||||||
fMovingLayer = NULL;
|
fMovingLayer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,27 +108,67 @@ void MyView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (fIs2ndButton)
|
||||||
|
{
|
||||||
|
SetHighColor(0,0,0);
|
||||||
|
StrokeLine(fLastPos, where);
|
||||||
|
Flush();
|
||||||
|
fLastPos = where;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case B_MOUSE_WHEEL_CHANGED:
|
||||||
|
{
|
||||||
|
float dy;
|
||||||
|
msg->FindFloat("be:wheel_delta_y", &dy);
|
||||||
|
|
||||||
|
BPoint pt;
|
||||||
|
uint32 buttons;
|
||||||
|
Layer *lay;
|
||||||
|
GetMouse(&pt, &buttons, false);
|
||||||
|
if ((lay = FindLayer(topLayer, pt)))
|
||||||
|
lay->ScrollBy(0, dy*5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
// Yes... in this sandbox app, do a redraw.
|
||||||
|
reg->OffsetBy(dx, dy);
|
||||||
wind->Lock();
|
wind->Lock();
|
||||||
ConstrainClippingRegion(reg);
|
ConstrainClippingRegion(reg);
|
||||||
|
PushState();
|
||||||
DrawSubTree(topLayer);
|
DrawSubTree(topLayer);
|
||||||
Flush();
|
PopState();
|
||||||
|
ConstrainClippingRegion(NULL);
|
||||||
wind->Unlock();
|
wind->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyView::RequestRedraw()
|
void MyView::RequestRedraw()
|
||||||
{
|
{
|
||||||
wind->Lock();
|
wind->Lock();
|
||||||
Invalidate();
|
ConstrainClippingRegion(&fRedrawReg);
|
||||||
|
PushState();
|
||||||
|
DrawSubTree(topLayer);
|
||||||
|
PopState();
|
||||||
|
ConstrainClippingRegion(NULL);
|
||||||
|
|
||||||
|
fRedrawReg.MakeEmpty();
|
||||||
|
|
||||||
wind->Unlock();
|
wind->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyView::Draw(BRect area)
|
void MyView::Draw(BRect area)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
ConstrainClippingRegion(&fRedrawReg);
|
ConstrainClippingRegion(&fRedrawReg);
|
||||||
//FillRect(Bounds());
|
//FillRect(Bounds());
|
||||||
//Flush();
|
//Flush();
|
||||||
@ -123,6 +178,7 @@ void MyView::Draw(BRect area)
|
|||||||
PopState();
|
PopState();
|
||||||
ConstrainClippingRegion(NULL);
|
ConstrainClippingRegion(NULL);
|
||||||
fRedrawReg.MakeEmpty();
|
fRedrawReg.MakeEmpty();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyView::DrawSubTree(Layer* lay)
|
void MyView::DrawSubTree(Layer* lay)
|
||||||
|
@ -14,6 +14,7 @@ public:
|
|||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message);
|
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message);
|
||||||
|
virtual void MessageReceived(BMessage*);
|
||||||
|
|
||||||
void CopyRegion(BRegion *reg, float dx, float dy);
|
void CopyRegion(BRegion *reg, float dx, float dy);
|
||||||
void RequestRedraw();
|
void RequestRedraw();
|
||||||
@ -29,4 +30,5 @@ private:
|
|||||||
BPoint fLastPos;
|
BPoint fLastPos;
|
||||||
Layer *fMovingLayer;
|
Layer *fMovingLayer;
|
||||||
bool fIsResize;
|
bool fIsResize;
|
||||||
|
bool fIs2ndButton;
|
||||||
};
|
};
|
@ -66,6 +66,7 @@ clsMainWindow::clsMainWindow(const char *uWindowTitle)
|
|||||||
wind = this;
|
wind = this;
|
||||||
fView = new MyView(Bounds(), "emu", B_FOLLOW_ALL, B_WILL_DRAW);
|
fView = new MyView(Bounds(), "emu", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
AddChild(fView);
|
AddChild(fView);
|
||||||
|
fView->MakeFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
clsMainWindow::~clsMainWindow()
|
clsMainWindow::~clsMainWindow()
|
||||||
@ -157,15 +158,13 @@ void clsMainWindow::test1()
|
|||||||
wb2->GetWantedRegion(temp);
|
wb2->GetWantedRegion(temp);
|
||||||
topLayer->RebuildVisibleRegions(temp, wb2);
|
topLayer->RebuildVisibleRegions(temp, wb2);
|
||||||
|
|
||||||
wind->Lock();
|
fView->RequestRedraw();
|
||||||
fView->Invalidate();
|
|
||||||
wind->Unlock();
|
|
||||||
|
|
||||||
snooze(2000000);
|
snooze(1000000);
|
||||||
|
|
||||||
wb1->Hide();
|
wb1->Hide();
|
||||||
|
|
||||||
snooze(2000000);
|
snooze(1000000);
|
||||||
|
|
||||||
wb1->Show();
|
wb1->Show();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user