diff --git a/src/mcedit2/editortools/brush/__init__.py b/src/mcedit2/editortools/brush/__init__.py index a518614..d6764ec 100644 --- a/src/mcedit2/editortools/brush/__init__.py +++ b/src/mcedit2/editortools/brush/__init__.py @@ -4,7 +4,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals import logging -from PySide import QtGui +from PySide import QtGui, QtCore import numpy from mcedit2.editortools import EditorTool @@ -15,6 +15,7 @@ from mcedit2.util.load_ui import load_ui, registerCustomWidget from mcedit2.util.settings import Settings from mcedit2.util.showprogress import showProgress from mcedit2.util.worldloader import WorldLoader +from mcedit2.widgets.layout import Row from mceditlib.geometry import Vector from mceditlib.selection import ShapedSelection, BoundingBox from mceditlib.util import exhaust @@ -246,7 +247,6 @@ class FakeBrushChunk(object): return section - class BrushTool(EditorTool): name = "Brush" iconName = "brush" @@ -259,13 +259,13 @@ class BrushTool(EditorTool): self.cursorWorldScene = None self.cursorNode = scenegraph.TranslateNode() - self.toolWidget.xSpinBox.valueChanged.connect(self.setX) - self.toolWidget.ySpinBox.valueChanged.connect(self.setY) - self.toolWidget.zSpinBox.valueChanged.connect(self.setZ) + self.toolWidget.xSpinSlider.setMinimum(1) + self.toolWidget.ySpinSlider.setMinimum(1) + self.toolWidget.zSpinSlider.setMinimum(1) - self.toolWidget.xSlider.valueChanged.connect(self.setX) - self.toolWidget.ySlider.valueChanged.connect(self.setY) - self.toolWidget.zSlider.valueChanged.connect(self.setZ) + self.toolWidget.xSpinSlider.valueChanged.connect(self.setX) + self.toolWidget.ySpinSlider.valueChanged.connect(self.setY) + self.toolWidget.zSpinSlider.valueChanged.connect(self.setZ) self.toolWidget.blockTypeInput.editorSession = editorSession self.toolWidget.blockTypeInput.block = editorSession.worldEditor.blocktypes["minecraft:stone"] @@ -277,9 +277,9 @@ class BrushTool(EditorTool): self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(5, 5, 5)).toTuple() # calls updateCursor - self.toolWidget.xSpinBox.setValue(self.brushSize[0]) - self.toolWidget.ySpinBox.setValue(self.brushSize[1]) - self.toolWidget.zSpinBox.setValue(self.brushSize[2]) + self.toolWidget.xSpinSlider.setValue(self.brushSize[0]) + self.toolWidget.ySpinSlider.setValue(self.brushSize[1]) + self.toolWidget.zSpinSlider.setValue(self.brushSize[2]) _brushSize = (0, 0, 0) @property @@ -296,22 +296,16 @@ class BrushTool(EditorTool): x, y, z = self.brushSize x = float(val) self.brushSize = x, y, z - self.toolWidget.xSlider.setValue(val) - self.toolWidget.xSpinBox.setValue(val) def setY(self, val): x, y, z = self.brushSize y = float(val) self.brushSize = x, y, z - self.toolWidget.ySlider.setValue(val) - self.toolWidget.ySpinBox.setValue(val) def setZ(self, val): x, y, z = self.brushSize z = float(val) self.brushSize = x, y, z - self.toolWidget.zSlider.setValue(val) - self.toolWidget.zSpinBox.setValue(val) def setBlocktypes(self, types): if len(types) == 0: diff --git a/src/mcedit2/ui/editortools/brush.ui b/src/mcedit2/ui/editortools/brush.ui index ea71763..f3532a8 100644 --- a/src/mcedit2/ui/editortools/brush.ui +++ b/src/mcedit2/ui/editortools/brush.ui @@ -16,6 +16,16 @@ + + + + + 0 + 0 + + + + @@ -24,7 +34,14 @@ - + + + + 0 + 0 + + + @@ -33,38 +50,6 @@ - - - - 1 - - - 1024 - - - - - - - 1 - - - 80 - - - 1 - - - Qt::Horizontal - - - false - - - QSlider::NoTicks - - - @@ -72,29 +57,6 @@ - - - - 1 - - - 1024 - - - - - - - 1 - - - 80 - - - Qt::Horizontal - - - @@ -102,26 +64,13 @@ - - - - 1 - - - 1024 - - - - - - - 1 - - - 80 - - - Qt::Horizontal + + + + + 0 + 0 + @@ -132,29 +81,6 @@ - - - - -1024 - - - 1024 - - - - - - - -80 - - - 80 - - - Qt::Horizontal - - - @@ -165,8 +91,8 @@ - - 0 + + 1 0 @@ -181,6 +107,12 @@ + + + 0 + 0 + + QFrame::StyledPanel @@ -208,6 +140,12 @@ + + + 0 + 0 + + 40 @@ -220,17 +158,40 @@ + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + - - - - 0 - 1 - + + + Qt::Vertical - + + + 20 + 40 + + + @@ -253,6 +214,12 @@
blocktypebutton.h
1 + + SpinSlider + QWidget +
spinslider.h
+ 1 +
diff --git a/src/mcedit2/widgets/spinslider.py b/src/mcedit2/widgets/spinslider.py new file mode 100644 index 0000000..997192a --- /dev/null +++ b/src/mcedit2/widgets/spinslider.py @@ -0,0 +1,68 @@ +""" + spinslider +""" +from __future__ import absolute_import, division, print_function +import logging +from PySide import QtGui, QtCore +from PySide.QtCore import Qt +from mcedit2.util.load_ui import registerCustomWidget +from mcedit2.widgets.layout import Row + +log = logging.getLogger(__name__) + + +@registerCustomWidget +class SpinSlider(QtGui.QWidget): + def __init__(self, *args, **kwargs): + super(SpinSlider, self).__init__(*args, **kwargs) + self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) + + self.spinBox = QtGui.QSpinBox() + self.slider = QtGui.QSlider() + self.slider.setOrientation(Qt.Horizontal) + self._value = 0 + + self._minimum = -(2 << 31) + self._maximum = (2 << 31) - 1 + + self.spinBox.valueChanged.connect(self.spinBoxChanged) + self.slider.valueChanged.connect(self.sliderChanged) + + self.setLayout(Row(self.spinBox, self.slider, margin=0)) + + def spinBoxChanged(self, value): + self._value = value + self.slider.setValue(value) + self.valueChanged.emit(value) + + def sliderChanged(self, value): + self._value = value + self.spinBox.setValue(value) + self.valueChanged.emit(value) + + def value(self): + return self._value + + def setValue(self, value): + self._value = value + self.spinBox.setValue(value) + self.slider.setValue(value) + + def minimum(self): + return self._minimum + + def setMinimum(self, value): + self._minimum = value + self.slider.setMinimum(value) + self.spinBox.setMinimum(value) + + def maximum(self): + return self._maximum + + def setMaximum(self, value): + self._maximum = value + self.slider.setMaximum(value) + self.spinBox.setMaximum(value) + + + valueChanged = QtCore.Signal(float)