Skip to content

Commit

Permalink
Merge pull request #1135 from chaosphere2112/text_rot_workaround
Browse files Browse the repository at this point in the history
Workaround for #1093
  • Loading branch information
doutriaux1 committed Mar 24, 2015
2 parents f084cab + 7042f6a commit e0b80a1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 50 deletions.
16 changes: 16 additions & 0 deletions Packages/vcs/Lib/editors/font.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import vcs

class FontEditor(object):
def __init__(self, toolbar, font_setter, current_font="default"):

self.toolbar = toolbar
self.set_font = font_setter

self.fonts = sorted(vcs.elements["font"].keys())

self.font_button = self.toolbar.add_button(self.fonts, action=self.font_state)
self.font_button.set_state(self.fonts.index(current_font))

def font_state(self, state):
font = self.fonts[state]
self.set_font(font)
27 changes: 2 additions & 25 deletions Packages/vcs/Lib/editors/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import text
#import vtk
import vcs.vcs2vtk
from functools import partial
from font import FontEditor

__valign_map__ = {
0: 0,
Expand Down Expand Up @@ -63,27 +63,8 @@ def __init__(self, interactor, label, dp, configurator):
valign.set_state(__valign_map__[self.to.valign])

self.angle_button = self.toolbar.add_slider_button(self.to.angle, 0, 360, "Angle", update=self.update_angle)
self.fonts = sorted(vcs.elements["font"].keys())

font_toolbar = self.toolbar.add_toolbar("Fonts")

self.font_buttons = {}

def font_setter(font):
return partial(self.set_font, font)

deactivate = font_setter("default")

for ind, font in enumerate(self.fonts):

if font[:4] != "Math":
button = font_toolbar.add_toggle_button(font, on=font_setter(font), off=deactivate, font=vcs.elements["font"][font])
else:
button = font_toolbar.add_toggle_button(font, on=font_setter(font), off=deactivate)

if vcs.elements["fontNumber"][self.tt.font] == font:
button.set_state(1)
self.font_buttons[font] = button
font_editor = FontEditor(self.toolbar, self.set_font, vcs.elements["fontNumber"][self.tt.font])

self.picker = None
self.toolbar.add_button(["Change Color"], action=self.change_color)
Expand All @@ -105,11 +86,7 @@ def sync_actor(self):
vcs.vcs2vtk.prepTextProperty(p,winSize,to=self.to,tt=self.tt,cmap=None)

def set_font(self, font):
current_font = vcs.getfontname(self.tt.font)
if font != current_font:
self.font_buttons[current_font].set_state(0)
self.tt.font = font
self.font_buttons[font].set_state(1)
self.save()

def halign(self, state):
Expand Down
27 changes: 2 additions & 25 deletions Packages/vcs/Lib/editors/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import priority
import vcs
from vcs.vcs2vtk import genTextActor
from functools import partial
from font import FontEditor

__valign_map__ = {
0: 0,
Expand Down Expand Up @@ -47,27 +47,8 @@ def __init__(self, interactor, text, index, dp, configurator):
valign.set_state(__valign_map__[self.text.valign])

self.toolbar.add_slider_button(text.angle, 0, 360, "Angle", update=self.update_angle)
self.fonts = sorted(vcs.elements["font"].keys())

font_toolbar = self.toolbar.add_toolbar("Fonts")

self.font_buttons = {}

def font_setter(font):
return partial(self.set_font, font)

deactivate = font_setter("default")

for ind, font in enumerate(self.fonts):

if font[:4] != "Math":
button = font_toolbar.add_toggle_button(font, on=font_setter(font), off=deactivate, font=vcs.elements["font"][font])
else:
button = font_toolbar.add_toggle_button(font, on=font_setter(font), off=deactivate)

if vcs.elements["fontNumber"][self.text.font] == font:
button.set_state(1)
self.font_buttons[font] = button
font_editor = FontEditor(self.toolbar, self.set_font, vcs.elements["fontNumber"][self.text.font])

self.picker = None
self.toolbar.add_button(["Change Color"], action=self.change_color)
Expand All @@ -86,11 +67,7 @@ def font_setter(font):
self.update()

def set_font(self, font):
current_font = vcs.getfontname(self.text.font)
if font != current_font:
self.font_buttons[current_font].set_state(0)
self.text.font = font
self.font_buttons[font].set_state(1)
self.update()

def get_object(self):
Expand Down

0 comments on commit e0b80a1

Please sign in to comment.