Breaking changes for expr_color

Removed the typedef-name nana::color_t
This commit is contained in:
cnjinhao
2014-12-18 13:08:44 +08:00
parent 42788db077
commit e64b6ec2b2
43 changed files with 185 additions and 915 deletions

View File

@@ -98,33 +98,30 @@ namespace nana
typedef unsigned char uint8_t;
typedef unsigned long uint32_t;
typedef unsigned uint_t;
typedef unsigned color_t; //deprecated
typedef long long long_long_t;
//const color_t null_color = 0xFFFFFFFF; //deprecated
union pixel_argb_t
{
struct element_tag
{
unsigned int blue:8;
unsigned int green:8;
unsigned int red:8;
unsigned int alpha_channel:8;
unsigned char blue;
unsigned char green;
unsigned char red;
unsigned char alpha_channel;
}element;
color_t value;
unsigned value;
};
union pixel_rgba_t
{
struct element_tag
{
unsigned int alpha_channel : 8;
unsigned int blue : 8;
unsigned int green : 8;
unsigned int red : 8;
unsigned char alpha_channel;
unsigned char blue;
unsigned char green;
unsigned char red;
}element;
color_t value;
unsigned value;
};
using pixel_color_t = pixel_argb_t;
@@ -150,12 +147,24 @@ namespace nana
highlight = 0x1CC4F7
};
#pragma pack(1)
struct rgb_color
{
unsigned char blue;
unsigned char green;
unsigned char red;
rgb_color(unsigned clr);
};
#pragma pack()
class expr_color
{
public:
expr_color() = default;
expr_color(colors);
expr_color(colors, double alpha);
expr_color(const rgb_color&);
expr_color(unsigned red, unsigned green, unsigned blue);
expr_color(unsigned red, unsigned green, unsigned blue, double alpha);

View File

@@ -1,6 +1,7 @@
/*
* Platform Specification Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -99,15 +100,14 @@ namespace detail
#if defined(NANA_UNICODE)
XftDraw * xftdraw;
XftColor xft_fgcolor;
//XftColor xft_bgcolor; //deprecated
const std::string charset(const nana::string& str, const std::string& strcode);
#endif
drawable_impl_type();
~drawable_impl_type();
void fgcolor(nana::color_t); //deprecated
void set_color(nana::color_t);
void set_text_color(nana::color_t);
void fgcolor(const ::nana::expr_color&); //deprecated
void set_color(const ::nana::expr_color&);
void set_text_color(const ::nana::expr_color&);
void update_color();
void update_text_color();

View File

@@ -1,6 +1,7 @@
/*
* Platform Specification Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -102,7 +103,7 @@ namespace detail
int style;
int width;
void set(HDC context, int style, int width, nana::color_t color);
void set(HDC context, int style, int width,unsigned color);
}pen;
struct brush_spec
@@ -111,9 +112,9 @@ namespace detail
HBRUSH handle;
t style;
nana::color_t color;
unsigned color;
void set(HDC context, t style, nana::color_t color);
void set(HDC context, t style, unsigned color);
}brush;
struct round_region_spec
@@ -136,10 +137,10 @@ namespace detail
drawable_impl_type();
~drawable_impl_type();
void fgcolor(nana::color_t); //deprecated
void fgcolor(const ::nana::expr_color&); //deprecated
unsigned get_color() const;
void set_color(nana::color_t);
void set_text_color(nana::color_t);
void set_color(const ::nana::expr_color&);
void set_text_color(const ::nana::expr_color&);
void update_pen();
void update_brush();

View File

@@ -97,25 +97,6 @@ namespace nana
os_insert = 0x2D, os_del
};
};
/*
namespace color //deprecated
{
enum
{
white = 0xFFFFFF,
blue = 0x0000FF,
green = 0x00FF00,
red = 0xFF0000,
button_face_shadow_start = 0xF5F4F2,
button_face_shadow_end = 0xD5D2CA,
button_face = 0xD4D0C8,
dark_border = 0x404040,
gray_border = 0x808080,
highlight = 0x1CC4F7
};
};
*/
enum class cursor
{

View File

@@ -177,10 +177,6 @@ namespace detail
struct
{
//color_t foreground; //deprecated
//color_t background; //deprecated
//color_t active; //deprecated
expr_color fgcolor;
expr_color bgcolor;
expr_color activated;

View File

@@ -120,12 +120,12 @@ namespace nana{
good_r.x = good_r.y = 1;
good_r.width = r.width - 2;
good_r.height = r.height - 2;
pixbuf.rectangle(good_r, wd->colors.activated.px_color().value, 0.95, false);
pixbuf.rectangle(good_r, wd->colors.activated, 0.95, false);
good_r.x = good_r.y = 0;
good_r.width = r.width;
good_r.height = r.height;
pixbuf.rectangle(good_r, wd->colors.activated.px_color().value, 0.4, false);
pixbuf.rectangle(good_r, wd->colors.activated, 0.4, false);
pixbuf.pixel(0, 0, px0);
pixbuf.pixel(r.width - 1, 0, px1);

View File

@@ -201,15 +201,6 @@ namespace API
void capture_ignore_children(bool ignore); ///< Enables or disables the captured window whether redirects the mouse input to its children if the mouse is over its children.
void modal_window(window); ///< Blocks the routine til the specified window is closed.
void wait_for(window);
/*
color_t foreground(window); //deprecated
color_t foreground(window, color_t); //deprecated
color_t background(window); //deprecated
color_t background(window, color_t); //deprecated
color_t active(window); //deprecated
color_t active(window, color_t); //deprecated
*/
expr_color fgcolor(window);
expr_color fgcolor(window, const expr_color&);

View File

@@ -68,8 +68,6 @@ namespace nana{
bool enable_pushed;
bool focus_color;
paint::image * icon;
//color_t bgcolor; //deprecated
//color_t fgcolor;
::nana::expr_color bgcolor;
::nana::expr_color fgcolor;
}attr_;

View File

@@ -45,7 +45,6 @@ namespace nana
void week_name(unsigned index, const nana::string&);
void month_name(unsigned index, const nana::string&);
private:
//void _m_init_color(); //deprecated
where _m_pos_where(graph_reference, int x, int y);
void _m_draw(graph_reference);
void _m_draw_topbar(graph_reference);

View File

@@ -26,7 +26,6 @@ namespace nana
public:
void attached(widget_reference, graph_reference) override;
void refresh(graph_reference) override;
//void resized(graph_reference, const arg_resized&) override; //deprecated
private:
widget* wd_{nullptr};
};

View File

@@ -37,8 +37,6 @@ namespace nana
struct
{
//unsigned background_shadow_start; //deprecated
//unsigned background_shadow_end;
::nana::expr_color gradual_from;
::nana::expr_color gradual_to;
bool horizontal;

View File

@@ -278,14 +278,14 @@ namespace nana
this->get_drawer_trigger().relate(pos, wd);
}
void tab_bgcolor(std::size_t i, nana::color_t color)
void tab_bgcolor(std::size_t i, const ::nana::expr_color& clr)
{
this->get_drawer_trigger().tab_color(i, true, color);
this->get_drawer_trigger().tab_color(i, true, clr);
}
void tab_fgcolor(std::size_t i, nana::color_t color)
void tab_fgcolor(std::size_t i, const ::nana::expr_color& clr)
{
this->get_drawer_trigger().tab_color(i, false, color);
this->get_drawer_trigger().tab_color(i, false, clr);
}
void tab_image(std::size_t i, const nana::paint::image& img)

View File

@@ -73,13 +73,6 @@ namespace nana
void move(int x, int y);
void move(const rectangle&);
/*
void foreground(nana::color_t); //deprecated
nana::color_t foreground() const;
void background(nana::color_t);
nana::color_t background() const;
*/
void fgcolor(const nana::expr_color&);
nana::expr_color fgcolor() const;
void bgcolor(const nana::expr_color&);

View File

@@ -352,8 +352,9 @@ namespace detail
if(d_rgb && s_rgb)
{
unsigned char* tablebuf = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2];
unsigned char* d_table = tablebuf;
auto ptr = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2];
unsigned char* d_table = ptr.get();
unsigned char* s_table = d_table + 0x100;
const unsigned rest = s_r.width & 0x3;
@@ -396,7 +397,6 @@ namespace detail
d_rgb = pixel_at(d_rgb, d_step_bytes);
s_rgb = pixel_at(s_rgb, s_step_bytes);
}
detail::free_fade_table(tablebuf);
}
}
};
@@ -405,15 +405,19 @@ namespace detail
class bresenham_line
: public image_process::line_interface
{
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate) const
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::expr_color& clr, double fade_rate) const
{
auto rgb_color = clr.px_color().value;
const std::size_t bytes_pl = pixbuf.bytes_per_line();
unsigned char * fade_table = nullptr;
std::unique_ptr<unsigned char[]> autoptr;
nana::pixel_argb_t rgb_imd;
if(fade_rate != 0.0)
{
fade_table = detail::alloc_fade_table(1 - fade_rate);
rgb_imd.value = color;
autoptr = detail::alloc_fade_table(1 - fade_rate);
fade_table = autoptr.get();
rgb_imd.value = rgb_color;
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
}
@@ -447,7 +451,7 @@ namespace detail
{
for(int x = 0; x < delta.x; ++x)
{
i->value = color;
i->value = rgb_color;
i = pixel_at(i, step_bytes);
}
}
@@ -479,7 +483,7 @@ namespace detail
{
for(int x = 0; x < delta.x; ++x)
{
i->value = color;
i->value = rgb_color;
if(error >= 0)
{
error -= dx_2;
@@ -513,7 +517,7 @@ namespace detail
{
for (int y = 0; y < delta.y; ++y)
{
i->value = color;
i->value = rgb_color;
if(error >= 0)
{
error -= dy_2;
@@ -525,8 +529,6 @@ namespace detail
}
}
}
detail::free_fade_table(fade_table);
}
};

View File

@@ -21,16 +21,16 @@ namespace detail
{
nana::size drawable_size(drawable_type);
unsigned char * alloc_fade_table(double fade_rate);
std::unique_ptr<unsigned char[]> alloc_fade_table(double fade_rate);
void free_fade_table(const unsigned char*);
//color = bgcolor * fade_rate + fgcolor * (1 - fade_rate);
//nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, double fade_rate); //deprecated
nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table);
nana::pixel_color_t fade_color_intermedia(nana::pixel_color_t fgcolor, const unsigned char* fade_table);
nana::pixel_color_t fade_color_by_intermedia(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table);
nana::pixel_color_t fade_color_intermedia(pixel_color_t fgcolor, const unsigned char* fade_table);
nana::pixel_color_t fade_color_by_intermedia(pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table);
void blend(drawable_type dw, const nana::rectangle& r, nana::color_t, double fade_rate);
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);

View File

@@ -1,6 +1,7 @@
/*
* Paint Graphics Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -99,29 +100,6 @@ namespace nana
bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const;
//unsigned bidi_string(int x, int y, color_t, const char_t *, std::size_t len); //deprecated
//void string(int x, int y, color_t, const ::nana::string&, std::size_t len);
//void string(int x, int y, color_t, const ::nana::string&);
//void string(int x, int y, color_t, const char_t*, std::size_t len);
//void string(int x, int y, color_t, const char_t*);
/*
void set_pixel(int x, int y, color_t);
void rectangle(int x, int y, unsigned width, unsigned height, color_t, bool solid);
void rectangle(color_t, bool solid);
void rectangle(const ::nana::rectangle&, color_t, bool solid);
void rectangle_line(const ::nana::rectangle&, color_t left, color_t top, color_t right, color_t bottom);
void round_rectangle(int x, int y, unsigned width, unsigned height, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
void shadow_rectangle(const ::nana::rectangle&, color_t beg_color, color_t end_color, bool vertical); //deprecated
void shadow_rectangle(int x, int y, unsigned width, unsigned height, color_t beg_color, color_t end_color, bool vertical); ///< Draws a width and height rectangle at (x, y) and the color in range of [begin, end]
void line(int x1, int y1, int x2, int y2, color_t); ///< Draws a line from point (x1, y1) to point (x2, y2) in the specified color.
void line(const point& beg, const point& end, color_t);
void lines(const point* points, std::size_t n_of_points, color_t);
void line_to(int x, int y, color_t);
*/
void line_begin(int x, int y);
void bitblt(int x, int y, const graphics& source); ///< Transfers the source to the specified point.
@@ -131,7 +109,6 @@ namespace nana
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
void blend(const ::nana::rectangle& r, color_t, double fade_rate); ///< blends the specifed block width the specified color.
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
@@ -154,8 +131,6 @@ namespace nana
void release();
void save_as_file(const char*);
//static color_t mix(color_t colorX, color_t colorY, double persent); //deprecated
void set_color(const ::nana::expr_color&);
void set_text_color(const ::nana::expr_color&);

View File

@@ -24,7 +24,7 @@ namespace nana
class stretch_interface
{
public:
virtual ~stretch_interface() = 0;
virtual ~stretch_interface() = default;
/// Copies the image from a source rectangle into a destination rectangle, stretching or compressing the image to fit the dimensions of the destination rectangle in destination(d_pixbuf).
virtual void process(const paint::pixel_buffer & s_pixbuf,
const nana::rectangle& source_rectangle,
@@ -36,14 +36,14 @@ namespace nana
class alpha_blend_interface
{
public:
virtual ~alpha_blend_interface() = 0;
virtual ~alpha_blend_interface() = default;
virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const point& d_pos) const = 0;
};
/// The interface of a blend algorithm.
class blend_interface
{
public:
virtual ~blend_interface() = 0;
virtual ~blend_interface() = default;
/// \brief Blends two images with specified area and blend rate.
///
/// Semantics: \code dest_pixbuf = dest_pixbuf * fade_rate + scr_pixbuf * (1 - fade_rate); \endcode
@@ -59,16 +59,16 @@ namespace nana
class line_interface
{
public:
virtual ~line_interface() = 0;
virtual ~line_interface() = default;
/// \brief Draws a line
///
/// Semantics: \code pixbuf = pixbuf * (1 - fade_rate) + color * fade_rate \endcode
/// The two points are calculated by Nana, they are always valid, and pos_beg.x <= pos_end.x
virtual void process(paint::pixel_buffer & pixbuf,
const nana::point& pos_beg, ///< left point
const nana::point& pos_end, ///< right point
nana::color_t color,
const point& pos_beg, ///< left point
const point& pos_end, ///< right point
const ::nana::expr_color&,
double fade_rate ///< blend rate in the range of [0, 1] If not 0, the line is blended to the pixbuf
) const = 0;
};
@@ -76,7 +76,7 @@ namespace nana
class blur_interface
{
public:
virtual ~blur_interface() = 0;
virtual ~blur_interface() = default;
virtual void process(paint::pixel_buffer&, const nana::rectangle& r, std::size_t radius) const = 0;
};
}

View File

@@ -67,10 +67,10 @@ namespace nana{ namespace paint
void put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative);
void line(const std::string& name);
void line(const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate);
void line(const ::nana::point& pos_beg, const ::nana::point& pos_end, const ::nana::expr_color&, double fade_rate);
void rectangle(const nana::rectangle&, nana::color_t, double fade_rate, bool solid);
void shadow_rectangle(const nana::rectangle&, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical); //deprecated
void rectangle(const nana::rectangle&, const ::nana::expr_color&, double fade_rate, bool solid);
//void shadow_rectangle(const nana::rectangle&, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical); //deprecated
void gradual_rectangle(const ::nana::rectangle&, const ::nana::expr_color& from, const ::nana::expr_color& to, double fade_rate, bool vertical);
pixel_argb_t pixel(int x, int y) const;