mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 13:09:56 +03:00
28 lines
759 B
D
28 lines
759 B
D
/// This example shows how to use the drag handle.
|
|
|
|
import parin;
|
|
|
|
auto handlePosition = Vec2(120, 60);
|
|
auto handleOptions = UiButtonOptions();
|
|
|
|
void ready() {
|
|
lockResolution(320, 180);
|
|
}
|
|
|
|
bool update(float dt) {
|
|
setUiStartPoint(Vec2(8));
|
|
// Toggle the limit of the drag handle.
|
|
if (uiButton(Vec2(80, 30), "Limit: {}".format(handleOptions.dragLimit))) {
|
|
if (handleOptions.dragLimit) handleOptions.dragLimit = UiDragLimit.none;
|
|
else handleOptions.dragLimit = UiDragLimit.viewport;
|
|
}
|
|
// Create the drag handle and print if it is dragged.
|
|
if (uiDragHandle(Vec2(60), handlePosition, handleOptions)) {
|
|
println(handlePosition);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void finish() { }
|
|
|
|
mixin runGame!(ready, update, finish);
|