()
| 4148 | } |
| 4149 | |
| 4150 | func (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 |
nothing calls this directly
no test coverage detected