fix bugs that button renderer generated bad values if it zero-size
This commit is contained in:
parent
fa80519526
commit
afd8225875
@ -445,7 +445,13 @@ namespace nana
|
|||||||
size dimension() const noexcept;
|
size dimension() const noexcept;
|
||||||
rectangle& dimension(const size&) noexcept;
|
rectangle& dimension(const size&) noexcept;
|
||||||
|
|
||||||
rectangle& pare_off(int pixels); ///<Pares the specified pixels off the rectangle. It's equal to x += pixels; y + pixels; width -= (pixels << 1); height -= (pixels << 1);
|
/// Pares the specified pixels off the rectangle.
|
||||||
|
/**
|
||||||
|
* It's equal to x += pixels; y + pixels; width -= (pixels << 1); height -= (pixels << 1);
|
||||||
|
* @param pixels The number of pixels to be pared. If the number that multiples pixels twice is larger than width/height, the width/height will be zero. If the pixels is a negative number, the width/height is add the number that multiple pixels twice.
|
||||||
|
* @return The reference of *this.
|
||||||
|
*/
|
||||||
|
rectangle& pare_off(int pixels);
|
||||||
|
|
||||||
int right() const noexcept;
|
int right() const noexcept;
|
||||||
int bottom() const noexcept;
|
int bottom() const noexcept;
|
||||||
|
|||||||
@ -591,21 +591,21 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
rectangle& rectangle::set_size(const size& sz)
|
|
||||||
{
|
|
||||||
width = sz.width;
|
|
||||||
height = sz.height;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
rectangle& rectangle::pare_off(int pixels)
|
rectangle& rectangle::pare_off(int pixels)
|
||||||
{
|
{
|
||||||
x += pixels;
|
x += pixels;
|
||||||
y += pixels;
|
y += pixels;
|
||||||
width -= (pixels << 1);
|
auto const px_twice = (pixels << 1);
|
||||||
height -= (pixels << 1);
|
if (px_twice > static_cast<int>(width))
|
||||||
|
width = 0;
|
||||||
|
else
|
||||||
|
width -= px_twice;
|
||||||
|
|
||||||
|
if (px_twice > static_cast<int>(height))
|
||||||
|
height = 0;
|
||||||
|
else
|
||||||
|
height -= px_twice;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -294,7 +294,7 @@ namespace nana
|
|||||||
|
|
||||||
void drawer::refresh()
|
void drawer::refresh()
|
||||||
{
|
{
|
||||||
if (data_impl_->realizer && !data_impl_->refreshing)
|
if (data_impl_->realizer && (!(data_impl_->refreshing || graphics.size().empty())))
|
||||||
{
|
{
|
||||||
data_impl_->refreshing = true;
|
data_impl_->refreshing = true;
|
||||||
data_impl_->realizer->refresh(graphics);
|
data_impl_->realizer->refresh(graphics);
|
||||||
|
|||||||
@ -1196,7 +1196,11 @@ namespace paint
|
|||||||
#elif defined(NANA_X11)
|
#elif defined(NANA_X11)
|
||||||
if (nullptr == impl_->handle) return;
|
if (nullptr == impl_->handle) return;
|
||||||
|
|
||||||
double deltapx = double(vertical ? rct.height : rct.width);
|
nana::rectangle good_rct;
|
||||||
|
if(!nana::overlap(nana::rectangle{ size() }, rct, good_rct))
|
||||||
|
return;
|
||||||
|
|
||||||
|
double deltapx = double(vertical ? good_rct.height : good_rct.width);
|
||||||
double r, g, b;
|
double r, g, b;
|
||||||
const double delta_r = (to.r() - (r = from.r())) / deltapx;
|
const double delta_r = (to.r() - (r = from.r())) / deltapx;
|
||||||
const double delta_g = (to.g() - (g = from.g())) / deltapx;
|
const double delta_g = (to.g() - (g = from.g())) / deltapx;
|
||||||
@ -1207,13 +1211,13 @@ namespace paint
|
|||||||
Display * disp = nana::detail::platform_spec::instance().open_display();
|
Display * disp = nana::detail::platform_spec::instance().open_display();
|
||||||
impl_->handle->set_color(static_cast<color_rgb>(last_color));
|
impl_->handle->set_color(static_cast<color_rgb>(last_color));
|
||||||
impl_->handle->update_color();
|
impl_->handle->update_color();
|
||||||
const int endpos = deltapx + (vertical ? rct.y : rct.x);
|
const int endpos = deltapx + (vertical ? good_rct.y : good_rct.x);
|
||||||
if (endpos > 0)
|
if (endpos > 0)
|
||||||
{
|
{
|
||||||
if (vertical)
|
if (vertical)
|
||||||
{
|
{
|
||||||
int x1 = rct.x, x2 = rct.right();
|
int x1 = good_rct.x, x2 = good_rct.right();
|
||||||
auto y = rct.y;
|
auto y = good_rct.y;
|
||||||
for (; y < endpos; ++y)
|
for (; y < endpos; ++y)
|
||||||
{
|
{
|
||||||
::XDrawLine(disp, impl_->handle->pixmap, impl_->handle->context, x1, y, x2, y);
|
::XDrawLine(disp, impl_->handle->pixmap, impl_->handle->context, x1, y, x2, y);
|
||||||
@ -1228,8 +1232,8 @@ namespace paint
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int y1 = rct.y, y2 = rct.bottom();
|
int y1 = good_rct.y, y2 = good_rct.bottom();
|
||||||
auto x = rct.x;
|
auto x = good_rct.x;
|
||||||
for (; x < endpos; ++x)
|
for (; x < endpos; ++x)
|
||||||
{
|
{
|
||||||
::XDrawLine(disp, impl_->handle->pixmap, impl_->handle->context, x, y1, x, y2);
|
::XDrawLine(disp, impl_->handle->pixmap, impl_->handle->context, x, y1, x, y2);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user