fix picture widget transparent image issue
This commit is contained in:
parent
70dabd9687
commit
ce98ffa7b1
@ -34,7 +34,7 @@ namespace nana
|
|||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
private:
|
private:
|
||||||
void refresh(graph_reference) override;
|
void refresh(graph_reference) override;
|
||||||
void _m_draw_background();
|
void _m_draw_background(unsigned,unsigned);
|
||||||
private:
|
private:
|
||||||
implement * const impl_;
|
implement * const impl_;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Paint Image Implementation
|
* Paint Image Implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
|
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -39,6 +40,8 @@ namespace paint
|
|||||||
bool empty() const;
|
bool empty() const;
|
||||||
operator unspecified_bool_t() const;
|
operator unspecified_bool_t() const;
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
bool alpha() const;
|
||||||
nana::size size() const;
|
nana::size size() const;
|
||||||
void paste(graphics& dst, int x, int y) const;
|
void paste(graphics& dst, int x, int y) const;
|
||||||
void paste(const nana::rectangle& r_src, graphics& dst, const point& p_dst) const;///< Paste the area of picture specified by r_src into the destination graphics specified by dst at position p_dst.
|
void paste(const nana::rectangle& r_src, graphics& dst, const point& p_dst) const;///< Paste the area of picture specified by r_src into the destination graphics specified by dst at position p_dst.
|
||||||
|
@ -109,8 +109,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fit_size.width < graphsize.width || fit_size.height < graphsize.height)
|
_m_draw_background(fit_size.width, fit_size.height);
|
||||||
_m_draw_background();
|
|
||||||
|
|
||||||
backimg.image.stretch(valid_area, graph, { pos, fit_size });
|
backimg.image.stretch(valid_area, graph, { pos, fit_size });
|
||||||
}
|
}
|
||||||
@ -141,14 +140,15 @@ namespace nana
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_area.width < graphsize.width || valid_area.height < graphsize.height)
|
_m_draw_background(valid_area.width, valid_area.height);
|
||||||
_m_draw_background();
|
|
||||||
|
|
||||||
backimg.image.paste(valid_area, graph, pos);
|
backimg.image.paste(valid_area, graph, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_m_draw_background(graphsize.width, graphsize.height);
|
||||||
|
|
||||||
color invalid_clr_for_call;
|
color invalid_clr_for_call;
|
||||||
backimg.bground->draw(graph, invalid_clr_for_call, invalid_clr_for_call, graphsize, element_state::normal);
|
backimg.bground->draw(graph, invalid_clr_for_call, invalid_clr_for_call, graphsize, element_state::normal);
|
||||||
}
|
}
|
||||||
@ -156,18 +156,22 @@ namespace nana
|
|||||||
graph.setsta();
|
graph.setsta();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::_m_draw_background()
|
void drawer::_m_draw_background(unsigned w, unsigned h)
|
||||||
{
|
{
|
||||||
auto graph = impl_->graph_ptr;
|
auto graph = impl_->graph_ptr;
|
||||||
|
|
||||||
if (graph && (bground_mode::basic != API::effects_bground_mode(*impl_->wdg_ptr)))
|
if (graph && (bground_mode::basic != API::effects_bground_mode(*impl_->wdg_ptr)))
|
||||||
{
|
{
|
||||||
auto & bground = impl_->gradual_bground;
|
if (w < graph->size().width || h < graph->size().width || impl_->backimg.image.alpha())
|
||||||
if (bground.gradual_from.invisible() || bground.gradual_to.invisible())
|
{
|
||||||
graph->rectangle(true, impl_->wdg_ptr->bgcolor());
|
auto & bground = impl_->gradual_bground;
|
||||||
else if (bground.gradual_from == bground.gradual_to)
|
if (bground.gradual_from.invisible() || bground.gradual_to.invisible())
|
||||||
graph->rectangle(true, bground.gradual_from);
|
graph->rectangle(true, impl_->wdg_ptr->bgcolor());
|
||||||
else
|
else if (bground.gradual_from == bground.gradual_to)
|
||||||
graph->gradual_rectangle(graph->size(), bground.gradual_from, bground.gradual_to, !bground.horizontal);
|
graph->rectangle(true, bground.gradual_from);
|
||||||
|
else
|
||||||
|
graph->gradual_rectangle(graph->size(), bground.gradual_from, bground.gradual_to, !bground.horizontal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end class drawer
|
//end class drawer
|
||||||
|
@ -250,6 +250,11 @@ namespace paint
|
|||||||
image_ptr_.reset();
|
image_ptr_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool image::alpha() const
|
||||||
|
{
|
||||||
|
return (image_ptr_ ? image_ptr_->alpha_channel() : false);
|
||||||
|
}
|
||||||
|
|
||||||
nana::size image::size() const
|
nana::size image::size() const
|
||||||
{
|
{
|
||||||
return (image_ptr_ ? image_ptr_->size() : nana::size());
|
return (image_ptr_ ? image_ptr_->size() : nana::size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user