summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2020-04-18 23:05:52 +0100
committerAleks Kissinger <aleks0@gmail.com>2020-04-18 23:05:52 +0100
commit706b7fc38c4ed4769a3a1a8602e729b672f13118 (patch)
tree1ae3124a5d70323828f2affb78ffbac82b9e08eb
parentef07176e5c5c8e2aa9ea5a380000302234f2934c (diff)
set no fill and no draw
-rw-r--r--src/data/style.cpp10
-rw-r--r--src/data/style.h11
-rw-r--r--src/gui/styleeditor.cpp81
-rw-r--r--src/gui/styleeditor.h2
-rw-r--r--src/gui/styleeditor.ui38
-rw-r--r--tex/logo.tikzstyles1
6 files changed, 115 insertions, 28 deletions
diff --git a/src/data/style.cpp b/src/data/style.cpp
index fe33ee0..af6a13f 100644
--- a/src/data/style.cpp
+++ b/src/data/style.cpp
@@ -67,6 +67,16 @@ QBrush Style::brush() const
else return QBrush(tikzit->colorByName(col));
}
+bool Style::hasFill() const
+{
+ return (propertyWithDefault("fill", "none") != "none");
+}
+
+bool Style::hasStroke() const
+{
+ return (propertyWithDefault("draw", "none") != "none");
+}
+
QString Style::shape(bool tikzitOverride) const
{
return propertyWithDefault("shape", "circle", tikzitOverride);
diff --git a/src/data/style.h b/src/data/style.h
index 78e11dc..0e795e1 100644
--- a/src/data/style.h
+++ b/src/data/style.h
@@ -57,18 +57,21 @@ public:
void setName(const QString &name);
QString propertyWithDefault(QString prop, QString def, bool tikzitOverride=true) const;
QString tikz() const;
- void setArrowAtom(QString atom);
-
- // only relevant for node styles
QColor fillColor(bool tikzitOverride=true) const;
QBrush brush() const;
+ bool hasFill() const;
+ bool hasStroke() const;
+
+ // only relevant for node styles
QString shape(bool tikzitOverride=true) const;
+ QString category() const;
// only relevant for edge styles
Style::ArrowTipStyle arrowHead() const;
Style::ArrowTipStyle arrowTail() const;
Style::DrawStyle drawStyle() const;
- QString category() const;
+ void setArrowAtom(QString atom);
+
protected:
QString _name;
diff --git a/src/gui/styleeditor.cpp b/src/gui/styleeditor.cpp
index e2ade45..f8972b1 100644
--- a/src/gui/styleeditor.cpp
+++ b/src/gui/styleeditor.cpp
@@ -32,8 +32,8 @@ StyleEditor::StyleEditor(QWidget *parent) :
{
ui->setupUi(this);
_formWidgets << ui->name << ui->category <<
- ui->fillColor << ui->hasTikzitFillColor << ui->tikzitFillColor <<
- ui->drawColor << ui->hasTikzitDrawColor << ui->tikzitDrawColor <<
+ ui->fillColor << ui->noFill << ui->hasTikzitFillColor << ui->tikzitFillColor <<
+ ui->drawColor << ui->noDraw << ui->hasTikzitDrawColor << ui->tikzitDrawColor <<
ui->shape << ui->hasTikzitShape << ui->tikzitShape <<
ui->leftArrow << ui->rightArrow <<
ui->properties;
@@ -283,8 +283,16 @@ void StyleEditor::refreshDisplay()
// draw
QColor realDraw = s->strokeColor(false);
QColor draw = s->strokeColor();
- ui->drawColor->setEnabled(true);
- setColor(ui->drawColor, realDraw);
+
+ ui->noDraw->setEnabled(true);
+ if (s->hasStroke()) {
+ ui->drawColor->setEnabled(true);
+ setColor(ui->drawColor, realDraw);
+ ui->noDraw->setChecked(false);
+ } else {
+ ui->noDraw->setChecked(true);
+ ui->drawColor->setEnabled(false);
+ }
// tikzit draw
bool drawOverride = s->data()->hasProperty("tikzit draw");
@@ -294,6 +302,27 @@ void StyleEditor::refreshDisplay()
ui->tikzitDrawColor->setEnabled(drawOverride);
if (drawOverride) setColor(ui->tikzitDrawColor, draw);
+ // fill
+ QColor realFill = s->fillColor(false);
+ QColor fill = s->fillColor();
+
+ ui->noFill->setEnabled(true);
+ if (s->hasFill()) {
+ ui->fillColor->setEnabled(true);
+ setColor(ui->fillColor, realFill);
+ ui->noFill->setChecked(false);
+ } else {
+ ui->noFill->setChecked(true);
+ ui->fillColor->setEnabled(false);
+ }
+
+ // tikzit fill
+ bool fillOverride = s->data()->hasProperty("tikzit fill");
+ ui->hasTikzitFillColor->setEnabled(true);
+ ui->hasTikzitFillColor->setChecked(fillOverride);
+ ui->tikzitFillColor->setEnabled(fillOverride);
+ if (fillOverride) setColor(ui->tikzitFillColor, fill);
+
if (!s->isEdgeStyle()) {
// qDebug() << "node style update";
// category
@@ -301,19 +330,6 @@ void StyleEditor::refreshDisplay()
ui->category->setCurrentText(
s->propertyWithDefault("tikzit category", "", false));
- // fill
- QColor realFill = s->fillColor(false);
- QColor fill = s->fillColor();
- ui->fillColor->setEnabled(true);
- setColor(ui->fillColor, realFill);
-
- // tikzit fill
- bool fillOverride = s->data()->hasProperty("tikzit fill");
- ui->hasTikzitFillColor->setEnabled(true);
- ui->hasTikzitFillColor->setChecked(fillOverride);
- ui->tikzitFillColor->setEnabled(fillOverride);
- if (fillOverride) setColor(ui->tikzitFillColor, fill);
-
// shape
QString realShape = s->propertyWithDefault("shape", "", false);
QString shape = s->propertyWithDefault("tikzit shape", "", false);
@@ -327,13 +343,6 @@ void StyleEditor::refreshDisplay()
ui->tikzitShape->setEnabled(shapeOverride);
if (shapeOverride) ui->tikzitShape->setCurrentText(shape);
} else {
-// qDebug() << "edge style update";
-
- // set fill to gray (disabled)
- ui->fillColor->setEnabled(false);
- ui->tikzitFillColor->setEnabled(false);
- ui->hasTikzitFillColor->setEnabled(false);
-
ui->shape->setEnabled(false);
ui->tikzitShape->setEnabled(false);
ui->hasTikzitShape->setEnabled(false);
@@ -425,6 +434,30 @@ void StyleEditor::on_hasTikzitDrawColor_stateChanged(int state)
}
}
+void StyleEditor::on_noFill_stateChanged(int state)
+{
+ Style *s = activeStyle();
+ if (s != nullptr) {
+ if (state == Qt::Checked) s->data()->setProperty("fill", "none");
+ else s->data()->setProperty("fill", "white");
+ refreshActiveStyle();
+ refreshDisplay();
+ setDirty(true);
+ }
+}
+
+void StyleEditor::on_noDraw_stateChanged(int state)
+{
+ Style *s = activeStyle();
+ if (s != nullptr) {
+ if (state == Qt::Checked) s->data()->setProperty("draw", "none");
+ else s->data()->setProperty("draw", "black");
+ refreshActiveStyle();
+ refreshDisplay();
+ setDirty(true);
+ }
+}
+
void StyleEditor::on_hasTikzitShape_stateChanged(int state)
{
Style *s = activeStyle();
diff --git a/src/gui/styleeditor.h b/src/gui/styleeditor.h
index 2c35d56..7fc62c0 100644
--- a/src/gui/styleeditor.h
+++ b/src/gui/styleeditor.h
@@ -68,6 +68,8 @@ public slots:
void on_tikzitDrawColor_clicked();
void on_hasTikzitFillColor_stateChanged(int state);
void on_hasTikzitDrawColor_stateChanged(int state);
+ void on_noFill_stateChanged(int state);
+ void on_noDraw_stateChanged(int state);
void on_hasTikzitShape_stateChanged(int state);
void on_tikzitShape_currentIndexChanged(int);
diff --git a/src/gui/styleeditor.ui b/src/gui/styleeditor.ui
index 9c06894..22b04a6 100644
--- a/src/gui/styleeditor.ui
+++ b/src/gui/styleeditor.ui
@@ -822,6 +822,44 @@
<bool>true</bool>
</attribute>
</widget>
+ <widget class="QCheckBox" name="noFill">
+ <property name="geometry">
+ <rect>
+ <x>340</x>
+ <y>110</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>9</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>none</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="noDraw">
+ <property name="geometry">
+ <rect>
+ <x>340</x>
+ <y>140</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>9</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>none</string>
+ </property>
+ </widget>
</widget>
</widget>
<resources/>
diff --git a/tex/logo.tikzstyles b/tex/logo.tikzstyles
index 4e05673..3419ee3 100644
--- a/tex/logo.tikzstyles
+++ b/tex/logo.tikzstyles
@@ -4,6 +4,7 @@
% \tikzstyle{NAME}=[PROPERTY LIST]
% Node styles
+\tikzstyle{test}=[fill=none, draw=black, shape=circle]
% Edge styles
\tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}]