diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 060072f..db3344f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -5,7 +5,6 @@ project (app CXX) set (qtlabels_sources qtlabels_main.cpp BarcodeStyle.cpp - Color.cpp ColorNode.cpp LabelModel.cpp LabelModelItem.cpp diff --git a/app/Color.cpp b/app/Color.cpp deleted file mode 100644 index 6c1fabd..0000000 --- a/app/Color.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* Color.cpp - * - * Copyright (C) 2011 Jim Evins - * - * This file is part of qtLabels. - * - * qtLabels 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 3 of the License, or - * (at your option) any later version. - * - * qtLabels 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 qtLabels. If not, see . - */ - -#include "Color.h" diff --git a/app/Color.h b/app/Color.h deleted file mode 100644 index 84cd48d..0000000 --- a/app/Color.h +++ /dev/null @@ -1,153 +0,0 @@ -/* Color.h - * - * Copyright (C) 2011 Jim Evins - * - * This file is part of qtLabels. - * - * qtLabels 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 3 of the License, or - * (at your option) any later version. - * - * qtLabels 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 qtLabels. If not, see . - */ - -#ifndef qtlabels_Color_h -#define qtlabels_Color_h - -#include - - -namespace qtLabels -{ - - class Color - { - - public: - /* double RGBA Constructor */ - Color( double r = 0, double g = 0, double b = 0, double a = 1 ) - : m_r(r), m_g(g), m_b(b), m_a(a) - { - } - - - static Color from_byte_rgba( uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255 ) - { - return Color( r/255.0, g/255.0, b/255.0, a/255.0 ); - } - - - static Color from_legacy_color( uint32_t c ) - { - return Color( ((c>>24) & 0xff) / 255.0, - ((c>>16) & 0xff) / 255.0, - ((c>>8) & 0xff) / 255.0, - ((c) & 0xff) / 255.0 ); - } - - - static Color none() - { - return Color( 0, 0, 0, 0 ); - } - - - static Color black() - { - return Color( 0, 0, 0, 1 ); - } - - - static Color white() - { - return Color( 1, 1, 1, 1 ); - } - - - /* Muliply by opacity. Create new color by applying opacity. */ - Color operator*( double opacity ) const - { - return Color( m_r, m_g, m_b, m_a * opacity ); - } - - - uint32_t to_legacy_color() - { - uint32_t c = (((uint32_t)(m_r*255) & 0xff) << 24) | - (((uint32_t)(m_g*255) & 0xff) << 16) | - (((uint32_t)(m_b*255) & 0xff) << 8) | - (((uint32_t)(m_a*255) & 0xff)); - return c; - } - - - bool operator==( const Color &c ) - { - return ( (m_r == c.m_r) && - (m_g == c.m_g) && - (m_b == c.m_b) && - (m_a == c.m_a) ); - } - - - bool operator!=( const Color &c ) - { - return ( (m_r != c.m_r) || - (m_g != c.m_g) || - (m_b != c.m_b) || - (m_a != c.m_a) ); - } - - - bool has_alpha() - { - return ( m_a != 0 ); - } - - - /* - * Red (r) Property - */ - double r( void ) { return m_r; } - void r( double value ) { m_r = value; } - - - /* - * Green (g) Property - */ - double g( void ) { return m_g; } - void g( double value ) { m_g = value; } - - - /* - * Blue (b) Property - */ - double b( void ) { return m_b; } - void b( double value ) { m_b = value; } - - - /* - * Alpha (a) Property - */ - double a( void ) { return m_a; } - void a( double value ) { m_a = value; } - - - private: - double m_r; - double m_g; - double m_b; - double m_a; - - }; - -} - -#endif // qtlabels_Color_h diff --git a/app/ColorNode.h b/app/ColorNode.h index 51f98d4..f5a80cb 100644 --- a/app/ColorNode.h +++ b/app/ColorNode.h @@ -22,8 +22,7 @@ #define qtlabels_ColorNode_h #include - -#include "Color.h" +#include namespace qtLabels @@ -34,25 +33,25 @@ namespace qtLabels public: ColorNode() - : m_field_flag(false), m_color(Color::none()), m_key("") + : m_field_flag(false), m_color(QColor::fromRgba(0x00000000)), m_key("") { } - ColorNode( bool field_flag, Color &color, QString &key ) + ColorNode( bool field_flag, QColor &color, QString &key ) : m_field_flag(field_flag), m_color(color), m_key(key) { } - ColorNode( const Color &color ) + ColorNode( const QColor &color ) : m_field_flag(false), m_color(color), m_key("") { } ColorNode( QString &key ) - : m_field_flag(true), m_color(Color::none()), m_key(key) + : m_field_flag(true), m_color(QColor::fromRgba(0x00000000)), m_key(key) { } @@ -74,13 +73,13 @@ namespace qtLabels #if TODO - Color expand( MergeRecord? record ) + QColor expand( MergeRecord? record ) { if ( field_flag ) { if ( record == null ) { - return Color.none(); + return QColor.fromRgba(0x00000000); } else { @@ -95,12 +94,12 @@ namespace qtLabels } else { - return Color.none(); + return Color.fromRgba(0x00000000); } } else { - return Color.none(); + return Color.fromRgba(0x00000000); } } } @@ -121,7 +120,7 @@ namespace qtLabels /* * color property */ - Color color( void ) { return m_color; } + QColor color( void ) { return m_color; } /* @@ -132,7 +131,7 @@ namespace qtLabels private: bool m_field_flag; - Color m_color; + QColor m_color; QString m_key; }; diff --git a/app/LabelModelItem.cpp b/app/LabelModelItem.cpp index 34ed5f5..263ccb9 100644 --- a/app/LabelModelItem.cpp +++ b/app/LabelModelItem.cpp @@ -38,7 +38,7 @@ namespace qtLabels m_shadow_state = false; m_shadow_x = 1.3; m_shadow_y = 1.3; - m_shadow_color_node = ColorNode( Color::black() ); + m_shadow_color_node = ColorNode( QColor::fromRgb(0x000000) ); m_shadow_opacity = 0.5; m_selected_flag = false; diff --git a/app/LabelModelItem.h b/app/LabelModelItem.h index 3df085e..b8712fc 100644 --- a/app/LabelModelItem.h +++ b/app/LabelModelItem.h @@ -244,7 +244,7 @@ namespace qtLabels */ Q_PROPERTY( ColorNode font_color_node READ font_color_node WRITE font_color_node ); - virtual ColorNode font_color_node( void ) { return ColorNode( Color::none() ); } + virtual ColorNode font_color_node( void ) { return ColorNode( QColor::fromRgba(0x00000000) ); } virtual void font_color_node( const ColorNode &value ) { } @@ -306,7 +306,7 @@ namespace qtLabels */ Q_PROPERTY( ColorNode line_color_node READ line_color_node WRITE line_color_node ); - virtual ColorNode line_color_node( void ) { return ColorNode( Color::none() ); } + virtual ColorNode line_color_node( void ) { return ColorNode( QColor::fromRgba(0x00000000) ); } virtual void line_color_node( const ColorNode &value ) { } @@ -315,7 +315,7 @@ namespace qtLabels */ Q_PROPERTY( ColorNode fill_color_node READ fill_color_node WRITE fill_color_node ); - virtual ColorNode fill_color_node( void ) { return ColorNode( Color::none() ); } + virtual ColorNode fill_color_node( void ) { return ColorNode( QColor::fromRgba(0x00000000) ); } virtual void fill_color_node( const ColorNode &value ) { } @@ -355,7 +355,7 @@ namespace qtLabels */ Q_PROPERTY( ColorNode bc_color_node READ bc_color_node WRITE bc_color_node ); - virtual ColorNode bc_color_node( void ) { return ColorNode( Color::none() ); } + virtual ColorNode bc_color_node( void ) { return ColorNode( QColor::fromRgba(0x00000000) ); } virtual void bc_color_node( const ColorNode &value ) { }