Use spinbox as info source rather than mutator

This commit is contained in:
DarkPhoenix
2019-08-07 23:02:15 +03:00
parent fb93aa1ad5
commit 95621b6aab
2 changed files with 16 additions and 7 deletions

View File

@@ -111,8 +111,11 @@ class AttributeSlider(wx.Panel):
self.SetSizerAndFit(vsizer1)
self.parent.SetClientSize((500, vsizer1.GetSize()[1]))
def GetValue(self):
return self.ctrl.GetValue()
def UpdateValue(self, evt):
self.SetValue(self.ctrl.GetValue())
self.SetValue(self.GetValue())
evt.Skip()
def SetValue(self, value, post_event=True):
@@ -129,13 +132,18 @@ class AttributeSlider(wx.Panel):
def OnMouseWheel(self, evt):
if evt.GetWheelRotation() > 0 and evt.GetWheelAxis() == wx.MOUSE_WHEEL_VERTICAL:
self.ctrl.Value = self.ctrl.Value + self.ctrl.Increment
self.SetValue(self.ctrl.GetValue())
self.SetValue(self.GetValue())
elif evt.GetWheelRotation() < 0 and evt.GetWheelAxis() == wx.MOUSE_WHEEL_VERTICAL:
self.ctrl.Value = self.ctrl.Value - self.ctrl.Increment
self.SetValue(self.ctrl.GetValue())
self.SetValue(self.GetValue())
else:
evt.Skip()
def OnWindowClose(self):
# Stop animations to prevent crashes when window is
# closed while animation is in progress
self.slider.FreezeAnimation()
class TestAttributeSlider(wx.Frame):

View File

@@ -216,17 +216,18 @@ class ItemMutatorList(wx.ScrolledWindow):
fit = Fit.getInstance().getFit(self.carryingFitID)
if self.mod in fit.modules:
currentMutation = {}
for m in self.event_mapping.values():
currentMutation[m.attrID] = m.value
for slider, m in self.event_mapping.items():
# Sliders may have more up-to-date info than mutator in case we changed
# value in slider and without confirming it, decided to close window
currentMutation[m.attrID] = slider.GetValue()
mainFrame = gui.mainFrame.MainFrame.getInstance()
mainFrame.getCommandForFit(self.carryingFitID).Submit(cmd.GuiChangeLocalModuleMutationCommand(
fitID=self.carryingFitID,
position=fit.modules.index(self.mod),
mutation=currentMutation,
oldMutation=self.initialMutations))
# Stop animations to prevent crashes when window is closed while it's in progress
for slider in self.event_mapping:
slider.slider.FreezeAnimation()
slider.OnWindowClose()
def callLater(self):
self.timer = None