]> Shamusworld >> Repos - architektonas/commitdiff
Initial addition of Layer and Block widgets.
authorShamus Hammons <jlhamm@acm.org>
Fri, 12 Jul 2013 20:09:18 +0000 (15:09 -0500)
committerShamus Hammons <jlhamm@acm.org>
Fri, 12 Jul 2013 20:09:18 +0000 (15:09 -0500)
res/architektonas.qrc
res/eye-closed.png [new file with mode: 0644]
res/eye-open.png [new file with mode: 0644]
src/applicationwindow.cpp
src/circle.cpp
src/circle.h
src/container.cpp
src/layerwidget.cpp
src/layerwidget.h
src/line.cpp
src/text.h

index f32a316eb4977a4b9f5fd6952f638973f004eadf..e8a96eb8d77ebb978c2c8d01441ed06837cdbe78 100644 (file)
@@ -18,5 +18,7 @@
                <file>quit.png</file>
                <file>zoom-in.png</file>
                <file>zoom-out.png</file>
+               <file>eye-open.png</file>
+               <file>eye-closed.png</file>
        </qresource>
 </RCC>
diff --git a/res/eye-closed.png b/res/eye-closed.png
new file mode 100644 (file)
index 0000000..d4d1285
Binary files /dev/null and b/res/eye-closed.png differ
diff --git a/res/eye-open.png b/res/eye-open.png
new file mode 100644 (file)
index 0000000..36e3693
Binary files /dev/null and b/res/eye-open.png differ
index 4aac209c35e3764bc7f59e1a8a74fad758469549..ef42ca24a6acc9fc2c00089965f7855ff5e13852 100644 (file)
 #include "applicationwindow.h"
 
 #include "about.h"
+#include "blockwidget.h"
 #include "drawingview.h"
 #include "fileio.h"
 #include "generaltab.h"
+#include "layerwidget.h"
 #include "painter.h"
 #include "settingsdialog.h"
 
@@ -53,20 +55,23 @@ ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Archit
        CreateMenus();
        CreateToolbars();
 
+       // Create Dock widgets
+       QDockWidget * dock1 = new QDockWidget(tr("Layers"), this);
+       LayerWidget * lw = new LayerWidget;
+       dock1->setWidget(lw);
+       addDockWidget(Qt::RightDockWidgetArea, dock1);
+       QDockWidget * dock2 = new QDockWidget(tr("Blocks"), this);
+//     BlockWidget * bw = new BlockWidget;
+//     dock2->setWidget(bw);
+       addDockWidget(Qt::RightDockWidgetArea, dock2);
+
        //      Create status bar
        zoomIndicator = new QLabel("Grid: 12.0\" Zoom: 12.5%");
        statusBar()->addPermanentWidget(zoomIndicator);
        statusBar()->showMessage(tr("Ready"));
 
        ReadSettings();
-
-//     connect(textEdit->document(), SIGNAL(contentsChanged()),
-//                     this, SLOT(documentWasModified()));
-
-//     setCurrentFile("");
        setUnifiedTitleAndToolBarOnMac(true);
-
-//     ((TTEdit *)qApp)->charWnd->show();//eh?
        Object::SetFont(new QFont("Verdana", 15, QFont::Bold));
 }
 
index 6473440ccdb287408e24870b501b23ebbd611551..1f350b0341615f7cc2abbde872c0448c13e68b66 100644 (file)
@@ -126,21 +126,7 @@ Circle::~Circle()
 }
 
 
-/*virtual*/ QRectF Circle::Extents(void)
-{
-       return QRectF(QPointF(position.x - radius, position.y - radius), QPointF(position.x + radius, position.y + radius));
-}
-
-
-#if 0
-/*virtual*/ ObjectType Circle::Type(void)
-{
-       return OTCircle;
-}
-#endif
-
-
-bool Circle::HitTest(Point point)
+/*virtual*/ bool Circle::HitTest(Point point)
 {
        SaveState();
        hitCenter = hitCircle = false;
@@ -173,6 +159,12 @@ pointed at length with our on screen length.
 }
 
 
+/*virtual*/ QRectF Circle::Extents(void)
+{
+       return QRectF(QPointF(position.x - radius, position.y - radius), QPointF(position.x + radius, position.y + radius));
+}
+
+
 void Circle::SaveState(void)
 {
        oldHitCenter = hitCenter;
index f420121b1f50a9484ac47b12ad9010e31e452080..1f0d38723836822e32ba82089f163dfde45ca9c2 100644 (file)
@@ -14,13 +14,13 @@ class Circle: public Object
                virtual bool Collided(Vector);
                virtual void PointerMoved(Vector);
                virtual void PointerReleased(void);
+               virtual bool HitTest(Point);
                virtual void Enumerate(FILE *);
                virtual QRectF Extents(void);
 //             virtual Object * Copy(void);
 //             virtual ObjectType Type(void);
 
        protected:
-               bool HitTest(Point);
                void SaveState(void);
                bool StateChanged(void);
 
index 47295f40f043576fdcd24b9d37ef803af439918d..25079d972e9cb0fb3f6ba925a40a3282baa69af6 100644 (file)
@@ -191,6 +191,26 @@ class so that we can leverage that stuff here as well.
 // every object for collision.
 /*virtual*/ void Container::PointerMoved(Vector point)
 {
+       if (!isTopLevelContainer)
+       {
+               // check for selection rectangle too
+
+
+               needUpdate = true;
+
+               for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+               {
+                       if ((*i)->HitTest(point))
+                       {
+                               state = OSSelected;
+                               return;
+                       }
+               }
+
+               state = OSInactive;
+               return;
+       }
+
 //     objectWasDragged = true;
 //printf("CONTAINER: PointerMoved()\n");
 
@@ -230,6 +250,13 @@ about keeping track of old states...
 
 /*virtual*/ bool Container::NeedsUpdate(void)
 {
+       // If this is *not* a top level container, then we treat it as an
+       // aggregate object.
+       if (!isTopLevelContainer)
+       {
+               return needUpdate;
+       }
+
        // Search through objects for one that needs an update; if one is found,
        // return immediately.
        for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
index 227225374b30f0e24cb31af833009be4af9293a4..ba907917acc627fef20f1199c8c25932c75345d6 100644 (file)
 //
 
 #include "layerwidget.h"
+
+
+#if 0
+OK, what it seems like we should do here, is instead of deriving from QDockWidget,
+we should derive from QWidget (or QScrollArea or somesuch). Then, when creating
+the dockwidget in the main window, we add the LayerWidget as the QDockWidget's
+main widget.
+#endif
+
+LayerWidget::LayerWidget(void): QWidget()
+{
+
+       // Make a QScrollArea, put in a QVBoxLayout.
+       // Use line widget (two checkboxes, one label), use setIcon() on the
+       // checkboxes to change their look (eye open/closed for visibility,
+       // lock open/closed for layer lock).
+
+       QIcon visibleChecked(":/res/eye-open.png");
+//     QIcon visibleUnchecked(":/res/eye-closed.png");
+       visibleChecked.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
+
+       QVBoxLayout * mainLayout = new QVBoxLayout;
+       QCheckBox * box1 = new QCheckBox("bleah");
+       box1->setIcon(visibleChecked);
+       mainLayout->addWidget(box1);
+       QPushButton * button1 = new QPushButton;//(visibleChecked);
+       button1->setFlat(true);
+       button1->setIcon(visibleChecked);
+       button1->setCheckable(true);
+       mainLayout->addWidget(button1);
+//printf("LayerWidget: About to set layout...\n");
+       setLayout(mainLayout);
+}
+
+
+LayerWidget::~LayerWidget()
+{
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..33000ea12a8594046fc5bd22dddc5f35ff2e7186 100644 (file)
@@ -0,0 +1,16 @@
+#ifndef __LAYERWIDGET_H__
+#define __LAYERWIDGET_H__
+
+#include <QtGui>
+
+class LayerWidget: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               LayerWidget(void);
+               ~LayerWidget();
+
+};
+
+#endif // __LAYERWIDGET_H__
index 156b55e6b6b05a812a83cb247e3c0d275e93ac9c..aa5054bab3da9ea9bb79ca65b8cf695093ccb687 100644 (file)
@@ -461,7 +461,7 @@ about keeping track of old states...
 }
 
 
-bool Line::HitTest(Point point)
+/*virtual*/ bool Line::HitTest(Point point)
 {
        SaveState();
 
index 351a1a1a088165a33ae22100cf45d1fe9126b6db..a075902a58a43a0b0c3f1dec431a85216e791d36 100644 (file)
@@ -15,6 +15,7 @@ class Text: public Object
                virtual bool Collided(Vector);
                virtual void PointerMoved(Vector);
                virtual void PointerReleased(void);
+               virtual bool HitTest(Point);
                virtual void Enumerate(FILE *);
 //             virtual Object * Copy(void);
                virtual Vector GetPointAtParameter(double parameter);