From: Youness Alaoui Date: Wed, 31 Dec 2014 07:14:31 +0000 (-0500) Subject: Use a separate ImageID for the default glComboButton X-Git-Tag: 14.09-1.18~5^2~6 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=eed9f30dbc056ff777815640f7e4f50890405a8c;p=cura.git Use a separate ImageID for the default glComboButton This seems better than having 1 extra imageID than tooltips and ignoring the imageID at offset 0. This fixes an index out of range issue as well due to len(imageID) being 1 too many. Fixes issue #67 --- diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index c9461dc9..447b5838 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -101,7 +101,7 @@ class SceneView(openglGui.glGuiPanel): openglGui.glLabel(self.scaleForm, _("Uniform scale"), (0,8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1,8), None) - self.viewSelection = openglGui.glComboButton(self, _("View mode"), [7,26,19,11,15,23], [_("Normal"), _("Overhang"), _("Transparent"), _("X-Ray"), _("Layers")], (-1,0), self.OnViewChange) + self.viewSelection = openglGui.glComboButton(self, _("View mode"), 7, [26,19,11,15,23], [_("Normal"), _("Overhang"), _("Transparent"), _("X-Ray"), _("Layers")], (-1,0), self.OnViewChange) self.viewSelection.setDisabled(True) #self.youMagineButton = openglGui.glButton(self, 26, _("Share on YouMagine"), (2,0), lambda button: youmagineGui.youmagineManager(self.GetTopLevelParent(), self._scene)) #self.youMagineButton.setDisabled(True) diff --git a/Cura/gui/util/openglGui.py b/Cura/gui/util/openglGui.py index c2b95ab1..9ed845f8 100644 --- a/Cura/gui/util/openglGui.py +++ b/Cura/gui/util/openglGui.py @@ -570,8 +570,8 @@ class glRadioButton(glButton): self._radioCallback(button) class glComboButton(glButton): - def __init__(self, parent, tooltip, imageIDs, tooltips, pos, callback): - super(glComboButton, self).__init__(parent, imageIDs[0], tooltip, pos, self._onComboOpenSelect) + def __init__(self, parent, tooltip, defaultImageID, imageIDs, tooltips, pos, callback): + super(glComboButton, self).__init__(parent, defaultImageID, tooltip, pos, self._onComboOpenSelect) self._imageIDs = imageIDs self._tooltips = tooltips self._comboCallback = callback @@ -599,7 +599,7 @@ class glComboButton(glButton): glPushMatrix() glTranslatef(pos[0]+bs*0.5, pos[1] + bs*0.5, 0) glBindTexture(GL_TEXTURE_2D, self._base._glButtonsTexture) - for n in xrange(1, len(self._imageIDs)): + for n in xrange(0, len(self._imageIDs)): glTranslatef(0, bs, 0) glColor4ub(255,255,255,255) openglHelpers.glDrawTexturedQuad(-0.85*bs,-0.8*bs,bs,bs, 0) @@ -645,7 +645,7 @@ class glComboButton(glButton): pos = self._getPixelPos() if 0 <= x - pos[0] <= bs and 0 <= y - pos[1] - bs <= bs * len(self._imageIDs): self._selection = int((y - pos[1] - bs) / bs) - self._imageID = self._imageIDs[(self._selection)+1] + self._imageID = self._imageIDs[self._selection] self._base._focus = None self._comboCallback() return True