Last active
December 16, 2015 10:09
-
-
Save ecere/5418159 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 OnLeftButtonDown(int x, int y, Modifiers mods) | |
{ | |
startScroll = scroll; | |
startDrag = { x, y }; | |
dragging = true; | |
Capture(); | |
scrollArea = { 1024, 1024 }; | |
return true; | |
} | |
bool OnLeftButtonUp(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 }; | |
dontAutoScrollArea = true; | |
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