changeset 161:849b66609571

a few fixes
author mwarning
date Wed, 17 Jun 2009 22:39:42 +0000
parents 624b4a58556e
children 4bbd9f3d9add
files demos/deform/build.sh demos/deform/deform.qrc demos/deform/main.d demos/deform/pathdeform.d demos/deform/pathdeform.html
diffstat 5 files changed, 69 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/deform/build.sh	Wed Jun 17 22:39:42 2009 +0000
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+../../tools/drcc/drcc deform.qrc -o qrc_deform.d
+
+ldc main.d pathdeform.d qrc_deform.d ../shared/arthurstyle.d ../shared/arthurwidgets.d -L-L../../lib -L-lqtdgui -L-lqtdcore -I../../ -I../../qt/d1 -L-lQtGui -L-lQtCore -ofbrowser -d-version=QT_NO_UITOOLS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/deform/deform.qrc	Wed Jun 17 22:39:42 2009 +0000
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/res/deform">
+   <file>pathdeform.d</file>
+   <file>pathdeform.html</file>
+</qresource>
+</RCC>
--- a/demos/deform/main.d	Wed Jun 17 17:42:02 2009 +0000
+++ b/demos/deform/main.d	Wed Jun 17 22:39:42 2009 +0000
@@ -38,38 +38,37 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module main;
 
-import
-    pathdeform,
-    arthurstyle,
-    qt.gui.QApplication;
+
+import qt.gui.QApplication;
+import pathdeform;
+import arthurstyle;
 
 
 int main(string[] args)
 {
-    //Q_INIT_RESOURCE(deform);
-
-    scope app = new QApplication(args);
+	scope app = new QApplication(args);
 
-    bool smallScreen = false;
-    foreach (arg; args)
-    {
-        if (arg == "-small-screen")
-            smallScreen = true;
-    }
+	bool smallScreen = false;
+	foreach (arg; args)
+	{
+		if (arg == "-small-screen")
+			smallScreen = true;
+	}
 
-    scope deformWidget = new PathDeformWidget(null, smallScreen);
+	scope deformWidget = new PathDeformWidget(null, smallScreen);
 
-    QStyle arthurStyle = new ArthurStyle();
-    deformWidget.setWidgetStyle(arthurStyle);
-    auto widgets = deformWidget.findChildren!(QWidget);
-    foreach (w; widgets)
-        w.setStyle(arthurStyle);
+	QStyle arthurStyle = new ArthurStyle();
+	deformWidget.setWidgetStyle(arthurStyle);
+	QWidget[] widgets; // = qFindChildren!(QWidget)(deformWidget); //TODO
+	foreach (w; widgets)
+		w.setStyle(arthurStyle);
 
-    if (smallScreen)
-        deformWidget.showFullScreen();
-    else
-        deformWidget.show();
+	if (smallScreen)
+		deformWidget.showFullScreen();
+	else
+		deformWidget.show();
 
-    return app.exec();
+	return app.exec();
 }
--- a/demos/deform/pathdeform.d	Wed Jun 17 17:42:02 2009 +0000
+++ b/demos/deform/pathdeform.d	Wed Jun 17 22:39:42 2009 +0000
@@ -38,6 +38,8 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module pathdeform;
+
 
 import arthurwidgets,
     qt.gui.QPainterPath,
@@ -62,6 +64,7 @@
     qt.opengl.QGLFormat,
     tango.math.Math;
 
+
 class PathDeformControls : QWidget
 {
     private PathDeformRenderer m_renderer;
@@ -324,7 +327,7 @@
         {
             m_controls.setStyle(style);
 
-            auto widgets = m_controls.findChildren!(QWidget);
+            QWidget[] widgets; // = qFindChildren!(QWidget)(m_controls); //TODO
             foreach (w; widgets)
                 w.setStyle(style);
         }
@@ -333,7 +336,7 @@
 
 private QRect circle_bounds(QPointF center, qreal radius, qreal compensation)
 {
-    return new QRect(qRound(center.x() - radius - compensation),
+    return QRect(qRound(center.x() - radius - compensation),
                  qRound(center.y() - radius - compensation),
                  qRound((radius + compensation) * 2),
                  qRound((radius + compensation) * 2));
@@ -415,7 +418,7 @@
         f.setStyleHint(QFont.Times);
 
         m_paths = null;
-        m_pathBounds = new QRectF();
+        m_pathBounds = QRectF();
 
         QPointF advance;
 
@@ -481,7 +484,7 @@
 
         if (e.timerId == m_repaintTimer.timerId) {
 
-            if ((new QLineF(QPointF(0,0), m_direction)).length > 1)
+            if ((QLineF(QPointF(0,0), m_direction)).length() > 1)
                 m_direction *= 0.995;
             qreal time = m_repaintTracker.restart();
 
@@ -544,10 +547,10 @@
 
         m_repaintTimer.stop();
         m_offset = QPointF();
-        if ((new QLineF(m_pos, QPointF(e.pos))).length <= m_radius)
+        if ((QLineF(m_pos, QPointF(e.pos))).length <= m_radius)
             m_offset = m_pos - QPointF(e.pos);
 
-        m_mousePress = e.pos;
+        m_mousePress = QPointF(e.pos);
 
         // If we're not running in small screen mode, always assume we're dragging
         m_mouseDrag = !m_smallScreen;
@@ -570,13 +573,13 @@
     {
         auto epos = QPointF(e.pos);
 
-        if (!m_mouseDrag && (new QLineF(m_mousePress, QPointF(e.pos))).length() > 25.0)
+        if (!m_mouseDrag && (QLineF(m_mousePress, QPointF(e.pos))).length() > 25.0)
             m_mouseDrag = true;
 
         if (m_mouseDrag) {
             QRect rectBefore = circle_bounds(m_pos, m_radius, m_fontSize);
             if (e.type() == QEvent.MouseMove) {
-                QLineF line = new QLineF(m_pos, epos + m_offset);
+                QLineF line = QLineF(m_pos, epos + m_offset);
                 line.setLength(line.length() * .1);
                 auto dir = QPointF(line.dx(), line.dy());
                 m_direction = (m_direction + dir) / 2;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/deform/pathdeform.html	Wed Jun 17 22:39:42 2009 +0000
@@ -0,0 +1,24 @@
+<html>
+<center>
+<h2>Vector deformation</h2>
+</center>
+
+<p>This demo shows how to use advanced vector techniques to draw text 
+using a <code>QPainterPath</code>.</p>
+
+<p>We define a vector deformation field in the shape of a lens and apply
+this to all points in a path. This means that what is rendered on
+screen is not pixel manipulation, but modified vector representations of
+the glyphs themselves. This is visible from the high quality of the
+antialiased edges for the deformed glyphs.</p>
+
+<p>To get a fairly complex path we allow the user to type in text and
+convert the text to paths. This is done using the
+<code>QPainterPath::addText()</code> function.</p>
+
+<p>The lens is drawn using a single call to <code>drawEllipse()</code>, using
+a <code>QRadialGradient</code> to fill it with a specialized color table,
+giving the effect of the Sun's reflection and a drop shadow. The lens
+is cached as a pixmap for better performance.</p>
+
+</html>