explicit conversion from point/size to rectangle

This commit is contained in:
Jinhao
2015-06-22 11:30:14 +08:00
parent 1bb9a09a8a
commit 28413b7f25
28 changed files with 82 additions and 77 deletions

View File

@@ -98,13 +98,13 @@ namespace detail
return bgcolor;
}
void blend(drawable_type dw, const nana::rectangle& area, pixel_color_t color, double fade_rate)
void blend(drawable_type dw, const rectangle& area, pixel_color_t color, double fade_rate)
{
if(fade_rate <= 0) return;
if(fade_rate > 1) fade_rate = 1;
nana::rectangle r;
if(false == nana::overlap(drawable_size(dw), area, r))
rectangle r;
if (false == ::nana::overlap(rectangle{ drawable_size(dw) }, area, r))
return;
unsigned red = static_cast<unsigned>((color.value & 0xFF0000) * fade_rate);

View File

@@ -604,7 +604,7 @@ namespace paint
if(dst.handle_ && handle_ && (dst.handle_ != handle_))
{
pixel_buffer s_pixbuf;
s_pixbuf.attach(handle_, size());
s_pixbuf.attach(handle_, ::nana::rectangle{ size() });
s_pixbuf.blend(s_r, dst.handle_, d_pos, fade_rate);
@@ -1022,13 +1022,13 @@ namespace paint
void graphics::rectangle(bool solid)
{
rectangle(size(), solid);
rectangle(::nana::rectangle{ size() }, solid);
}
void graphics::rectangle(bool solid, const ::nana::color& clr)
{
set_color(clr);
rectangle(size(), solid);
rectangle(::nana::rectangle{ size() }, solid);
}
void graphics::rectangle(const ::nana::rectangle& r, bool solid)

View File

@@ -263,7 +263,7 @@ namespace paint
void image::paste(graphics& dst, int x, int y) const
{
if(image_ptr_)
image_ptr_->paste(image_ptr_->size(), dst, x, y);
image_ptr_->paste(::nana::rectangle{ image_ptr_->size() }, dst, x, y);
}
void image::paste(const nana::rectangle& r_src, graphics & dst, const nana::point& p_dst) const

View File

@@ -22,10 +22,10 @@
namespace nana{ namespace paint
{
nana::rectangle valid_rectangle(const nana::size& s, const nana::rectangle& r)
nana::rectangle valid_rectangle(const size& s, const rectangle& r)
{
nana::rectangle good_r;
nana::overlap(s, r, good_r);
nana::overlap(rectangle{ s }, r, good_r);
return good_r;
}
@@ -384,13 +384,13 @@ namespace nana{ namespace paint
close();
}
void pixel_buffer::attach(drawable_type drawable, const nana::rectangle& want_r)
void pixel_buffer::attach(drawable_type drawable, const ::nana::rectangle& want_r)
{
storage_.reset();
if(drawable)
{
nana::rectangle r;
if(nana::overlap(nana::paint::detail::drawable_size(drawable), want_r, r))
if (::nana::overlap(::nana::rectangle{ nana::paint::detail::drawable_size(drawable) }, want_r, r))
storage_ = std::make_shared<pixel_buffer_storage>(drawable, r);
}
}
@@ -429,16 +429,16 @@ namespace nana{ namespace paint
bool pixel_buffer::open(drawable_type drawable, const nana::rectangle & want_rectangle)
{
nana::size sz = nana::paint::detail::drawable_size(drawable);
auto sz = nana::paint::detail::drawable_size(drawable);
if(want_rectangle.x >= static_cast<int>(sz.width) || want_rectangle.y >= static_cast<int>(sz.height))
return false;
nana::rectangle want_r = want_rectangle;
auto want_r = want_rectangle;
if(want_r.width == 0) want_r.width = sz.width - want_r.x;
if(want_r.height == 0) want_r.height = sz.height - want_r.y;
nana::rectangle r;
if(false == overlap(sz, want_r, r))
::nana::rectangle r;
if (false == overlap(::nana::rectangle{ sz }, want_r, r))
return false;
#if defined(NANA_WINDOWS)
BITMAPINFO bmpinfo;
@@ -1039,13 +1039,13 @@ namespace nana{ namespace paint
}
}
void pixel_buffer::blur(const nana::rectangle& r, std::size_t radius)
void pixel_buffer::blur(const ::nana::rectangle& r, std::size_t radius)
{
auto sp = storage_.get();
if(nullptr == sp || radius < 1) return;
nana::rectangle good_r;
if(overlap(r, this->size(), good_r))
::nana::rectangle good_r;
if (overlap(r, ::nana::rectangle{ this->size() }, good_r))
(*(sp->img_pro.blur))->process(*this, good_r, radius);
}
}//end namespace paint