Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
DraggableContainerWidget.cs
1using System.Drawing;
2using System.Numerics;
6
7namespace Gondwana.Widgets;
8
13{
14 private readonly WidgetDragBehavior _dragBehavior;
15
19 public event Action<WidgetDragEventArgs>? DragStarted;
20
24 public event Action<WidgetDragEventArgs>? Dragged;
25
29 public event Action<WidgetDragEventArgs>? DragEnded;
30
40 PointF anchor = default,
41 string? nickname = null)
42 : base(renderSurfaceHost, mode, anchor, nickname)
43 {
44 _dragBehavior = new WidgetDragBehavior(this);
45 }
46
50 public bool IsDragEnabled
51 {
52 get => _dragBehavior.IsDragEnabled;
53 set => _dragBehavior.IsDragEnabled = value;
54 }
55
59 public bool IsDragging => _dragBehavior.IsDragging;
60
64 public float DragThresholdPx
65 {
66 get => _dragBehavior.DragThresholdPx;
67 set => _dragBehavior.DragThresholdPx = value;
68 }
69
71 protected sealed override void ProcessHidden()
72 {
73 base.ProcessHidden();
74
75 _dragBehavior.ResetPointerState(clearClickSuppression: true);
76 }
77
79 protected sealed override void ProcessCancelled()
80 {
81 base.ProcessCancelled();
82
83 _dragBehavior.ResetPointerState(clearClickSuppression: true);
84 }
85
87 protected sealed override void ProcessPointerDown(WidgetPointerEventArgs args)
88 {
89 base.ProcessPointerDown(args);
90
91 _dragBehavior.ProcessPointerDown(args, CanStartDrag);
92 }
93
95 protected sealed override void ProcessPointerMove(WidgetPointerEventArgs args)
96 {
97 base.ProcessPointerMove(args);
98
99 _dragBehavior.ProcessPointerMove(args,
102 DispatchDragStarted,
103 DispatchDragged);
104 }
105
107 protected sealed override void ProcessPointerUp(WidgetPointerEventArgs args)
108 {
109 base.ProcessPointerUp(args);
110
111 _dragBehavior.ProcessPointerUp(args,
114 DispatchDragEnded);
115 }
116
118 protected sealed override bool ShouldDispatchPointerClick(WidgetPointerEventArgs args)
119 {
120 return base.ShouldDispatchPointerClick(args) &&
121 _dragBehavior.ShouldDispatchPointerClick(args);
122 }
123
129 protected virtual bool CanStartDrag(WidgetPointerEventArgs args)
130 {
131 return _dragBehavior.CanStartDrag(args);
132 }
133
140 protected virtual Vector2 ConvertScreenDeltaToPositionDelta(Vector2 totalScreenDeltaPx, View view)
141 {
142 return _dragBehavior.ConvertScreenDeltaToPositionDelta(totalScreenDeltaPx, view);
143 }
144
150 protected virtual Vector2 ConstrainDragPosition(Vector2 proposedPositionPx)
151 {
152 return proposedPositionPx;
153 }
154
159 protected virtual void OnDragStarted(WidgetDragEventArgs args)
160 {
161 }
162
167 protected virtual void OnDragged(WidgetDragEventArgs args)
168 {
169 }
170
175 protected virtual void OnDragEnded(WidgetDragEventArgs args)
176 {
177 }
178
179 private void DispatchDragStarted(WidgetDragEventArgs args)
180 {
181 OnDragStarted(args);
182 DragStarted?.Invoke(args);
183 }
184
185 private void DispatchDragged(WidgetDragEventArgs args)
186 {
187 OnDragged(args);
188 Dragged?.Invoke(args);
189 }
190
191 private void DispatchDragEnded(WidgetDragEventArgs args)
192 {
193 OnDragEnded(args);
194 DragEnded?.Invoke(args);
195 }
196}
View? View
Gets the view shared by all children in view mode.
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
ContainerWidget(RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
Initializes a new instance of the ContainerWidget class.
override void ProcessPointerDown(WidgetPointerEventArgs args)
Performs processing when a pointer press begins on the widget before notification callbacks are invok...
override void ProcessCancelled()
Performs processing when the widget is cancelled before notification callbacks are invoked.
virtual void OnDragged(WidgetDragEventArgs args)
Called after the container moves during dragging.
bool IsDragEnabled
Gets or sets whether new drag operations may begin.
virtual void OnDragStarted(WidgetDragEventArgs args)
Called when dragging begins.
virtual Vector2 ConstrainDragPosition(Vector2 proposedPositionPx)
Constrains a proposed anchor position before it is applied.
override bool ShouldDispatchPointerClick(WidgetPointerEventArgs args)
Determines whether a pointer-click event should be dispatched for the specified pointer event data....
override void ProcessHidden()
Performs processing when the widget is hidden before notification callbacks are invoked.
virtual Vector2 ConvertScreenDeltaToPositionDelta(Vector2 totalScreenDeltaPx, View view)
Converts total screen movement into this widget's coordinate space.
override void ProcessPointerMove(WidgetPointerEventArgs args)
Performs processing when pointer movement is routed to the widget before notification callbacks are i...
virtual void OnDragEnded(WidgetDragEventArgs args)
Called when dragging ends.
virtual bool CanStartDrag(WidgetPointerEventArgs args)
Determines whether a pointer-down event may begin drag tracking.
float DragThresholdPx
Gets or sets the minimum pointer movement required to begin dragging.
Action< WidgetDragEventArgs >? DragEnded
Raised when an active drag ends.
override void ProcessPointerUp(WidgetPointerEventArgs args)
Performs processing when a pointer press is released for the widget before notification callbacks are...
bool IsDragging
Gets whether a drag operation is active.
Action< WidgetDragEventArgs >? DragStarted
Raised when pointer movement first crosses DragThresholdPx.
Action< WidgetDragEventArgs >? Dragged
Raised after the container is repositioned during an active drag.
DraggableContainerWidget(RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
Initializes a new instance of the DraggableContainerWidget class.
Event arguments for widget drag callbacks.
Event arguments for pointer-based widget callbacks.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.