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

Method MouseActions

project.go:1078–1135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1076}
1077
1078func (project *Project) MouseActions() {
1079
1080 if globals.State == StateNeutral {
1081
1082 if globals.Mouse.Button(sdl.BUTTON_LEFT).PressedTimes(2) && globals.Settings.Get(SettingsDoubleClickMode).AsString() != DoubleClickNothing {
1083
1084 globals.Mouse.Button(sdl.BUTTON_LEFT).Consume()
1085
1086 project.CurrentPage.Selection.BoxSelecting = false
1087
1088 cardType := ContentTypeCheckbox
1089 if globals.Settings.Get(SettingsDoubleClickMode).AsString() == DoubleClickLast {
1090 cardType = project.LastCardType
1091 }
1092 card := project.CurrentPage.CreateNewCard(cardType)
1093
1094 project.CurrentPage.Selection.Clear()
1095 project.CurrentPage.Selection.Add(card)
1096 card.Rect.X = globals.Mouse.WorldPosition().X - (card.Rect.W / 2)
1097 card.Rect.Y = globals.Mouse.WorldPosition().Y - (card.Rect.H / 2)
1098
1099 card.LockPosition()
1100
1101 }
1102
1103 if globals.Keybindings.Pressed(KBOpenContextMenu) && !globals.MenuSystem.ExclusiveMenuOpen() {
1104 contextMenu := globals.MenuSystem.Get("context")
1105 contextMenu.Rect.X = globals.Mouse.Position().X
1106 contextMenu.Rect.Y = globals.Mouse.Position().Y
1107 contextMenu.Open()
1108 contextMenu.Update()
1109 }
1110
1111 }
1112
1113 if globals.State != StateContextMenu {
1114
1115 if globals.Mouse.Wheel() > 0 {
1116 scrollSensitivity := percentageToNumber[globals.Settings.Get(SettingsMouseWheelSensitivity).AsString()]
1117 project.Camera.AddZoom(project.Camera.Zoom * 0.1 * scrollSensitivity)
1118 } else if globals.Mouse.Wheel() < 0 {
1119 scrollSensitivity := percentageToNumber[globals.Settings.Get(SettingsMouseWheelSensitivity).AsString()]
1120 project.Camera.AddZoom(-project.Camera.Zoom * 0.1 * scrollSensitivity)
1121 }
1122
1123 if globals.Keybindings.Pressed(KBPanModifier) {
1124
1125 pan := globals.Mouse.RelativeMovement().Div(project.Camera.TargetZoom)
1126 if globals.Settings.Get(SettingsReversePan).AsBool() {
1127 pan = pan.Mult(-1)
1128 }
1129 project.Camera.TargetPosition = project.Camera.TargetPosition.Sub(pan)
1130
1131 }
1132
1133 }
1134
1135}

Callers 1

DrawMethod · 0.95

Calls 15

PressedTimesMethod · 0.80
ButtonMethod · 0.80
AsStringMethod · 0.80
ConsumeMethod · 0.80
CreateNewCardMethod · 0.80
WorldPositionMethod · 0.80
ExclusiveMenuOpenMethod · 0.80
WheelMethod · 0.80
AddZoomMethod · 0.80
DivMethod · 0.80
RelativeMovementMethod · 0.80
AsBoolMethod · 0.80

Tested by

no test coverage detected