From a7a9909f617d5dbcebfc6d4baa7053dbe3961751 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Sat, 13 Jul 2013 11:08:57 -0500 Subject: [PATCH] More work on LayerWidget. Not functional yet. --- architektonas.pro | 2 ++ res/architektonas.qrc | 2 ++ res/lock-closed.png | Bin 0 -> 376 bytes res/lock-open.png | Bin 0 -> 340 bytes src/layeritemwidget.cpp | 54 ++++++++++++++++++++++++++++++++++++ src/layeritemwidget.h | 20 ++++++++++++++ src/layerwidget.cpp | 60 +++++++++++++++++++++++++++++++++------- 7 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 res/lock-closed.png create mode 100644 res/lock-open.png create mode 100644 src/layeritemwidget.cpp create mode 100644 src/layeritemwidget.h diff --git a/architektonas.pro b/architektonas.pro index 609aaf6..65afe20 100644 --- a/architektonas.pro +++ b/architektonas.pro @@ -59,6 +59,7 @@ HEADERS = \ src/fileio.h \ src/generaltab.h \ src/layerwidget.h \ + src/layeritemwidget.h \ src/line.h \ src/main.h \ src/mathconstants.h \ @@ -87,6 +88,7 @@ SOURCES = \ src/fileio.cpp \ src/generaltab.cpp \ src/layerwidget.cpp \ + src/layeritemwidget.cpp \ src/line.cpp \ src/main.cpp \ src/object.cpp \ diff --git a/res/architektonas.qrc b/res/architektonas.qrc index e8a96eb..8e79c6d 100644 --- a/res/architektonas.qrc +++ b/res/architektonas.qrc @@ -20,5 +20,7 @@ zoom-out.png eye-open.png eye-closed.png + lock-open.png + lock-closed.png diff --git a/res/lock-closed.png b/res/lock-closed.png new file mode 100644 index 0000000000000000000000000000000000000000..ec066cd4dc4e078d8b8988426fe84e85ea3f2987 GIT binary patch literal 376 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP)J1?I&Ypmy=exQ(SW=KSdbAE1aYF-JD%fR4Vl$uzQ znxasiS(2gP?&%wlqL<1J6u;x?;uvCa`s}5>Ml6mZtPj?wpYiH6yX8~K;IgMjD1u+% zlbX;|Q=3i~Pn8s>vbL!)p=-0Nrkz>2>uT)s^Ew$o|LEUf1| z;;BApD|%AA(Cz`-_7~f`?w{Ex+*z(YdFFMsNd;4D>vh^LEZHbm5?Ft0L(Jw2etJQ? zhp(u8i?|wQHv5>?7W)f{oyRL=v@W)%{fu?9YxUprpwwCN{ldTMKbYKqSjX@5IrJJ7 N0G_UXF6*2UngB$Cm4^TT literal 0 HcmV?d00001 diff --git a/res/lock-open.png b/res/lock-open.png new file mode 100644 index 0000000000000000000000000000000000000000..7187f5674b1c13853f88d8c30c3cd5864865aa75 GIT binary patch literal 340 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP)J1?Jr@UuJjC4oY+nIRD+&iT2ysd*(pE(3#eQEFmI zYKlU6W=V#EyQgnJie4%^P<)4{i(`nz>8+Qo^Oy_;*dFAUg}azoGP65aO1X9^1YUf~ zpjl+VcR)6SBd|l$VA9r4hm?-!M}D)h`S<)`fm^%1j=^EE_||_~QF{~mvuLq3vu!)ot_x3^+apdqd)PSRl>dO7e!0-r^HwBsO>Eg$&}r7sNkmkMs1mJ z=KlSUY}vSWoqs#~!S+YRM??gt&a~*$Nm$UUohvK+;G>?6>Vc{!cfVffSZ2-P@;3cm a^EZ~7JVl}R6DNVfkHOQ`&t;ucLK6Td-gq7W literal 0 HcmV?d00001 diff --git a/src/layeritemwidget.cpp b/src/layeritemwidget.cpp new file mode 100644 index 0000000..273ebf1 --- /dev/null +++ b/src/layeritemwidget.cpp @@ -0,0 +1,54 @@ +// layeritemwidget.cpp: Layer item widget +// +// Part of the Architektonas Project +// (C) 2011 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 07/13/2013 Created this file +// + +#include "layeritemwidget.h" + + +LayerItemWidget::LayerItemWidget(QString s, bool invisible/*=false*/, bool locked/*=false*/): + QWidget(), + name(new QLabel(s)), + visibility(new QPushButton), + editibility(new QPushButton) +{ + QIcon visibleIcon(":/res/eye-open.png"); + visibleIcon.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On); + QIcon lockedIcon(":/res/lock-open.png"); + lockedIcon.addFile(":/res/lock-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On); + QSize buttonSize(20, 20); + + QHBoxLayout * mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/ + + visibility->setFlat(true); + visibility->setIcon(visibleIcon); + visibility->setCheckable(true); + visibility->setMaximumSize(buttonSize); + visibility->setChecked(invisible); + + editibility->setFlat(true); + editibility->setIcon(lockedIcon); + editibility->setCheckable(true); + editibility->setMaximumSize(buttonSize); + editibility->setChecked(locked); + + mainLayout->addWidget(visibility); + mainLayout->addWidget(editibility); + mainLayout->addWidget(name); + setLayout(mainLayout); +} + + +LayerItemWidget::~LayerItemWidget() +{ +} + diff --git a/src/layeritemwidget.h b/src/layeritemwidget.h new file mode 100644 index 0000000..0ee1119 --- /dev/null +++ b/src/layeritemwidget.h @@ -0,0 +1,20 @@ +#ifndef __LAYERITEMWIDGET_H__ +#define __LAYERITEMWIDGET_H__ + +#include + +class LayerItemWidget: public QWidget +{ + Q_OBJECT + + public: + LayerItemWidget(QString, bool invisible = false, bool locked = false); + ~LayerItemWidget(); + + public: + QLabel * name; + QPushButton * visibility; + QPushButton * editibility; +}; + +#endif // __LAYERITEMWIDGET_H__ diff --git a/src/layerwidget.cpp b/src/layerwidget.cpp index ba90791..b45eed6 100644 --- a/src/layerwidget.cpp +++ b/src/layerwidget.cpp @@ -12,6 +12,7 @@ // #include "layerwidget.h" +#include "layeritemwidget.h" #if 0 @@ -29,20 +30,59 @@ LayerWidget::LayerWidget(void): QWidget() // 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); + QIcon visible(":/res/eye-open.png"); + visible.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On); + QIcon locked(":/res/lock-open.png"); + locked.addFile(":/res/lock-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); + QHBoxLayout * line1 = new QHBoxLayout; + QHBoxLayout * line2 = new QHBoxLayout; + +// QCheckBox * box1 = new QCheckBox("bleah"); +// box1->setIcon(visible); +// mainLayout->addWidget(box1); + + QPushButton * button1 = new QPushButton; button1->setFlat(true); - button1->setIcon(visibleChecked); + button1->setIcon(visible); button1->setCheckable(true); - mainLayout->addWidget(button1); -//printf("LayerWidget: About to set layout...\n"); + button1->setMaximumSize(QSize(20, 20)); + QPushButton * button2 = new QPushButton; + button2->setFlat(true); + button2->setIcon(locked); + button2->setCheckable(true); + button2->setMaximumSize(QSize(20, 20)); + QLabel * label1 = new QLabel("Background"); + + QPushButton * button3 = new QPushButton; + button3->setFlat(true); + button3->setIcon(visible); + button3->setCheckable(true); + button3->setMaximumSize(QSize(20, 20)); + QPushButton * button4 = new QPushButton; + button4->setFlat(true); + button4->setIcon(locked); + button4->setCheckable(true); + button4->setMaximumSize(QSize(20, 20)); + QLabel * label2 = new QLabel("Guides"); + + line1->addWidget(button1); + line1->addWidget(button2); + line1->addWidget(label1); + + line2->addWidget(button3); + line2->addWidget(button4); + line2->addWidget(label2); + + LayerItemWidget * liw1 = new LayerItemWidget("Floor #1"); + LayerItemWidget * liw2 = new LayerItemWidget("Mechanical"); + + mainLayout->addLayout(line1); + mainLayout->addLayout(line2); + mainLayout->addWidget(liw1); + mainLayout->addWidget(liw2); + mainLayout->addStretch(); setLayout(mainLayout); } -- 2.37.2