Created
April 19, 2013 04:41
-
-
Save ecere/5418188 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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