summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-08-02 17:44:37 +0200
committerAleks Kissinger <aleks0@gmail.com>2018-08-02 17:44:37 +0200
commit31a78ae551b781eccc47546a2f6d4bf121af24cf (patch)
treeb997a471d484f9b096878919fcd38b074dc7a59a /src
parentf978634e8607f568b83952db9255e08f3f7cbe92 (diff)
started style editor
Diffstat (limited to 'src')
-rw-r--r--src/data/nodestyle.cpp8
-rw-r--r--src/data/nodestyle.h4
-rw-r--r--src/data/style.cpp15
-rw-r--r--src/data/style.h4
-rw-r--r--src/data/tikzstyles.cpp83
-rw-r--r--src/data/tikzstyles.h10
-rw-r--r--src/gui/mainwindow.ui6
-rw-r--r--src/gui/styleeditor.cpp230
-rw-r--r--src/gui/styleeditor.h41
-rw-r--r--src/gui/styleeditor.ui752
-rw-r--r--src/gui/stylepalette.cpp33
-rw-r--r--src/gui/stylepalette.h1
-rw-r--r--src/gui/stylepalette.ui18
-rw-r--r--src/main.cpp6
-rw-r--r--src/tikzit.cpp7
-rw-r--r--src/tikzit.h4
-rw-r--r--src/util.cpp1
-rw-r--r--src/util.h1
18 files changed, 1181 insertions, 43 deletions
diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp
index ae9f0f7..928712d 100644
--- a/src/data/nodestyle.cpp
+++ b/src/data/nodestyle.cpp
@@ -30,11 +30,11 @@ NodeStyle::NodeStyle(QString name, GraphElementData *data): Style(name, data)
{
}
-QColor NodeStyle::fillColor() const
+QColor NodeStyle::fillColor(bool tikzitOverride) const
{
if (_data == 0) return Qt::white;
- QString col = propertyWithDefault("fill", "white");
+ QString col = propertyWithDefault("fill", "white", tikzitOverride);
QColor namedColor(col);
if (namedColor.isValid()) {
@@ -50,11 +50,11 @@ QBrush NodeStyle::brush() const
return QBrush(fillColor());
}
-NodeStyle::Shape NodeStyle::shape() const
+NodeStyle::Shape NodeStyle::shape(bool tikzitOverride) const
{
if (_data == 0) return NodeStyle::Circle;
- QString sh = propertyWithDefault("shape", "circle");
+ QString sh = propertyWithDefault("shape", "circle", tikzitOverride);
if (sh == "circle") return NodeStyle::Circle;
else if (sh == "rectangle") return NodeStyle::Rectangle;
else return NodeStyle::Circle;
diff --git a/src/data/nodestyle.h b/src/data/nodestyle.h
index c6fc0f6..ce36006 100644
--- a/src/data/nodestyle.h
+++ b/src/data/nodestyle.h
@@ -37,10 +37,10 @@ public:
NodeStyle();
NodeStyle(QString name, GraphElementData *data);
- QColor fillColor() const;
+ QColor fillColor(bool tikzitOverride=true) const;
QBrush brush() const;
QPainterPath path() const override;
- Shape shape() const;
+ Shape shape(bool tikzitOverride=true) const;
QPainterPath palettePath() const override;
QIcon icon() const override;
diff --git a/src/data/style.cpp b/src/data/style.cpp
index 41013c0..61c86d6 100644
--- a/src/data/style.cpp
+++ b/src/data/style.cpp
@@ -41,11 +41,11 @@ QString Style::name() const
return _name;
}
-QColor Style::strokeColor() const
+QColor Style::strokeColor(bool tikzitOverride) const
{
if (_data == 0) return Qt::black;
- QString col = propertyWithDefault("draw", "black");
+ QString col = propertyWithDefault("draw", "black", tikzitOverride);
QColor namedColor(col);
if (namedColor.isValid()) {
@@ -69,10 +69,15 @@ QPen Style::pen() const
return p;
}
-QString Style::propertyWithDefault(QString prop, QString def) const
+QString Style::propertyWithDefault(QString prop, QString def, bool tikzitOverride) const
{
- QString val = _data->property("tikzit " + prop);
- if (val.isNull()) val = _data->property(prop);
+ QString val;
+ if (tikzitOverride) {
+ val = _data->property("tikzit " + prop);
+ if (val.isNull()) val = _data->property(prop);
+ } else {
+ val = _data->property(prop);
+ }
if (val.isNull()) val = def;
return val;
}
diff --git a/src/data/style.h b/src/data/style.h
index 8315e5a..0be8b87 100644
--- a/src/data/style.h
+++ b/src/data/style.h
@@ -38,7 +38,7 @@ public:
// properties that both edges and nodes have
GraphElementData *data() const;
QString name() const;
- QColor strokeColor() const;
+ QColor strokeColor(bool tikzitOverride=true) const;
int strokeThickness() const;
// methods that are implemented differently for edges and nodes
@@ -47,7 +47,7 @@ public:
virtual QPainterPath palettePath() const = 0;
virtual QIcon icon() const = 0;
protected:
- QString propertyWithDefault(QString prop, QString def) const;
+ QString propertyWithDefault(QString prop, QString def, bool tikzitOverride=true) const;
QString _name;
GraphElementData *_data;
};
diff --git a/src/data/tikzstyles.cpp b/src/data/tikzstyles.cpp
index addd464..c96c55b 100644
--- a/src/data/tikzstyles.cpp
+++ b/src/data/tikzstyles.cpp
@@ -20,10 +20,38 @@
#include "nodestyle.h"
#include <QDebug>
+#include <QColorDialog>
TikzStyles::TikzStyles(QObject *parent) : QObject(parent)
{
+ // 19 standard xcolor colours
+ _colNames <<
+ "black" <<
+ "gray" <<
+ "darkgray" <<
+ "lightgray" <<
+ "white" <<
+ "red" <<
+ "orange" <<
+ "yellow" <<
+ "lime" <<
+ "blue" <<
+ "purple" <<
+
+ "brown" <<
+ "olive" <<
+ "green" <<
+ "teal" <<
+ "cyan" <<
+
+ "magenta" <<
+ "violet" <<
+ "pink";
+
+ for (int i = 0; i < _colNames.length(); ++i) {
+ _cols << QColor(_colNames[i]);
+ }
}
NodeStyle *TikzStyles::nodeStyle(QString name) const
@@ -51,6 +79,61 @@ void TikzStyles::clear()
_edgeStyles.clear();
}
+QColor TikzStyles::colorByIndex(int i)
+{
+ return _cols[i];
+}
+
+QColor TikzStyles::colorByName(QString name)
+{
+ for (int i = 0; i < _colNames.length(); ++i) {
+ if (_colNames[i] == name) return _cols[i];
+ }
+ return QColor();
+}
+
+QString TikzStyles::nameForColor(QColor col)
+{
+ for (int i = 0; i < _colNames.length(); ++i) {
+ if (_cols[i] == col) return _colNames[i];
+ }
+ return QString();
+}
+
+void TikzStyles::refreshModels(QStandardItemModel *nodeModel, QStandardItemModel *edgeModel)
+{
+ nodeModel->clear();
+ edgeModel->clear();
+ //QString f = tikzit->styleFile();
+ //ui->styleFile->setText(f);
+
+ QStandardItem *it;
+
+ it = new QStandardItem(noneStyle->icon(), noneStyle->name());
+ it->setEditable(false);
+ it->setData(noneStyle->name());
+ nodeModel->appendRow(it);
+
+ foreach(NodeStyle *ns, _nodeStyles) {
+ it = new QStandardItem(ns->icon(), ns->name());
+ it->setEditable(false);
+ it->setData(ns->name());
+ nodeModel->appendRow(it);
+ }
+
+ it = new QStandardItem(noneEdgeStyle->icon(), noneEdgeStyle->name());
+ it->setEditable(false);
+ it->setData(noneEdgeStyle->name());
+ edgeModel->appendRow(it);
+
+ foreach(EdgeStyle *es, _edgeStyles) {
+ it = new QStandardItem(es->icon(), es->name());
+ it->setEditable(false);
+ it->setData(es->name());
+ edgeModel->appendRow(it);
+ }
+}
+
QVector<EdgeStyle *> TikzStyles::edgeStyles() const
{
return _edgeStyles;
diff --git a/src/data/tikzstyles.h b/src/data/tikzstyles.h
index da9a05f..51392b2 100644
--- a/src/data/tikzstyles.h
+++ b/src/data/tikzstyles.h
@@ -25,6 +25,8 @@
#include <QObject>
#include <QString>
+#include <QColor>
+#include <QStandardItemModel>
class TikzStyles : public QObject
{
@@ -39,6 +41,12 @@ public:
QVector<EdgeStyle *> edgeStyles() const;
void clear();
+ // convenience functions for named colors
+ QColor colorByIndex(int i);
+ QColor colorByName(QString name);
+ QString nameForColor(QColor col);
+ void refreshModels(QStandardItemModel *nodeModel, QStandardItemModel *edgeModel);
+
signals:
public slots:
@@ -46,6 +54,8 @@ public slots:
private:
QVector<NodeStyle*> _nodeStyles;
QVector<EdgeStyle*> _edgeStyles;
+ QStringList _colNames;
+ QVector<QColor> _cols;
};
#endif // PROJECT_H
diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui
index 137d6cf..cae5735 100644
--- a/src/gui/mainwindow.ui
+++ b/src/gui/mainwindow.ui
@@ -10,6 +10,12 @@
<height>580</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
<string>TikZiT - untitled</string>
</property>
diff --git a/src/gui/styleeditor.cpp b/src/gui/styleeditor.cpp
new file mode 100644
index 0000000..fae5e1a
--- /dev/null
+++ b/src/gui/styleeditor.cpp
@@ -0,0 +1,230 @@
+#include <QColorDialog>
+#include <QDebug>
+
+#include "tikzit.h"
+#include "styleeditor.h"
+#include "ui_styleeditor.h"
+
+StyleEditor::StyleEditor(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::StyleEditor)
+{
+ ui->setupUi(this);
+
+ setColor(ui->fillColor, QColor(Qt::white));
+ setColor(ui->drawColor, QColor(Qt::black));
+ setColor(ui->tikzitFillColor, QColor(Qt::white));
+ setColor(ui->tikzitDrawColor, QColor(Qt::black));
+
+ TikzStyles *styles = tikzit->styles();
+
+ _nodeModel = new QStandardItemModel(this);
+ _edgeModel = new QStandardItemModel(this);
+
+ ui->styleListView->setModel(_nodeModel);
+ ui->styleListView->setViewMode(QListView::IconMode);
+ ui->styleListView->setMovement(QListView::Static);
+ ui->styleListView->setGridSize(QSize(48,48));
+
+
+ ui->edgeStyleListView->setModel(_edgeModel);
+ ui->edgeStyleListView->setViewMode(QListView::IconMode);
+ ui->edgeStyleListView->setMovement(QListView::Static);
+ ui->edgeStyleListView->setGridSize(QSize(48,48));
+
+ // setup the color dialog to display only the named colors that tikzit/xcolor knows
+ // about as "standard colors".
+ for (int i = 0; i < 48; ++i) {
+ QColorDialog::setStandardColor(i, QColor(Qt::white));
+ }
+
+ // grayscale in column 1
+ int pos = 0;
+ for (int i=0; i < 5; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // rainbow in column 2
+ pos = 6;
+ for (int i=5; i < 11; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // brown/green/teal spectrum in column 3
+ pos = 12;
+ for (int i=11; i < 16; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // pinks in column 4
+ pos = 18;
+ for (int i=16; i < 19; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ updateFields();
+}
+
+StyleEditor::~StyleEditor()
+{
+ delete ui;
+}
+
+void StyleEditor::showEvent(QShowEvent *)
+{
+ tikzit->styles()->refreshModels(_nodeModel, _edgeModel);
+}
+
+void StyleEditor::updateFields()
+{
+ ui->name->setEnabled(false);
+ ui->category->setEnabled(false);
+ ui->fillColor->setEnabled(false);
+ ui->drawColor->setEnabled(false);
+ ui->tikzitFillColor->setEnabled(false);
+ ui->tikzitDrawColor->setEnabled(false);
+ ui->hasTikzitFillColor->setEnabled(false);
+ ui->hasTikzitDrawColor->setEnabled(false);
+ ui->shape->setEnabled(false);
+ ui->hasTikzitShape->setEnabled(false);
+ ui->tikzitShape->setEnabled(false);
+ ui->leftArrow->setEnabled(false);
+ ui->rightArrow->setEnabled(false);
+ ui->properties->setEnabled(false);
+
+ if (_activeNodeStyle != 0) {
+ ui->name->setEnabled(true);
+ ui->name->setText(_activeNodeStyle->name());
+
+ ui->category->setEnabled(true);
+ // TODO
+
+ // passing 'false' to these methods prevents 'tikzit foo' from overriding property 'foo'
+ QColor realFill = _activeNodeStyle->fillColor(false);
+ QColor fill = _activeNodeStyle->fillColor();
+ bool fillOverride = realFill != fill;
+ QColor realDraw = _activeNodeStyle->strokeColor(false);
+ QColor draw = _activeNodeStyle->strokeColor();
+ bool drawOverride = realDraw != draw;
+
+ ui->fillColor->setEnabled(true);
+ setColor(ui->fillColor, realFill);
+
+ ui->drawColor->setEnabled(true);
+ setColor(ui->drawColor, realDraw);
+
+
+ ui->hasTikzitFillColor->setEnabled(true);
+ ui->hasTikzitFillColor->setChecked(fillOverride);
+
+ ui->tikzitFillColor->setEnabled(fillOverride);
+ setColor(ui->tikzitFillColor, fill);
+
+ ui->hasTikzitDrawColor->setEnabled(true);
+ ui->hasTikzitDrawColor->setChecked(drawOverride);
+
+ ui->tikzitDrawColor->setEnabled(drawOverride);
+ setColor(ui->tikzitDrawColor, draw);
+
+ // TODO
+ ui->shape->setEnabled(true);
+ ui->hasTikzitShape->setEnabled(true);
+ ui->tikzitShape->setEnabled(true);
+ ui->properties->setEnabled(true);
+ } else if (_activeEdgeStyle != 0) {
+ ui->name->setEnabled(true);
+ ui->name->setText(_activeEdgeStyle->name());
+
+ ui->category->setEnabled(true);
+ // TODO
+
+
+ setColor(ui->fillColor, QColor(Qt::gray));
+ setColor(ui->tikzitFillColor, QColor(Qt::gray));
+ ui->hasTikzitFillColor->setChecked(false);
+
+
+ // passing 'false' to these methods prevents 'tikzit foo' from overriding property 'foo'
+ QColor realDraw = _activeEdgeStyle->strokeColor(false);
+ QColor draw = _activeEdgeStyle->strokeColor();
+ bool drawOverride = realDraw != draw;
+
+ ui->drawColor->setEnabled(true);
+ setColor(ui->drawColor, realDraw);
+
+ ui->hasTikzitDrawColor->setEnabled(true);
+ ui->hasTikzitDrawColor->setChecked(drawOverride);
+
+ ui->tikzitDrawColor->setEnabled(drawOverride);
+ setColor(ui->tikzitDrawColor, draw);
+
+ // TODO
+ ui->leftArrow->setEnabled(true);
+ ui->rightArrow->setEnabled(true);
+ ui->properties->setEnabled(true);
+ } else {
+ setColor(ui->fillColor, QColor(Qt::gray));
+ setColor(ui->drawColor, QColor(Qt::gray));
+ setColor(ui->tikzitDrawColor, QColor(Qt::gray));
+ setColor(ui->tikzitFillColor, QColor(Qt::gray));
+ }
+}
+
+
+void StyleEditor::on_fillColor_clicked()
+{
+ QColor col = QColorDialog::getColor(
+ color(ui->fillColor),
+ this,
+ "Fill Color",
+ QColorDialog::DontUseNativeDialog);
+ if (col.isValid()) setColor(ui->fillColor, col);
+}
+
+void StyleEditor::on_styleListView_clicked()
+{
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ const QModelIndexList i = ui->styleListView->selectionModel()->selectedIndexes();
+ QString sty;
+ if (!i.isEmpty()) {
+ sty = i[0].data().toString();
+ if (sty != "none")
+ _activeNodeStyle = tikzit->styles()->nodeStyle(sty);
+ }
+ updateFields();
+}
+
+void StyleEditor::on_edgeStyleListView_clicked()
+{
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ const QModelIndexList i = ui->edgeStyleListView->selectionModel()->selectedIndexes();
+ QString sty;
+ if (!i.isEmpty()) {
+ sty = i[0].data().toString();
+ if (sty != "none")
+ _activeEdgeStyle = tikzit->styles()->edgeStyle(sty);
+ }
+ updateFields();
+}
+
+void StyleEditor::setColor(QPushButton *btn, QColor col)
+{
+ QPalette pal = btn->palette();
+ pal.setColor(QPalette::Button, col);
+ btn->setPalette(pal);
+ btn->update();
+}
+
+QColor StyleEditor::color(QPushButton *btn)
+{
+ QPalette pal = btn->palette();
+ return pal.color(QPalette::Button);
+}
diff --git a/src/gui/styleeditor.h b/src/gui/styleeditor.h
new file mode 100644
index 0000000..3a8dd9d
--- /dev/null
+++ b/src/gui/styleeditor.h
@@ -0,0 +1,41 @@
+#ifndef STYLEEDITOR_H
+#define STYLEEDITOR_H
+
+#include "nodestyle.h"
+#include "edgestyle.h"
+
+#include <QMainWindow>
+#include <QPushButton>
+#include <QStandardItemModel>
+
+namespace Ui {
+class StyleEditor;
+}
+
+class StyleEditor : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit StyleEditor(QWidget *parent = 0);
+ ~StyleEditor();
+
+ void showEvent(QShowEvent *) override;
+ void updateFields();
+
+public slots:
+ void on_fillColor_clicked();
+ void on_styleListView_clicked();
+ void on_edgeStyleListView_clicked();
+
+private:
+ Ui::StyleEditor *ui;
+ void setColor(QPushButton *btn, QColor col);
+ QColor color(QPushButton *btn);
+ QStandardItemModel *_nodeModel;
+ QStandardItemModel *_edgeModel;
+ NodeStyle *_activeNodeStyle;
+ EdgeStyle *_activeEdgeStyle;
+};
+
+#endif // STYLEEDITOR_H
diff --git a/src/gui/styleeditor.ui b/src/gui/styleeditor.ui
new file mode 100644
index 0000000..9888954
--- /dev/null
+++ b/src/gui/styleeditor.ui
@@ -0,0 +1,752 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StyleEditor</class>
+ <widget class="QMainWindow" name="StyleEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>580</width>
+ <height>519</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <widget class="QComboBox" name="currentCategory">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>181</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelName">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>50</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelCategory">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>80</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Category</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelFillColor">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>110</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Fill Color</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>140</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Draw Color</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="name">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>50</y>
+ <width>301</width>
+ <height>20</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="category">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>80</y>
+ <width>301</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="fillColor">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>110</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="drawColor">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>140</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitFillColor">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>110</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>140</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="tikzitFillColor">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>110</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="tikzitDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>140</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelShape">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>170</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Shape</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="shape">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>170</y>
+ <width>211</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>circle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>rectangle</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitShape">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>200</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="tikzitShape">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>200</y>
+ <width>131</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelArrowhead">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>230</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Arrowhead</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="leftArrow">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>230</y>
+ <width>71</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&lt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&gt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>|</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>stealth</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>latex</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>[</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>]</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>(</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>)</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QLabel" name="labelDash">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>230</y>
+ <width>16</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>16</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="rightArrow">
+ <property name="geometry">
+ <rect>
+ <x>370</x>
+ <y>230</y>
+ <width>71</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&gt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&lt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>|</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>stealth</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>latex</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>]</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>[</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>(</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QLabel" name="labelProperties">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>270</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QTreeWidget" name="properties">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>270</y>
+ <width>301</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <column>
+ <property name="text">
+ <string notr="true">Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ <widget class="QToolButton" name="addProperty">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addAtom">
+ <property name="geometry">
+ <rect>
+ <x>300</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+a</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeProperty">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="propertyUp">
+ <property name="geometry">
+ <rect>
+ <x>360</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="propertyDown">
+ <property name="geometry">
+ <rect>
+ <x>390</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ <widget class="QListView" name="styleListView">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>181</width>
+ <height>251</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QListView" name="edgeStyleListView">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>330</y>
+ <width>181</width>
+ <height>151</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addStyle">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeStyle">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="styleUp">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="styleDown">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeEdgeStyle">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addEdgeStyle">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="edgeStyleUp">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="edgeStyleDown">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/gui/stylepalette.cpp b/src/gui/stylepalette.cpp
index b5e1475..500384b 100644
--- a/src/gui/stylepalette.cpp
+++ b/src/gui/stylepalette.cpp
@@ -67,36 +67,10 @@ StylePalette::~StylePalette()
void StylePalette::reloadStyles()
{
- _nodeModel->clear();
- _edgeModel->clear();
QString f = tikzit->styleFile();
ui->styleFile->setText(f);
- QStandardItem *it;
-
- it = new QStandardItem(noneStyle->icon(), noneStyle->name());
- it->setEditable(false);
- it->setData(noneStyle->name());
- _nodeModel->appendRow(it);
-
- foreach(NodeStyle *ns, tikzit->styles()->nodeStyles()) {
- it = new QStandardItem(ns->icon(), ns->name());
- it->setEditable(false);
- it->setData(ns->name());
- _nodeModel->appendRow(it);
- }
-
- it = new QStandardItem(noneEdgeStyle->icon(), noneEdgeStyle->name());
- it->setEditable(false);
- it->setData(noneEdgeStyle->name());
- _edgeModel->appendRow(it);
-
- foreach(EdgeStyle *es, tikzit->styles()->edgeStyles()) {
- it = new QStandardItem(es->icon(), es->name());
- it->setEditable(false);
- it->setData(es->name());
- _edgeModel->appendRow(it);
- }
+ tikzit->styles()->refreshModels(_nodeModel, _edgeModel);
}
void StylePalette::changeNodeStyle(int increment)
@@ -161,6 +135,11 @@ void StylePalette::on_buttonOpenTikzstyles_clicked()
tikzit->openTikzStyles();
}
+void StylePalette::on_buttonEditTikzstyles_clicked()
+{
+ tikzit->showStyleEditor();
+}
+
void StylePalette::on_buttonRefreshTikzstyles_clicked()
{
QSettings settings("tikzit", "tikzit");
diff --git a/src/gui/stylepalette.h b/src/gui/stylepalette.h
index 45dc8da..3c0c721 100644
--- a/src/gui/stylepalette.h
+++ b/src/gui/stylepalette.h
@@ -44,6 +44,7 @@ public slots:
void nodeStyleDoubleClicked(const QModelIndex &index);
void edgeStyleDoubleClicked(const QModelIndex &index);
void on_buttonOpenTikzstyles_clicked();
+ void on_buttonEditTikzstyles_clicked();
void on_buttonRefreshTikzstyles_clicked();
//void on_buttonApplyNodeStyle_clicked();
diff --git a/src/gui/stylepalette.ui b/src/gui/stylepalette.ui
index 4f5b58d..10b80fb 100644
--- a/src/gui/stylepalette.ui
+++ b/src/gui/stylepalette.ui
@@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>88</width>
- <height>518</height>
+ <height>506</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -72,6 +72,20 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="buttonEditTikzstyles">
+ <property name="toolTip">
+ <string>New Project</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../tikzit.qrc">
+ <normaloff>:/images/document-new.svg</normaloff>:/images/document-new.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QToolButton" name="buttonRefreshTikzstyles">
<property name="text">
<string/>
diff --git a/src/main.cpp b/src/main.cpp
index 412f15f..1fcefc0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,10 +28,16 @@
#include <QApplication>
#include <QMenuBar>
+// #ifdef Q_OS_WIN
+// #include <Windows.h>
+// #endif
int main(int argc, char *argv[])
{
+ // #ifdef Q_OS_WIN
+ // SetProcessDPIAware();
+ // #endif
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
//QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
diff --git a/src/tikzit.cpp b/src/tikzit.cpp
index 9a4e166..1dc8bd9 100644
--- a/src/tikzit.cpp
+++ b/src/tikzit.cpp
@@ -47,6 +47,8 @@ void Tikzit::init(QApplication *app)
//_stylePalette = new StylePalette(dummy);
_styles = new TikzStyles(this);
+ _styleEditor = new StyleEditor();
+
//_stylePalette->show();
_windows << new MainWindow();
_windows[0]->show();
@@ -176,6 +178,11 @@ void Tikzit::loadStyles(QString fileName)
}
}
+void Tikzit::showStyleEditor()
+{
+ _styleEditor->show();
+}
+
QString Tikzit::styleFile() const
{
return _styleFile;
diff --git a/src/tikzit.h b/src/tikzit.h
index 232a4aa..3369962 100644
--- a/src/tikzit.h
+++ b/src/tikzit.h
@@ -53,6 +53,7 @@
#include "mainmenu.h"
#include "ui_mainmenu.h"
+#include "styleeditor.h"
#include "toolpalette.h"
#include "propertypalette.h"
#include "stylepalette.h"
@@ -116,6 +117,7 @@ public:
void openTikzStyles();
void loadStyles(QString fileName);
+ void showStyleEditor();
TikzStyles *styles() const;
QString styleFile() const;
//StylePalette *stylePalette() const;
@@ -133,7 +135,7 @@ private:
MainWindow *_activeWindow;
TikzStyles *_styles;
QString _styleFile;
-
+ StyleEditor *_styleEditor;
};
extern Tikzit *tikzit;
diff --git a/src/util.cpp b/src/util.cpp
index 9c699f5..d5e2b96 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -18,6 +18,7 @@
#include "util.h"
+
float bezierInterpolate(float dist, float c0, float c1, float c2, float c3) {
float distp = 1 - dist;
return (distp*distp*distp) * c0 +
diff --git a/src/util.h b/src/util.h
index aff0587..89d0c5b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -25,6 +25,7 @@
#include <QPoint>
#include <QString>
+#include <QColor>
#include <cmath>
#ifndef M_PI