Use spinbox as info source rather than mutator
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user