示例#1
0
    def draw(self):
        if self._hidden:
            return

        width, height = self.getMinSize()
        pos = self._getPixelPos()

        scale = 1
        if self._focus:
            scale = 1.05
        if self._disabled:
            glColor4ub(128, 128, 128, 128)
        else:
            if self._focus:
                glColor4ub(5, 15, 30, 200)
            else:
                glColor4ub(5, 15, 30, 255)
        openglHelpers.glDrawQuad(pos[0] - width * scale / 2,
                                 pos[1] - height * scale / 2, width * scale,
                                 height * scale)
        glPushMatrix()
        glTranslatef(pos[0], pos[1] + height * scale / 8, 0)
        glDisable(GL_TEXTURE_2D)
        glColor4ub(255, 255, 255, 255)
        openglHelpers.glDrawStringCenter(self._tooltip)
        glPopMatrix()
示例#2
0
文件: openglGui.py 项目: Odemia/Cura
	def draw(self):
		if self._hidden:
			return

		cx = (self._imageID % 4) / 4
		cy = int(self._imageID / 4) / 4
		bs = self.getMinSize()[0]
		pos = self._getPixelPos()

		glBindTexture(GL_TEXTURE_2D, self._base._glButtonsTexture)
		#button sizing		
		scale = 1.0
		if self._selected:
			scale = 1.0
		elif self._focus:
			scale = 1.0
		if self._disabled:
			glColor4ub(128,128,128,128)
		else:
			glColor4ub(255,255,255,255)
		openglHelpers.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, 0)
		openglHelpers.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, self._imageID)
		if self._showExpandArrow:
			if self._selected:
				openglHelpers.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1)
			else:
				openglHelpers.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1, 2)
		glPushMatrix()
		glTranslatef(pos[0], pos[1], 0)
		glDisable(GL_TEXTURE_2D)
		'''if self._focus:
			glTranslatef(0, -0.55*bs*scale, 0)

			glPushMatrix()
			glColor4ub(60,60,60,255)
			glTranslatef(-1, -1, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(0, 2, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(2, 0, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(0, -2, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glPopMatrix()

			glColor4ub(255,255,255,255)
			openglHelpers.glDrawStringCenter(self._tooltip)
		'''
		glPopMatrix()
		progress = self._progressBar
		if progress is not None:
			glColor4ub(60,60,60,255)
			openglHelpers.glDrawQuad(pos[0]-bs/2, pos[1]+bs/2, bs, bs / 4)
			glColor4ub(255,255,255,255)
			openglHelpers.glDrawQuad(pos[0]-bs/2+2, pos[1]+bs/2+2, (bs - 5) * progress + 1, bs / 4 - 4)
		elif len(self._altTooltip) > 0:
			glPushMatrix()
			glTranslatef(pos[0], pos[1], 0)
			glTranslatef(0, 0.6*bs, 0)
			glTranslatef(0, 6, 0)
			#glTranslatef(0.6*bs*scale, 0, 0)

			for line in self._altTooltip.split('\n'):
				glPushMatrix()
				glColor4ub(60,60,60,255)
				glTranslatef(-1, -1, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, 2, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(2, 0, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, -2, 0)
				openglHelpers.glDrawStringCenter(line)
				glPopMatrix()

				glColor4ub(255,255,255,255)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, 18, 0)
			glPopMatrix()
示例#3
0
    def draw(self):
        if self._hidden:
            return

        cx = (self._imageID % 4) / 4
        cy = int(self._imageID / 4) / 4
        bs = self.getMinSize()[0]
        pos = self._getPixelPos()

        glBindTexture(GL_TEXTURE_2D, self._base._glButtonsTexture)
        scale = 0.8
        if self._selected:
            scale = 1.0
        elif self._focus:
            scale = 0.9
        if self._disabled:
            glColor4ub(128, 128, 128, 128)
        else:
            glColor4ub(255, 255, 255, 255)
        openglHelpers.glDrawTexturedQuad(pos[0] - bs * scale / 2,
                                         pos[1] - bs * scale / 2, bs * scale,
                                         bs * scale, 1)
        openglHelpers.glDrawTexturedQuad(pos[0] - bs * scale / 2,
                                         pos[1] - bs * scale / 2, bs * scale,
                                         bs * scale, self._imageID)
        if self._showExpandArrow:
            if self._selected:
                openglHelpers.glDrawTexturedQuad(
                    pos[0] + bs * scale / 2 - bs * scale / 4 * 1.2,
                    pos[1] - bs * scale / 2 * 1.2, bs * scale / 4,
                    bs * scale / 4, 1)
            else:
                openglHelpers.glDrawTexturedQuad(
                    pos[0] + bs * scale / 2 - bs * scale / 4 * 1.2,
                    pos[1] - bs * scale / 2 * 1.2, bs * scale / 4,
                    bs * scale / 4, 1, 2)
        glPushMatrix()
        glTranslatef(pos[0], pos[1], 0)
        glDisable(GL_TEXTURE_2D)
        if self._focus:
            glTranslatef(0, -0.55 * bs * scale, 0)

            glPushMatrix()
            glColor4ub(150, 0, 0, 10)
            glTranslatef(-1, -1, 0)
            openglHelpers.glDrawStringCenter(self._tooltip)
            glTranslatef(0, 2, 0)
            openglHelpers.glDrawStringCenter(self._tooltip)
            glTranslatef(2, 0, 0)
            openglHelpers.glDrawStringCenter(self._tooltip)
            glTranslatef(0, -2, 0)
            openglHelpers.glDrawStringCenter(self._tooltip)
            glPopMatrix()

            glColor4ub(10, 10, 10, 255)
            openglHelpers.glDrawStringCenter(self._tooltip)
        glPopMatrix()
        progress = self._progressBar
        if progress is not None:
            glColor4ub(60, 60, 60, 255)
            openglHelpers.glDrawQuad(pos[0] - bs / 2, pos[1] + bs / 2, bs,
                                     bs / 4)
            glColor4ub(255, 255, 255, 255)
            openglHelpers.glDrawQuad(pos[0] - bs / 2 + 2, pos[1] + bs / 2 + 2,
                                     (bs - 5) * progress + 1, bs / 4 - 4)
        elif len(self._altTooltip) > 0:
            glPushMatrix()
            glTranslatef(pos[0], pos[1], 0)
            glTranslatef(0, 0.6 * bs, 0)
            glTranslatef(0, 6, 0)
            #glTranslatef(0.6*bs*scale, 0, 0)

            for line in self._altTooltip.split('\n'):
                glPushMatrix()
                glColor4ub(60, 60, 60, 255)
                glTranslatef(-1, -1, 0)
                openglHelpers.glDrawStringCenter(line)
                glTranslatef(0, 2, 0)
                openglHelpers.glDrawStringCenter(line)
                glTranslatef(2, 0, 0)
                openglHelpers.glDrawStringCenter(line)
                glTranslatef(0, -2, 0)
                openglHelpers.glDrawStringCenter(line)
                glPopMatrix()

                glColor4ub(255, 255, 255, 255)
                openglHelpers.glDrawStringCenter(line)
                glTranslatef(0, 18, 0)
            glPopMatrix()
示例#4
0
	def draw(self):
		# if self._hidden: #Comment by dagoma
		# 	return
		try :

			cx = (self._imageID % 4) / 4
			cy = int(self._imageID / 4) / 4
		except :
			pass
		bs = self.getMinSize()[0]
		pos = self._getPixelPos()

		glBindTexture(GL_TEXTURE_2D, self._base._glButtonsTexture)
		scale = 0.8
		if self._selected:
			scale = 1.0
		elif self._focus:
			scale = 0.9
		if self._disabled:
			glColor4ub(128,128,128,128)
		else:
			glColor4ub(255,255,255,255)
		openglHelpers.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, 0)
		try :
			openglHelpers.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, self._imageID)
		except :
			pass
		if self._showExpandArrow:
			if self._selected:
				openglHelpers.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1)
			else:
				openglHelpers.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1, 2)
		glPushMatrix()
		glTranslatef(pos[0], pos[1], 0)
		glDisable(GL_TEXTURE_2D)
		if self._focus:
			glTranslatef(0, -0.55*bs*scale, 0)

			glPushMatrix()
			glColor4ub(60,60,60,255)
			glTranslatef(-1, -1, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(0, 2, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(2, 0, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glTranslatef(0, -2, 0)
			openglHelpers.glDrawStringCenter(self._tooltip)
			glPopMatrix()

			glColor4ub(255,255,255,255)
			openglHelpers.glDrawStringCenter(self._tooltip)
		glPopMatrix()
		progress = self._progressBar
		if progress is not None:
			bs = 64 #Add by dagoma
			glColor4ub(60,60,60,255)
			openglHelpers.glDrawQuad(pos[0]-bs/2, pos[1]+bs/2, bs, bs / 4)
			glColor4ub(255,255,255,255)
			openglHelpers.glDrawQuad(pos[0]-bs/2+2, pos[1]+bs/2+2, (bs - 5) * progress + 1, bs / 4 - 4)
		elif len(self._altTooltip) > 0:
			glPushMatrix()
			glTranslatef(pos[0], pos[1], 0)
			split_tooltip = self._altTooltip.split('\n')
			if self._imageID is None:
				max_line = ''
				for line in split_tooltip:
					if len(line) > len(max_line):
						max_line = line
				#print self._base._buttonSize
				tooltip_translate_x = (self._base._buttonSize - openglHelpers.glGetStringSize(max_line)[0]) / 2
				tooltip_translate_y = 0
				if not self._base._buttonSize == 32:
					tooltip_translate_y = self._base._buttonSize - (len(split_tooltip) + 1) * 18 + (6 - self._base._buttonSize / 16) * 4
				elif len(split_tooltip) > 2:
					tooltip_translate_y = - 18 * (len(split_tooltip) - 2) - 4
				else:
					tooltip_translate_y = -4
				glTranslatef(tooltip_translate_x, tooltip_translate_y, 0)
				#glTranslatef(0.6*bs*scale, 0, 0)
			else:
				glTranslatef(0, 0.6*bs, 0)
				glTranslatef(0, 6, 0)
				#glTranslatef(0.6*bs*scale, 0, 0)

			for line in split_tooltip:
				glPushMatrix()
				glColor4ub(60,60,60,255)
				glTranslatef(-1, -1, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, 2, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(2, 0, 0)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, -2, 0)
				openglHelpers.glDrawStringCenter(line)
				glPopMatrix()

				glColor4ub(255,255,255,255)
				openglHelpers.glDrawStringCenter(line)
				glTranslatef(0, 18, 0)
			glPopMatrix()