← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/cleanups into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/cleanups into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Add option the the Theme handing to allow the size of the shadow and outline to be changed within a theme.
Themes will default to current values so no change
-- 
https://code.launchpad.net/~trb143/openlp/cleanups/+merge/16217
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2009-12-14 16:55:58 +0000
+++ openlp/core/lib/renderer.py	2009-12-15 20:40:30 +0000
@@ -43,9 +43,8 @@
         self._rect = None
         self._debug = 0
         self._right_margin = 64 # the amount of right indent
-        self._shadow_offset = 5
-        self._shadow_offset_footer = 3
-        self._outline_offset = 2
+        self._display_shadow_size_footer = 0
+        self._display_outline_size_footer = 0
         self.theme_name = None
         self._theme = None
         self._bg_image_filename = None
@@ -426,23 +425,25 @@
         # dont allow alignment messing with footers
         if footer:
             align = 0
-            shadow_offset = self._shadow_offset_footer
+            display_shadow_size = self._display_shadow_size_footer
+            display_outline_size = self._display_outline_size_footer
         else:
             align = self._theme.display_horizontalAlign
-            shadow_offset = self._shadow_offset
+            display_shadow_size = int(self._theme.display_shadow_size)
+            display_outline_size = int(self._theme.display_outline_size)
         for linenum in range(len(lines)):
             line = lines[linenum]
             #find out how wide line is
             w, h = self._get_extent_and_render(line, footer, tlcorner=(x, y),
                 draw=False)
             if self._theme.display_shadow:
-                w += shadow_offset
-                h += shadow_offset
+                w += display_shadow_size
+                h += display_shadow_size
             if self._theme.display_outline:
                 # pixels either side
-                w += 2 * self._outline_offset
+                w += 2 * display_outline_size
                 #  pixels top/bottom
-                h += 2 * self._outline_offset
+                h += 2 * display_outline_size
             if align == 0: # left align
                 rightextent = x + w
                 # shift right from last line's rh edge
@@ -464,36 +465,36 @@
                 # now draw the text, and any outlines/shadows
                 if self._theme.display_shadow:
                     self._get_extent_and_render(line, footer,
-                        tlcorner=(x + shadow_offset, y + shadow_offset),
+                        tlcorner=(x + display_shadow_size, y + display_shadow_size),
                         draw=True, color = self._theme.display_shadow_color)
                 if self._theme.display_outline:
                     self._get_extent_and_render(line, footer,
-                        (x + self._outline_offset, y), draw=True,
-                        color = self._theme.display_outline_color)
-                    self._get_extent_and_render(line, footer,
-                        (x, y + self._outline_offset), draw=True,
-                        color = self._theme.display_outline_color)
-                    self._get_extent_and_render(line, footer,
-                        (x, y - self._outline_offset), draw=True,
-                        color = self._theme.display_outline_color)
-                    self._get_extent_and_render(line, footer,
-                        (x - self._outline_offset, y), draw=True,
-                        color = self._theme.display_outline_color)
-                    if self._outline_offset > 1:
-                        self._get_extent_and_render(line, footer,
-                            (x + self._outline_offset, y + self._outline_offset),
-                            draw=True,
-                            color = self._theme.display_outline_color)
-                        self._get_extent_and_render(line, footer,
-                            (x - self._outline_offset, y + self._outline_offset),
-                            draw=True,
-                            color = self._theme.display_outline_color)
-                        self._get_extent_and_render(line, footer,
-                            (x + self._outline_offset, y - self._outline_offset),
-                            draw=True,
-                            color = self._theme.display_outline_color)
-                        self._get_extent_and_render(line, footer,
-                            (x - self._outline_offset, y - self._outline_offset),
+                        (x + display_outline_size, y), draw=True,
+                        color = self._theme.display_outline_color)
+                    self._get_extent_and_render(line, footer,
+                        (x, y + display_outline_size), draw=True,
+                        color = self._theme.display_outline_color)
+                    self._get_extent_and_render(line, footer,
+                        (x, y - display_outline_size), draw=True,
+                        color = self._theme.display_outline_color)
+                    self._get_extent_and_render(line, footer,
+                        (x - display_outline_size, y), draw=True,
+                        color = self._theme.display_outline_color)
+                    if display_outline_size > 1:
+                        self._get_extent_and_render(line, footer,
+                            (x + display_outline_size, y + display_outline_size),
+                            draw=True,
+                            color = self._theme.display_outline_color)
+                        self._get_extent_and_render(line, footer,
+                            (x - display_outline_size, y + display_outline_size),
+                            draw=True,
+                            color = self._theme.display_outline_color)
+                        self._get_extent_and_render(line, footer,
+                            (x + display_outline_size, y - display_outline_size),
+                            draw=True,
+                            color = self._theme.display_outline_color)
+                        self._get_extent_and_render(line, footer,
+                            (x - display_outline_size, y - display_outline_size),
                             draw=True,
                             color = self._theme.display_outline_color)
                 self._get_extent_and_render(line, footer,tlcorner=(x, y),

=== modified file 'openlp/core/lib/themexmlhandler.py'
--- openlp/core/lib/themexmlhandler.py	2009-12-09 17:09:45 +0000
+++ openlp/core/lib/themexmlhandler.py	2009-12-15 20:40:30 +0000
@@ -65,8 +65,8 @@
       <location override="False" x="10" y="730" width="1024" height="38"/>
    </font>
    <display>
-      <shadow color="#000000">True</shadow>
-      <outline color="#000000">False</outline>
+      <shadow color="#000000" size="5">True</shadow>
+      <outline color="#000000" size="2">False</outline>
       <horizontalAlign>0</horizontalAlign>
       <verticalAlign>0</verticalAlign>
       <wrapStyle>0</wrapStyle>
@@ -238,7 +238,7 @@
         background.appendChild(element)
 
     def add_display(self, shadow, shadow_color, outline, outline_color,
-        horizontal, vertical, wrap, transition):
+        horizontal, vertical, wrap, transition, shadow_pixel=5, outline_pixel=2):
         """
         Add a Display options.
 
@@ -272,12 +272,14 @@
         # Shadow
         element = self.theme_xml.createElement(u'shadow')
         element.setAttribute(u'color', shadow_color)
+        element.setAttribute(u'size', unicode(shadow_pixel))
         value = self.theme_xml.createTextNode(shadow)
         element.appendChild(value)
         background.appendChild(element)
         # Outline
         element = self.theme_xml.createElement(u'outline')
         element.setAttribute(u'color', outline_color)
+        element.setAttribute(u'size', unicode(outline_pixel))
         value = self.theme_xml.createTextNode(outline)
         element.appendChild(value)
         background.appendChild(element)

=== modified file 'openlp/core/ui/amendthemedialog.py'
--- openlp/core/ui/amendthemedialog.py	2009-12-08 17:52:45 +0000
+++ openlp/core/ui/amendthemedialog.py	2009-12-15 20:40:30 +0000
@@ -410,13 +410,13 @@
         self.OptionsLeftLayout.setSpacing(8)
         self.OptionsLeftLayout.setMargin(0)
         self.OptionsLeftLayout.setObjectName(u'OptionsLeftLayout')
-        self.ShadowGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
-        self.ShadowGroupBox.setObjectName(u'ShadowGroupBox')
-        self.verticalLayout = QtGui.QVBoxLayout(self.ShadowGroupBox)
+        self.OutlineGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
+        self.OutlineGroupBox.setObjectName(u'OutlineGroupBox')
+        self.verticalLayout = QtGui.QVBoxLayout(self.OutlineGroupBox)
         self.verticalLayout.setSpacing(8)
         self.verticalLayout.setMargin(8)
         self.verticalLayout.setObjectName(u'verticalLayout')
-        self.OutlineWidget = QtGui.QWidget(self.ShadowGroupBox)
+        self.OutlineWidget = QtGui.QWidget(self.OutlineGroupBox)
         self.OutlineWidget.setObjectName(u'OutlineWidget')
         self.OutlineLayout = QtGui.QFormLayout(self.OutlineWidget)
         self.OutlineLayout.setMargin(0)
@@ -425,16 +425,30 @@
         self.OutlineCheckBox = QtGui.QCheckBox(self.OutlineWidget)
         self.OutlineCheckBox.setObjectName(u'OutlineCheckBox')
         self.OutlineLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.OutlineCheckBox)
+        self.OutlineSpinBox = QtGui.QSpinBox(self.OutlineWidget)
+        self.OutlineSpinBox.setObjectName("OutlineSpinBox")
+        self.OutlineSpinBox.setMaximum(10)
+        self.OutlineLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.OutlineSpinBox)
+        self.OutlineSpinBoxLabel = QtGui.QLabel(self.OutlineWidget)
+        self.OutlineSpinBoxLabel.setObjectName(u'OutlineSpinBoxLabel')
+        self.OutlineLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.OutlineSpinBoxLabel)
         self.OutlineColorLabel = QtGui.QLabel(self.OutlineWidget)
         self.OutlineColorLabel.setObjectName(u'OutlineColorLabel')
-        self.OutlineLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.OutlineColorLabel)
+        self.OutlineLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.OutlineColorLabel)
         self.OutlineColorPushButton = QtGui.QPushButton(self.OutlineWidget)
         self.OutlineColorPushButton.setObjectName(u'OutlineColorPushButton')
-        self.OutlineLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.OutlineColorPushButton)
+        self.OutlineLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.OutlineColorPushButton)
         self.OutlineEnabledLabel = QtGui.QLabel(self.OutlineWidget)
         self.OutlineEnabledLabel.setObjectName(u'OutlineEnabledLabel')
         self.OutlineLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.OutlineEnabledLabel)
         self.verticalLayout.addWidget(self.OutlineWidget)
+        self.OptionsLeftLayout.addWidget(self.OutlineGroupBox)
+        self.ShadowGroupBox = QtGui.QGroupBox(self.OptionsLeftWidget)
+        self.ShadowGroupBox.setObjectName(u'ShadowGroupBox')
+        self.verticalLayout = QtGui.QVBoxLayout(self.ShadowGroupBox)
+        self.verticalLayout.setSpacing(8)
+        self.verticalLayout.setMargin(8)
+        self.verticalLayout.setObjectName(u'verticalLayout')
         self.ShadowWidget = QtGui.QWidget(self.ShadowGroupBox)
         self.ShadowWidget.setObjectName(u'ShadowWidget')
         self.ShadowLayout = QtGui.QFormLayout(self.ShadowWidget)
@@ -444,12 +458,19 @@
         self.ShadowCheckBox = QtGui.QCheckBox(self.ShadowWidget)
         self.ShadowCheckBox.setObjectName(u'ShadowCheckBox')
         self.ShadowLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.ShadowCheckBox)
+        self.ShadowSpinBox = QtGui.QSpinBox(self.OutlineWidget)
+        self.ShadowSpinBox.setObjectName("ShadowSpinBox")
+        self.ShadowSpinBox.setMaximum(10)
+        self.ShadowLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ShadowSpinBox)
+        self.ShadowSpinBoxLabel = QtGui.QLabel(self.OutlineWidget)
+        self.ShadowSpinBoxLabel.setObjectName(u'ShadowSpinBoxLabel')
+        self.ShadowLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.ShadowSpinBoxLabel)
         self.ShadowColorLabel = QtGui.QLabel(self.ShadowWidget)
         self.ShadowColorLabel.setObjectName(u'ShadowColorLabel')
-        self.ShadowLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.ShadowColorLabel)
+        self.ShadowLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.ShadowColorLabel)
         self.ShadowColorPushButton = QtGui.QPushButton(self.ShadowWidget)
         self.ShadowColorPushButton.setObjectName(u'ShadowColorPushButton')
-        self.ShadowLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ShadowColorPushButton)
+        self.ShadowLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.ShadowColorPushButton)
         self.ShadowEnabledLabel = QtGui.QLabel(self.ShadowWidget)
         self.ShadowEnabledLabel.setObjectName(u'ShadowEnabledLabel')
         self.ShadowLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ShadowEnabledLabel)
@@ -640,9 +661,14 @@
         self.ThemeTabWidget.setTabText(
             self.ThemeTabWidget.indexOf(self.FontFooterTab),
             self.trUtf8('Font Footer'))
-        self.ShadowGroupBox.setTitle(self.trUtf8('Shadow && Outline'))
+        self.OutlineGroupBox.setTitle(self.trUtf8('Outline'))
+        self.OutlineSpinBoxLabel.setText(self.trUtf8('Outline Size:'))
+        self.OutlineSpinBox.setSuffix(self.trUtf8('px'))
         self.OutlineColorLabel.setText(self.trUtf8('Outline Color:'))
         self.OutlineEnabledLabel.setText(self.trUtf8('Show Outline:'))
+        self.ShadowGroupBox.setTitle(self.trUtf8('Shadow'))
+        self.ShadowSpinBoxLabel.setText(self.trUtf8('Shadow Size:'))
+        self.ShadowSpinBox.setSuffix(self.trUtf8('px'))
         self.ShadowColorLabel.setText(self.trUtf8('Shadow Color:'))
         self.ShadowEnabledLabel.setText(self.trUtf8('Show Shadow:'))
         self.AlignmentGroupBox.setTitle(self.trUtf8('Alignment'))

=== modified file 'openlp/core/ui/amendthemeform.py'
--- openlp/core/ui/amendthemeform.py	2009-12-09 17:09:45 +0000
+++ openlp/core/ui/amendthemeform.py	2009-12-15 20:40:30 +0000
@@ -121,8 +121,14 @@
             self.onFontFooterHeightSpinBoxChanged)
         QtCore.QObject.connect(self.OutlineCheckBox,
             QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged)
+        QtCore.QObject.connect(self.ShadowSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.onShadowSpinBoxChanged)
         QtCore.QObject.connect(self.ShadowCheckBox,
             QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged)
+        QtCore.QObject.connect(self.OutlineSpinBox,
+            QtCore.SIGNAL(u'editingFinished()'),
+            self.onOutlineSpinBoxChanged)
         QtCore.QObject.connect(self.SlideTransitionCheckedBox,
             QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTransitionCheckedBoxChanged)
 
@@ -179,7 +185,9 @@
                 unicode(self.theme.display_horizontalAlign),
                 unicode(self.theme.display_verticalAlign),
                 unicode(self.theme.display_wrapStyle),
-                unicode(self.theme.display_slideTransition))
+                unicode(self.theme.display_slideTransition),
+                unicode(self.theme.display_shadow_size),
+                unicode(self.theme.display_outline_size))
         theme = new_theme.extract_xml()
         pretty_theme = new_theme.extract_formatted_xml()
         if self.thememanager.saveTheme(theme_name, theme, pretty_theme,
@@ -434,6 +442,16 @@
         self.stateChanging(self.theme)
         self.previewTheme()
 
+    def onOutlineSpinBoxChanged(self):
+        if self.theme.display_outline_size != self.OutlineSpinBox.value():
+            self.theme.display_outline_size = self.OutlineSpinBox.value()
+            self.previewTheme()
+
+    def onShadowSpinBoxChanged(self):
+        if self.theme.display_shadow_size != self.ShadowSpinBox.value():
+            self.theme.display_shadow_size = self.ShadowSpinBox.value()
+            self.previewTheme()
+
     def onOutlineColorPushButtonClicked(self):
         self.theme.display_outline_color = QtGui.QColorDialog.getColor(
             QtGui.QColor(self.theme.display_outline_color), self).name()
@@ -565,6 +583,7 @@
         else:
             self.OutlineCheckBox.setChecked(False)
             self.OutlineColorPushButton.setEnabled(False)
+        self.OutlineSpinBox.setValue(int(self.theme.display_outline_size))
 
         if self.theme.display_shadow:
             self.ShadowCheckBox.setChecked(True)
@@ -572,6 +591,7 @@
         else:
             self.ShadowCheckBox.setChecked(False)
             self.ShadowColorPushButton.setEnabled(False)
+        self.ShadowSpinBox.setValue(int(self.theme.display_shadow_size))
 
         if self.theme.display_slideTransition:
             self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Checked)


Follow ups