Пример #1
0
 def getToolTipPosition(self, mousePos, infoArea, placement):
     """Returns a position to place the ToolTip window in self.toolTipGUI so it is outside the info
     area positioned according to placement's hint"""
     width, height = clipSize(self.component)
     if placement == ToolTip.PLACE_BELOW:
         position = [mousePos[0], infoArea[3] - ToolTip.GAP_SIZE - height / 2]
     elif placement == ToolTip.PLACE_ABOVE:
         position = [mousePos[0], infoArea[1] + ToolTip.GAP_SIZE + height / 2]
     elif placement == ToolTip.PLACE_LEFT:
         position = [infoArea[0] - ToolTip.GAP_SIZE - width / 2, mousePos[1]]
     elif placement == ToolTip.PLACE_RIGHT:
         position = [infoArea[2] + ToolTip.GAP_SIZE + width / 2, mousePos[1]]
     if position[0] - width / 2 < -1.0:
         if placement == ToolTip.PLACE_LEFT:
             position[0] = infoArea[2] + ToolTip.GAP_SIZE + width / 2
         else:
             position[0] = -1.0 + ToolTip.GAP_SIZE + width / 2
     elif position[0] + width / 2 > 1.0:
         if placement == ToolTip.PLACE_RIGHT:
             position[0] = infoArea[0] - ToolTip.GAP_SIZE - width / 2
         else:
             position[0] = 1.0 - ToolTip.GAP_SIZE - width / 2
     if position[1] - height / 2 < -1.0:
         if placement == ToolTip.PLACE_BELOW:
             position[1] = infoArea[1] + ToolTip.GAP_SIZE + height / 2
         else:
             position[1] = -1.0 + ToolTip.GAP_SIZE + height / 2
     elif position[1] + height / 2 > 1.0:
         if placement == ToolTip.PLACE_ABOVE:
             position[1] = infoArea[3] - ToolTip.GAP_SIZE - height / 2
         else:
             position[1] = 1.0 - ToolTip.GAP_SIZE - height / 2
     return (position[0], position[1], 0.0)
Пример #2
0
 def _setValue(self, value):
     sliderWidth, sliderHeight = clipSize(self.component)
     slider = self.component.parent.script
     thumbPos = (value - slider.minValue) / (slider.maxValue - slider.minValue)
     if slider.isHorizontal:
         thumbPos = (2.0 - sliderWidth) * thumbPos - 1.0 + sliderWidth / 2
     else:
         thumbPos = (2.0 - sliderHeight) * thumbPos - 1.0 + sliderHeight / 2
     self.component.position = (thumbPos, 0, 1) if slider.isHorizontal else (0, thumbPos, 1)
Пример #3
0
 def _setValue(self, value):
     sliderWidth, sliderHeight = clipSize(self.component)
     slider = self.component.parent.script
     thumbPos = (value - slider.minValue) / (slider.maxValue - slider.minValue)
     if slider.isHorizontal:
         thumbPos = (2.0 - sliderWidth) * thumbPos - 1.0 + sliderWidth / 2
     else:
         thumbPos = (2.0 - sliderHeight) * thumbPos - 1.0 + sliderHeight / 2
     self.component.position = (thumbPos, 0, 1) if slider.isHorizontal else (0, thumbPos, 1)
Пример #4
0
 def _onDragging(self):
     position = clipPosition(self.component)
     sliderWidth, sliderHeight = clipSize(self.component)
     slider = self.component.parent.script
     if slider.isHorizontal:
         thumbPos = (position[0] + 1.0 - sliderWidth / 2) / (2.0 - sliderWidth)
     else:
         thumbPos = (position[1] + 1.0 - sliderHeight / 2) / (2.0 - sliderHeight)
     thumbPos = min(max(0.0, thumbPos), 1.0)
     newValue = thumbPos * (slider.maxValue - slider.minValue) + slider.minValue
     newValue += slider.stepSize / 2.0
     newValue -= math.fmod(newValue, slider.stepSize)
     self._setValue(newValue)
     slider.value = newValue
     slider.onValueChanged()
Пример #5
0
 def _onDragging(self):
     position = clipPosition(self.component)
     sliderWidth, sliderHeight = clipSize(self.component)
     slider = self.component.parent.script
     if slider.isHorizontal:
         thumbPos = (position[0] + 1.0 - sliderWidth / 2) / (2.0 - sliderWidth)
     else:
         thumbPos = (position[1] + 1.0 - sliderHeight / 2) / (2.0 - sliderHeight)
     thumbPos = min(max(0.0, thumbPos), 1.0)
     newValue = thumbPos * (slider.maxValue - slider.minValue) + slider.minValue
     newValue += slider.stepSize / 2.0
     newValue -= math.fmod(newValue, slider.stepSize)
     self._setValue(newValue)
     slider.value = newValue
     slider.onValueChanged()
Пример #6
0
 def getToolTipPosition(self, mousePos, infoArea, placement):
     """Returns a position to place the ToolTip window in self.toolTipGUI so it is outside the info
     area positioned according to placement's hint"""
     width, height = clipSize(self.component)
     if placement == ToolTip.PLACE_BELOW:
         position = [
             mousePos[0], infoArea[3] - ToolTip.GAP_SIZE - height / 2
         ]
     elif placement == ToolTip.PLACE_ABOVE:
         position = [
             mousePos[0], infoArea[1] + ToolTip.GAP_SIZE + height / 2
         ]
     elif placement == ToolTip.PLACE_LEFT:
         position = [
             infoArea[0] - ToolTip.GAP_SIZE - width / 2, mousePos[1]
         ]
     elif placement == ToolTip.PLACE_RIGHT:
         position = [
             infoArea[2] + ToolTip.GAP_SIZE + width / 2, mousePos[1]
         ]
     if position[0] - width / 2 < -1.0:
         if placement == ToolTip.PLACE_LEFT:
             position[0] = infoArea[2] + ToolTip.GAP_SIZE + width / 2
         else:
             position[0] = -1.0 + ToolTip.GAP_SIZE + width / 2
     elif position[0] + width / 2 > 1.0:
         if placement == ToolTip.PLACE_RIGHT:
             position[0] = infoArea[0] - ToolTip.GAP_SIZE - width / 2
         else:
             position[0] = 1.0 - ToolTip.GAP_SIZE - width / 2
     if position[1] - height / 2 < -1.0:
         if placement == ToolTip.PLACE_BELOW:
             position[1] = infoArea[1] + ToolTip.GAP_SIZE + height / 2
         else:
             position[1] = -1.0 + ToolTip.GAP_SIZE + height / 2
     elif position[1] + height / 2 > 1.0:
         if placement == ToolTip.PLACE_ABOVE:
             position[1] = infoArea[3] - ToolTip.GAP_SIZE - height / 2
         else:
             position[1] = 1.0 - ToolTip.GAP_SIZE - height / 2
     return (position[0], position[1], 0.0)
Пример #7
0
 def getToolTipPosition(self, mousePos, infoArea, placement):
     width, height = clipSize(self.component)
     if placement == ToolTip.PLACE_BELOW:
         position = [
             mousePos[0], infoArea[3] - ToolTip.GAP_SIZE - height / 2
         ]
     elif placement == ToolTip.PLACE_ABOVE:
         position = [
             mousePos[0], infoArea[1] + ToolTip.GAP_SIZE + height / 2
         ]
     elif placement == ToolTip.PLACE_LEFT:
         position = [
             infoArea[0] - ToolTip.GAP_SIZE - width / 2, mousePos[1]
         ]
     elif placement == ToolTip.PLACE_RIGHT:
         position = [
             infoArea[2] + ToolTip.GAP_SIZE + width / 2, mousePos[1]
         ]
     if position[0] - width / 2 < -1.0:
         if placement == ToolTip.PLACE_LEFT:
             position[0] = infoArea[2] + ToolTip.GAP_SIZE + width / 2
         else:
             position[0] = -1.0 + ToolTip.GAP_SIZE + width / 2
     elif position[0] + width / 2 > 1.0:
         if placement == ToolTip.PLACE_RIGHT:
             position[0] = infoArea[0] - ToolTip.GAP_SIZE - width / 2
         else:
             position[0] = 1.0 - ToolTip.GAP_SIZE - width / 2
     if position[1] - height / 2 < -1.0:
         if placement == ToolTip.PLACE_BELOW:
             position[1] = infoArea[1] + ToolTip.GAP_SIZE + height / 2
         else:
             position[1] = -1.0 + ToolTip.GAP_SIZE + height / 2
     elif position[1] + height / 2 > 1.0:
         if placement == ToolTip.PLACE_ABOVE:
             position[1] = infoArea[3] - ToolTip.GAP_SIZE - height / 2
         else:
             position[1] = 1.0 - ToolTip.GAP_SIZE - height / 2
     return (position[0], position[1], 0.0)