unify semantics of the blend methods
This commit is contained in:
parent
f261fa296e
commit
4e9646cf64
@ -84,7 +84,7 @@ namespace nana
|
||||
|
||||
enum class mouse_action
|
||||
{
|
||||
begin, normal = begin, hovered, pressed, end
|
||||
begin, normal = begin, normal_captured, hovered, pressed, end
|
||||
};
|
||||
|
||||
enum class element_state
|
||||
@ -298,8 +298,7 @@ namespace nana
|
||||
color(color_rgb);
|
||||
color(color_argb);
|
||||
color(color_rgba);
|
||||
color(unsigned red, unsigned green, unsigned blue);
|
||||
color(unsigned red, unsigned green, unsigned blue, double alpha);
|
||||
color(unsigned red, unsigned green, unsigned blue, double alpha = 1.0);
|
||||
|
||||
/// Initializes the color with a CSS-like rgb string.
|
||||
explicit color(std::string css_rgb);
|
||||
@ -313,10 +312,7 @@ namespace nana
|
||||
/// @param lightness in range of [0, 1]
|
||||
color& from_hsl(double hue, double saturation, double lightness); ///< immutable alpha channel
|
||||
|
||||
color blend(const color& bgcolor, bool ignore_bgcolor_alpha) const;
|
||||
|
||||
/// Blends two colors with the specified alpha, and the alpha values that come with these two colors are both ignored.
|
||||
color blend(const color& bgcolor, double alpha) const;
|
||||
color blend(const color& blending_color, double alpha) const;
|
||||
|
||||
/// Determines whether the color is completely transparent.
|
||||
bool invisible() const;
|
||||
|
||||
@ -118,7 +118,7 @@ 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& r, const ::nana::color&, double fade_rate);
|
||||
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& blend_r, const graphics& blend_graph, const point& blend_graph_point, double fade_rate);///< blends with the blend_graph.
|
||||
|
||||
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
|
||||
|
||||
|
||||
@ -53,11 +53,6 @@ namespace nana
|
||||
a_((static_cast<int>(rgba) & 0xFF) / 255.0)
|
||||
{}
|
||||
|
||||
color::color(unsigned red, unsigned green, unsigned blue)
|
||||
: r_(red), g_(green), b_(blue), a_(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
color::color(unsigned red, unsigned green, unsigned blue, double alpha)
|
||||
: r_(red), g_(green), b_(blue), a_(alpha)
|
||||
{
|
||||
@ -426,47 +421,12 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
color color::blend(const color& bgcolor, bool ignore_bgcolor_alpha) const
|
||||
{
|
||||
if (a_ < 1.0)
|
||||
{
|
||||
color result;
|
||||
if (0.0 < a_)
|
||||
{
|
||||
if (ignore_bgcolor_alpha || (1.0 == bgcolor.b_))
|
||||
{
|
||||
result.r_ = r_ * a_ + bgcolor.r_ * (1.0 - a_);
|
||||
result.g_ = g_ * a_ + bgcolor.g_ * (1.0 - a_);
|
||||
result.b_ = b_ * a_ + bgcolor.b_ * (1.0 - a_);
|
||||
result.a_ = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.r_ = r_ * a_ + bgcolor.r_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.g_ = g_ * a_ + bgcolor.g_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.b_ = b_ * a_ + bgcolor.b_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.a_ = a_ + (bgcolor.a_ * (1.0 - a_));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.r_ = bgcolor.r_;
|
||||
result.g_ = bgcolor.g_;
|
||||
result.b_ = bgcolor.b_;
|
||||
result.a_ = (ignore_bgcolor_alpha ? 1.0 : bgcolor.a_);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
color color::blend(const color& bgcolor, double alpha) const
|
||||
{
|
||||
color result;
|
||||
result.r_ = r_ * alpha + bgcolor.r_ * (1.0 - alpha);
|
||||
result.g_ = g_ * alpha + bgcolor.g_ * (1.0 - alpha);
|
||||
result.b_ = b_ * alpha + bgcolor.b_ * (1.0 - alpha);
|
||||
result.r_ = r_ * (1.0 - alpha) + bgcolor.r_ * alpha;
|
||||
result.g_ = g_ * (1.0 - alpha) + bgcolor.g_ * alpha;
|
||||
result.b_ = b_ * (1.0 - alpha) + bgcolor.b_ * alpha;
|
||||
result.a_ = 1.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -776,7 +776,7 @@ namespace detail
|
||||
if(prev_captured_inside)
|
||||
{
|
||||
evt_code = event_code::mouse_leave;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
msgwnd->set_action(mouse_action::normal_captured);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1063,7 +1063,7 @@ namespace detail
|
||||
if(prev_captured_inside)
|
||||
{
|
||||
evt_code = event_code::mouse_leave;
|
||||
msgwnd->set_action(mouse_action::normal);
|
||||
msgwnd->set_action(mouse_action::normal_captured);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -382,7 +382,9 @@ namespace nana
|
||||
if (effect.bground)
|
||||
{
|
||||
if (effect.bground_fade_rate >= 0.01)
|
||||
data_impl_->window_handle->other.glass_buffer.blend(::nana::rectangle{ data_impl_->window_handle->other.glass_buffer.size() }, graphics, nana::point(), effect.bground_fade_rate);
|
||||
{
|
||||
graphics.blend(::nana::rectangle{ data_impl_->window_handle->other.glass_buffer.size() }, data_impl_->window_handle->other.glass_buffer, {}, 1 - effect.bground_fade_rate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Elements of GUI Gadgets
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -148,22 +148,22 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
::nana::color highlighted(0x5e, 0xb6, 0xf7);
|
||||
::nana::color highlighted(static_cast<color_rgb>(0x5eb6f7));
|
||||
auto bld_bgcolor = bgcolor;
|
||||
auto bld_fgcolor = fgcolor;
|
||||
switch(es)
|
||||
{
|
||||
case element_state::hovered:
|
||||
case element_state::focus_hovered:
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.8);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.8);
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.2);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.2);
|
||||
break;
|
||||
case element_state::pressed:
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.4);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.4);
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.6);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.6);
|
||||
break;
|
||||
case element_state::disabled:
|
||||
bld_bgcolor = bld_fgcolor = nana::color(0xb2, 0xb7, 0xbc);
|
||||
bld_bgcolor = bld_fgcolor = static_cast<color_rgb>(0xb2b7bc);
|
||||
break;
|
||||
default:
|
||||
//Leave things as they are
|
||||
@ -493,10 +493,10 @@ namespace nana
|
||||
{
|
||||
case element_state::hovered:
|
||||
case element_state::focus_hovered:
|
||||
bgcolor = arg_bgcolor.blend(colors::white, 0.8);
|
||||
bgcolor = arg_bgcolor.blend(colors::white, 0.2);
|
||||
break;
|
||||
case element_state::pressed:
|
||||
bgcolor = arg_bgcolor.blend(colors::black, 0.8);
|
||||
bgcolor = arg_bgcolor.blend(colors::black, 0.2);
|
||||
break;
|
||||
case element_state::disabled:
|
||||
bgcolor = colors::dark_gray;
|
||||
@ -505,13 +505,13 @@ namespace nana
|
||||
}
|
||||
|
||||
auto part_px = (r.height - 3) * 5 / 13;
|
||||
graph.rectangle(r, false, bgcolor.blend(colors::black, 0.6));
|
||||
graph.rectangle(r, false, bgcolor.blend(colors::black, 0.4));
|
||||
|
||||
::nana::point left_top{ r.x + 1, r.y + 1 }, right_top{r.right() - 2, r.y + 1};
|
||||
::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast<int>(part_px) }, right_mid{ right_top.x, left_mid.y };
|
||||
::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 };
|
||||
|
||||
graph.palette(false, bgcolor.blend(colors::white, 0.9));
|
||||
graph.palette(false, bgcolor.blend(colors::white, 0.1));
|
||||
graph.line(left_top, left_mid);
|
||||
graph.line(right_top, right_mid);
|
||||
|
||||
@ -520,12 +520,12 @@ namespace nana
|
||||
|
||||
left_mid.y++;
|
||||
right_mid.y++;
|
||||
graph.palette(false, bgcolor.blend(colors::black, 0.8));
|
||||
graph.palette(false, bgcolor.blend(colors::black, 0.2));
|
||||
graph.line(left_mid, left_bottom);
|
||||
graph.line(right_mid, right_bottom);
|
||||
|
||||
::nana::rectangle part_r{ r.x + 2, r.y + 2, r.width - 4, part_px };
|
||||
graph.rectangle(part_r, true, bgcolor.blend(colors::white, 0.8));
|
||||
graph.rectangle(part_r, true, bgcolor.blend(colors::white, 0.2));
|
||||
|
||||
part_r.y += static_cast<int>(part_r.height);
|
||||
part_r.height = (r.height - 3 - part_r.height);
|
||||
@ -545,7 +545,7 @@ namespace nana
|
||||
{
|
||||
case element_state::hovered:
|
||||
case element_state::pressed:
|
||||
clr = clr.blend(colors::black, 0.8);
|
||||
clr = clr.blend(colors::black, 0.2);
|
||||
break;
|
||||
case element_state::disabled:
|
||||
clr = colors::dark_gray;
|
||||
@ -954,7 +954,7 @@ namespace nana
|
||||
ps[11].x = r.x + gap;
|
||||
ps[11].y = r.y + gap;
|
||||
|
||||
graph.palette(false, fgcolor.blend(colors::black, true));
|
||||
graph.palette(false, fgcolor.blend(colors::black, 1.0 - fgcolor.a()));
|
||||
|
||||
for (int i = 0; i < 11; ++i)
|
||||
graph.line(ps[i], ps[i + 1]);
|
||||
|
||||
@ -149,7 +149,7 @@ namespace nana
|
||||
color xclr = colors::red;
|
||||
|
||||
if(x_state_ == ::nana::mouse_action::pressed)
|
||||
xclr = xclr.blend(colors::white, 0.8);
|
||||
xclr = xclr.blend(colors::white, 0.2);
|
||||
|
||||
graph.rectangle(r, true, xclr);
|
||||
}
|
||||
|
||||
@ -1380,6 +1380,7 @@ namespace API
|
||||
switch(iwd->flags.action)
|
||||
{
|
||||
case nana::mouse_action::normal:
|
||||
case nana::mouse_action::normal_captured:
|
||||
return (is_focused ? nana::element_state::focus_normal : nana::element_state::normal);
|
||||
case nana::mouse_action::hovered:
|
||||
return (is_focused ? nana::element_state::focus_hovered : nana::element_state::hovered);
|
||||
|
||||
@ -311,8 +311,8 @@ namespace nana{ namespace drawerbase
|
||||
nana::rectangle r(graph.size());
|
||||
r.pare_off(1);
|
||||
|
||||
auto from = attr_.bgcolor.blend(colors::white, 0.2);
|
||||
auto to = attr_.bgcolor.blend(colors::black, 0.95);
|
||||
auto from = attr_.bgcolor.blend(colors::white, 0.8);
|
||||
auto to = attr_.bgcolor.blend(colors::black, 0.05);
|
||||
|
||||
if (element_state::pressed == attr_.e_state)
|
||||
{
|
||||
|
||||
@ -78,7 +78,7 @@ namespace nana
|
||||
|
||||
if(ue.what == ue.none || (API::window_enabled(wd) == false))
|
||||
{ //the mouse is out of the widget.
|
||||
style_.bgcolor = style_.bgcolor.blend(static_cast<color_rgb>(0xa0c9f5), 0.9);
|
||||
style_.bgcolor = style_.bgcolor.blend(static_cast<color_rgb>(0xa0c9f5), 0.1);
|
||||
}
|
||||
graph.rectangle(r, true, style_.bgcolor);
|
||||
}
|
||||
|
||||
@ -238,7 +238,9 @@ namespace nana
|
||||
{
|
||||
paint::graphics trns_graph{ graph.size() };
|
||||
if (API::dev::copy_transparent_background(this->widget_ptr()->handle(), trns_graph))
|
||||
trns_graph.blend(rectangle{ trns_graph.size() }, graph, { 0, 0 }, 0.5);
|
||||
{
|
||||
graph.blend(rectangle{ trns_graph.size() }, trns_graph, {}, 0.5);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A date chooser Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -93,7 +93,8 @@ namespace nana
|
||||
r.y = static_cast<int>(newbuf.height() - r.height) / 2;
|
||||
newbuf.stretch(nzbuf, r);
|
||||
|
||||
nzbuf.blend(::nana::rectangle{ nzbuf.size() }, dzbuf, nana::point(), fade * (count - i));
|
||||
dzbuf.blend(::nana::rectangle{ nzbuf.size() }, nzbuf, {}, 1 - fade * (count - i));
|
||||
|
||||
graph.bitblt(refpos.x, refpos.y, dzbuf);
|
||||
|
||||
API::update_window(window_handle);
|
||||
@ -121,7 +122,8 @@ namespace nana
|
||||
nzbuf.rectangle(true, colors::white);
|
||||
newbuf.stretch(nzbuf, r);
|
||||
|
||||
nzbuf.blend(::nana::rectangle{ nzbuf.size() }, dzbuf, nana::point(), fade * (count - i));
|
||||
dzbuf.blend(::nana::rectangle{ nzbuf.size() }, nzbuf, {}, 1.0 - fade * (count - i));
|
||||
|
||||
graph.bitblt(refpos.x, refpos.y, dzbuf);
|
||||
|
||||
API::update_window(window_handle);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* A group widget implementation
|
||||
* Nana C++ Library(http://www.nanaro.org)
|
||||
* Copyright(C) 2015-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2015-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -210,9 +210,9 @@ namespace nana{
|
||||
|
||||
color pbg = API::bgcolor(this->parent());
|
||||
|
||||
impl_->caption.bgcolor(pbg.blend(colors::black, 0.975));
|
||||
impl_->caption.bgcolor(pbg.blend(colors::black, 0.025));
|
||||
|
||||
this->bgcolor(pbg.blend(colors::black, 0.950));
|
||||
this->bgcolor(pbg.blend(colors::black, 0.05));
|
||||
|
||||
drawing dw(*this);
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ namespace nana
|
||||
graph.typeface(pre_font);
|
||||
}
|
||||
|
||||
bool find(int x, int y, std::wstring& target, std::wstring& url) const
|
||||
bool find(int x, int y, std::wstring& target, std::wstring& url) const noexcept
|
||||
{
|
||||
for (auto & t : traceable_)
|
||||
{
|
||||
@ -225,7 +225,7 @@ namespace nana
|
||||
def_.fgcolor = fgcolor;
|
||||
}
|
||||
|
||||
const ::nana::color& _m_fgcolor(nana::widgets::skeletons::fblock* fp)
|
||||
const ::nana::color& _m_fgcolor(nana::widgets::skeletons::fblock* fp) noexcept
|
||||
{
|
||||
while(fp->fgcolor.invisible())
|
||||
{
|
||||
@ -236,7 +236,7 @@ namespace nana
|
||||
return fp->fgcolor;
|
||||
}
|
||||
|
||||
std::size_t _m_font_size(nana::widgets::skeletons::fblock* fp)
|
||||
std::size_t _m_font_size(nana::widgets::skeletons::fblock* fp) noexcept
|
||||
{
|
||||
while(fp->font_size == 0xFFFFFFFF)
|
||||
{
|
||||
@ -247,7 +247,7 @@ namespace nana
|
||||
return fp->font_size;
|
||||
}
|
||||
|
||||
bool _m_bold(nana::widgets::skeletons::fblock* fp)
|
||||
bool _m_bold(nana::widgets::skeletons::fblock* fp) noexcept
|
||||
{
|
||||
while(fp->bold_empty)
|
||||
{
|
||||
@ -258,7 +258,7 @@ namespace nana
|
||||
return fp->bold;
|
||||
}
|
||||
|
||||
const std::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
|
||||
const std::string& _m_fontname(nana::widgets::skeletons::fblock* fp) noexcept
|
||||
{
|
||||
while(fp->font.empty())
|
||||
{
|
||||
@ -305,7 +305,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void _m_align_x_base(const render_status& rs, pixel_tag & px, unsigned w)
|
||||
void _m_align_x_base(const render_status& rs, pixel_tag & px, unsigned w) noexcept
|
||||
{
|
||||
switch(rs.text_align)
|
||||
{
|
||||
@ -498,7 +498,7 @@ namespace nana
|
||||
return (rs.pos.y <= lastpos);
|
||||
}
|
||||
|
||||
static bool _m_overline(const render_status& rs, int right, bool equal_required)
|
||||
static bool _m_overline(const render_status& rs, int right, bool equal_required) noexcept
|
||||
{
|
||||
if(align::left == rs.text_align)
|
||||
return (equal_required ? right >= static_cast<int>(rs.allowed_width) : right > static_cast<int>(rs.allowed_width));
|
||||
@ -569,9 +569,12 @@ namespace nana
|
||||
else
|
||||
{
|
||||
auto str = data_ptr->text().substr(text_range.first, text_range.second);
|
||||
graph.string({ rs.pos.x, y }, str, _m_fgcolor(fblock_ptr));
|
||||
sz = graph.text_extent_size(str);
|
||||
|
||||
graph.string({ rs.pos.x, y }, str, _m_fgcolor(fblock_ptr));
|
||||
}
|
||||
|
||||
|
||||
_m_inser_if_traceable(rs.pos.x, y, sz, fblock_ptr);
|
||||
rs.pos.x += static_cast<int>(sz.width);
|
||||
|
||||
@ -586,7 +589,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<std::size_t, std::size_t> _m_locate(dstream::linecontainer::iterator& i, std::size_t pos)
|
||||
static std::pair<std::size_t, std::size_t> _m_locate(dstream::linecontainer::iterator& i, std::size_t pos)
|
||||
{
|
||||
std::size_t n = i->data_ptr->text().length();
|
||||
while(pos >= n)
|
||||
|
||||
@ -46,7 +46,6 @@ namespace nana
|
||||
{
|
||||
namespace listbox
|
||||
{
|
||||
|
||||
class model_lock_guard
|
||||
{
|
||||
model_lock_guard(const model_lock_guard&) = delete;
|
||||
@ -3128,7 +3127,7 @@ namespace nana
|
||||
|
||||
void draw(graph_reference graph, const nana::rectangle& r)
|
||||
{
|
||||
const auto border_color = essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::black, 0.8);
|
||||
const auto border_color = essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::black, 0.2);
|
||||
|
||||
int text_top = (r.height - essence_->text_height) / 2 + r.y;
|
||||
auto text_color = essence_->scheme_ptr->header_fgcolor.get_color();
|
||||
@ -3169,7 +3168,7 @@ namespace nana
|
||||
{
|
||||
column_r.width = (r.right() - column_r.x);
|
||||
if(API::dev::copy_transparent_background(essence_->listbox_ptr->handle(), column_r, graph, column_r.position()))
|
||||
graph.blend(column_r, essence_->scheme_ptr->header_bgcolor, 0.8);
|
||||
graph.blend(column_r, essence_->scheme_ptr->header_bgcolor, 0.5);
|
||||
else
|
||||
graph.rectangle(column_r, true, essence_->scheme_ptr->header_bgcolor);
|
||||
}
|
||||
@ -3237,10 +3236,10 @@ namespace nana
|
||||
paint::graphics grad_graph{column_r.dimension()};
|
||||
grad_graph.gradual_rectangle(rectangle{column_r.dimension()}, bgcolor.blend(colors::white, 0.1), bgcolor.blend(colors::black, 0.1), true);
|
||||
|
||||
grad_graph.blend(rectangle{column_r.dimension()}, graph, column_r.position(), 0.3);
|
||||
graph.blend(column_r, grad_graph, {}, 0.8);
|
||||
}
|
||||
else
|
||||
graph.gradual_rectangle(column_r, bgcolor.blend(colors::white, 0.9), bgcolor.blend(colors::black, 0.9), true);
|
||||
graph.gradual_rectangle(column_r, bgcolor.blend(colors::white, 0.1), bgcolor.blend(colors::black, 0.1), true);
|
||||
|
||||
paint::aligner text_aligner{ graph, column.alignment, column.alignment };
|
||||
|
||||
@ -3283,7 +3282,7 @@ namespace nana
|
||||
|
||||
auto xpos = essence_->header.position(col.index, nullptr) + pos.x - grabs_.start_pos;
|
||||
|
||||
fl_graph.blend(rectangle{ fl_graph.size() }, *(essence_->graph), point{ xpos - essence_->content_view->origin().x + rect.x, rect.y }, 0.5);
|
||||
essence_->graph->blend(rectangle{ point{ xpos - essence_->content_view->origin().x + rect.x, rect.y } , fl_graph.size() }, fl_graph, {}, 0.5);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3479,10 +3478,10 @@ namespace nana
|
||||
};
|
||||
|
||||
paint::graphics box_graph{ box_size };
|
||||
box_graph.rectangle(true, essence_->scheme_ptr->selection_box.get_color().blend(colors::white, 0.4));
|
||||
box_graph.rectangle(true, essence_->scheme_ptr->selection_box.get_color().blend(colors::white, 0.6));
|
||||
box_graph.rectangle(false, essence_->scheme_ptr->selection_box.get_color());
|
||||
|
||||
box_graph.blend(rectangle{ box_size }, *essence_->graph, essence_->coordinate_cast(box_position, false), 0.5);
|
||||
essence_->graph->blend(rectangle{ essence_->coordinate_cast(box_position, false), box_size }, box_graph, {}, 0.5);
|
||||
}
|
||||
}
|
||||
private:
|
||||
@ -3552,9 +3551,9 @@ namespace nana
|
||||
if (item_state::highlighted == state)
|
||||
{
|
||||
if (item.flags.selected)
|
||||
bgcolor = bgcolor.blend(colors::black, 0.9);
|
||||
bgcolor = bgcolor.blend(colors::black, 0.1);
|
||||
else
|
||||
bgcolor = bgcolor.blend(essence_->scheme_ptr->item_highlighted, 0.3);
|
||||
bgcolor = bgcolor.blend(essence_->scheme_ptr->item_highlighted, 0.7);
|
||||
}
|
||||
|
||||
if (is_transparent)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Menubar implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2009-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2009-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -204,7 +204,7 @@ namespace nana
|
||||
{
|
||||
int x = item_pos.x + item_s.width;
|
||||
int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1;
|
||||
graph.line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.4));
|
||||
graph.line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.6));
|
||||
graph.line({ x + 1, y1 }, { x + 1, y2 }, bgcolor.blend(colors::button_face_shadow_end, 0.5));
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ namespace nana
|
||||
}
|
||||
|
||||
color rgb = schm.color_slider;
|
||||
if (mouse_action::normal != mouse_act)
|
||||
if (mouse_action::normal != mouse_act && mouse_action::normal_captured != mouse_act)
|
||||
rgb = schm.color_slider_highlighted;
|
||||
|
||||
graph.frame_rectangle(area, rgb + static_cast<color_rgb>(0x0d0d0d), 1);
|
||||
@ -128,7 +128,7 @@ namespace nana
|
||||
arrow_pos = data.position - arrow_weight;
|
||||
}
|
||||
|
||||
graph_vern.blend(rectangle{ label_size }, graph, label_pos, 0.5);
|
||||
graph.blend(rectangle{ label_pos, label_size }, graph_vern, {}, 0.5);
|
||||
|
||||
|
||||
unsigned arrow_color = 0x7F | schm.color_vernier.get_color().argb().value;
|
||||
@ -210,8 +210,7 @@ namespace nana
|
||||
arrow_pos = data.position;
|
||||
}
|
||||
|
||||
graph_vern.blend(rectangle{ label_size }, graph, label_pos, 0.5);
|
||||
|
||||
graph.blend(rectangle{ label_pos, label_size }, graph_vern, {}, 0.5);
|
||||
|
||||
unsigned arrow_color = 0x7F | schm.color_vernier.get_color().argb().value;
|
||||
for (auto & color : arrow_pxbuf)
|
||||
@ -483,7 +482,7 @@ namespace nana
|
||||
attr_.adorn_pos = xpos;
|
||||
attr_.is_draw_adorn = true;
|
||||
|
||||
if (::nana::mouse_action::normal == slider_state_.mouse_state)
|
||||
if (mouse_action::normal == slider_state_.mouse_state || mouse_action::normal_captured == slider_state_.mouse_state)
|
||||
slider_state_.mouse_state = ::nana::mouse_action::hovered;
|
||||
|
||||
return (adorn_pos != static_cast<int>(xpos));
|
||||
@ -610,7 +609,7 @@ namespace nana
|
||||
if (attr_.slider.vert)
|
||||
attr_.slider.pos = range - attr_.slider.pos;
|
||||
|
||||
if(::nana::mouse_action::normal == slider_state_.mouse_state)
|
||||
if(mouse_action::normal == slider_state_.mouse_state || mouse_action::normal_captured == slider_state_.mouse_state)
|
||||
attr_.adorn_pos = attr_.slider.pos;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Tabbar Implementation
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -49,9 +49,9 @@ namespace nana
|
||||
{
|
||||
bgcolor_ = bgcolor;
|
||||
|
||||
dark_bgcolor_ = bgcolor.blend(colors::black, 0.9);
|
||||
dark_bgcolor_ = bgcolor.blend(colors::black, 0.1);
|
||||
blcolor_ = bgcolor.blend(colors::black, 0.5);
|
||||
ilcolor_ = bgcolor.blend(colors::white, 0.9);
|
||||
ilcolor_ = bgcolor.blend(colors::white, 0.1);
|
||||
}
|
||||
|
||||
graph.rectangle(true, bgcolor);
|
||||
@ -74,7 +74,7 @@ namespace nana
|
||||
{
|
||||
bgcolor = m.bgcolor;
|
||||
blcolor = m.bgcolor.blend(colors::black, 0.5);
|
||||
dark_bgcolor = m.bgcolor.blend(colors::black, 0.9);
|
||||
dark_bgcolor = m.bgcolor.blend(colors::black, 0.1);
|
||||
}
|
||||
|
||||
auto round_r = r;
|
||||
@ -141,9 +141,9 @@ namespace nana
|
||||
::nana::color rect_clr{ static_cast<color_rgb>(0x9da3ab) };
|
||||
graph.round_rectangle(r, 1, 1, rect_clr, false, {});
|
||||
nana::rectangle draw_r(r);
|
||||
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.8));
|
||||
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.4));
|
||||
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.2));
|
||||
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.6));
|
||||
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.8));
|
||||
}
|
||||
else if (!active)
|
||||
clr = static_cast<color_rgb>(0x9299a4);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Toolbar Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -166,8 +166,10 @@ namespace nana
|
||||
gh.rgb_to_wb();
|
||||
gh.paste(graph, pos.x, pos.y);
|
||||
}
|
||||
else if(state == state_t::normal)
|
||||
else if (state == state_t::normal)
|
||||
{
|
||||
graph.blend(nana::rectangle(pos, imgsize), ::nana::color(0xc0, 0xdd, 0xfc).blend(bgcolor, 0.5), 0.25);
|
||||
}
|
||||
|
||||
x += scale;
|
||||
width -= scale;
|
||||
@ -230,7 +232,7 @@ namespace nana
|
||||
|
||||
auto bgcolor = API::bgcolor(widget_->handle());
|
||||
graph.palette(true, bgcolor);
|
||||
graph.gradual_rectangle(rectangle{ graph.size() }, bgcolor.blend(colors::white, 0.9), bgcolor.blend(colors::black, 0.95), true);
|
||||
graph.gradual_rectangle(rectangle{ graph.size() }, bgcolor.blend(colors::white, 0.1), bgcolor.blend(colors::black, 0.05), true);
|
||||
|
||||
item_renderer ir(graph, impl_->textout, impl_->scale, bgcolor);
|
||||
size_type index = 0;
|
||||
|
||||
@ -1240,7 +1240,8 @@ namespace nana
|
||||
item_graph.rectangle(false, clrptr[1]);
|
||||
item_graph.rectangle(rectangle{attr.area.dimension()}.pare_off(1), true, *clrptr);
|
||||
|
||||
item_graph.blend(rectangle{ attr.area.dimension() }, graph, attr.area.position(), 0.5);
|
||||
|
||||
graph.blend(attr.area, item_graph, attr.area.position(), 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Nana GUI Library Definition
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -41,7 +41,11 @@ namespace nana
|
||||
{
|
||||
if (!wait) return;
|
||||
std::cout << "waiting " << wait << " sec...\n";
|
||||
#ifdef STD_THREAD_NOT_SUPPORTED
|
||||
boost::this_thread::sleep_for(boost::chrono::seconds{ wait });
|
||||
#else
|
||||
std::this_thread::sleep_for(std::chrono::seconds{ wait });
|
||||
#endif
|
||||
}
|
||||
|
||||
void pump()
|
||||
|
||||
@ -100,16 +100,16 @@ namespace detail
|
||||
|
||||
void blend(drawable_type dw, const rectangle& area, pixel_color_t color, double fade_rate)
|
||||
{
|
||||
if (fade_rate < 0)
|
||||
fade_rate = 0;
|
||||
else if (fade_rate >= 1)
|
||||
if (fade_rate <= 0)
|
||||
return;
|
||||
else if (fade_rate >= 1)
|
||||
fade_rate = 1;
|
||||
|
||||
rectangle r;
|
||||
if (false == ::nana::overlap(rectangle{ drawable_size(dw) }, area, r))
|
||||
return;
|
||||
|
||||
auto const color_fd_rate = (double(color.element.alpha_channel) / 255.0) * (1 - fade_rate);
|
||||
auto const color_fd_rate = (double(color.element.alpha_channel) / 255.0) * fade_rate;
|
||||
|
||||
fade_rate = (1 - color_fd_rate);
|
||||
|
||||
|
||||
@ -659,19 +659,6 @@ namespace paint
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::blend(const nana::rectangle& s_r, graphics& dst, const nana::point& d_pos, double fade_rate) const
|
||||
{
|
||||
if(dst.impl_->handle && impl_->handle && (dst.impl_->handle != impl_->handle))
|
||||
{
|
||||
pixel_buffer s_pixbuf;
|
||||
s_pixbuf.attach(impl_->handle, ::nana::rectangle{ size() });
|
||||
|
||||
s_pixbuf.blend(s_r, dst.impl_->handle, d_pos, fade_rate);
|
||||
|
||||
if(dst.impl_->changed == false) dst.impl_->changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::blend(const nana::rectangle& r, const ::nana::color& clr, double fade_rate)
|
||||
{
|
||||
if (impl_->handle)
|
||||
@ -681,6 +668,21 @@ namespace paint
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::blend(const ::nana::rectangle& blend_r, const graphics& graph, const point& blend_graph_point, double fade_rate)///< blends with the blend_graph.
|
||||
{
|
||||
if (graph.impl_->handle && impl_->handle && (graph.impl_->handle != impl_->handle))
|
||||
{
|
||||
pixel_buffer graph_px;
|
||||
|
||||
nana::rectangle r{ blend_graph_point, blend_r.dimension() };
|
||||
|
||||
graph_px.attach(graph.impl_->handle, r);
|
||||
graph_px.blend(r, impl_->handle, blend_r.position(), 1 - fade_rate);
|
||||
|
||||
if (graph.impl_->changed == false) graph.impl_->changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::blur(const nana::rectangle& r, std::size_t radius)
|
||||
{
|
||||
if(impl_->handle)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user