Skip to content

Instantly share code, notes, and snippets.

@ecere
Created April 19, 2013 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecere/5418188 to your computer and use it in GitHub Desktop.
Save ecere/5418188 to your computer and use it in GitHub Desktop.
import "ecere"
class SlidingPanel : Window
{
bool dragging;
Point startScroll, startDrag;
bool OnCreate()
{
group.size = { scrollArea.w - 20, scrollArea.h - 20 };
return true;
}
Window group { this, clickThrough = true, opacity = 0, position = { 10, 10 }, borderStyle = deepContour };
bool OnRightButtonDown(int x, int y, Modifiers mods)
{
startScroll = scroll;
startDrag = { x, y };
dragging = true;
Capture();
return true;
}
bool OnRightButtonUp(int x, int y, Modifiers mods)
{
if(dragging)
{
dragging = false;
ReleaseCapture();
}
return true;
}
bool OnMouseMove(int x, int y, Modifiers mods)
{
if(dragging)
{
scroll =
{
Max(0, Min(scrollArea.w, startScroll.x - (x - startDrag.x))),
Max(0, Min(scrollArea.h, startScroll.y - (y - startDrag.y)))
};
// To cause children to reposition...
size = size;
}
return true;
}
}
class Form1 : SlidingPanel
{
caption = "Form1";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
clientSize = { 616, 422 };
scrollArea = { 1024, 1024 };
position = { 696, 296 };
Button button1 { this, caption = "button1", position = { 156, 284 } };
Button button2 { this, caption = "button2", position = { 500, 88 } };
Button button3 { this, caption = "button3", position = { 316, 324 } };
}
Form1 form1 {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment