Merge branch 'hotfix-1.6.2' of https://github.com/cnjinhao/nana into hotfix-1.6.2
This commit is contained in:
commit
02d082959f
@ -104,6 +104,7 @@ namespace drawerbase
|
|||||||
struct element_tag
|
struct element_tag
|
||||||
{
|
{
|
||||||
checkbox * uiobj;
|
checkbox * uiobj;
|
||||||
|
event_handle eh_clicked;
|
||||||
event_handle eh_checked;
|
event_handle eh_checked;
|
||||||
event_handle eh_destroy;
|
event_handle eh_destroy;
|
||||||
event_handle eh_keyboard;
|
event_handle eh_keyboard;
|
||||||
|
@ -42,6 +42,13 @@ namespace nana{
|
|||||||
using field_reference = place::field_reference;
|
using field_reference = place::field_reference;
|
||||||
constexpr static const std::size_t npos = static_cast<std::size_t>(-1);
|
constexpr static const std::size_t npos = static_cast<std::size_t>(-1);
|
||||||
|
|
||||||
|
enum class background_mode
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
transparent,
|
||||||
|
blending
|
||||||
|
};
|
||||||
|
|
||||||
/// The default construction
|
/// The default construction
|
||||||
group();
|
group();
|
||||||
|
|
||||||
@ -66,7 +73,8 @@ namespace nana{
|
|||||||
checkbox& add_option(::std::string);
|
checkbox& add_option(::std::string);
|
||||||
|
|
||||||
/// Modifies the alignment of the title
|
/// Modifies the alignment of the title
|
||||||
void caption_align(align position);
|
group& caption_align(align position);
|
||||||
|
group& caption_background_mode(background_mode mode);
|
||||||
|
|
||||||
/// Enables/disables the radio mode which is single selection
|
/// Enables/disables the radio mode which is single selection
|
||||||
group& radio_mode(bool);
|
group& radio_mode(bool);
|
||||||
|
@ -163,7 +163,8 @@ namespace nana
|
|||||||
bld_fgcolor = fgcolor.blend(highlighted, 0.6);
|
bld_fgcolor = fgcolor.blend(highlighted, 0.6);
|
||||||
break;
|
break;
|
||||||
case element_state::disabled:
|
case element_state::disabled:
|
||||||
bld_bgcolor = bld_fgcolor = static_cast<color_rgb>(0xb2b7bc);
|
bld_bgcolor = static_cast<color_rgb>(0xE0E0E0);
|
||||||
|
bld_fgcolor = static_cast<color_rgb>(0x999A9E);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//Leave things as they are
|
//Leave things as they are
|
||||||
|
@ -85,9 +85,13 @@ namespace nana{ namespace drawerbase
|
|||||||
graph.text_metrics(txt_px, descent, ileading);
|
graph.text_metrics(txt_px, descent, ileading);
|
||||||
txt_px += (descent + 2);
|
txt_px += (descent + 2);
|
||||||
|
|
||||||
|
auto e_state = API::element_state(*wdg);
|
||||||
|
if(!wdg->enabled())
|
||||||
|
e_state = element_state::disabled;
|
||||||
|
|
||||||
impl_->crook.draw(graph,
|
impl_->crook.draw(graph,
|
||||||
impl_->scheme_ptr->square_bgcolor.get(wdg->bgcolor()), impl_->scheme_ptr->square_border_color.get(wdg->fgcolor()),
|
impl_->scheme_ptr->square_bgcolor.get(wdg->bgcolor()), impl_->scheme_ptr->square_border_color.get(wdg->fgcolor()),
|
||||||
rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg));
|
rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), e_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
||||||
@ -212,6 +216,7 @@ namespace nana{ namespace drawerbase
|
|||||||
{
|
{
|
||||||
e.uiobj->radio(false);
|
e.uiobj->radio(false);
|
||||||
e.uiobj->react(true);
|
e.uiobj->react(true);
|
||||||
|
API::umake_event(e.eh_clicked);
|
||||||
API::umake_event(e.eh_checked);
|
API::umake_event(e.eh_checked);
|
||||||
API::umake_event(e.eh_destroy);
|
API::umake_event(e.eh_destroy);
|
||||||
API::umake_event(e.eh_keyboard);
|
API::umake_event(e.eh_keyboard);
|
||||||
@ -228,7 +233,7 @@ namespace nana{ namespace drawerbase
|
|||||||
|
|
||||||
el.uiobj = &uiobj;
|
el.uiobj = &uiobj;
|
||||||
|
|
||||||
uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg)
|
el.eh_checked = uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg)
|
||||||
{
|
{
|
||||||
if (arg.widget->checked())
|
if (arg.widget->checked())
|
||||||
{
|
{
|
||||||
@ -240,7 +245,7 @@ namespace nana{ namespace drawerbase
|
|||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
|
el.eh_clicked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
|
||||||
{
|
{
|
||||||
for (auto & i : ui_container_)
|
for (auto & i : ui_container_)
|
||||||
i.uiobj->check(arg.window_handle == i.uiobj->handle());
|
i.uiobj->check(arg.window_handle == i.uiobj->handle());
|
||||||
|
@ -33,13 +33,14 @@ namespace nana
|
|||||||
static const char* field_title = "__nana_group_title__";
|
static const char* field_title = "__nana_group_title__";
|
||||||
static const char* field_options = "__nana_group_options__";
|
static const char* field_options = "__nana_group_options__";
|
||||||
|
|
||||||
struct group::implement
|
struct group::implement
|
||||||
{
|
{
|
||||||
label caption;
|
label caption;
|
||||||
align caption_align{ align::left };
|
align caption_align{ align::left };
|
||||||
place place_content;
|
background_mode caption_mode{ background_mode::blending };
|
||||||
unsigned gap{2};
|
place place_content;
|
||||||
std::string usr_div_str;
|
unsigned gap{2};
|
||||||
|
std::string usr_div_str;
|
||||||
|
|
||||||
nana::size caption_dimension;
|
nana::size caption_dimension;
|
||||||
|
|
||||||
@ -143,200 +144,216 @@ checkbox& group::add_option(std::string text)
|
|||||||
impl_->options.emplace_back(new checkbox(handle()));
|
impl_->options.emplace_back(new checkbox(handle()));
|
||||||
auto & opt = impl_->options.back();
|
auto & opt = impl_->options.back();
|
||||||
#endif
|
#endif
|
||||||
opt->transparent(true);
|
|
||||||
opt->caption(std::move(text));
|
|
||||||
impl_->place_content[field_options] << *opt;
|
|
||||||
impl_->place_content.field_display(field_options, true);
|
|
||||||
impl_->place_content.collocate();
|
|
||||||
|
|
||||||
if (impl_->radio_logic)
|
opt->transparent(true);
|
||||||
impl_->radio_logic->add(*opt);
|
opt->caption(std::move(text));
|
||||||
|
impl_->place_content[field_options] << *opt;
|
||||||
|
impl_->place_content.field_display(field_options, true);
|
||||||
|
impl_->place_content.collocate();
|
||||||
|
|
||||||
return *impl_->options.back();
|
if (impl_->radio_logic)
|
||||||
}
|
impl_->radio_logic->add(*opt);
|
||||||
|
|
||||||
void group::caption_align(align position)
|
return *impl_->options.back();
|
||||||
{
|
}
|
||||||
if (position != impl_->caption_align)
|
|
||||||
{
|
|
||||||
impl_->caption_align = position;
|
|
||||||
impl_->update_div();
|
|
||||||
impl_->place_content.collocate();
|
|
||||||
API::refresh_window(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group& group::radio_mode(bool enable)
|
group& group::caption_align(align position)
|
||||||
{
|
{
|
||||||
_THROW_IF_EMPTY()
|
if (position != impl_->caption_align)
|
||||||
|
{
|
||||||
|
impl_->caption_align = position;
|
||||||
|
impl_->update_div();
|
||||||
|
impl_->place_content.collocate();
|
||||||
|
API::refresh_window(*this);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
if (enable)
|
group& group::caption_background_mode(background_mode mode)
|
||||||
{
|
{
|
||||||
//Create radio_group if it is null
|
if (mode != impl_->caption_mode)
|
||||||
if (!impl_->radio_logic)
|
{
|
||||||
impl_->radio_logic = new ::nana::radio_group;
|
impl_->caption_mode = mode;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case background_mode::none:
|
||||||
|
impl_->caption.bgcolor(this->bgcolor());
|
||||||
|
impl_->caption.transparent(false);
|
||||||
|
break;
|
||||||
|
case background_mode::blending:
|
||||||
|
impl_->caption.transparent(true);
|
||||||
|
impl_->caption.bgcolor(API::bgcolor(this->parent()).blend(colors::black, 0.025));
|
||||||
|
break;
|
||||||
|
case background_mode::transparent:
|
||||||
|
impl_->caption.transparent(true);
|
||||||
|
impl_->caption.bgcolor(API::bgcolor(this->parent()).blend(colors::black, 0.025));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
API::refresh_window(*this);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//add all options into the radio_group
|
group& group::radio_mode(bool enable)
|
||||||
for (auto & opt : impl_->options)
|
{
|
||||||
impl_->radio_logic->add(*opt);
|
_THROW_IF_EMPTY()
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete impl_->radio_logic;
|
|
||||||
impl_->radio_logic = nullptr;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t group::option() const
|
if (enable)
|
||||||
{
|
{
|
||||||
_THROW_IF_EMPTY();
|
//Create radio_group if it is null
|
||||||
|
if (!impl_->radio_logic)
|
||||||
|
impl_->radio_logic = new ::nana::radio_group;
|
||||||
|
|
||||||
if (impl_->radio_logic)
|
//add all options into the radio_group
|
||||||
return impl_->radio_logic->checked();
|
for (auto & opt : impl_->options)
|
||||||
|
impl_->radio_logic->add(*opt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete impl_->radio_logic;
|
||||||
|
impl_->radio_logic = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
throw std::logic_error("the radio_mode of the group is disabled");
|
std::size_t group::option() const
|
||||||
}
|
{
|
||||||
|
_THROW_IF_EMPTY();
|
||||||
|
|
||||||
bool group::option_checked(std::size_t pos) const
|
if (impl_->radio_logic)
|
||||||
{
|
return impl_->radio_logic->checked();
|
||||||
_THROW_IF_EMPTY();
|
|
||||||
return impl_->options.at(pos)->checked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void group::typeface( const nana::paint::font& font )
|
throw std::logic_error("the radio_mode of the group is disabled");
|
||||||
{
|
}
|
||||||
// change typeface of caption label
|
|
||||||
impl_->caption.typeface( font );
|
|
||||||
|
|
||||||
/* change size of caption label
|
bool group::option_checked(std::size_t pos) const
|
||||||
|
{
|
||||||
|
_THROW_IF_EMPTY();
|
||||||
|
return impl_->options.at(pos)->checked();
|
||||||
|
}
|
||||||
|
|
||||||
The caption may be changed AFTER this call
|
group& group::enable_format_caption(bool format)
|
||||||
so the neccessary label size is unknown
|
{
|
||||||
set it to 80% of the current widget width and 50 pixels
|
impl_->caption.format(format);
|
||||||
*/
|
return *this;
|
||||||
impl_->caption.move( rectangle(0,0,size().width * 0.8,50));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
group& group::enable_format_caption(bool format)
|
group& group::collocate() noexcept
|
||||||
{
|
{
|
||||||
impl_->caption.format(format);
|
impl_->place_content.collocate();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
group& group::collocate() noexcept
|
group& group::div(const char* div_str) noexcept
|
||||||
{
|
{
|
||||||
impl_->place_content.collocate();
|
if (div_str)
|
||||||
return *this;
|
impl_->usr_div_str = div_str;
|
||||||
}
|
else
|
||||||
|
impl_->usr_div_str.clear();
|
||||||
|
|
||||||
group& group::div(const char* div_str) noexcept
|
impl_->update_div();
|
||||||
{
|
return *this;
|
||||||
if (div_str)
|
}
|
||||||
impl_->usr_div_str = div_str;
|
|
||||||
else
|
|
||||||
impl_->usr_div_str.clear();
|
|
||||||
|
|
||||||
impl_->update_div();
|
group::field_reference group::operator[](const char* field)
|
||||||
return *this;
|
{
|
||||||
}
|
return impl_->place_content.field(field);
|
||||||
|
}
|
||||||
|
|
||||||
group::field_reference group::operator[](const char* field)
|
void group::field_display(const char* field_name, bool display)
|
||||||
{
|
{
|
||||||
return impl_->place_content.field(field);
|
impl_->place_content.field_display(field_name, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
void group::field_display(const char* field_name, bool display)
|
bool group::field_display(const char* field_name) const
|
||||||
{
|
{
|
||||||
impl_->place_content.field_display(field_name, display);
|
return impl_->place_content.field_display(field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool group::field_display(const char* field_name) const
|
void group::erase(window handle)
|
||||||
{
|
{
|
||||||
return impl_->place_content.field_display(field_name);
|
impl_->place_content.erase(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void group::erase(window handle)
|
void group::_m_add_child(const char* field, widget* wdg)
|
||||||
{
|
{
|
||||||
impl_->place_content.erase(handle);
|
impl_->place_content[field] << wdg->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void group::_m_add_child(const char* field, widget* wdg)
|
void group::_m_init()
|
||||||
{
|
{
|
||||||
impl_->place_content[field] << wdg->handle();
|
this->div(nullptr);
|
||||||
}
|
|
||||||
|
|
||||||
void group::_m_init()
|
auto & outter = impl_->place_content;
|
||||||
{
|
|
||||||
this->div(nullptr);
|
|
||||||
|
|
||||||
auto & outter = impl_->place_content;
|
outter[field_title] << impl_->caption;
|
||||||
|
outter.collocate();
|
||||||
|
|
||||||
outter[field_title] << impl_->caption;
|
impl_->caption.transparent(true);
|
||||||
outter.collocate();
|
color pbg = API::bgcolor(this->parent());
|
||||||
|
impl_->caption.bgcolor(pbg.blend(colors::black, 0.025));
|
||||||
|
|
||||||
impl_->caption.transparent(true);
|
this->bgcolor(pbg.blend(colors::black, 0.05));
|
||||||
color pbg = API::bgcolor(this->parent());
|
|
||||||
impl_->caption.bgcolor(pbg.blend(colors::black, 0.025));
|
|
||||||
|
|
||||||
this->bgcolor(pbg.blend(colors::black, 0.05));
|
drawing dw(*this);
|
||||||
|
|
||||||
drawing dw(*this);
|
//When the group is resized, the drawing is called before moving the caption, but
|
||||||
|
//the drawing of group requires the lastest position of caption for gradual rectangle.
|
||||||
|
//For the requirement, a move event handler is required for listning the change of caption's position.
|
||||||
|
impl_->caption.events().move([this](const arg_move&){
|
||||||
|
if (align::left != impl_->caption_align)
|
||||||
|
API::refresh_window(*this);
|
||||||
|
});
|
||||||
|
|
||||||
//When the group is resized, the drawing is called before moving the caption, but
|
// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
|
||||||
//the drawing of group requires the lastest position of caption for gradual rectangle.
|
dw.draw([this](paint::graphics& graph)
|
||||||
//For the requirement, a move event handler is required for listning the change of caption's position.
|
{
|
||||||
impl_->caption.events().move([this](const arg_move&)
|
auto gap_px = impl_->gap - 1;
|
||||||
{
|
|
||||||
if (align::left != impl_->caption_align)
|
|
||||||
API::refresh_window(*this);
|
|
||||||
});
|
|
||||||
|
|
||||||
// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
|
auto const top_round_line = static_cast<int>(impl_->caption_dimension.height) / 2;
|
||||||
dw.draw([this](paint::graphics& graph)
|
|
||||||
{
|
|
||||||
auto gap_px = impl_->gap - 1;
|
|
||||||
|
|
||||||
auto const top_round_line = static_cast<int>(impl_->caption_dimension.height) / 2;
|
graph.rectangle(true, API::bgcolor(this->parent()));
|
||||||
|
graph.round_rectangle(rectangle(point(gap_px, top_round_line),
|
||||||
|
nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px)
|
||||||
|
),
|
||||||
|
3, 3, this->scheme().border, true, this->bgcolor());
|
||||||
|
|
||||||
graph.rectangle(true, API::bgcolor(this->parent()));
|
if (background_mode::blending == impl_->caption_mode)
|
||||||
graph.round_rectangle(rectangle(point(gap_px, top_round_line),
|
{
|
||||||
nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px)
|
auto opt_r = API::window_rectangle(impl_->caption);
|
||||||
),
|
if (opt_r)
|
||||||
3, 3, this->scheme().border, true, this->bgcolor());
|
{
|
||||||
|
rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width + 4, static_cast<unsigned>(top_round_line - opt_r->y) } };
|
||||||
|
|
||||||
auto opt_r = API::window_rectangle(impl_->caption);
|
grad_r.y += top_round_line * 2 / 3;
|
||||||
if (opt_r)
|
grad_r.x -= 2;
|
||||||
{
|
|
||||||
rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width + 4, static_cast<unsigned>(top_round_line - opt_r->y) } };
|
|
||||||
|
|
||||||
grad_r.y += top_round_line*2 / 3;
|
graph.gradual_rectangle(grad_r,
|
||||||
grad_r.x -= 2;
|
API::bgcolor(this->parent()), this->bgcolor(), true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
graph.gradual_rectangle(grad_r,
|
void group::_m_complete_creation()
|
||||||
API::bgcolor(this->parent()), this->bgcolor(), true
|
{
|
||||||
);
|
widget::_m_complete_creation();
|
||||||
}
|
impl_->create(handle());
|
||||||
});
|
_m_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void group::_m_complete_creation()
|
auto group::_m_caption() const noexcept -> native_string_type
|
||||||
{
|
{
|
||||||
widget::_m_complete_creation();
|
return impl_->caption.caption_native();
|
||||||
impl_->create(handle());
|
}
|
||||||
_m_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto group::_m_caption() const noexcept -> native_string_type
|
void group::_m_caption(native_string_type&& str)
|
||||||
{
|
{
|
||||||
return impl_->caption.caption_native();
|
impl_->caption.caption(std::move(str));
|
||||||
}
|
impl_->update_div();
|
||||||
|
impl_->place_content.collocate();
|
||||||
|
}
|
||||||
|
|
||||||
void group::_m_caption(native_string_type&& str)
|
|
||||||
{
|
|
||||||
impl_->caption.caption(std::move(str));
|
|
||||||
impl_->update_div();
|
|
||||||
impl_->place_content.collocate();
|
|
||||||
}
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A text editor implementation
|
* A text editor implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 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
|
||||||
@ -1728,7 +1728,7 @@ namespace nana {
|
|||||||
str = impl_->textbase.getline(0);
|
str = impl_->textbase.getline(0);
|
||||||
for (std::size_t i = 1; i < lines; ++i)
|
for (std::size_t i = 1; i < lines; ++i)
|
||||||
{
|
{
|
||||||
str += L"\n\r";
|
str += L"\r\n";
|
||||||
str += impl_->textbase.getline(i);
|
str += impl_->textbase.getline(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2002,7 +2002,7 @@ namespace nana {
|
|||||||
|
|
||||||
auto fgcolor = scheme_->foreground.get_color();
|
auto fgcolor = scheme_->foreground.get_color();
|
||||||
if (!API::window_enabled(window_))
|
if (!API::window_enabled(window_))
|
||||||
fgcolor.blend(bgcolor, 0.5);
|
fgcolor = fgcolor.blend(bgcolor, 0.5); //Thank to besh81 for getting the fgcolor to be changed
|
||||||
|
|
||||||
if (API::widget_borderless(window_))
|
if (API::widget_borderless(window_))
|
||||||
graph_.rectangle(false, bgcolor);
|
graph_.rectangle(false, bgcolor);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <nana/push_ignore_diagnostic>
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/paint/detail/image_process_provider.hpp>
|
#include <nana/paint/detail/image_process_provider.hpp>
|
||||||
|
|
||||||
#include <nana/paint/detail/image_processor.hpp>
|
#include "image_processor.hpp"
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Image Processor Algorithm Implementation
|
* Image Processor Algorithm Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2018 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
|
||||||
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#ifndef NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP
|
#ifndef NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP
|
||||||
#define NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP
|
#define NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP
|
||||||
#include "../image_process_interface.hpp"
|
|
||||||
#include <nana/paint/pixel_buffer.hpp>
|
#include <nana/paint/pixel_buffer.hpp>
|
||||||
|
#include <nana/paint/image_process_interface.hpp>
|
||||||
#include <nana/paint/detail/native_paint_interface.hpp>
|
#include <nana/paint/detail/native_paint_interface.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -421,15 +421,19 @@ namespace detail
|
|||||||
{
|
{
|
||||||
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::color& clr, double fade_rate) const
|
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::color& clr, double fade_rate) const
|
||||||
{
|
{
|
||||||
|
//Return if it is completely transparent
|
||||||
|
if (fade_rate <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
auto rgb_color = clr.px_color().value;
|
auto rgb_color = clr.px_color().value;
|
||||||
const std::size_t bytes_pl = pixbuf.bytes_per_line();
|
const std::size_t bytes_pl = pixbuf.bytes_per_line();
|
||||||
|
|
||||||
unsigned char * fade_table = nullptr;
|
unsigned char * fade_table = nullptr;
|
||||||
std::unique_ptr<unsigned char[]> autoptr;
|
std::unique_ptr<unsigned char[]> autoptr;
|
||||||
nana::pixel_argb_t rgb_imd = {};
|
nana::pixel_argb_t rgb_imd = {};
|
||||||
if(fade_rate != 0.0)
|
if(fade_rate < 1)
|
||||||
{
|
{
|
||||||
autoptr = detail::alloc_fade_table(1 - fade_rate);
|
autoptr = detail::alloc_fade_table(1.0 - fade_rate);
|
||||||
fade_table = autoptr.get();
|
fade_table = autoptr.get();
|
||||||
rgb_imd.value = rgb_color;
|
rgb_imd.value = rgb_color;
|
||||||
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
|
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
|
Loading…
x
Reference in New Issue
Block a user