Improved processing of edge nimbus effect
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
#include <nana/gui/effects.hpp>
|
#include <nana/gui/effects.hpp>
|
||||||
#include <nana/paint/graphics.hpp>
|
#include <nana/paint/graphics.hpp>
|
||||||
#include <nana/paint/pixel_buffer.hpp>
|
#include <nana/paint/pixel_buffer.hpp>
|
||||||
|
|
||||||
#include <nana/gui/layout_utility.hpp>
|
#include <nana/gui/layout_utility.hpp>
|
||||||
|
|
||||||
namespace nana{
|
namespace nana{
|
||||||
@@ -12,7 +11,7 @@ namespace nana{
|
|||||||
template<typename CoreWindow>
|
template<typename CoreWindow>
|
||||||
class edge_nimbus_renderer
|
class edge_nimbus_renderer
|
||||||
{
|
{
|
||||||
edge_nimbus_renderer(){}
|
edge_nimbus_renderer() = default;
|
||||||
public:
|
public:
|
||||||
typedef CoreWindow core_window_t;
|
typedef CoreWindow core_window_t;
|
||||||
typedef window_layout window_layer;
|
typedef window_layout window_layer;
|
||||||
@@ -44,7 +43,7 @@ namespace nana{
|
|||||||
auto graph = root_wd->root_graph;
|
auto graph = root_wd->root_graph;
|
||||||
|
|
||||||
std::vector<core_window_t*> erase;
|
std::vector<core_window_t*> erase;
|
||||||
std::vector<rectangle> r_set;
|
std::vector<std::pair<rectangle,core_window_t*>> rd_set;
|
||||||
nana::rectangle r;
|
nana::rectangle r;
|
||||||
for(auto & action : nimbus)
|
for(auto & action : nimbus)
|
||||||
{
|
{
|
||||||
@@ -53,9 +52,13 @@ namespace nana{
|
|||||||
if(action.window == wd)
|
if(action.window == wd)
|
||||||
rendered = true;
|
rendered = true;
|
||||||
|
|
||||||
r_set.push_back(r);
|
//Avoiding duplicated rendering. If the window is declared to lazy refresh, it should be rendered.
|
||||||
|
if (!action.rendered || (action.window->other.upd_state == core_window_t::update_state::refresh))
|
||||||
|
{
|
||||||
|
rd_set.emplace_back(r, action.window);
|
||||||
action.rendered = true;
|
action.rendered = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(action.rendered)
|
else if(action.rendered)
|
||||||
{
|
{
|
||||||
action.rendered = false;
|
action.rendered = false;
|
||||||
@@ -77,13 +80,9 @@ namespace nana{
|
|||||||
graph->paste(native, r, r.x, r.y);
|
graph->paste(native, r, r.x, r.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto visual_iterator = r_set.begin();
|
|
||||||
//Render
|
//Render
|
||||||
for(auto & action : nimbus)
|
for (auto & rd : rd_set)
|
||||||
{
|
_m_render_edge_nimbus(rd.second, rd.first);
|
||||||
if(action.rendered)
|
|
||||||
_m_render_edge_nimbus(action.window, *(visual_iterator++));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return rendered;
|
return rendered;
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ namespace nana{
|
|||||||
nana::rectangle r(visual);
|
nana::rectangle r(visual);
|
||||||
r.pare_off(-static_cast<int>(weight()));
|
r.pare_off(-static_cast<int>(weight()));
|
||||||
nana::rectangle good_r;
|
nana::rectangle good_r;
|
||||||
if(overlap(r, nana::rectangle(wd->root_graph->size()), good_r))
|
if(overlap(r, wd->root_graph->size(), good_r))
|
||||||
{
|
{
|
||||||
if( (good_r.x < wd->pos_root.x) || (good_r.y < wd->pos_root.y) ||
|
if( (good_r.x < wd->pos_root.x) || (good_r.y < wd->pos_root.y) ||
|
||||||
(good_r.x + good_r.width > visual.x + visual.width) || (good_r.y + good_r.height > visual.y + visual.height))
|
(good_r.x + good_r.width > visual.x + visual.width) || (good_r.y + good_r.height > visual.y + visual.height))
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ namespace nana
|
|||||||
|
|
||||||
bool drawer::_m_lazy_decleared() const
|
bool drawer::_m_lazy_decleared() const
|
||||||
{
|
{
|
||||||
return (basic_window::update_state::refresh != core_window_->other.upd_state);
|
return (basic_window::update_state::refresh == core_window_->other.upd_state);
|
||||||
}
|
}
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <nana/gui/detail/native_window_interface.hpp>
|
#include <nana/gui/detail/native_window_interface.hpp>
|
||||||
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
||||||
#include <nana/gui/layout_utility.hpp>
|
#include <nana/gui/layout_utility.hpp>
|
||||||
|
#include <nana/gui/detail/effects_renderer.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -747,6 +748,12 @@ namespace detail
|
|||||||
wndlayout_type::paint(wd, false, false);
|
wndlayout_type::paint(wd, false, false);
|
||||||
this->map(wd);
|
this->map(wd);
|
||||||
}
|
}
|
||||||
|
else if (effects::edge_nimbus::none != wd->effect.edge_nimbus)
|
||||||
|
{
|
||||||
|
//Update the nimbus effect
|
||||||
|
using nimbus_renderer = detail::edge_nimbus_renderer<core_window_t>;
|
||||||
|
nimbus_renderer::instance().render(wd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wndlayout_type::paint(wd, true, false); //only refreshing if it has an invisible parent
|
wndlayout_type::paint(wd, true, false); //only refreshing if it has an invisible parent
|
||||||
|
|||||||
Reference in New Issue
Block a user