Merge pull request #1 from cnjinhao/hotfix-1.6.2

Hotfix 1.6.2
This commit is contained in:
besh81 2019-01-08 17:09:03 +01:00 committed by GitHub
commit 7d05edb47b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 20 deletions

View File

@ -104,6 +104,7 @@ namespace drawerbase
struct element_tag
{
checkbox * uiobj;
event_handle eh_clicked;
event_handle eh_checked;
event_handle eh_destroy;
event_handle eh_keyboard;

View File

@ -42,6 +42,13 @@ namespace nana{
using field_reference = place::field_reference;
constexpr static const std::size_t npos = static_cast<std::size_t>(-1);
enum class background_mode
{
none,
transparent,
blending
};
/// The default construction
group();
@ -66,7 +73,8 @@ namespace nana{
checkbox& add_option(::std::string);
/// 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
group& radio_mode(bool);

View File

@ -216,6 +216,7 @@ namespace nana{ namespace drawerbase
{
e.uiobj->radio(false);
e.uiobj->react(true);
API::umake_event(e.eh_clicked);
API::umake_event(e.eh_checked);
API::umake_event(e.eh_destroy);
API::umake_event(e.eh_keyboard);
@ -232,7 +233,7 @@ namespace nana{ namespace drawerbase
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())
{
@ -244,7 +245,7 @@ namespace nana{ namespace drawerbase
}
}, 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_)
i.uiobj->check(arg.window_handle == i.uiobj->handle());

View File

@ -36,6 +36,7 @@ namespace nana{
{
label caption;
align caption_align{ align::left };
background_mode caption_mode{ background_mode::blending };
place place_content;
unsigned gap{2};
std::string usr_div_str;
@ -154,7 +155,7 @@ namespace nana{
return *impl_->options.back();
}
void group::caption_align(align position)
group& group::caption_align(align position)
{
if (position != impl_->caption_align)
{
@ -163,6 +164,32 @@ namespace nana{
impl_->place_content.collocate();
API::refresh_window(*this);
}
return *this;
}
group& group::caption_background_mode(background_mode mode)
{
if (mode != impl_->caption_mode)
{
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;
}
group& group::radio_mode(bool enable)
@ -289,18 +316,21 @@ namespace nana{
),
3, 3, this->scheme().border, true, this->bgcolor());
if (background_mode::blending == impl_->caption_mode)
{
auto opt_r = API::window_rectangle(impl_->caption);
if (opt_r)
{
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;
grad_r.y += top_round_line * 2 / 3;
grad_r.x -= 2;
graph.gradual_rectangle(grad_r,
API::bgcolor(this->parent()), this->bgcolor(), true
);
}
}
});
}

View File

@ -1,7 +1,7 @@
/*
* A text editor implementation
* 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.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -1728,7 +1728,7 @@ namespace nana {
str = impl_->textbase.getline(0);
for (std::size_t i = 1; i < lines; ++i)
{
str += L"\n\r";
str += L"\r\n";
str += impl_->textbase.getline(i);
}
}
@ -2002,7 +2002,7 @@ namespace nana {
auto fgcolor = scheme_->foreground.get_color();
if (!API::window_enabled(window_))
fgcolor.blend(bgcolor, 0.5); // do nothing !!! should be replace with <code> fgcolor = fgcolor.blend(bgcolor, 0.5); <\code> or removed
fgcolor = fgcolor.blend(bgcolor, 0.5); //Thank to besh81 for getting the fgcolor to be changed
if (API::widget_borderless(window_))
graph_.rectangle(false, bgcolor);

View File

@ -1,7 +1,7 @@
#include <nana/push_ignore_diagnostic>
#include <nana/paint/detail/image_process_provider.hpp>
#include <nana/paint/detail/image_processor.hpp>
#include "image_processor.hpp"
namespace nana
{

View File

@ -1,7 +1,7 @@
/*
* Image Processor Algorithm Implementation
* 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.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -15,8 +15,8 @@
#ifndef 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/image_process_interface.hpp>
#include <nana/paint/detail/native_paint_interface.hpp>
#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
{
//Return if it is completely transparent
if (fade_rate <= 0)
return;
auto rgb_color = clr.px_color().value;
const std::size_t bytes_pl = pixbuf.bytes_per_line();
unsigned char * fade_table = nullptr;
std::unique_ptr<unsigned char[]> autoptr;
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();
rgb_imd.value = rgb_color;
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);