]> sigrok.org Git - pulseview.git/commitdiff
Integrated ColourButton into popup
authorJoel Holdsworth <redacted>
Sat, 5 Oct 2013 11:27:12 +0000 (12:27 +0100)
committerJoel Holdsworth <redacted>
Sun, 13 Oct 2013 10:05:23 +0000 (11:05 +0100)
CMakeLists.txt
pv/view/header.cpp
pv/view/signal.cpp
pv/view/trace.cpp
pv/view/trace.h
pv/view/tracepalette.cpp [new file with mode: 0644]
pv/view/tracepalette.h [new file with mode: 0644]

index 469cb5e22fb7c24598a15e6d8de4b6f80386bdcf..05af3458acf462527df0a0b04d1b225d9b4b70de 100644 (file)
@@ -138,9 +138,12 @@ set(pulseview_SOURCES
        pv/view/signal.cpp
        pv/view/timemarker.cpp
        pv/view/trace.cpp
        pv/view/signal.cpp
        pv/view/timemarker.cpp
        pv/view/trace.cpp
+       pv/view/tracepalette.cpp
        pv/view/view.cpp
        pv/view/viewport.cpp
        pv/view/decode/annotation.cpp
        pv/view/view.cpp
        pv/view/viewport.cpp
        pv/view/decode/annotation.cpp
+       pv/widgets/colourbutton.cpp
+       pv/widgets/colourpopup.cpp
        pv/widgets/popup.cpp
        pv/widgets/wellarray.cpp
 )
        pv/widgets/popup.cpp
        pv/widgets/wellarray.cpp
 )
@@ -166,6 +169,8 @@ set(pulseview_HEADERS
        pv/view/trace.h
        pv/view/view.h
        pv/view/viewport.h
        pv/view/trace.h
        pv/view/view.h
        pv/view/viewport.h
+       pv/widgets/colourbutton.h
+       pv/widgets/colourpopup.h
        pv/widgets/wellarray.h
 )
 
        pv/widgets/wellarray.h
 )
 
index f8f5b6380514ac2604730ce0a687c0c469fff04a..ba16247a8c8e5609245bc8233943295ff068b32b 100644 (file)
@@ -240,7 +240,10 @@ void Header::on_signals_changed()
        const vector< shared_ptr<Trace> > traces(_view.get_traces());
        BOOST_FOREACH(shared_ptr<Trace> t, traces) {
                assert(t);
        const vector< shared_ptr<Trace> > traces(_view.get_traces());
        BOOST_FOREACH(shared_ptr<Trace> t, traces) {
                assert(t);
-               connect(t.get(), SIGNAL(text_changed()), this, SLOT(update()));
+               connect(t.get(), SIGNAL(text_changed()),
+                       this, SLOT(update()));
+               connect(t.get(), SIGNAL(colour_changed()),
+                       this, SLOT(update()));
        }
 }
 
        }
 }
 
index 96417f2bdcd51a212713e59f5be414b274bbb156..dadba05aec0ed607927142edeab0e7fac1ec7adc 100644 (file)
@@ -88,6 +88,8 @@ void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
                this, SLOT(on_text_changed(const QString&)));
 
        form->addRow(tr("Name"), _name_widget);
                this, SLOT(on_text_changed(const QString&)));
 
        form->addRow(tr("Name"), _name_widget);
+
+       add_colour_option(parent, form);
 }
 
 } // namespace view
 }
 
 } // namespace view
index ebf28b6224c69a5786a760333b34dd99ec6d1f10..de036a941820dd256a1429f1545175cada6058de 100644 (file)
 #include <QInputDialog>
 
 #include "trace.h"
 #include <QInputDialog>
 
 #include "trace.h"
+#include "tracepalette.h"
 #include "view.h"
 
 #include "view.h"
 
-#include <pv/widgets/popup.h>
+#include <pv/widgets/colourbutton.h>
 
 namespace pv {
 namespace view {
 
 namespace pv {
 namespace view {
@@ -211,6 +212,20 @@ void Trace::paint_axis(QPainter &p, int y, int left, int right)
        p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f));
 }
 
        p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f));
 }
 
+void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
+{
+       using pv::widgets::ColourButton;
+
+       ColourButton *const colour_button = new ColourButton(
+               TracePalette::Rows, TracePalette::Cols, parent);
+       colour_button->set_palette(TracePalette::Colours);
+       colour_button->set_colour(_colour);
+       connect(colour_button, SIGNAL(selected(const QColor&)),
+               this, SLOT(on_colour_changed(const QColor&)));
+
+       form->addRow(tr("Colour"), colour_button);
+}
+
 void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        QLineEdit *const name_edit = new QLineEdit(parent);
 void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        QLineEdit *const name_edit = new QLineEdit(parent);
@@ -218,6 +233,8 @@ void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
        connect(name_edit, SIGNAL(textChanged(const QString&)),
                this, SLOT(on_text_changed(const QString&)));
        form->addRow(tr("Name"), name_edit);
        connect(name_edit, SIGNAL(textChanged(const QString&)),
                this, SLOT(on_text_changed(const QString&)));
        form->addRow(tr("Name"), name_edit);
+
+       add_colour_option(parent, form);
 }
 
 void Trace::compute_text_size(QPainter &p)
 }
 
 void Trace::compute_text_size(QPainter &p)
@@ -270,5 +287,11 @@ void Trace::on_text_changed(const QString &text)
        text_changed();
 }
 
        text_changed();
 }
 
+void Trace::on_colour_changed(const QColor &colour)
+{
+       set_colour(colour);
+       colour_changed();
+}
+
 } // namespace view
 } // namespace pv
 } // namespace view
 } // namespace pv
index 243bc2ad41c307799a32b81e03943e7d7db7c3f7..0b9c509aeda37e2f7e017ec1ffda7d0c7e1d6131 100644 (file)
@@ -158,6 +158,8 @@ protected:
         */
        void paint_axis(QPainter &p, int y, int left, int right);
 
         */
        void paint_axis(QPainter &p, int y, int left, int right);
 
+       void add_colour_option(QWidget *parent, QFormLayout *form);
+
        virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
 
 private:
        virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
 
 private:
@@ -183,8 +185,11 @@ private slots:
 
        void on_text_changed(const QString &text);
 
 
        void on_text_changed(const QString &text);
 
+       void on_colour_changed(const QColor &colour);
+
 signals:
        void text_changed();    
 signals:
        void text_changed();    
+       void colour_changed();
 
 protected:
        pv::SigSession &_session;
 
 protected:
        pv::SigSession &_session;
diff --git a/pv/view/tracepalette.cpp b/pv/view/tracepalette.cpp
new file mode 100644 (file)
index 0000000..cefb952
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include "tracepalette.h"
+
+namespace pv {
+namespace view {
+
+const QColor TracePalette::Colours[Cols * Rows] = {
+
+       // Light Colours
+       QColor(0xFC, 0xE9, 0x4F),       // Butter
+       QColor(0xFC, 0xAF, 0x3E),       // Orange
+       QColor(0xE9, 0xB9, 0x6E),       // Chocolate
+       QColor(0x8A, 0xE2, 0x34),       // Chameleon
+       QColor(0x72, 0x9F, 0xCF),       // Sky Blue
+       QColor(0xAD, 0x7F, 0xA8),       // Plum
+       QColor(0xCF, 0x72, 0xC3),       // Magenta
+       QColor(0xEF, 0x29, 0x29),       // Scarlet Red
+
+       // Mid Colours
+       QColor(0xED, 0xD4, 0x00),       // Butter
+       QColor(0xF5, 0x79, 0x00),       // Orange
+       QColor(0xC1, 0x7D, 0x11),       // Chocolate
+       QColor(0x73, 0xD2, 0x16),       // Chameleon
+       QColor(0x34, 0x65, 0xA4),       // Sky Blue
+       QColor(0x75, 0x50, 0x7B),       // Plum
+       QColor(0xA3, 0x34, 0x96),       // Magenta
+       QColor(0xCC, 0x00, 0x00),       // Scarlet Red
+
+       // Dark Colours
+       QColor(0xC4, 0xA0, 0x00),       // Butter
+       QColor(0xCE, 0x5C, 0x00),       // Orange
+       QColor(0x8F, 0x59, 0x02),       // Chocolate
+       QColor(0x4E, 0x9A, 0x06),       // Chameleon
+       QColor(0x20, 0x4A, 0x87),       // Sky Blue
+       QColor(0x5C, 0x35, 0x66),       // Plum
+       QColor(0x87, 0x20, 0x7A),       // Magenta
+       QColor(0xA4, 0x00, 0x00),       // Scarlet Red
+
+       // Greys
+       QColor(0x16, 0x19, 0x1A),       // Black
+       QColor(0x2E, 0x34, 0x36),       // Grey 1
+       QColor(0x55, 0x57, 0x53),       // Grey 2
+       QColor(0x88, 0x8A, 0x8F),       // Grey 3
+       QColor(0xBA, 0xBD, 0xB6),       // Grey 4
+       QColor(0xD3, 0xD7, 0xCF),       // Grey 5
+       QColor(0xEE, 0xEE, 0xEC),       // Grey 6
+       QColor(0xFF, 0xFF, 0xFF),       // White
+};
+
+} // view
+} // pv
diff --git a/pv/view/tracepalette.h b/pv/view/tracepalette.h
new file mode 100644 (file)
index 0000000..ae3c69a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_TRACEPALETTE_H
+#define PULSEVIEW_PV_TRACEPALETTE_H
+
+#include <QColor>
+
+namespace pv {
+namespace view {
+
+class TracePalette
+{
+public:
+       static const unsigned int Cols = 8;
+       static const unsigned int Rows = 4;
+       static const QColor Colours[Cols * Rows];
+};
+
+
+} // view
+} // pv
+
+#endif // PULSEVIEW_PV_VIEW_TRACEPALETTE_H