Skip to content

Commit

Permalink
Polished UI
Browse files Browse the repository at this point in the history
  • Loading branch information
justinjk007 committed Feb 2, 2018
1 parent 9f3a672 commit a100af1
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 14 deletions.
66 changes: 63 additions & 3 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,25 @@
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="left_side" stretch="0">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
Expand All @@ -56,7 +71,7 @@
<item>
<layout class="QVBoxLayout" name="right_side">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="pentagon_info">
Expand All @@ -66,6 +81,9 @@
<verstretch>5</verstretch>
</sizepolicy>
</property>
<property name="cursor" stdset="0">
<cursorShape>IBeamCursor</cursorShape>
</property>
</widget>
</item>
<item>
Expand All @@ -81,6 +99,15 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Consolas</family>
<pointsize>10</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
Expand All @@ -96,6 +123,12 @@
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
Expand All @@ -112,6 +145,9 @@
<property name="text">
<string>Stop and Reset</string>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
Expand All @@ -120,19 +156,37 @@
<item row="1" column="0">
<widget class="QPushButton" name="pause_btn">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">font: 10pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>Pause</string>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="resume_btn">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<family>Consolas</family>
<pointsize>10</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="styleSheet">
Expand All @@ -141,6 +195,12 @@
<property name="text">
<string>Resume</string>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand Down
7 changes: 5 additions & 2 deletions src/pentagonGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pentagonGen::pentagonGen(QWidget* parent) : QWidget(parent)
// start, it has something to draw
Line line(Point(0, 0), Point(0, 0));
this->current_pentagon.push_back(line);
this->pixel_scaling = 0;
}

void pentagonGen::paintEvent(QPaintEvent* e)
Expand All @@ -19,11 +20,12 @@ void pentagonGen::paintEvent(QPaintEvent* e)
}
// Make custom pen
QPen pen;
pen.setWidth(3);
pen.setWidth(this->pixel_scaling);
pen.setColor(QColor(42, 161, 152));
// Now draw the line to widget
QPainter painter(this);
painter.fillRect(e->rect(), QColor(238, 232, 213)); // Background color
// painter.fillRect(e->rect(), QColor(238, 232, 213)); // Background color
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(150, 20);
painter.setPen(pen);
painter.drawLines(qtLines);
Expand All @@ -34,6 +36,7 @@ void pentagonGen::updateLine(std::vector<Line> pentagon)
/**
* Update the current line so it can drawn on to the widget
*/
this->pixel_scaling = 5;
this->current_pentagon = pentagon;
this->update(); // This function is inherited from Qt and it
// repaints the widget automatically
Expand Down
1 change: 1 addition & 0 deletions src/pentagonGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class pentagonGen : public QWidget

private:
std::vector<Line> current_pentagon;
int pixel_scaling;

protected:
void paintEvent(QPaintEvent* e) override;
Expand Down
10 changes: 5 additions & 5 deletions src/run_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

int main(int argc, char* argv[])
{
qRegisterMetaType<std::vector<Line>>("std::vector<Line>"); // This is very important, this is done to Make emitting Line possible
qRegisterMetaType<std::list<Line>>("std::list<Line>"); // This is very important, this is done to Make emitting Line possible
// Emitted types are registered here to make queued connections possible
qRegisterMetaType<std::vector<Line>>("std::vector<Line>");
qRegisterMetaType<std::list<Line>>("std::list<Line>");

QApplication a(argc, argv);
MainWindow w;

// Window settings
w.setWindowTitle("Pentagonal Tiling - Visulization");
w.setWindowIcon(QIcon("favicon.ico"));
w.setStyleSheet("QMainWindow {background: rgb(147,161,161);}"); // Set background color

// After all this time
w.show();
return a.exec();
// Always
}
10 changes: 6 additions & 4 deletions src/tilingGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ void tilingGen::paintEvent(QPaintEvent* e)
{
// Make custom pen
QPen pen;
pen.setWidth(7); // Set width with floating point precision
pen.setColor(QColor(42, 161, 152));
// pen.setWidthF(0.3); // Set width with floating point precision
pen.setWidth(7);
pen.setColor(QColor(211, 54, 130));
// Make a brush to fill the polygon
QBrush fill;
fill.setColor(QColor(148, 208, 203));
fill.setStyle(Qt::SolidPattern);
QPainterPath canvas;
QPainter painter(this);
painter.fillRect(e->rect(), QColor(238, 232, 213));
// painter.fillRect(e->rect(), QColor(238, 232, 213));
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(pen);
painter.translate(100,100);
painter.translate(100, 100);
painter.scale(0.6, 0.6);
size_t count = 0; // Count the number of points appended to the polygon
QPolygon polygon;
Expand Down

0 comments on commit a100af1

Please sign in to comment.