MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Update

Method Update

gui.go:4150–4271  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4148}
4149
4150func (ds *DraggableLabel) Update() {
4151
4152 dragArea := *ds.TargetRect
4153 dragArea.W = 32
4154 dragArea.H = 32
4155 cursorPos := globals.Mouse.WorldPosition()
4156 lmb := globals.Mouse.Button(sdl.BUTTON_LEFT)
4157
4158 // if cursorPos.Inside(ds.Rect) && globals.Mouse.WorldPosition().Distance(dragHandlePoint) < 16 {
4159
4160 // For now, we will just check to see if the mouse is close enough to grab the point
4161 if cursorPos.Inside(&dragArea) {
4162
4163 globals.Mouse.SetCursor(CursorHand)
4164
4165 if lmb.Pressed() {
4166 lmb.Consume()
4167 ds.Dragging = true
4168 ds.Label.EndEditing()
4169 ds.TableData.DraggingLabel = ds
4170 PlayUISound(UISoundTypeToggleOff)
4171 }
4172
4173 }
4174
4175 if ds.Dragging {
4176 globals.Mouse.SetCursor(CursorHandGrab)
4177 if ds.Vertical {
4178 ds.TargetRect.X = globals.Mouse.WorldPosition().X - (ds.TargetRect.W / 2)
4179 ds.TargetRect.Y = globals.Mouse.WorldPosition().Y - 16
4180 } else {
4181 ds.TargetRect.X = globals.Mouse.WorldPosition().X
4182 ds.TargetRect.Y = globals.Mouse.WorldPosition().Y - (ds.TargetRect.H / 2)
4183 }
4184 if lmb.Released() {
4185 ds.Dragging = false
4186 ds.TableData.DraggingLabel = nil
4187 ds.TableData.TableHeaderDropped(ds)
4188 PlayUISound(UISoundTypeToggleOn)
4189 }
4190 }
4191
4192 if ds.Label.Editing {
4193 ds.TableData.EditingLabel = ds
4194 } else if ds.TableData.EditingLabel == ds {
4195 ds.TableData.EditingLabel = nil
4196 }
4197
4198 textSize := ds.Label.TextSize()
4199
4200 if textSize.X < 16 {
4201 textSize.X = 16
4202 }
4203
4204 if textSize.Y < 16 {
4205 textSize.Y = 16
4206 }
4207

Callers

nothing calls this directly

Calls 15

PlayUISoundFunction · 0.85
WorldPositionMethod · 0.80
ButtonMethod · 0.80
InsideMethod · 0.80
SetCursorMethod · 0.80
ConsumeMethod · 0.80
EndEditingMethod · 0.80
ReleasedMethod · 0.80
TableHeaderDroppedMethod · 0.80
TextSizeMethod · 0.80
PressedTimesMethod · 0.80
BeginEditingMethod · 0.80

Tested by

no test coverage detected