mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 04:59:54 +03:00
28 lines
745 B
D
28 lines
745 B
D
/// This example shows how to use the drag handle.
|
|
|
|
import parin;
|
|
|
|
auto handleArea = Rect(40, 60, 60, 60);
|
|
auto handleOptions = UiOptions();
|
|
|
|
void ready() {
|
|
lockResolution(320, 180);
|
|
}
|
|
|
|
bool update(float dt) {
|
|
prepareUi();
|
|
setUiFocus(0);
|
|
// Toggle the limit of the drag handle.
|
|
if (uiButton(Rect(8, 8, 120, 25), handleOptions.dragLimit.toStr())) {
|
|
handleOptions.dragLimit = handleOptions.dragLimit ? UiDragLimit.none : UiDragLimit.viewport;
|
|
}
|
|
// Create the drag handle and print if it is dragged.
|
|
if (uiDragHandle(handleArea, handleOptions)) {
|
|
printfln("({}, {})", handleArea.position.x, handleArea.position.y);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void finish() { }
|
|
|
|
mixin runGame!(ready, update, finish);
|