From ecf392968beecb370c31bc570a3127732cff9465 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 28 Jul 2008 23:45:20 +0100 Subject: [PATCH] Implemented new icon workflow --- .../{ => prerendered/16x16}/assets-panel.png | Bin .../16x16}/timeline-panel.png | Bin .../{ => prerendered/16x16}/viewer-panel.png | Bin icons/render-icons.py | 127 +++ icons/svg/arrow.svg | 732 ++++++++++++++++++ icons/svg/i-beam.svg | 690 +++++++++++++++++ src/gui/Makefile.am | 24 +- 7 files changed, 1561 insertions(+), 12 deletions(-) rename icons/{ => prerendered/16x16}/assets-panel.png (100%) rename icons/{ => prerendered/16x16}/timeline-panel.png (100%) rename icons/{ => prerendered/16x16}/viewer-panel.png (100%) create mode 100755 icons/render-icons.py create mode 100644 icons/svg/arrow.svg create mode 100644 icons/svg/i-beam.svg diff --git a/icons/assets-panel.png b/icons/prerendered/16x16/assets-panel.png similarity index 100% rename from icons/assets-panel.png rename to icons/prerendered/16x16/assets-panel.png diff --git a/icons/timeline-panel.png b/icons/prerendered/16x16/timeline-panel.png similarity index 100% rename from icons/timeline-panel.png rename to icons/prerendered/16x16/timeline-panel.png diff --git a/icons/viewer-panel.png b/icons/prerendered/16x16/viewer-panel.png similarity index 100% rename from icons/viewer-panel.png rename to icons/prerendered/16x16/viewer-panel.png diff --git a/icons/render-icons.py b/icons/render-icons.py new file mode 100755 index 000000000..4ebbd3fc4 --- /dev/null +++ b/icons/render-icons.py @@ -0,0 +1,127 @@ +#!/usr/bin/python + +# render-icons.py - Icon rendering utility script +# +# Copyright (C) Lumiera.org +# 2008, Joel Holdsworth +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +from xml.dom import minidom +import os +import shutil + +svgDir = "svg" +prerenderedDir = "prerendered" +inkscapePath = "/usr/bin/inkscape" +artworkLayerPrefix = "artwork:" + +def createDirectory( name ): + if os.path.exists(name) == False: + os.mkdir(name) + +def copyMergeDirectory( src, dst ): + listing = os.listdir(src) + for file_name in listing: + src_file_path = os.path.join(src, file_name) + dst_file_path = os.path.join(dst, file_name) + shutil.copyfile(src_file_path, dst_file_path) + +def getDocumentSize( svg_element ): + width = float(svg_element.getAttribute("width")) + height = float(svg_element.getAttribute("height")) + return [width, height] + +def findChildLayerElement( parent_element ): + for node in parent_element.childNodes: + if node.nodeType == minidom.Node.ELEMENT_NODE: + if node.tagName == "g": + if node.getAttribute("inkscape:groupmode") == "layer": + return node + return None + +def parsePlateLayer( layer ): + rectangles = [] + for node in layer.childNodes: + if node.nodeType == minidom.Node.ELEMENT_NODE: + if node.tagName == "rect": + x = float(node.getAttribute("x")) + y = float(node.getAttribute("y")) + width = float(node.getAttribute("width")) + height = float(node.getAttribute("height")) + rectangles.append([x, y, width, height]) + return rectangles + + +def parseSVG( file_path ): + print "Rendering " + file_path + svgdoc = minidom.parse(file_path) + for root_node in svgdoc.childNodes: + if root_node.nodeType == minidom.Node.ELEMENT_NODE: + if root_node.tagName == "svg": + size = getDocumentSize( root_node ) + layer = findChildLayerElement( root_node ) + if layer != None: + layer_name = layer.getAttribute("inkscape:label") + if layer_name[:len(artworkLayerPrefix)] == artworkLayerPrefix: + artwork_name = layer_name[len(artworkLayerPrefix):] + plate = findChildLayerElement( layer ) + if plate != None: + return artwork_name, size, parsePlateLayer( plate ) + return None + +def renderSVGIcons(): + listing = os.listdir(svgDir) + for file_path in listing: + [root, extension] = os.path.splitext(file_path) + if extension.lower() == ".svg": + file_path = os.path.join(svgDir, file_path) + artwork_name, doc_size, rectangles = parseSVG(file_path) + for rectangle in rectangles: + x1 = rectangle[0] + y1 = doc_size[1] - rectangle[1] - rectangle[3] + x2 = x1 + rectangle[2] + y2 = y1 + rectangle[3] + os.spawnlp(os.P_WAIT, inkscapePath, inkscapePath, + file_path, + "-z", + "-a %g:%g:%g:%g" % (x1, y1, x2, y2), + "-w %g" % (rectangle[2]), "-h %g" % (rectangle[3]), + "--export-png=%gx%g/%s.png" % (rectangle[2], rectangle[3], artwork_name)) + +def copyPrerenderedIcons(): + listing = os.listdir(prerenderedDir) + for list_item in listing: + src_dir = os.path.join(prerenderedDir, list_item) + copyMergeDirectory(src_dir, list_item) + +def main(): + + # Create the icons folders + createDirectory("48x48") + createDirectory("32x32") + createDirectory("24x24") + createDirectory("22x22") + createDirectory("16x16") + + # Render the SVG icons + renderSVGIcons() + + # Copy in prerendered icons + copyPrerenderedIcons() + +if __name__=="__main__": + main() + diff --git a/icons/svg/arrow.svg b/icons/svg/arrow.svg new file mode 100644 index 000000000..2434fad9d --- /dev/null +++ b/icons/svg/arrow.svg @@ -0,0 +1,732 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/svg/i-beam.svg b/icons/svg/i-beam.svg new file mode 100644 index 000000000..2f4e82f27 --- /dev/null +++ b/icons/svg/i-beam.svg @@ -0,0 +1,690 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 14cdc33c2..53f7c8452 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -75,19 +75,19 @@ lumigui_LDFLAGS = lumigui_LDADD = $(GTK_LUMIERA_LIBS) liblumicommon.a liblumi.a lumigui_DEPENDENCIES = \ - $(top_builddir)/lumiera_ui.rc \ - $(top_builddir)/assets-panel.png \ - $(top_builddir)/timeline-panel.png \ - $(top_builddir)/viewer-panel.png + $(top_builddir)/lumiera_ui.rc +# $(top_builddir)/assets-panel.png \ +# $(top_builddir)/timeline-panel.png \ +# $(top_builddir)/viewer-panel.png -$(top_builddir)/lumiera_ui.rc: - cp $(lumigui_srcdir)/lumiera_ui.rc $(top_builddir) +#$(top_builddir)/lumiera_ui.rc: +# cp $(lumigui_srcdir)/lumiera_ui.rc $(top_builddir) -$(top_builddir)/assets-panel.png: - cp $(top_srcdir)/icons/assets-panel.png $(top_builddir) -$(top_builddir)/timeline-panel.png: - cp $(top_srcdir)/icons/timeline-panel.png $(top_builddir) -$(top_builddir)/viewer-panel.png: - cp $(top_srcdir)/icons/viewer-panel.png $(top_builddir) +#$(top_builddir)/assets-panel.png: +# cp $(top_srcdir)/icons/assets-panel.png $(top_builddir) +#$(top_builddir)/timeline-panel.png: +# cp $(top_srcdir)/icons/timeline-panel.png $(top_builddir) +#$(top_builddir)/viewer-panel.png: +# cp $(top_srcdir)/icons/viewer-panel.png $(top_builddir)