Add option for Center Tab

These changes addresses issue #68
This commit is contained in:
Wendel Voigt 2016-07-11 18:15:08 -05:00
parent 5d3fb7589e
commit 48c6ee0def
2 changed files with 12 additions and 13 deletions

View File

@ -13,7 +13,7 @@ from draw import DividerDrawer
LOCATION_CHOICES = ["tab", "body-top", "hide"]
NAME_ALIGN_CHOICES = ["left", "right", "centre", "edge"]
TAB_SIDE_CHOICES = ["left", "right", "left-alternate", "right-alternate",
"full"]
"centre", "full"]
TEXT_CHOICES = ["card", "rules", "blank"]
@ -101,6 +101,7 @@ def parse_opts(arglist):
" left/right forces all tabs to left/right side;"
" left-alternate will start on the left and then toggle between left and right for the tabs;"
" right-alternate will start on the right and then toggle between right and left for the tabs;" # noqa
" centre will force all label tabs to the centre;"
" full will force all label tabs to be full width of the divider"
" default:right-alternate")
parser.add_argument(

View File

@ -42,7 +42,10 @@ class DividerDrawer(object):
self.fontNameBold = 'Times-Bold'
self.fontNameOblique = 'Times-Oblique'
def getOutline(self, card, isExpansionDivider=False):
def wantCentreTab(self,card):
return (card.isExpansion() and self.options.centre_expansion_dividers) or self.options.tab_side == "centre"
def getOutline(self, card):
dividerWidth = self.options.dividerWidth
dividerHeight = self.options.dividerHeight
@ -55,7 +58,7 @@ class DividerDrawer(object):
theTabHeight = dividerHeight - dividerBaseHeight
theTabWidth = self.options.labelWidth
if isExpansionDivider:
if self.wantCentreTab(card):
side_2_tab = (dividerWidth - theTabWidth) / 2
else:
side_2_tab = 0
@ -231,8 +234,7 @@ class DividerDrawer(object):
x,
y,
rightSide,
isBack=False,
isExpansionDivider=False):
isBack=False):
# draw outline or cropmarks
self.canvas.saveState()
self.canvas.setLineWidth(self.options.linewidth)
@ -244,9 +246,6 @@ class DividerDrawer(object):
if not self.options.cropmarks and not isBack:
# don't draw outline on back, in case lines don't line up with
# front
if isExpansionDivider and self.options.centre_expansion_dividers:
self.getOutline(card, isExpansionDivider=True)
else:
self.getOutline(card)
elif self.options.cropmarks and not self.options.wrapper:
@ -414,7 +413,7 @@ class DividerDrawer(object):
def drawTab(self, card, rightSide, wrapper="no"):
# draw tab flap
self.canvas.saveState()
if card.isExpansion() and self.options.centre_expansion_dividers:
if self.wantCentreTab(card):
translate_x = self.options.dividerWidth / 2 - self.options.labelWidth / 2
translate_y = self.options.dividerHeight - self.options.labelHeight
elif not rightSide:
@ -426,7 +425,7 @@ class DividerDrawer(object):
if wrapper == "back":
translate_y = self.options.labelHeight
if card.isExpansion() and self.options.centre_expansion_dividers:
if self.wantCentreTab(card):
translate_x = self.options.dividerWidth / 2 + self.options.labelWidth / 2
elif not rightSide:
translate_x = self.options.dividerWidth
@ -736,8 +735,7 @@ class DividerDrawer(object):
# actual drawing
if not self.options.tabs_only:
self.drawOutline(card, x, y, rightSide, isBack,
card.getType().getTypeNames() == ('Expansion', ))
self.drawOutline(card, x, y, rightSide, isBack)
if self.options.wrapper:
wrap = "front"