def build_display_list(self): if not self.lit: opengl.glDisable(opengl.GL_LIGHTING) opengl.glColor4f(*self._color) opengl.glScalef(self._size, -self._size, 1.0) w, h = self._font.get_print_size(self._text) if self.center_x == 0: opengl.glTranslatef(-w / 2.0, 0.0, 0.0) elif self.center_x == 1: opengl.glTranslatef(-w, 0.0, 0.0) if self.center_y == 0: opengl.glTranslatef(0.0, -h / 2.0, 0.0) elif self.center_y == 1: opengl.glTranslatef(0.0, -h, 0.0) if self._auto_flip: opengl.glEnable(opengl.GL_CULL_FACE) self._font.draw(self._text, 0.0, 0.0, 0.0, 1) opengl.glTranslatef(w, 0.0, 0.0) opengl.glScalef(-1.0, 1.0, 1.0) self._font.draw(self._text, 0.0, 0.0, 0.0, 1) opengl.glDisable(opengl.GL_CULL_FACE) else: self._font.draw(self._text, 0.0, 0.0, 0.0) opengl.glEnable(opengl.GL_BLEND) # Font.draw calls glDisable(GL_BLEND) if not self.lit: opengl.glEnable(opengl.GL_LIGHTING)
def activated(self): f1 = self.amplitude * (math.cos(self.angle) + 1.0) f2 = 1.0 - 2.0 * f1 opengl.glMatrixMode(opengl.GL_TEXTURE) opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called opengl.glTranslatef(f1, f1, 0.0) opengl.glScalef(f2, f2, 1.0) opengl.glMatrixMode(opengl.GL_MODELVIEW)
def render(self): if self.tree.render_y >= self.tree.render_y2: return if self.tree.render_y >= self.tree.render_y1 - self.height: if self.selected: soya.gui.widgets.STYLE.rectangle(-1, -1, self.tree.visible_width, self.height - 3, self.highlight or self.tree.focus) if soya.gui.widgets.STYLE.char_height < self.icon_height: y0 = (self.icon_height - soya.gui.widgets.STYLE.char_height) // 2 else: y0 = 0 if self.is_expandable(): if self.expanded: soya.gui.widgets.STYLE.triangle(3, self.x, y0, self.x + soya.gui.widgets.STYLE.char_height, y0 + soya.gui.widgets.STYLE.char_height, self.highlight) else: soya.gui.widgets.STYLE.triangle(1, self.x, y0, self.x + soya.gui.widgets.STYLE.char_height, y0 + soya.gui.widgets.STYLE.char_height, self.highlight) if self.material: x1 = self.x + soya.gui.widgets.STYLE.char_height + 4 x2 = x1 + self.icon_width self.material.activate() if self.material.is_alpha(): opengl.glEnable(opengl.GL_BLEND) opengl.glBegin (opengl.GL_QUADS) opengl.glTexCoord2f(0.0, 0.0); opengl.glVertex2i(x1, 0) opengl.glTexCoord2f(0.0, 1.0); opengl.glVertex2i(x1, self.icon_height) opengl.glTexCoord2f(1.0, 1.0); opengl.glVertex2i(x2, self.icon_height) opengl.glTexCoord2f(1.0, 0.0); opengl.glVertex2i(x2, 0) opengl.glEnd() soya.DEFAULT_MATERIAL.activate() opengl.glColor4f(*soya.gui.widgets.STYLE.text_colors[self.highlight]) if self.changed != self.tree.font._pixels_height: self.tree.font.create_glyphs(self.text) opengl.glNewList(self._display_list.id, opengl.GL_COMPILE_AND_EXECUTE) self.tree.font.draw(self.text, self.x + soya.gui.widgets.STYLE.char_height + 8 + self.icon_width, y0) opengl.glEndList() self._changed = self.tree.font._pixels_height else: opengl.glCallList(self._display_list.id) self.tree.render_y += self.height opengl.glTranslatef(0.0, self.height, 0.0) if self.expanded: for child in self.children: child.render()
def render(self): if self._init_walk(): opengl.glPushMatrix() opengl.glTranslatef(self.x + 2, self.y + 2, 0.0) self.node.render() opengl.glPopMatrix()
def activated(self): opengl.glMatrixMode(opengl.GL_TEXTURE) opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called opengl.glTranslatef(self.amplitude * math.cos(self._angle), self.amplitude * math.sin(self._angle), 0.0) opengl.glMatrixMode(opengl.GL_MODELVIEW)
def activated(self): opengl.glMatrixMode(opengl.GL_TEXTURE) opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called opengl.glTranslatef(self._tex_x, self._tex_y, 0.0) opengl.glMatrixMode(opengl.GL_MODELVIEW)