Commit 962461fa807e8621331d5b608e7083be0c333cfc

Authored by tfmoraes
1 parent d7cad2db

FIX: Resolved the mad comportment in gradient

Showing 1 changed file with 14 additions and 1 deletions   Show diff stats
invesalius/gui/widgets/gradient.py
... ... @@ -141,6 +141,16 @@ class SliderBorder(object):
141 141 elif self.type == MAXBORDER and self.pos+self.width >= self.WindowWidth:
142 142 self.pos = self.WindowWidth - self.width
143 143  
  144 + def SetPosition(self, pos):
  145 + """
  146 + Move the border
  147 + """
  148 + self.pos = pos
  149 + if self.type == MINBORDER and self.pos < 0:
  150 + self.pos = 0
  151 + elif self.type == MAXBORDER and self.pos+self.width >= self.WindowWidth:
  152 + self.pos = self.WindowWidth - self.width
  153 +
144 154 def GetCursor(self):
145 155 """
146 156 This function returns the cursor related to the SliderBorder
... ... @@ -432,7 +442,10 @@ class GradientPanel(wx.Panel):
432 442 slide = x - self.MousePositionX
433 443 self.MousePositionX += slide
434 444 self.SetCursor(self.SelectedObject.GetCursor())
435   - self.SelectedObject.DoSlide(slide)
  445 + if isinstance(self.SelectedObject, SliderControl):
  446 + self.SelectedObject.DoSlide(slide)
  447 + else:
  448 + self.SelectedObject.SetPosition(x)
436 449 self.Slider.Calculate(self.SelectedObject)
437 450 if self.GetMin() >= self.GetMax():
438 451 self.SetMinValue(self.GetMax()-1)
... ...