Refactoring: layColor -> tlColor

This commit is contained in:
Matthias Koefferlein
2022-05-30 23:21:32 +02:00
parent 84cf60dbb7
commit 62bbef53ac
91 changed files with 555 additions and 555 deletions
+4 -4
View File
@@ -299,22 +299,22 @@ static void clear_lower_hier_level (lay::LayerProperties *n)
n->set_source (s);
}
static lay::color_t get_eff_frame_color_1 (const lay::LayerProperties *n)
static tl::color_t get_eff_frame_color_1 (const lay::LayerProperties *n)
{
return n->eff_frame_color (true);
}
static lay::color_t get_eff_fill_color_1 (const lay::LayerProperties *n)
static tl::color_t get_eff_fill_color_1 (const lay::LayerProperties *n)
{
return n->eff_fill_color (true);
}
static lay::color_t get_frame_color_1 (const lay::LayerProperties *n)
static tl::color_t get_frame_color_1 (const lay::LayerProperties *n)
{
return n->frame_color (true);
}
static lay::color_t get_fill_color_1 (const lay::LayerProperties *n)
static tl::color_t get_fill_color_1 (const lay::LayerProperties *n)
{
return n->fill_color (true);
}
@@ -329,23 +329,23 @@ static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::
static lay::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
{
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box);
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
}
static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
{
return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box);
return view->get_pixels_with_options_mono (width, height, linewidth, tl::Color (), tl::Color (), tl::Color (), target_box);
}
static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
{
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome);
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
}
#if defined(HAVE_QTBINDINGS)
static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
{
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome);
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
}
#endif
+4 -4
View File
@@ -37,13 +37,13 @@ lay::DMarker *create_marker (lay::LayoutViewBase *view)
static
void reset_frame_color (lay::DMarker *marker)
{
marker->set_frame_color (lay::Color ());
marker->set_frame_color (tl::Color ());
}
static
void set_frame_color (lay::DMarker *marker, unsigned int color)
{
marker->set_frame_color (lay::Color (color));
marker->set_frame_color (tl::Color (color));
}
static
@@ -61,13 +61,13 @@ bool has_frame_color (const lay::DMarker *marker)
static
void reset_color (lay::DMarker *marker)
{
marker->set_color (lay::Color ());
marker->set_color (tl::Color ());
}
static
void set_color (lay::DMarker *marker, unsigned int color)
{
marker->set_color (lay::Color (color));
marker->set_color (tl::Color (color));
}
static
@@ -46,16 +46,16 @@ static void fill_with_qcolor (lay::PixelBuffer *pb, QColor c)
}
#endif
lay::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned int x, unsigned int y)
tl::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned int x, unsigned int y)
{
if (x < pb->width () && y < pb->height ()) {
return pb->scan_line (y)[x];
} else {
return lay::color_t (0);
return tl::color_t (0);
}
}
void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, lay::color_t c)
void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, tl::color_t c)
{
if (! pb->transparent ()) {
c |= 0xff000000; // ensures that alpha is set properly even if not required
+6 -6
View File
@@ -462,7 +462,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
std::vector<lay::ViewOp> view_ops;
std::vector<const lay::Bitmap *> pbitmaps;
std::vector<std::pair <lay::color_t, lay::color_t> > masks;
std::vector<std::pair <tl::color_t, tl::color_t> > masks;
std::vector<uint32_t> non_empty_sls;
view_ops.reserve (n_in);
@@ -588,13 +588,13 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
if (masks.size () > 0) {
lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y);
tl::color_t *pt = (tl::color_t *) pimage->scan_line (height - 1 - y);
uint32_t *dptr_end = dptr;
unsigned int i = 0;
for (unsigned int x = 0; x < width; x += 32, ++i) {
lay::color_t y[32];
tl::color_t y[32];
if (transparent) {
for (int i = 0; i < 32; ++i) {
y[i] = 0;
@@ -605,7 +605,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
}
};
lay::color_t z[32] = {
tl::color_t z[32] = {
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
@@ -700,7 +700,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
std::vector<lay::ViewOp> view_ops;
std::vector<const lay::Bitmap *> pbitmaps;
std::vector<std::pair <lay::color_t, lay::color_t> > masks;
std::vector<std::pair <tl::color_t, tl::color_t> > masks;
std::vector<uint32_t> non_empty_sls;
view_ops.reserve (n_in);
@@ -825,7 +825,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
if (masks.size () > 0) {
lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y);
tl::color_t *pt = (tl::color_t *) pimage->scan_line (height - 1 - y);
uint32_t *dptr_end = dptr;
unsigned int i = 0;
-199
View File
@@ -1,199 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
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 "layColor.h"
#include "tlString.h"
#include "tlMath.h"
#include <ctype.h>
#include <algorithm>
namespace lay
{
Color::Color ()
: m_color (0)
{
// .. nothing yet ..
}
Color::Color (color_t color)
: m_color (color | 0xff000000)
{
// .. nothing yet ..
}
Color::Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha)
: m_color ((b & 0xff) | ((g & 0xff) << 8) | ((r & 0xff) << 16) | ((alpha & 0xff) << 24))
{
// .. nothing yet ..
}
Color::Color (const std::string &name)
{
m_color = 0;
tl::Extractor ex (name.c_str ());
unsigned int n = 0;
ex.test ("#");
while (! ex.at_end ()) {
char c = tolower (*ex.get ());
if (c >= '0' && c <= '9') {
m_color <<= 4;
m_color |= (c - '0');
++n;
} else if (c >= 'a' && c <= 'f') {
m_color <<= 4;
m_color |= (c - 'a') + 10;
++n;
}
++ex;
}
if (n == 0) {
m_color = 0;
} else if (n <= 3) {
m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | 0xff000000;
} else if (n <= 4) {
m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | ((m_color & 0xf000) * 0x11000);
} else if (n <= 6) {
m_color |= 0xff000000;
}
}
std::string
Color::to_string () const
{
if (! is_valid ()) {
return std::string ();
} else {
unsigned int n = 8;
if ((m_color & 0xff000000) == 0xff000000) {
n = 6;
}
uint32_t c = m_color;
char s [10];
s[n + 1] = 0;
s[0] = '#';
while (n > 0) {
s [n] = "0123456789abcdef" [c & 0xf];
c >>= 4;
--n;
}
return std::string (s);
}
}
bool
Color::is_valid () const
{
return (m_color & 0xff000000) != 0;
}
void
Color::get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const
{
double r = double (red ()) / 255.0;
double g = double (green ()) / 255.0;
double b = double (blue ()) / 255.0;
double max = std::max (r, std::max (g, b));
double min = std::min (r, std::min (g, b));
double delta = max - min;
value = (unsigned int) tl::round (255.0 * max, 1);
hue = 0;
saturation = 0;
if (! tl::equal (delta, 0.0)) {
saturation = (unsigned int) tl::round (255.0 * delta / max, 1);
double h = 0.0;
if (tl::equal (r, max)) {
h = (g - b) / delta;
} else if (tl::equal (g, max)) {
h = 2.0f + (b - r) / delta;
} else if (tl::equal (b, max)) {
h = 4.0f + (r - g) / delta;
}
h *= 60.0;
if (tl::less (h, 0.0)) {
h += 360.0;
}
hue = (unsigned int) tl::round (h, 1);
}
}
static lay::Color color_d (double r, double g, double b)
{
return lay::Color (tl::round (r * 255.0, 1), tl::round (g * 255.0, 1), tl::round (b * 255.0, 1));
}
lay::Color
Color::from_hsv (unsigned int hue, unsigned int saturation, unsigned int value)
{
if (saturation == 0) {
return lay::Color (value, value, value);
}
hue = (hue + 360) % 360;
double h = double (hue) / 60.0;
double s = double (saturation) / 255.0;
double v = double (value) / 255.0;
int i = int (tl::round_down (h, 1));
double f = (i & 1) != 0 ? h - i : 1.0 - h + i;
double p = v * (1.0 - s);
double q = v * (1.0 - s * f);
switch (i) {
case 0:
return color_d (v, q, p);
case 1:
return color_d (q, v, p);
case 2:
return color_d (p, v, q);
case 3:
return color_d (p, q, v);
case 4:
return color_d (q, p, v);
case 5:
return color_d (v, p, q);
default:
return lay::Color ();
}
}
}
-179
View File
@@ -1,179 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
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 HDR_layColor
#define HDR_layColor
#include "laybasicCommon.h"
#include <stdint.h>
#include <string>
namespace lay
{
/**
* @brief The basic color type for a RGB triplet
*/
typedef uint32_t color_t;
/**
* @brief Gets the color components from a color_t
*/
inline unsigned int alpha (color_t c) { return (c >> 24) & 0xff; }
inline unsigned int red (color_t c) { return (c >> 16) & 0xff; }
inline unsigned int green (color_t c) { return (c >> 8) & 0xff; }
inline unsigned int blue (color_t c) { return c & 0xff; }
/**
* @brief A wrapper for a color value
*
* This class is a replacement for QColor. It offers invalid color values and
* string conversion.
*/
class LAYBASIC_PUBLIC Color
{
public:
/**
* @brief Default constructor - creates an invalid color
*/
Color ();
/**
* @brief Creates a color from a RGB triplet
*/
Color (color_t color);
/**
* @brief Creates a color from a RGB triplet and alpha value
*
* An alpha value of 0 generates an invalid color.
*/
Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha = 0xff);
/**
* @brief Creates a color value from a string
*/
Color (const std::string &name);
/**
* @brief Comparison: equal
*/
bool operator== (const Color &color) const
{
return m_color == color.m_color;
}
/**
* @brief Comparison: not equal
*/
bool operator!= (const Color &color) const
{
return m_color != color.m_color;
}
/**
* @brief Comparison: less
*/
bool operator< (const Color &color) const
{
return m_color < color.m_color;
}
/**
* @brief Gets the string value from a color
*/
std::string to_string () const;
/**
* @brief Gets a value indicating whether the color is valid
*/
bool is_valid () const;
/**
* @brief Gets the RGB triplet
*/
color_t rgb () const
{
return m_color;
}
/**
* @brief Gets the alpha component
*/
unsigned int alpha () const
{
return (m_color & 0xff000000) >> 24;
}
/**
* @brief Gets the red component
*/
unsigned int red () const
{
return (m_color & 0xff0000) >> 16;
}
/**
* @brief Gets the green component
*/
unsigned int green () const
{
return (m_color & 0xff00) >> 8;
}
/**
* @brief Gets the blue component
*/
unsigned int blue () const
{
return (m_color & 0xff);
}
/**
* @brief Converts the color into monochrome "on" value
*/
bool to_mono () const
{
return (m_color & 0x8000) != 0;
}
/**
* @brief Gets the HSV color components
* hue: 0..359
* saturation: 0..255
* value: 0..255
*/
void get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const;
/**
* @brief Creates the color from a HSV color
*/
static lay::Color from_hsv (unsigned int hue, unsigned int saturation, unsigned int value);
private:
color_t m_color;
};
}
#endif
+5 -5
View File
@@ -87,7 +87,7 @@ ColorPalette::ColorPalette ()
// .. nothing yet ..
}
ColorPalette::ColorPalette (const std::vector<lay::color_t> &colors, const std::vector<unsigned int> &luminous_colors)
ColorPalette::ColorPalette (const std::vector<tl::color_t> &colors, const std::vector<unsigned int> &luminous_colors)
: m_colors (colors), m_luminous_color_indices (luminous_colors)
{
// .. nothing yet ..
@@ -115,7 +115,7 @@ ColorPalette::operator== (const ColorPalette &d) const
return m_colors == d.m_colors && m_luminous_color_indices == d.m_luminous_color_indices;
}
lay::color_t
tl::color_t
ColorPalette::color_by_index (unsigned int n) const
{
return m_colors [n % colors ()];
@@ -140,7 +140,7 @@ ColorPalette::luminous_colors () const
}
void
ColorPalette::set_color (unsigned int n, lay::color_t c)
ColorPalette::set_color (unsigned int n, tl::color_t c)
{
while (m_colors.size () <= n) {
m_colors.push_back (0);
@@ -180,7 +180,7 @@ ColorPalette::to_string () const
res += " ";
}
lay::color_t c = m_colors [i];
tl::color_t c = m_colors [i];
res += tl::sprintf ("%d,%d,%d", (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
for (unsigned int j = 0; j < m_luminous_color_indices.size (); ++j) {
@@ -217,7 +217,7 @@ ColorPalette::from_string (const std::string &s, bool simple)
}
x.expect (",").read (g).expect (",").read (b);
m_colors.push_back (0xff000000 | (lay::color_t (r & 0xff) << 16) | (lay::color_t (g & 0xff) << 8) | lay::color_t (b & 0xff));
m_colors.push_back (0xff000000 | (tl::color_t (r & 0xff) << 16) | (tl::color_t (g & 0xff) << 8) | tl::color_t (b & 0xff));
if (x.test ("[")) {
x.read (lc).expect ("]");
+5 -5
View File
@@ -51,7 +51,7 @@ public:
* @param color The colors as a vector
* @param luminous_colors The list of indices of luminous colors as a vector
*/
ColorPalette (const std::vector<lay::color_t> &colors, const std::vector<unsigned int> &luminous_colors);
ColorPalette (const std::vector<tl::color_t> &colors, const std::vector<unsigned int> &luminous_colors);
/**
* @brief Copy constructor
@@ -79,7 +79,7 @@ public:
/**
* @brief Change a specific color
*/
void set_color (unsigned int n, lay::color_t c);
void set_color (unsigned int n, tl::color_t c);
/**
* @brief Clear the colors list
@@ -99,7 +99,7 @@ public:
/**
* @brief Retrieve the color by index
*/
lay::color_t color_by_index (unsigned int n) const;
tl::color_t color_by_index (unsigned int n) const;
/**
* @brief Retrieve the number of colors in the palette
@@ -111,7 +111,7 @@ public:
/**
* @brief Retrieve the luminous color by index
*/
lay::color_t
tl::color_t
luminous_color_by_index (unsigned int n) const
{
return color_by_index (luminous_color_index_by_index (n));
@@ -157,7 +157,7 @@ public:
static ColorPalette default_palette ();
private:
std::vector <lay::color_t> m_colors;
std::vector <tl::color_t> m_colors;
std::vector <unsigned int> m_luminous_color_indices;
};
+4 -4
View File
@@ -44,7 +44,7 @@ ColorConverter::to_string (const QColor &c) const
#endif
std::string
ColorConverter::to_string (const lay::Color &c) const
ColorConverter::to_string (const tl::Color &c) const
{
if (! c.is_valid ()) {
return "auto";
@@ -67,13 +67,13 @@ ColorConverter::from_string (const std::string &s, QColor &c) const
#endif
void
ColorConverter::from_string (const std::string &s, lay::Color &c) const
ColorConverter::from_string (const std::string &s, tl::Color &c) const
{
std::string t (tl::trim (s));
if (t == "auto") {
c = lay::Color ();
c = tl::Color ();
} else {
c = lay::Color (t);
c = tl::Color (t);
}
}
+3 -3
View File
@@ -25,7 +25,7 @@
#define HDR_layConverters
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#if defined(HAVE_QT)
# include <QColor>
@@ -43,8 +43,8 @@ struct LAYBASIC_PUBLIC ColorConverter
std::string to_string (const QColor &c) const;
void from_string (const std::string &s, QColor &c) const;
#endif
std::string to_string (const lay::Color &c) const;
void from_string (const std::string &s, lay::Color &c) const;
std::string to_string (const tl::Color &c) const;
void from_string (const std::string &s, tl::Color &c) const;
};
}
+1 -1
View File
@@ -121,7 +121,7 @@ public:
/**
* @brief Get the current appearance
*/
virtual std::vector <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const = 0;
virtual std::vector <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, tl::Color background, tl::Color foreground, tl::Color active) const = 0;
private:
unsigned int m_num_planes;
@@ -63,7 +63,7 @@ public:
uint32_t cursor_color (lay::ViewObjectCanvas &canvas) const
{
lay::Color color;
tl::Color color;
if (mp_service) {
color = mp_service->tracking_cursor_color ();
}
@@ -267,7 +267,7 @@ EditorServiceBase::configure (const std::string &name, const std::string &value)
if (name == cfg_tracking_cursor_color) {
lay::Color color;
tl::Color color;
lay::ColorConverter ().from_string (value, color);
if (color != m_cursor_color) {
+2 -2
View File
@@ -92,7 +92,7 @@ public:
/**
* @brief Gets the tracking cursor color
*/
lay::Color tracking_cursor_color () const
tl::Color tracking_cursor_color () const
{
return m_cursor_color;
}
@@ -133,7 +133,7 @@ protected:
private:
// The marker representing the mouse cursor
std::vector<lay::ViewObject *> m_mouse_cursor_markers;
lay::Color m_cursor_color;
tl::Color m_cursor_color;
bool m_cursor_enabled;
bool m_has_tracking_position;
db::DPoint m_tracking_position;
+12 -12
View File
@@ -48,8 +48,8 @@ namespace lay
* All channels are scaled the same way in order not to change the
* color but the brightness alone.
*/
color_t
LayerProperties::brighter (color_t in, int x)
tl::color_t
LayerProperties::brighter (tl::color_t in, int x)
{
// shortcut for no correction
if (x == 0) {
@@ -248,25 +248,25 @@ LayerProperties::is_visual () const
return valid (true) && visible (true) && (layer_index () >= 0 || is_cell_box_layer ());
}
color_t
tl::color_t
LayerProperties::eff_frame_color (bool real) const
{
return brighter (frame_color (real) & 0xffffff, frame_brightness (real));
}
color_t
tl::color_t
LayerProperties::eff_fill_color (bool real) const
{
return brighter (fill_color (real) & 0xffffff, fill_brightness (real));
}
color_t
tl::color_t
LayerProperties::eff_frame_color_brighter (bool real, int plus_brightness) const
{
return brighter (frame_color (real) & 0xffffff, frame_brightness (real) + plus_brightness);
}
color_t
tl::color_t
LayerProperties::eff_fill_color_brighter (bool real, int plus_brightness) const
{
return brighter (fill_color (real) & 0xffffff, fill_brightness (real) + plus_brightness);
@@ -1645,21 +1645,21 @@ LayerPropertiesList::back () const
struct UIntColorConverter
: private ColorConverter
{
std::string to_string (const color_t &c) const
std::string to_string (const tl::color_t &c) const
{
if (c == 0) {
return "";
} else {
return ColorConverter::to_string (lay::Color (c | 0xff000000));
return ColorConverter::to_string (tl::Color (c | 0xff000000));
}
}
void from_string (const std::string &s, color_t &c) const
void from_string (const std::string &s, tl::color_t &c) const
{
if (s.empty ()) {
c = 0;
} else {
lay::Color qc;
tl::Color qc;
ColorConverter::from_string (s, qc);
c = qc.rgb () | 0xff000000;
}
@@ -1767,8 +1767,8 @@ struct LineStyleIndexConverter
static const tl::XMLElementList layer_element = tl::XMLElementList (
// HINT: these make_member calls want to be qualified: otherwise an internal error
// was observed ..
tl::make_member<lay::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
tl::make_member<lay::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::frame_brightness_loc, &LayerPropertiesNode::set_frame_brightness, "frame-brightness") +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::fill_brightness_loc, &LayerPropertiesNode::set_fill_brightness, "fill-brightness") +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::dither_pattern_loc, &LayerPropertiesNode::set_dither_pattern, "dither-pattern", DitherPatternIndexConverter ()) +
+17 -17
View File
@@ -137,7 +137,7 @@ public:
/**
* @brief Utility: compute the effective color from a color with brightness correction
*/
static color_t brighter (color_t in, int b);
static tl::color_t brighter (tl::color_t in, int b);
/**
* @brief render the effective frame color
@@ -145,7 +145,7 @@ public:
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_frame_color (bool real) const;
tl::color_t eff_frame_color (bool real) const;
/**
* @brief render the effective fill color
@@ -153,7 +153,7 @@ public:
* The effective fill color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_fill_color (bool real) const;
tl::color_t eff_fill_color (bool real) const;
/**
* @brief render the effective frame color plus an additional brightness adjustment
@@ -161,7 +161,7 @@ public:
* This method returns the effective frame color with an additional brightness adjustment
* applied.
*/
color_t eff_frame_color_brighter (bool real, int plus_brightness) const;
tl::color_t eff_frame_color_brighter (bool real, int plus_brightness) const;
/**
* @brief render the effective frame color plus an additional brightness adjustment
@@ -169,14 +169,14 @@ public:
* This method returns the effective fill color with an additional brightness adjustment
* applied.
*/
color_t eff_fill_color_brighter (bool real, int plus_brightness) const;
tl::color_t eff_fill_color_brighter (bool real, int plus_brightness) const;
/**
* @brief Get the frame color
*
* This method may return an invalid color if the color is not set.
*/
color_t frame_color (bool real) const
tl::color_t frame_color (bool real) const
{
if (real) {
ensure_visual_realized ();
@@ -193,7 +193,7 @@ public:
* To clear the frame color, pass 0 to this method. Valid colors have the
* upper 8 bits set.
*/
void set_frame_color_code (color_t c)
void set_frame_color_code (tl::color_t c)
{
refresh ();
if (m_frame_color != c) {
@@ -205,7 +205,7 @@ public:
/**
* @brief Set the frame color to the given value
*/
void set_frame_color (color_t c)
void set_frame_color (tl::color_t c)
{
set_frame_color_code (c | 0xff000000);
}
@@ -231,7 +231,7 @@ public:
*
* This method may return an invalid color if the color is not set.
*/
color_t fill_color (bool real) const
tl::color_t fill_color (bool real) const
{
if (real) {
ensure_visual_realized ();
@@ -248,7 +248,7 @@ public:
* To clear the fill color, pass 0 to this method. Valid colors have the
* upper 8 bits set.
*/
void set_fill_color_code (color_t c)
void set_fill_color_code (tl::color_t c)
{
refresh ();
if (m_fill_color != c) {
@@ -260,7 +260,7 @@ public:
/**
* @brief Set the fill color to the given value
*/
void set_fill_color (color_t c)
void set_fill_color (tl::color_t c)
{
set_fill_color_code (c | 0xff000000);
}
@@ -844,8 +844,8 @@ public:
/**
* @brief Adaptors required for the XML reader
*/
color_t frame_color_loc () const { return frame_color (false); }
color_t fill_color_loc () const { return fill_color (false); }
tl::color_t frame_color_loc () const { return frame_color (false); }
tl::color_t fill_color_loc () const { return fill_color (false); }
int frame_brightness_loc () const { return frame_brightness (false); }
int fill_brightness_loc () const { return fill_brightness (false); }
int dither_pattern_loc () const { return dither_pattern (false); }
@@ -928,10 +928,10 @@ private:
// the generation number
size_t m_gen_id;
// display styles
color_t m_frame_color;
mutable color_t m_frame_color_real;
color_t m_fill_color;
mutable color_t m_fill_color_real;
tl::color_t m_frame_color;
mutable tl::color_t m_frame_color_real;
tl::color_t m_fill_color;
mutable tl::color_t m_fill_color_real;
int m_frame_brightness;
mutable int m_frame_brightness_real;
int m_fill_brightness;
+16 -16
View File
@@ -291,7 +291,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing),
m_image_cache_size (1)
{
lay::Color bg (0xffffffff), fg (0xff000000), active (0xffc0c0c0);
tl::Color bg (0xffffffff), fg (0xff000000), active (0xffc0c0c0);
#if defined(HAVE_QT)
if (widget ()) {
@@ -303,9 +303,9 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
widget ()->setObjectName (QString::fromUtf8 ("canvas"));
widget ()->setBackgroundRole (QPalette::NoRole);
bg = lay::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Window).rgb ());
fg = lay::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Text).rgb ());
active = lay::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Mid).rgb ());
bg = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Window).rgb ());
fg = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Text).rgb ());
active = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Mid).rgb ());
widget ()->setAttribute (Qt::WA_NoSystemBackground);
@@ -393,7 +393,7 @@ LayoutCanvas::set_oversampling (unsigned int os)
}
void
LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Color active)
LayoutCanvas::set_colors (tl::Color background, tl::Color foreground, tl::Color active)
{
m_background = background.rgb ();
m_foreground = foreground.rgb ();
@@ -712,7 +712,7 @@ class DetachedViewObjectCanvas
: public BitmapViewObjectCanvas
{
public:
DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img)
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img)
: BitmapViewObjectCanvas (width_l, height_l, resolution),
m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img)
{
@@ -738,17 +738,17 @@ public:
}
}
lay::Color background_color () const
tl::Color background_color () const
{
return m_bg;
}
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return m_fg;
}
lay::Color active_color () const
tl::Color active_color () const
{
return m_ac;
}
@@ -780,7 +780,7 @@ public:
}
private:
lay::Color m_bg, m_fg, m_ac;
tl::Color m_bg, m_fg, m_ac;
lay::PixelBuffer *mp_image;
lay::PixelBuffer *mp_image_l;
double m_gamma;
@@ -809,17 +809,17 @@ public:
clear_fg_bitmaps ();
}
lay::Color background_color () const
tl::Color background_color () const
{
return m_bg ? 0xffffffff : 0;
}
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return m_fg ? 0xffffffff : 0;
}
lay::Color active_color () const
tl::Color active_color () const
{
return m_ac ? 0xffffffff : 0;
}
@@ -831,11 +831,11 @@ private:
lay::PixelBuffer
LayoutCanvas::image (unsigned int width, unsigned int height)
{
return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox ());
return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
}
lay::PixelBuffer
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
if (oversampling <= 0) {
oversampling = m_oversampling;
@@ -911,7 +911,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
}
lay::BitmapBuffer
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background_c, lay::Color foreground_c, lay::Color active_c, const db::DBox &target_box)
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background_c, tl::Color foreground_c, tl::Color active_c, const db::DBox &target_box)
{
if (linewidth <= 0) {
linewidth = 1;
+13 -13
View File
@@ -31,7 +31,7 @@
#include "layViewOp.h"
#include "layViewObject.h"
#include "layBitmap.h"
#include "layColor.h"
#include "tlColor.h"
#include "layDrawing.h"
#include "layDitherPattern.h"
#include "layLineStyles.h"
@@ -143,7 +143,7 @@ public:
LayoutCanvas (lay::LayoutViewBase *view);
~LayoutCanvas ();
void set_colors (lay::Color background, lay::Color foreground, lay::Color active);
void set_colors (tl::Color background, tl::Color foreground, tl::Color active);
/**
* @brief Set the view ops for the layers
@@ -166,8 +166,8 @@ public:
lay::PixelBuffer screenshot ();
lay::PixelBuffer image (unsigned int width, unsigned int height);
lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box);
lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box);
void update_image ();
@@ -288,25 +288,25 @@ public:
/**
* @brief Reimplementation of ViewObjectCanvas: Background color
*/
lay::Color background_color () const
tl::Color background_color () const
{
return lay::Color (m_background);
return tl::Color (m_background);
}
/**
* @brief Reimplementation of ViewObjectCanvas: Foreground color
*/
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return lay::Color (m_foreground);
return tl::Color (m_foreground);
}
/**
* @brief Reimplementation of ViewObjectCanvas: Active color
*/
lay::Color active_color () const
tl::Color active_color () const
{
return lay::Color (m_active);
return tl::Color (m_active);
}
/**
@@ -363,9 +363,9 @@ private:
lay::PixelBuffer *mp_image_fg;
db::DBox m_precious_box;
lay::Viewport m_viewport, m_viewport_l;
lay::color_t m_background;
lay::color_t m_foreground;
lay::color_t m_active;
tl::color_t m_background;
tl::color_t m_foreground;
tl::color_t m_active;
std::vector <lay::ViewOp> m_view_ops;
lay::DitherPattern m_dither_pattern;
lay::LineStyles m_line_styles;
+32 -32
View File
@@ -327,7 +327,7 @@ LayoutViewBase::init (db::Manager *mgr)
m_paste_display_mode = 2;
m_guiding_shape_visible = true;
m_guiding_shape_line_width = 1;
m_guiding_shape_color = lay::Color ();
m_guiding_shape_color = tl::Color ();
m_guiding_shape_vertex_size = 5;
m_to_level = 0;
m_ctx_dimming = 50;
@@ -713,7 +713,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_background_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
background_color (color);
// do not take - let others receive the background color events as well
@@ -758,7 +758,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_ctx_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
ctx_color (color);
return true;
@@ -779,7 +779,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_child_ctx_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
child_ctx_color (color);
return true;
@@ -863,14 +863,14 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_cell_box_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
cell_box_color (color);
return true;
} else if (name == cfg_text_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
text_color (color);
return true;
@@ -989,14 +989,14 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_guiding_shape_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
guiding_shapes_color (color);
return true;
} else if (name == cfg_guiding_shape_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
guiding_shapes_color (color);
return true;
@@ -1151,7 +1151,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_sel_color) {
lay::Color color;
tl::Color color;
lay::ColorConverter ().from_string (value, color);
// Change the color
@@ -2503,7 +2503,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p) const
void
LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const
{
lay::color_t c = 0;
tl::color_t c = 0;
if (m_palette.luminous_colors () > 0) {
c = m_palette.luminous_color_by_index (p.source (true /*real*/).color_index ());
}
@@ -2638,7 +2638,7 @@ LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
#if defined(HAVE_QT)
QImage
LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@@ -2655,7 +2655,7 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height,
lay::PixelBuffer
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@@ -2667,7 +2667,7 @@ LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height
lay::BitmapBuffer
LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@@ -2731,7 +2731,7 @@ LayoutViewBase::save_image (const std::string &, unsigned int, unsigned int)
void
LayoutViewBase::save_image_with_options (const std::string &fn,
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
@@ -2762,7 +2762,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
void
LayoutViewBase::save_image_with_options (const std::string &fn,
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
@@ -2793,7 +2793,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
void
LayoutViewBase::save_image_with_options (const std::string &,
unsigned int, unsigned int, int, int, double,
lay::Color, lay::Color, lay::Color, const db::DBox &, bool)
tl::Color, tl::Color, tl::Color, const db::DBox &, bool)
{
throw tl::Exception (tl::to_string (tr ("Unable to save image - PNG library not compiled in")));
}
@@ -3795,7 +3795,7 @@ LayoutViewBase::set_view_ops ()
std::vector <lay::ViewOp> view_ops;
view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after);
lay::Color box_color;
tl::Color box_color;
if (! m_box_color.is_valid ()) {
box_color = mp_canvas->foreground_color ();
} else {
@@ -3854,7 +3854,7 @@ LayoutViewBase::set_view_ops ()
// produce the ViewOps for the guiding shapes
color_t gs_color = box_color.rgb ();
tl::color_t gs_color = box_color.rgb ();
if (m_guiding_shape_color.is_valid ()) {
gs_color = m_guiding_shape_color.rgb ();
}
@@ -3863,7 +3863,7 @@ LayoutViewBase::set_view_ops ()
lay::ViewOp::Mode mode = lay::ViewOp::Copy;
color_t fill_color, frame_color, text_color;
tl::color_t fill_color, frame_color, text_color;
int dp = 1; // no stipples for guiding shapes
if (ctx == 0) {
@@ -3978,7 +3978,7 @@ LayoutViewBase::set_view_ops ()
}
}
color_t fill_color, frame_color, text_color;
tl::color_t fill_color, frame_color, text_color;
int dp = m_no_stipples ? 1 : l->dither_pattern (true /*real*/);
int ls = l->line_style (true /*real*/);
@@ -4081,7 +4081,7 @@ LayoutViewBase::guiding_shapes_visible (bool v)
}
void
LayoutViewBase::guiding_shapes_color (lay::Color c)
LayoutViewBase::guiding_shapes_color (tl::Color c)
{
if (c != m_guiding_shape_color) {
m_guiding_shape_color = c;
@@ -4144,7 +4144,7 @@ LayoutViewBase::drop_small_cells_cond (drop_small_cells_cond_type t)
}
void
LayoutViewBase::cell_box_color (lay::Color c)
LayoutViewBase::cell_box_color (tl::Color c)
{
if (c != m_box_color) {
m_box_color = c;
@@ -4266,7 +4266,7 @@ LayoutViewBase::set_palette (const lay::LineStylePalette &p)
}
void
LayoutViewBase::ctx_color (lay::Color c)
LayoutViewBase::ctx_color (tl::Color c)
{
if (c != m_ctx_color) {
m_ctx_color = c;
@@ -4293,7 +4293,7 @@ LayoutViewBase::ctx_hollow (bool h)
}
void
LayoutViewBase::child_ctx_color (lay::Color c)
LayoutViewBase::child_ctx_color (tl::Color c)
{
if (c != m_child_ctx_color) {
m_child_ctx_color = c;
@@ -4349,20 +4349,20 @@ LayoutViewBase::abstract_mode_enabled (bool e)
}
}
lay::Color
tl::Color
LayoutViewBase::default_background_color ()
{
return lay::Color (0, 0, 0); // black.
return tl::Color (0, 0, 0); // black.
}
void
LayoutViewBase::do_set_background_color (lay::Color /*color*/, lay::Color /*contrast*/)
LayoutViewBase::do_set_background_color (tl::Color /*color*/, tl::Color /*contrast*/)
{
// .. nothing yet ..
}
void
LayoutViewBase::background_color (lay::Color c)
LayoutViewBase::background_color (tl::Color c)
{
if (c == mp_canvas->background_color ()) {
return;
@@ -4373,11 +4373,11 @@ LayoutViewBase::background_color (lay::Color c)
c = default_background_color ();
}
lay::Color contrast;
tl::Color contrast;
if (c.to_mono ()) {
contrast = lay::Color (0, 0, 0);
contrast = tl::Color (0, 0, 0);
} else {
contrast = lay::Color (255, 255, 255);
contrast = tl::Color (255, 255, 255);
}
do_set_background_color (c, contrast);
@@ -4987,7 +4987,7 @@ LayoutViewBase::show_markers (bool f)
}
void
LayoutViewBase::text_color (lay::Color c)
LayoutViewBase::text_color (tl::Color c)
{
if (m_text_color != c) {
m_text_color = c;
+41 -41
View File
@@ -123,7 +123,7 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_frame_color () const;
tl::color_t eff_frame_color () const;
/**
* @brief render the effective frame color
@@ -131,11 +131,11 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_fill_color () const;
tl::color_t eff_fill_color () const;
// display styles
color_t frame_color;
color_t fill_color;
tl::color_t frame_color;
tl::color_t fill_color;
int frame_brightness;
int fill_brightness;
unsigned int dither_pattern;
@@ -855,13 +855,13 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
* @param monochrome If true, monochrome images will be produced
*/
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome);
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
#if defined(HAVE_QT)
/**
@@ -884,13 +884,13 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
* @param monochrome If true, monochrome images will be produced
*/
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome);
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
#endif
/**
@@ -901,12 +901,12 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
*/
lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
/**
* @brief Get the screen content as a monochrome lay::BitmapBuffer object with the given options
@@ -916,14 +916,14 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
*
* The colors will are converted to "on" pixels with a green channel value >= 50%.
*/
lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
/**
* @brief Hierarchy level selection setter
@@ -980,12 +980,12 @@ public:
/**
* @brief Cell box/label color setter
*/
void cell_box_color (lay::Color c);
void cell_box_color (tl::Color c);
/**
* @brief Cell box/label getter
*/
lay::Color cell_box_color () const
tl::Color cell_box_color () const
{
return m_box_color;
}
@@ -1178,12 +1178,12 @@ public:
/**
* @brief Text object color
*/
void text_color (lay::Color c);
void text_color (tl::Color c);
/**
* @brief Text object color
*/
lay::Color text_color () const
tl::Color text_color () const
{
return m_text_color;
}
@@ -1697,7 +1697,7 @@ public:
/**
* @brief Background color property
*/
lay::Color background_color () const
tl::Color background_color () const
{
return mp_canvas->background_color ();
}
@@ -1705,7 +1705,7 @@ public:
/**
* @brief Foreground color property
*/
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return mp_canvas->foreground_color ();
}
@@ -1713,7 +1713,7 @@ public:
/**
* @brief Active color property
*/
lay::Color active_color () const
tl::Color active_color () const
{
return mp_canvas->active_color ();
}
@@ -1773,7 +1773,7 @@ public:
/**
* @brief Gets the guiding shapes color
*/
lay::Color guiding_shapes_color () const
tl::Color guiding_shapes_color () const
{
return m_guiding_shape_color;
}
@@ -1781,7 +1781,7 @@ public:
/**
* @brief Sets the guiding shapes color
*/
void guiding_shapes_color (lay::Color c);
void guiding_shapes_color (tl::Color c);
/**
* @brief Gets the guiding shapes line width
@@ -2205,7 +2205,7 @@ public:
/**
* @brief Get the default color for markers
*/
lay::Color default_marker_color () const
tl::Color default_marker_color () const
{
return m_marker_color;
}
@@ -2687,15 +2687,15 @@ private:
int m_paste_display_mode;
int m_wheel_mode;
bool m_guiding_shape_visible;
lay::Color m_guiding_shape_color;
tl::Color m_guiding_shape_color;
int m_guiding_shape_line_width;
int m_guiding_shape_vertex_size;
lay::Color m_ctx_color;
tl::Color m_ctx_color;
int m_ctx_dimming;
bool m_ctx_hollow;
lay::Color m_child_ctx_color;
tl::Color m_child_ctx_color;
int m_child_ctx_dimming;
bool m_child_ctx_hollow;
bool m_child_ctx_enabled;
@@ -2703,13 +2703,13 @@ private:
double m_abstract_mode_width;
bool m_abstract_mode_enabled;
lay::Color m_box_color;
tl::Color m_box_color;
bool m_box_text_transform;
unsigned int m_box_font;
int m_min_size_for_label;
bool m_cell_box_visible;
lay::Color m_marker_color;
tl::Color m_marker_color;
int m_marker_line_width;
int m_marker_vertex_size;
int m_marker_dither_pattern;
@@ -2727,7 +2727,7 @@ private:
bool m_text_lazy_rendering;
bool m_bitmap_caching;
bool m_show_properties;
lay::Color m_text_color;
tl::Color m_text_color;
bool m_apply_text_trans;
double m_default_text_size;
unsigned int m_text_font;
@@ -2797,11 +2797,11 @@ private:
void do_redraw ();
void set_view_ops ();
void background_color (lay::Color c);
void ctx_color (lay::Color c);
void background_color (tl::Color c);
void ctx_color (tl::Color c);
void ctx_dimming (int percent);
void ctx_hollow (bool h);
void child_ctx_color (lay::Color c);
void child_ctx_color (tl::Color c);
void child_ctx_dimming (int percent);
void child_ctx_hollow (bool h);
void child_ctx_enabled (bool e);
@@ -2845,8 +2845,8 @@ protected:
void free_resources ();
void shutdown ();
virtual lay::Color default_background_color ();
virtual void do_set_background_color (lay::Color color, lay::Color contrast);
virtual tl::Color default_background_color ();
virtual void do_set_background_color (tl::Color color, tl::Color contrast);
virtual void do_paste ();
virtual void begin_layer_updates ();
virtual void end_layer_updates ();
+4 -4
View File
@@ -196,7 +196,7 @@ MarkerBase::MarkerBase (lay::LayoutViewBase *view)
}
void
MarkerBase::set_frame_color (lay::Color color)
MarkerBase::set_frame_color (tl::Color color)
{
if (color != m_frame_color) {
m_frame_color = color;
@@ -205,7 +205,7 @@ MarkerBase::set_frame_color (lay::Color color)
}
void
MarkerBase::set_color (lay::Color color)
MarkerBase::set_color (tl::Color color)
{
if (color != m_color) {
m_color = color;
@@ -292,7 +292,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay:
int basic_width = int(0.5 + 1.0 / resolution);
// obtain bitmaps
lay::Color color = m_color;
tl::Color color = m_color;
if (! color.is_valid ()) {
color = mp_view->default_marker_color ();
}
@@ -300,7 +300,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay:
color = canvas.foreground_color ();
}
lay::Color frame_color = m_frame_color;
tl::Color frame_color = m_frame_color;
if (! frame_color.is_valid ()) {
frame_color = color;
}
+6 -6
View File
@@ -66,7 +66,7 @@ public:
*
* If the color is invalid, the marker is drawn with the canvases foreground color.
*/
lay::Color get_color () const
tl::Color get_color () const
{
return m_color;
}
@@ -76,14 +76,14 @@ public:
*
* If the color is invalid, the marker is drawn with the canvases foreground color.
*/
void set_color (lay::Color color);
void set_color (tl::Color color);
/**
* @brief Get the color by which the marker's frame is drawn
*
* If the color is invalid, the marker's frame is drawn with the fill color.
*/
lay::Color get_frame_color () const
tl::Color get_frame_color () const
{
return m_frame_color;
}
@@ -93,7 +93,7 @@ public:
*
* If the color is invalid, the marker's frame is drawn with the fill color.
*/
void set_frame_color (lay::Color color);
void set_frame_color (tl::Color color);
/**
* @brief Get the line width with which the marker is drawn
@@ -226,8 +226,8 @@ public:
protected:
void get_bitmaps (const Viewport &vp, ViewObjectCanvas &canvas, lay::CanvasPlane *&fill, lay::CanvasPlane *&frame, lay::CanvasPlane *&vertex, lay::CanvasPlane *&text);
lay::Color m_color;
lay::Color m_frame_color;
tl::Color m_color;
tl::Color m_frame_color;
char m_line_width, m_vertex_size, m_halo;
bool m_text_enabled;
lay::ViewOp::Shape m_vertex_shape;
+6 -6
View File
@@ -38,7 +38,7 @@ NetColorizer::NetColorizer ()
}
void
NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors)
NetColorizer::configure (const tl::Color &marker_color, const lay::ColorPalette *auto_colors)
{
m_marker_color = marker_color;
if (auto_colors) {
@@ -58,7 +58,7 @@ NetColorizer::has_color_for_net (const db::Net *net)
}
void
NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color)
NetColorizer::set_color_of_net (const db::Net *net, const tl::Color &color)
{
m_custom_color[net] = color;
emit_colors_changed ();
@@ -110,14 +110,14 @@ NetColorizer::emit_colors_changed ()
}
}
lay::Color
tl::Color
NetColorizer::color_of_net (const db::Net *net) const
{
if (! net) {
return lay::Color ();
return tl::Color ();
}
std::map<const db::Net *, lay::Color>::const_iterator c = m_custom_color.find (net);
std::map<const db::Net *, tl::Color>::const_iterator c = m_custom_color.find (net);
if (c != m_custom_color.end ()) {
return c->second;
}
@@ -146,7 +146,7 @@ NetColorizer::color_of_net (const db::Net *net) const
return m_auto_colors.color_by_index ((unsigned int) index);
} else {
return lay::Color ();
return tl::Color ();
}
}
+7 -7
View File
@@ -26,7 +26,7 @@
#include "laybasicCommon.h"
#include "layColorPalette.h"
#include "layColor.h"
#include "tlColor.h"
#include "tlEvents.h"
#include <map>
@@ -49,15 +49,15 @@ class LAYBASIC_PUBLIC NetColorizer
public:
NetColorizer ();
void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors);
void configure (const tl::Color &marker_color, const lay::ColorPalette *auto_colors);
bool has_color_for_net (const db::Net *net);
void set_color_of_net (const db::Net *net, const lay::Color &color);
void set_color_of_net (const db::Net *net, const tl::Color &color);
void reset_color_of_net (const db::Net *net);
void clear ();
lay::Color color_of_net (const db::Net *net) const;
tl::Color color_of_net (const db::Net *net) const;
const lay::Color &marker_color () const
const tl::Color &marker_color () const
{
return m_marker_color;
}
@@ -68,10 +68,10 @@ public:
tl::Event colors_changed;
private:
lay::Color m_marker_color;
tl::Color m_marker_color;
lay::ColorPalette m_auto_colors;
bool m_auto_colors_enabled;
std::map<const db::Net *, lay::Color> m_custom_color;
std::map<const db::Net *, tl::Color> m_custom_color;
bool m_update_needed;
bool m_signals_enabled;
mutable std::map<const db::Net *, size_t> m_net_index_by_object;
+40 -40
View File
@@ -113,7 +113,7 @@ static void flush_stream_f (png_structp png_ptr)
// -----------------------------------------------------------------------------------------------------
// PixelBuffer implementation
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data)
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, tl::color_t *data)
: m_data ()
{
m_width = w;
@@ -122,18 +122,18 @@ PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data)
m_data.reset (new ImageData (data, w * h));
}
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride)
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, const tl::color_t *data, unsigned int stride)
: m_data ()
{
m_width = w;
m_height = h;
m_transparent = false;
tl_assert ((stride % sizeof (lay::color_t)) == 0);
stride /= sizeof (lay::color_t);
tl_assert ((stride % sizeof (tl::color_t)) == 0);
stride /= sizeof (tl::color_t);
lay::color_t *d = new lay::color_t [w * h];
lay::color_t *new_data = d;
tl::color_t *d = new tl::color_t [w * h];
tl::color_t *new_data = d;
if (data) {
for (unsigned int i = 0; i < h; ++i) {
@@ -181,11 +181,11 @@ PixelBuffer::operator== (const PixelBuffer &other) const
return false;
}
lay::color_t m = transparent () ? 0xffffffff : 0xffffff;
tl::color_t m = transparent () ? 0xffffffff : 0xffffff;
for (unsigned int i = 0; i < other.height (); ++i) {
const lay::color_t *d = scan_line (i);
const lay::color_t *de = d + width ();
const lay::color_t *dd = other.scan_line (i);
const tl::color_t *d = scan_line (i);
const tl::color_t *de = d + width ();
const tl::color_t *dd = other.scan_line (i);
while (d != de) {
if (((*d++ ^ *dd++) & m) != 0) {
return false;
@@ -239,13 +239,13 @@ PixelBuffer::swap (PixelBuffer &other)
}
void
PixelBuffer::fill (lay::color_t c)
PixelBuffer::fill (tl::color_t c)
{
if (! transparent ()) {
c |= 0xff000000; // ensures that alpha is properly set
}
color_t *d = data ();
tl::color_t *d = data ();
for (unsigned int i = 0; i < m_height; ++i) {
for (unsigned int j = 0; j < m_width; ++j) {
*d++ = c;
@@ -253,27 +253,27 @@ PixelBuffer::fill (lay::color_t c)
}
}
color_t *
tl::color_t *
PixelBuffer::scan_line (unsigned int n)
{
tl_assert (n < m_height);
return m_data->data () + n * m_width;
}
const color_t *
const tl::color_t *
PixelBuffer::scan_line (unsigned int n) const
{
tl_assert (n < m_height);
return m_data->data () + n * m_width;
}
color_t *
tl::color_t *
PixelBuffer::data ()
{
return m_data->data ();
}
const color_t *
const tl::color_t *
PixelBuffer::data () const
{
return m_data->data ();
@@ -303,9 +303,9 @@ PixelBuffer::from_image (const QImage &img)
{
if (img.format () != QImage::Format_ARGB32 && img.format () != QImage::Format_RGB32) {
QImage img_argb32 = img.convertToFormat (QImage::Format_ARGB32);
return PixelBuffer (img_argb32.width (), img_argb32.height (), (const lay::color_t *) img_argb32.bits ());
return PixelBuffer (img_argb32.width (), img_argb32.height (), (const tl::color_t *) img_argb32.bits ());
} else {
return PixelBuffer (img.width (), img.height (), (const lay::color_t *) img.bits ());
return PixelBuffer (img.width (), img.height (), (const tl::color_t *) img.bits ());
}
}
#endif
@@ -317,11 +317,11 @@ PixelBuffer::patch (const PixelBuffer &other)
tl_assert (height () == other.height ());
tl_assert (other.transparent ());
const color_t *d = other.data ();
color_t *dd = data ();
const tl::color_t *d = other.data ();
tl::color_t *dd = data ();
for (unsigned int i = 0; i < m_height; ++i) {
for (unsigned int j = 0; j < m_width; ++j) {
color_t c = *d++;
tl::color_t c = *d++;
if ((c & 0x80000000) != 0) {
*dd = c;
}
@@ -339,9 +339,9 @@ PixelBuffer::diff (const PixelBuffer &other) const
PixelBuffer res (m_width, m_height);
res.set_transparent (true);
const color_t *d2 = other.data ();
const color_t *d1 = data ();
color_t *dd = res.data ();
const tl::color_t *d2 = other.data ();
const tl::color_t *d1 = data ();
tl::color_t *dd = res.data ();
for (unsigned int i = 0; i < m_height; ++i) {
for (unsigned int j = 0; j < m_width; ++j) {
@@ -373,7 +373,7 @@ PixelBuffer::read_png (tl::InputStream &input)
tl_assert (info_ptr != NULL);
png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f);
png_set_bgr (png_ptr); // compatible with lay::color_t
png_set_bgr (png_ptr); // compatible with tl::color_t
png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
@@ -384,11 +384,11 @@ PixelBuffer::read_png (tl::InputStream &input)
if (fmt == PNG_COLOR_TYPE_RGBA && bd == 8) {
tl_assert (png_get_rowbytes (png_ptr, info_ptr) == res.width () * sizeof (lay::color_t));
tl_assert (png_get_rowbytes (png_ptr, info_ptr) == res.width () * sizeof (tl::color_t));
png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr);
for (unsigned int i = 0; i < res.height (); ++i) {
memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], sizeof (lay::color_t) * res.width ());
memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], sizeof (tl::color_t) * res.width ());
}
res.set_transparent (true);
@@ -402,13 +402,13 @@ PixelBuffer::read_png (tl::InputStream &input)
png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr);
for (unsigned int i = 0; i < res.height (); ++i) {
lay::color_t *c = res.scan_line (i);
tl::color_t *c = res.scan_line (i);
const uint8_t *d = row_pointers [i];
const uint8_t *dd = d + rb;
while (d < dd) {
lay::color_t b = *d++;
lay::color_t g = *d++;
lay::color_t r = *d++;
tl::color_t b = *d++;
tl::color_t g = *d++;
tl::color_t r = *d++;
*c++ = 0xff000000 | ((r << 8 | g) << 8) | b;
}
}
@@ -422,12 +422,12 @@ PixelBuffer::read_png (tl::InputStream &input)
png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr);
for (unsigned int i = 0; i < res.height (); ++i) {
lay::color_t *c = res.scan_line (i);
tl::color_t *c = res.scan_line (i);
const uint8_t *d = row_pointers [i];
const uint8_t *dd = d + rb;
while (d < dd) {
lay::color_t g = *d++;
lay::color_t a = *d++;
tl::color_t g = *d++;
tl::color_t a = *d++;
*c++ = (a << 24) | ((g << 8 | g) << 8) | g;
}
}
@@ -443,11 +443,11 @@ PixelBuffer::read_png (tl::InputStream &input)
png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr);
for (unsigned int i = 0; i < res.height (); ++i) {
lay::color_t *c = res.scan_line (i);
tl::color_t *c = res.scan_line (i);
const uint8_t *d = row_pointers [i];
const uint8_t *dd = d + rb;
while (d < dd) {
lay::color_t g = *d++;
tl::color_t g = *d++;
*c++ = 0xff000000 | ((g << 8 | g) << 8) | g;
}
}
@@ -477,7 +477,7 @@ PixelBuffer::write_png (tl::OutputStream &output) const
tl_assert (info_ptr != NULL);
png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f);
png_set_bgr (png_ptr); // compatible with lay::color_t
png_set_bgr (png_ptr); // compatible with tl::color_t
unsigned int bd = 8; // bit depth
unsigned int fmt = transparent () ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB;
@@ -507,10 +507,10 @@ PixelBuffer::write_png (tl::OutputStream &output) const
for (unsigned int i = 0; i < height (); ++i) {
uint8_t *d = buffer.get ();
const lay::color_t *s = scan_line (i);
const lay::color_t *se = s + width ();
const tl::color_t *s = scan_line (i);
const tl::color_t *se = s + width ();
while (s != se) {
lay::color_t c = *s++;
tl::color_t c = *s++;
*d++ = c & 0xff;
c >>= 8;
*d++ = c & 0xff;
+16 -16
View File
@@ -24,7 +24,7 @@
#define HDR_layPixelBuffer
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#include "tlCopyOnWrite.h"
#include "tlStream.h"
#include "tlException.h"
@@ -65,7 +65,7 @@ public:
* @brief An 32bit RGB/RGBA image class
*
* This class substitutes QImage in Qt-less applications.
* It provides 32bit RGBA pixels with the format used by lay::Color.
* It provides 32bit RGBA pixels with the format used by tl::Color.
*/
class LAYBASIC_PUBLIC PixelBuffer
{
@@ -78,7 +78,7 @@ public:
*
* The size of the data block needs to be w*h elements.
*/
PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data);
PixelBuffer (unsigned int w, unsigned int h, tl::color_t *data);
/**
* @brief Creates an image with the given height and width
@@ -88,7 +88,7 @@ public:
* "stride" specifies the stride (distance between two rows of data).
* The size of the data block needs to be stride*h elements or w*h if stride is not given.
*/
PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0);
PixelBuffer (unsigned int w, unsigned int h, const tl::color_t *data = 0, unsigned int stride = 0);
/**
* @brief Default constructor
@@ -172,33 +172,33 @@ public:
*/
unsigned int stride () const
{
return sizeof (lay::color_t) * m_width;
return sizeof (tl::color_t) * m_width;
}
/**
* @brief Fills the image with the given color
*/
void fill (lay::color_t);
void fill (tl::color_t);
/**
* @brief Gets the scanline for row n
*/
color_t *scan_line (unsigned int n);
tl::color_t *scan_line (unsigned int n);
/**
* @brief Gets the scanline for row n (const version)
*/
const color_t *scan_line (unsigned int n) const;
const tl::color_t *scan_line (unsigned int n) const;
/**
* @brief Gets the data pointer
*/
color_t *data ();
tl::color_t *data ();
/**
* @brief Gets the data pointer (const version)
*/
const color_t *data () const;
const tl::color_t *data () const;
#if defined(HAVE_QT)
/**
@@ -287,7 +287,7 @@ private:
// .. nothing yet ..
}
ImageData (lay::color_t *data, size_t length)
ImageData (tl::color_t *data, size_t length)
: mp_data (data), m_length (length)
{
// .. nothing yet ..
@@ -296,8 +296,8 @@ private:
ImageData (const ImageData &other)
{
m_length = other.length ();
mp_data = new lay::color_t [other.length ()];
memcpy (mp_data, other.data (), m_length * sizeof (lay::color_t));
mp_data = new tl::color_t [other.length ()];
memcpy (mp_data, other.data (), m_length * sizeof (tl::color_t));
}
~ImageData ()
@@ -307,11 +307,11 @@ private:
}
size_t length () const { return m_length; }
lay::color_t *data () { return mp_data; }
const lay::color_t *data () const { return mp_data; }
tl::color_t *data () { return mp_data; }
const tl::color_t *data () const { return mp_data; }
private:
lay::color_t *mp_data;
tl::color_t *mp_data;
size_t m_length;
ImageData &operator= (const ImageData &other);
@@ -36,7 +36,7 @@ PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int widt
}
void
PixelBufferPainter::set (const db::Point &p, lay::Color c)
PixelBufferPainter::set (const db::Point &p, tl::Color c)
{
if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) {
((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb ();
@@ -44,7 +44,7 @@ PixelBufferPainter::set (const db::Point &p, lay::Color c)
}
void
PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Color c)
{
if (p1.x () == p2.x ()) {
@@ -79,7 +79,7 @@ PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c)
{
int y1 = std::min (p1.y (), p2.y ());
int y2 = std::max (p1.y (), p2.y ());
@@ -89,7 +89,7 @@ PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, tl::Color c)
{
int y1 = std::min (p1.y (), p2.y ());
int y2 = std::max (p1.y (), p2.y ());
@@ -102,7 +102,7 @@ PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign)
PixelBufferPainter::draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign)
{
const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution);
int x = p.x (), y = p.y ();
@@ -25,7 +25,7 @@
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#include "dbPoint.h"
namespace lay {
@@ -43,11 +43,11 @@ class LAYBASIC_PUBLIC PixelBufferPainter
public:
PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
void set (const db::Point &p, lay::Color c);
void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c);
void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c);
void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c);
void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign);
void set (const db::Point &p, tl::Color c);
void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c);
void fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c);
void draw_rect (const db::Point &p1, const db::Point &p2, tl::Color c);
void draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign);
private:
lay::PixelBuffer *mp_img;
@@ -392,7 +392,7 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in
}
void
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height)
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height)
{
if (width > m_width) {
width = m_width;
@@ -319,7 +319,7 @@ public:
/**
* @brief Transfer the content to a PixelBuffer
*/
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height);
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height);
/**
* @brief Transfer the content to a BitmapBuffer (monochrome)
+1 -1
View File
@@ -68,7 +68,7 @@ SelectionService::~SelectionService ()
}
void
SelectionService::set_colors (lay::Color /*background*/, lay::Color color)
SelectionService::set_colors (tl::Color /*background*/, tl::Color color)
{
m_color = color.rgb ();
if (mp_box) {
+1 -1
View File
@@ -55,7 +55,7 @@ public:
SelectionService (lay::LayoutViewBase *view);
~SelectionService ();
void set_colors (lay::Color background, lay::Color color);
void set_colors (tl::Color background, tl::Color color);
void begin (const db::DPoint &pos);
bool dragging () const { return mp_box != 0; }
+4 -4
View File
@@ -258,7 +258,7 @@ public:
/**
* @brief This method is called to set the background and text (foreground) color
*/
virtual void set_colors (lay::Color /*background*/, lay::Color /*text*/) { }
virtual void set_colors (tl::Color /*background*/, tl::Color /*text*/) { }
/**
* @brief This method is called when a drag operation should be cancelled
@@ -1113,17 +1113,17 @@ public:
/**
* @brief Background color property: background color of the canvas
*/
virtual lay::Color background_color () const = 0;
virtual tl::Color background_color () const = 0;
/**
* @brief Foreground color property: foreground color of the canvas (some "contrast" color to background)
*/
virtual lay::Color foreground_color () const = 0;
virtual tl::Color foreground_color () const = 0;
/**
* @brief Active color property: color of active elements on the canvas (some "contrast" color to background and different from foreground)
*/
virtual lay::Color active_color () const = 0;
virtual tl::Color active_color () const = 0;
/**
* @brief Get the resolution
+2 -2
View File
@@ -34,7 +34,7 @@ ViewOp::ViewOp ()
init (0, Copy);
}
ViewOp::ViewOp (color_t color, Mode mode, unsigned int line_style_index, unsigned int dither_index, unsigned int dither_offset, Shape shape, int width, int bitmap_index)
ViewOp::ViewOp (tl::color_t color, Mode mode, unsigned int line_style_index, unsigned int dither_index, unsigned int dither_offset, Shape shape, int width, int bitmap_index)
: m_line_style_index (line_style_index),
m_dither_index (dither_index), m_dither_offset (dither_offset),
m_shape (shape),
@@ -45,7 +45,7 @@ ViewOp::ViewOp (color_t color, Mode mode, unsigned int line_style_index, unsigne
}
void
ViewOp::init (color_t color, Mode mode)
ViewOp::init (tl::color_t color, Mode mode)
{
m_or = (mode == Copy || mode == Or) ? color : 0;
m_and = (mode == Copy || mode == And) ? color : wordones;
+9 -9
View File
@@ -26,7 +26,7 @@
#define HDR_layViewOp
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#include <stdint.h>
@@ -80,12 +80,12 @@ public:
/**
* @brief The constructor given all the parameters to describe the operator
*/
ViewOp (color_t color, Mode mode, unsigned int line_style_index, unsigned int dither_index, unsigned int dither_offset, Shape shape = Rect, int width = 1, int bitmap_index = -1);
ViewOp (tl::color_t color, Mode mode, unsigned int line_style_index, unsigned int dither_index, unsigned int dither_offset, Shape shape = Rect, int width = 1, int bitmap_index = -1);
/**
* @brief Internal: provide the mask for the "or" part of the operation
*/
color_t ormask () const
tl::color_t ormask () const
{
return m_or;
}
@@ -93,7 +93,7 @@ public:
/**
* @brief Internal: provide the mask for the "and" part of the operation
*/
color_t andmask () const
tl::color_t andmask () const
{
return m_and;
}
@@ -101,7 +101,7 @@ public:
/**
* @brief Internal: provide the mask for the "xor" part of the operation
*/
color_t xormask () const
tl::color_t xormask () const
{
return m_xor;
}
@@ -237,16 +237,16 @@ public:
}
private:
color_t m_or;
color_t m_and;
color_t m_xor;
tl::color_t m_or;
tl::color_t m_and;
tl::color_t m_xor;
unsigned int m_line_style_index;
unsigned int m_dither_index, m_dither_offset;
Shape m_shape;
int m_width;
int m_bitmap_index;
void init (color_t color, Mode mode);
void init (tl::color_t color, Mode mode);
};
} // namespace lay
+1 -1
View File
@@ -54,7 +54,7 @@ ZoomService::drag_cancel ()
}
void
ZoomService::set_colors (lay::Color /*background*/, lay::Color color)
ZoomService::set_colors (tl::Color /*background*/, tl::Color color)
{
m_color = color.rgb ();
if (mp_box) {
+1 -1
View File
@@ -41,7 +41,7 @@ public:
ZoomService (lay::LayoutViewBase *view);
~ZoomService ();
void set_colors (lay::Color background, lay::Color text);
void set_colors (tl::Color background, tl::Color text);
void begin (const db::DPoint &pos);
void begin_pan (const db::DPoint &pos);
-2
View File
@@ -44,7 +44,6 @@ SOURCES += \
layBitmapsToImage.cc \
layBookmarkList.cc \
layCellView.cc \
layColor.cc \
layColorPalette.cc \
layConverters.cc \
layDispatcher.cc \
@@ -97,7 +96,6 @@ HEADERS += \
layBookmarkList.h \
layCellView.h \
layColorPalette.h \
layColor.h \
layConverters.h \
layDispatcher.h \
layDisplayState.h \
-219
View File
@@ -1,219 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
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 "layColor.h"
#include "tlUnitTest.h"
#if defined(HAVE_QT)
#include <QColor>
#endif
TEST(1)
{
EXPECT_EQ (lay::Color ().is_valid (), false);
EXPECT_EQ (lay::Color ().to_string (), "");
EXPECT_EQ (lay::Color ().rgb (), 0x00000000);
#if defined(HAVE_QT)
EXPECT_EQ (QColor ().isValid (), false);
EXPECT_EQ (tl::to_string (QColor ().name ()), "#000000"); // why?
EXPECT_EQ (QColor ().rgb (), 0xff000000);
#endif
}
TEST(2)
{
EXPECT_EQ (lay::Color (0x102030).is_valid (), true);
EXPECT_EQ (lay::Color (0x102030).to_string (), "#102030");
EXPECT_EQ (lay::Color (0x102030).rgb (), 0xff102030);
#if defined(HAVE_QT)
EXPECT_EQ (QColor (0x102030).isValid (), true);
EXPECT_EQ (tl::to_string (QColor (0x102030).name ()), "#102030");
EXPECT_EQ (QColor (0x102030).rgb (), 0xff102030);
#endif
}
TEST(3)
{
EXPECT_EQ (lay::Color (std::string ()).is_valid (), false);
EXPECT_EQ (lay::Color ("#102030").is_valid (), true);
EXPECT_EQ (lay::Color ("#102030").to_string (), "#102030");
EXPECT_EQ (lay::Color ("#102030").rgb (), 0xff102030);
EXPECT_EQ (lay::Color ("102030").is_valid (), true);
EXPECT_EQ (lay::Color ("102030").to_string (), "#102030");
EXPECT_EQ (lay::Color ("102030").rgb (), 0xff102030);
#if defined(HAVE_QT)
EXPECT_EQ (QColor (tl::to_qstring ("#102030")).isValid (), true);
EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#102030")).name ()), "#102030");
EXPECT_EQ (QColor (tl::to_qstring ("#102030")).rgb (), 0xff102030);
#endif
}
TEST(4)
{
EXPECT_EQ (lay::Color ("#123").is_valid (), true);
EXPECT_EQ (lay::Color ("#123").to_string (), "#112233");
EXPECT_EQ (lay::Color ("#123").rgb (), 0xff112233);
}
TEST(5)
{
EXPECT_EQ (lay::Color ("#80102030").is_valid (), true);
EXPECT_EQ (lay::Color ("#80102030").alpha (), 128);
EXPECT_EQ (lay::Color ("#80102030").red (), 16);
EXPECT_EQ (lay::Color ("#80102030").green (), 32);
EXPECT_EQ (lay::Color ("#80102030").blue (), 48);
EXPECT_EQ (lay::Color ("#80102030").to_string (), "#80102030");
EXPECT_EQ (lay::Color ("#80102030").rgb (), 0x80102030);
#if defined(HAVE_QT) && QT_VERSION >= 0x50000
// no alpha support in Qt
EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).isValid (), true);
EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#80102030")).name ()), "#102030");
EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).rgb (), 0xff102030);
#endif
}
TEST(6)
{
EXPECT_EQ (lay::Color ("#8123").is_valid (), true);
EXPECT_EQ (lay::Color ("#8123").to_string (), "#88112233");
EXPECT_EQ (lay::Color ("#8123").rgb (), 0x88112233);
}
TEST(7)
{
EXPECT_EQ (lay::Color (16, 32, 48, 128).is_valid (), true);
EXPECT_EQ (lay::Color (16, 32, 48, 128).to_string (), "#80102030");
EXPECT_EQ (lay::Color (16, 32, 48, 128).rgb (), 0x80102030);
#if defined(HAVE_QT)
// no alpha support in Qt
EXPECT_EQ (QColor (16, 32, 48, 128).isValid (), true);
EXPECT_EQ (tl::to_string (QColor (16, 32, 48, 128).name ()), "#102030");
EXPECT_EQ (QColor (16, 32, 48, 128).rgb (), 0xff102030);
#endif
}
TEST(8)
{
unsigned int h, s, v;
int ih, is, iv;
lay::Color c = lay::Color (16, 32, 48);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 210);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#102030");
#if defined(HAVE_QT)
QColor qc = QColor (16, 32, 48);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 210);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
c = lay::Color (32, 16, 48);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 270);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#201030");
#if defined(HAVE_QT)
qc = QColor (32, 16, 48);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 270);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
c = lay::Color (32, 48, 16);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 90);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#203010");
#if defined(HAVE_QT)
qc = QColor (32, 48, 16);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 90);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
c = lay::Color (48, 32, 16);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 30);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#302010");
#if defined(HAVE_QT)
qc = QColor (48, 32, 16);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 30);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
c = lay::Color (48, 16, 32);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 330);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#301020");
#if defined(HAVE_QT)
qc = QColor (48, 16, 32);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 330);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
c = lay::Color (16, 48, 32);
c.get_hsv (h, s, v);
EXPECT_EQ (h, 150);
EXPECT_EQ (s, 170);
EXPECT_EQ (v, 48);
EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#103020");
#if defined(HAVE_QT)
qc = QColor (16, 48, 32);
qc.getHsv (&ih, &is, &iv);
EXPECT_EQ (ih, 150);
EXPECT_EQ (is, 170);
EXPECT_EQ (iv, 48);
#endif
}
@@ -38,7 +38,7 @@ static bool compare_images (const QImage &qimg, const std::string &au)
if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) {
for (int j = 0; j < qimg.height (); ++j) {
for (int i = 0; i < qimg.width (); ++i) {
if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) {
if (((const tl::color_t *) qimg.scanLine (j))[i] != ((const tl::color_t *) qimg2.scanLine (j))[i]) {
return false;
}
}
@@ -87,7 +87,7 @@ TEST(1)
lay::PixelBuffer img (15, 25);
EXPECT_EQ (img.width (), 15);
EXPECT_EQ (img.height (), 25);
EXPECT_EQ (img.stride (), 15 * sizeof (lay::color_t));
EXPECT_EQ (img.stride (), 15 * sizeof (tl::color_t));
EXPECT_EQ (img.transparent (), false);
img.set_transparent (true);
@@ -159,11 +159,11 @@ TEST(1)
EXPECT_EQ (img4.scan_line (5)[8], 0xff102030);
// other constructors
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true);
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true);
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data ()), img4), true);
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data (), img4.stride ()), img4), true);
lay::color_t *dnew = new lay::color_t [ img4.width () * img4.height () * sizeof (lay::color_t) ];
memcpy (dnew, (const lay::color_t *) img4.data (), img4.width () * img4.height () * sizeof (lay::color_t));
tl::color_t *dnew = new tl::color_t [ img4.width () * img4.height () * sizeof (tl::color_t) ];
memcpy (dnew, (const tl::color_t *) img4.data (), img4.width () * img4.height () * sizeof (tl::color_t));
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), dnew), img4), true);
}
-1
View File
@@ -10,7 +10,6 @@ SOURCES = \
layAnnotationShapes.cc \
layBitmap.cc \
layBitmapsToImage.cc \
layColorTests.cc \
layLayerProperties.cc \
layParsedLayerSource.cc \
layPixelBufferTests.cc \