Added listbox color scheme

This commit is contained in:
cnjinhao 2014-12-30 06:28:23 +08:00
parent 052d34a746
commit aa12254844
22 changed files with 142 additions and 107 deletions

View File

@ -309,10 +309,10 @@ namespace nana
color& from_rgb(unsigned red, unsigned green, unsigned blue); ///< immutable alpha channel color& from_rgb(unsigned red, unsigned green, unsigned blue); ///< immutable alpha channel
color& from_hsl(double hue, double saturation, double lightness); ///< immutable alpha channel color& from_hsl(double hue, double saturation, double lightness); ///< immutable alpha channel
color& blend(const color& bgcolor, bool ignore_bgcolor_alpha); color blend(const color& bgcolor, bool ignore_bgcolor_alpha) const;
///< Blends two colors with the specified alpha, and the alpha values that come with these two colors are both ignored. ///< Blends two colors with the specified alpha, and the alpha values that come with these two colors are both ignored.
color& blend(const color& bgcolor, double alpha); color blend(const color& bgcolor, double alpha) const;
bool invisible() const; bool invisible() const;
pixel_color_t px_color() const; pixel_color_t px_color() const;

View File

@ -223,9 +223,9 @@ namespace detail
void read_keystate(XKeyEvent&); void read_keystate(XKeyEvent&);
XIC caret_input_context(native_window_type) const; XIC caret_input_context(native_window_type) const;
void caret_open(native_window_type, unsigned width, unsigned height); void caret_open(native_window_type, const ::nana::size&);
void caret_close(native_window_type); void caret_close(native_window_type);
void caret_pos(native_window_type, int x, int y); void caret_pos(native_window_type, const ::nana::point&);
void caret_visible(native_window_type, bool); void caret_visible(native_window_type, bool);
void caret_flash(caret_tag&); void caret_flash(caret_tag&);
bool caret_update(native_window_type, nana::paint::graphics& root_graph, bool is_erase_caret_from_root_graph); bool caret_update(native_window_type, nana::paint::graphics& root_graph, bool is_erase_caret_from_root_graph);

View File

@ -69,9 +69,9 @@ namespace detail
static nana::point cursor_position(); static nana::point cursor_position();
static native_window_type get_owner_window(native_window_type); static native_window_type get_owner_window(native_window_type);
//For Caret //For Caret
static void caret_create(native_window_type, unsigned width, unsigned height); static void caret_create(native_window_type, const ::nana::size&);
static void caret_destroy(native_window_type); static void caret_destroy(native_window_type);
static void caret_pos(native_window_type, int x, int y); static void caret_pos(native_window_type, const ::nana::point&);
static void caret_visible(native_window_type, bool); static void caret_visible(native_window_type, bool);
static void set_focus(native_window_type); static void set_focus(native_window_type);

View File

@ -25,6 +25,8 @@ namespace nana
color_proxy(colors); color_proxy(colors);
color_proxy& operator=(const color_proxy&); color_proxy& operator=(const color_proxy&);
color_proxy& operator=(const ::nana::color&); color_proxy& operator=(const ::nana::color&);
color_proxy& operator=(color_rgb);
color_proxy& operator=(colors);
color get_color() const; color get_color() const;
operator color() const; operator color() const;
private: private:

View File

@ -230,7 +230,7 @@ namespace API
void create_caret(window, unsigned width, unsigned height); void create_caret(window, unsigned width, unsigned height);
void destroy_caret(window); void destroy_caret(window);
void caret_effective_range(window, const rectangle&); void caret_effective_range(window, const rectangle&);
void caret_pos(window, int x, int y); void caret_pos(window, const ::nana::point&);
nana::point caret_pos(window); nana::point caret_pos(window);
nana::size caret_size(window); nana::size caret_size(window);
void caret_size(window, const size&); void caret_size(window, const size&);

View File

@ -431,6 +431,15 @@ namespace nana
basic_event<arg_listbox> checked; basic_event<arg_listbox> checked;
basic_event<arg_listbox> selected; basic_event<arg_listbox> selected;
}; };
struct scheme
: public widget_colors
{
color_proxy header_bgcolor{static_cast<color_rgb>(0xf1f2f4)};
color_proxy header_grabbed{ static_cast<color_rgb>(0x8BD6F6)};
color_proxy header_floated{ static_cast<color_rgb>(0xBABBBC)};
color_proxy item_selected{ static_cast<color_rgb>(0xD5EFFC) };
};
} }
}//end namespace drawerbase }//end namespace drawerbase
@ -442,7 +451,7 @@ The user can \a drag the header to \a reisize it or to \a reorganize it.
By \a clicking on a header the list get \a reordered, first up, and then down alternatively, By \a clicking on a header the list get \a reordered, first up, and then down alternatively,
*/ */
class listbox class listbox
: public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events>, : public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events, drawerbase::listbox::scheme>,
public concepts::any_objective<drawerbase::listbox::size_type, 2> public concepts::any_objective<drawerbase::listbox::size_type, 2>
{ {
public: public:

View File

@ -114,45 +114,49 @@ namespace nana
return *this; return *this;
} }
color& color::blend(const color& bgcolor, bool ignore_bgcolor_alpha) color color::blend(const color& bgcolor, bool ignore_bgcolor_alpha) const
{ {
if (a_ < 1.0) if (a_ < 1.0)
{ {
color result;
if (0.0 < a_) if (0.0 < a_)
{ {
if (ignore_bgcolor_alpha || (1.0 == bgcolor.b_)) if (ignore_bgcolor_alpha || (1.0 == bgcolor.b_))
{ {
r_ = r_ * a_ + bgcolor.r_ * (1.0 - a_); result.r_ = r_ * a_ + bgcolor.r_ * (1.0 - a_);
g_ = g_ * a_ + bgcolor.g_ * (1.0 - a_); result.g_ = g_ * a_ + bgcolor.g_ * (1.0 - a_);
b_ = b_ * a_ + bgcolor.b_ * (1.0 - a_); result.b_ = b_ * a_ + bgcolor.b_ * (1.0 - a_);
a_ = 1.0; result.a_ = 1.0;
} }
else else
{ {
r_ = r_ * a_ + bgcolor.r_ * bgcolor.a_ * (1.0 - a_); result.r_ = r_ * a_ + bgcolor.r_ * bgcolor.a_ * (1.0 - a_);
g_ = g_ * a_ + bgcolor.g_ * bgcolor.a_ * (1.0 - a_); result.g_ = g_ * a_ + bgcolor.g_ * bgcolor.a_ * (1.0 - a_);
b_ = b_ * a_ + bgcolor.b_ * bgcolor.a_ * (1.0 - a_); result.b_ = b_ * a_ + bgcolor.b_ * bgcolor.a_ * (1.0 - a_);
a_ = a_ + (bgcolor.a_ * (1.0 - a_)); result.a_ = a_ + (bgcolor.a_ * (1.0 - a_));
} }
} }
else else
{ {
r_ = bgcolor.r_; result.r_ = bgcolor.r_;
g_ = bgcolor.g_; result.g_ = bgcolor.g_;
b_ = bgcolor.b_; result.b_ = bgcolor.b_;
a_ = (ignore_bgcolor_alpha ? 1.0 : bgcolor.a_); result.a_ = (ignore_bgcolor_alpha ? 1.0 : bgcolor.a_);
} }
return result;
} }
return *this; return *this;
} }
color& color::blend(const color& bgcolor, double alpha) color color::blend(const color& bgcolor, double alpha) const
{ {
r_ = r_ * alpha + bgcolor.r_ * (1.0 - alpha); color result;
g_ = g_ * alpha + bgcolor.g_ * (1.0 - alpha); result.r_ = r_ * alpha + bgcolor.r_ * (1.0 - alpha);
b_ = b_ * alpha + bgcolor.b_ * (1.0 - alpha); result.g_ = g_ * alpha + bgcolor.g_ * (1.0 - alpha);
a_ = 1.0; result.b_ = b_ * alpha + bgcolor.b_ * (1.0 - alpha);
return *this; result.a_ = 1.0;
return result;
} }
bool color::invisible() const bool color::invisible() const

View File

@ -715,7 +715,7 @@ namespace detail
return 0; return 0;
} }
void platform_spec::caret_open(native_window_type wd, unsigned width, unsigned height) void platform_spec::caret_open(native_window_type wd, const ::nana::size& caret_sz)
{ {
bool is_start_routine = false; bool is_start_routine = false;
platform_scope_guard psg; platform_scope_guard psg;
@ -794,12 +794,11 @@ namespace detail
} }
addr->visible = false; addr->visible = false;
addr->graph.make(width, height); addr->graph.make(caret_sz.width, caret_sz.height);
addr->graph.rectangle(0x0, true); addr->graph.rectangle(0x0, true);
addr->rev_graph.make(width, height); addr->rev_graph.make(caret_sz.width, caret_sz.height);
addr->size.width = width; addr->size = caret_sz;
addr->size.height = height;
if(addr->input_context && (false == addr->has_input_method_focus)) if(addr->input_context && (false == addr->has_input_method_focus))
{ {
@ -872,7 +871,7 @@ namespace detail
} }
} }
void platform_spec::caret_pos(native_window_type wd, int x, int y) void platform_spec::caret_pos(native_window_type wd, const point& pos)
{ {
platform_scope_guard psg; platform_scope_guard psg;
auto i = caret_holder_.carets.find(wd); auto i = caret_holder_.carets.find(wd);
@ -880,8 +879,7 @@ namespace detail
{ {
caret_tag & crt = *i->second; caret_tag & crt = *i->second;
caret_reinstate(crt); caret_reinstate(crt);
crt.pos.x = x; crt.pos = pos;
crt.pos.y = y;
} }
} }

View File

@ -21,7 +21,7 @@ namespace nana
{ {
if(active) if(active)
{ {
native_interface::caret_create(wd_->root, size_.width, size_.height); native_interface::caret_create(wd_->root, size_);
real_visible_state_ = false; real_visible_state_ = false;
visible_ = false; visible_ = false;
this->position(point_.x, point_.y); this->position(point_.x, point_.y);
@ -173,7 +173,7 @@ namespace nana
if(paint_size_ != size) if(paint_size_ != size)
{ {
native_interface::caret_destroy(wd_->root); native_interface::caret_destroy(wd_->root);
native_interface::caret_create(wd_->root, size.width, size.height); native_interface::caret_create(wd_->root, size);
real_visible_state_ = false; real_visible_state_ = false;
if(visible_) if(visible_)
_m_visible(true); _m_visible(true);
@ -181,7 +181,7 @@ namespace nana
paint_size_ = size; paint_size_ = size;
} }
native_interface::caret_pos(wd_->root, wd_->pos_root.x + pos.x, wd_->pos_root.y + pos.y); native_interface::caret_pos(wd_->root, wd_->pos_root + pos);
} }
} }
//end class caret_descriptor //end class caret_descriptor

View File

@ -29,6 +29,18 @@ namespace nana
return *this; return *this;
} }
color_proxy& color_proxy::operator = (color_rgb clr)
{
color_ = std::make_shared<::nana::color>(clr);
return *this;
}
color_proxy& color_proxy::operator = (colors clr)
{
color_ = std::make_shared<::nana::color>(clr);
return *this;
}
color color_proxy::get_color() const color color_proxy::get_color() const
{ {
return *color_; return *color_;

View File

@ -1193,13 +1193,13 @@ namespace nana{
#endif #endif
} }
void native_interface::caret_create(native_window_type wd, unsigned width, unsigned height) void native_interface::caret_create(native_window_type wd, const ::nana::size& caret_sz)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::CreateCaret(reinterpret_cast<HWND>(wd), 0, int(width), int(height)); ::CreateCaret(reinterpret_cast<HWND>(wd), 0, int(caret_sz.width), int(caret_sz.height));
#elif defined(NANA_X11) #elif defined(NANA_X11)
nana::detail::platform_scope_guard psg; nana::detail::platform_scope_guard psg;
restrict::spec.caret_open(wd, width, height); restrict::spec.caret_open(wd, caret_sz);
#endif #endif
} }
@ -1216,21 +1216,21 @@ namespace nana{
#endif #endif
} }
void native_interface::caret_pos(native_window_type wd, int x, int y) void native_interface::caret_pos(native_window_type wd, const point& pos)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0)) if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
{ {
auto cp = new nana::detail::messages::caret; auto cp = new nana::detail::messages::caret;
cp->x = x; cp->x = pos.x;
cp->y = y; cp->y = pos.y;
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::operate_caret, 2, reinterpret_cast<LPARAM>(cp)); ::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::operate_caret, 2, reinterpret_cast<LPARAM>(cp));
} }
else else
::SetCaretPos(x, y); ::SetCaretPos(pos.x, pos.y);
#elif defined(NANA_X11) #elif defined(NANA_X11)
nana::detail::platform_scope_guard psg; nana::detail::platform_scope_guard psg;
restrict::spec.caret_pos(wd, x, y); restrict::spec.caret_pos(wd, pos);
#endif #endif
} }

View File

@ -141,19 +141,19 @@ namespace nana
} }
else else
{ {
nana::color highlighted(0x5e, 0xb6, 0xf7); ::nana::color highlighted(0x5e, 0xb6, 0xf7);
auto bld_bgcolor = bgcolor; auto bld_bgcolor = bgcolor;
auto bld_fgcolor = fgcolor; auto bld_fgcolor = fgcolor;
switch(es) switch(es)
{ {
case element_state::hovered: case element_state::hovered:
case element_state::focus_hovered: case element_state::focus_hovered:
bld_bgcolor.blend(highlighted, 0.8); bld_bgcolor = bgcolor.blend(highlighted, 0.8);
bld_fgcolor.blend(highlighted, 0.8); bld_fgcolor = fgcolor.blend(highlighted, 0.8);
break; break;
case element_state::pressed: case element_state::pressed:
bld_bgcolor.blend(highlighted, 0.4); bld_bgcolor = bgcolor.blend(highlighted, 0.4);
bld_fgcolor.blend(highlighted, 0.4); bld_fgcolor = fgcolor.blend(highlighted, 0.4);
break; break;
case element_state::disabled: case element_state::disabled:
bld_bgcolor = bld_fgcolor = nana::color(0xb2, 0xb7, 0xbc); bld_bgcolor = bld_fgcolor = nana::color(0xb2, 0xb7, 0xbc);
@ -244,14 +244,11 @@ namespace nana
int x = r.x + (static_cast<int>(r.width) - 16) / 2; int x = r.x + (static_cast<int>(r.width) - 16) / 2;
int y = r.y + (static_cast<int>(r.height) - 16) / 2; int y = r.y + (static_cast<int>(r.height) - 16) / 2;
::nana::color light(colors::white);
light.blend(fgcolor, 0.5);
graph.set_color(fgcolor); graph.set_color(fgcolor);
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 }); graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 });
graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 }); graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 });
graph.set_color(light); graph.set_color(fgcolor.blend(colors::white, 0.5));
graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 }); graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 });
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 }); graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 }); graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });

View File

@ -908,12 +908,12 @@ namespace API
} }
} }
void caret_pos(window wd, int x, int y) void caret_pos(window wd, const point& pos)
{ {
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd); auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard lock; internal_scope_guard lock;
if(restrict::window_manager.available(iwd) && iwd->together.caret) if(restrict::window_manager.available(iwd) && iwd->together.caret)
iwd->together.caret->position(x, y); iwd->together.caret->position(pos.x, pos.y);
} }
nana::point caret_pos(window wd) nana::point caret_pos(window wd)

View File

@ -298,10 +298,8 @@ namespace nana{ namespace drawerbase
nana::rectangle r(graph.size()); nana::rectangle r(graph.size());
r.pare_off(1); r.pare_off(1);
::nana::color from(colors::white); auto from = attr_.bgcolor.blend(colors::white, 0.2);
from.blend(attr_.bgcolor, 0.8); auto to = attr_.bgcolor.blend(colors::black, 0.95);
::nana::color to(colors::black);
to.blend(attr_.bgcolor, 0.05);
if (element_state::pressed == attr_.e_state) if (element_state::pressed == attr_.e_state)
{ {

View File

@ -78,7 +78,7 @@ namespace nana
if(ue.what == ue.none || (API::window_enabled(wd) == false)) if(ue.what == ue.none || (API::window_enabled(wd) == false))
{ //the mouse is out of the widget. { //the mouse is out of the widget.
style_.bgcolor.blend(color{ 0xa0, 0xc9, 0xf5 }, 0.9); style_.bgcolor = style_.bgcolor.blend(color{ 0xa0, 0xc9, 0xf5 }, 0.9);
} }
graph.rectangle(r, true, style_.bgcolor); graph.rectangle(r, true, style_.bgcolor);
} }

View File

@ -1693,10 +1693,11 @@ namespace nana
// the state of the struct does not effect on member funcions, therefore all data members are public. // the state of the struct does not effect on member funcions, therefore all data members are public.
struct essence_t struct essence_t
{ {
enum class state_t{normal, highlighted, pressed, grabed, floated}; enum class state_t{normal, highlighted, pressed, grabbed, floated};
enum class where_t{unknown = -1, header, lister, checker}; enum class where_t{unknown = -1, header, lister, checker};
nana::paint::graphics *graph{nullptr}; ::nana::listbox::scheme_type* scheme_ptr{nullptr};
::nana::paint::graphics *graph{nullptr};
bool auto_draw{true}; bool auto_draw{true};
bool checkable{false}; bool checkable{false};
bool if_image{false}; bool if_image{false};
@ -2207,9 +2208,14 @@ namespace nana
_m_draw(essence_->header.cont(), r); _m_draw(essence_->header.cont(), r);
const int y = r.y + r.height - 1; const int y = r.y + r.height - 1;
essence_->graph->line({ r.x, y }, { r.x + static_cast<int>(r.width), y }, { 0xDE, 0xDF, 0xE1 }); essence_->graph->line({ r.x, y }, { r.x + static_cast<int>(r.width), y }, _m_border_color());
} }
private: private:
::nana::color _m_border_color() const
{
return essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::black, 0.8);
}
size_type _m_target_strip(int x, const nana::rectangle& rect, size_type grab, bool& place_front) size_type _m_target_strip(int x, const nana::rectangle& rect, size_type grab, bool& place_front)
{ {
//convert x to header logic coordinate. //convert x to header logic coordinate.
@ -2268,32 +2274,36 @@ namespace nana
if(next_x > rect.x) if(next_x > rect.x)
{ {
_m_draw_item(graph, x, rect.y, height, txtop, txtcolor, i, (i.index == essence_->pointer_where.second ? state : essence_t::state_t::normal)); _m_draw_item(graph, x, rect.y, height, txtop, txtcolor, i, (i.index == essence_->pointer_where.second ? state : essence_t::state_t::normal));
graph.line({ next_x - 1, rect.y }, { next_x - 1, bottom_y }, { 0xDE, 0xDF, 0xE1 }); graph.line({ next_x - 1, rect.y }, { next_x - 1, bottom_y }, _m_border_color());
} }
if(next_x > rect.right())
break;
x = next_x; x = next_x;
if(x - rect.x > static_cast<int>(rect.width)) break;
} }
} }
if(x - rect.x < static_cast<int>(rect.width)) if(x - rect.x < static_cast<int>(rect.width))
graph.rectangle({ x, rect.y, rect.width - x + rect.x, height }, true, { 0xF1, 0xF2, 0xF4 }); graph.rectangle({ x, rect.y, rect.width - x + rect.x, height }, true, essence_->scheme_ptr->header_bgcolor);
} }
template<typename Item> template<typename Item>
void _m_draw_item(graph_reference graph, int x, int y, unsigned height, int txtop, const ::nana::color& fgcolor, const Item& item, essence_t::state_t state) void _m_draw_item(graph_reference graph, int x, int y, unsigned height, int txtop, const ::nana::color& fgcolor, const Item& item, essence_t::state_t state)
{ {
essence_->scheme_ptr->header_bgcolor.get_color();
::nana::color bgcolor; ::nana::color bgcolor;
typedef essence_t::state_t state_t; typedef essence_t::state_t state_t;
switch(state) switch(state)
{ {
case state_t::normal: bgcolor.from_rgb(0xf1, 0xf2, 0xf4); break; case state_t::normal: bgcolor = essence_->scheme_ptr->header_bgcolor.get_color(); break;
case state_t::highlighted: bgcolor = colors::white; break; case state_t::highlighted: bgcolor = essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::white, 0.5); break;
case state_t::pressed: case state_t::pressed:
case state_t::grabed: bgcolor.from_rgb(0x8B, 0xD6, 0xF6); break; case state_t::grabbed: bgcolor = essence_->scheme_ptr->header_grabbed.get_color(); break;
case state_t::floated: bgcolor.from_rgb(0xBA, 0xBB, 0xBC); break; case state_t::floated: bgcolor = essence_->scheme_ptr->header_floated.get_color(); break;
} }
graph.rectangle({ x, y, item.pixels, height }, true, bgcolor); graph.gradual_rectangle({ x, y, item.pixels, height }, bgcolor.blend(colors::white, 0.9), bgcolor.blend(colors::black, 0.9), true);
graph.string({ x + 5, txtop }, item.text, fgcolor); graph.string({ x + 5, txtop }, item.text, fgcolor);
if(item.index == essence_->lister.sort_index()) if(item.index == essence_->lister.sort_index())
@ -2467,7 +2477,7 @@ namespace nana
bgcolor = nana::color(0xD5, 0xEF, 0xFC); bgcolor = nana::color(0xD5, 0xEF, 0xFC);
if (state == essence_t::state_t::highlighted) if (state == essence_t::state_t::highlighted)
bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8); bgcolor = bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8);
auto graph = essence_->graph; auto graph = essence_->graph;
graph->set_color(bgcolor); graph->set_color(bgcolor);
@ -2501,8 +2511,8 @@ namespace nana
void _m_draw_item(const item_t& item, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, const std::vector<size_type>& seqs, nana::color bgcolor, nana::color fgcolor, essence_t::state_t state) const void _m_draw_item(const item_t& item, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, const std::vector<size_type>& seqs, nana::color bgcolor, nana::color fgcolor, essence_t::state_t state) const
{ {
if(item.flags.selected) if (item.flags.selected)
bgcolor = nana::color(0xD5, 0xEF, 0xFC); bgcolor = essence_->scheme_ptr->item_selected;
else if (!item.bgcolor.invisible()) else if (!item.bgcolor.invisible())
bgcolor = item.bgcolor; bgcolor = item.bgcolor;
@ -2511,7 +2521,12 @@ namespace nana
auto graph = essence_->graph; auto graph = essence_->graph;
if (essence_t::state_t::highlighted == state) if (essence_t::state_t::highlighted == state)
bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8); {
if (item.flags.selected)
bgcolor = bgcolor.blend(colors::black, 0.98);
else
bgcolor = bgcolor.blend(essence_->scheme_ptr->item_selected, 0.7);
}
unsigned show_w = width - essence_->scroll.offset_x; unsigned show_w = width - essence_->scroll.offset_x;
if(show_w >= r.width) show_w = r.width; if(show_w >= r.width) show_w = r.width;
@ -2541,7 +2556,7 @@ namespace nana
{ {
case essence_t::state_t::highlighted: case essence_t::state_t::highlighted:
estate = element_state::hovered; break; estate = element_state::hovered; break;
case essence_t::state_t::grabed: case essence_t::state_t::grabbed:
estate = element_state::pressed; break; estate = element_state::pressed; break;
default: break; default: break;
} }
@ -2573,10 +2588,10 @@ namespace nana
{ {
if (!item.flags.selected) if (!item.flags.selected)
{ {
auto cell_bgcolor = m_cell.custom_format->bgcolor;
if (essence_t::state_t::highlighted == state) if (essence_t::state_t::highlighted == state)
cell_bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8); graph->set_color(m_cell.custom_format->bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8));
graph->set_color(cell_bgcolor); else
graph->set_color(m_cell.custom_format->bgcolor);
graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true); graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true);
} }
@ -2688,6 +2703,7 @@ namespace nana
void trigger::attached(widget_reference widget, graph_reference graph) void trigger::attached(widget_reference widget, graph_reference graph)
{ {
essence_->scheme_ptr = static_cast<::nana::listbox::scheme_type*>(API::dev::get_scheme(widget));
essence_->graph = &graph; essence_->graph = &graph;
typeface_changed(graph); typeface_changed(graph);
@ -2719,7 +2735,7 @@ namespace nana
{ {
if(essence_->pointer_where.first == essence_t::where_t::header) if(essence_->pointer_where.first == essence_t::where_t::header)
{ {
essence_->ptr_state = essence_t::state_t::grabed; essence_->ptr_state = essence_t::state_t::grabbed;
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);
drawer_header_->grab(pos, true); drawer_header_->grab(pos, true);
@ -2728,7 +2744,7 @@ namespace nana
} }
} }
if(essence_->ptr_state == essence_t::state_t::grabed) if(essence_->ptr_state == essence_t::state_t::grabbed)
{ {
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);
@ -2756,7 +2772,7 @@ namespace nana
} }
} }
} }
if(set_spliter == false && essence_->ptr_state != essence_t::state_t::grabed) if(set_spliter == false && essence_->ptr_state != essence_t::state_t::grabbed)
{ {
if((drawer_header_->item_spliter() != npos) || (essence_->lister.wd_ptr()->cursor() == cursor::size_we)) if((drawer_header_->item_spliter() != npos) || (essence_->lister.wd_ptr()->cursor() == cursor::size_we))
{ {
@ -2783,7 +2799,7 @@ namespace nana
typedef essence_t::state_t state_t; typedef essence_t::state_t state_t;
if((essence_->pointer_where.first != essence_t::where_t::unknown) || (essence_->ptr_state != state_t::normal)) if((essence_->pointer_where.first != essence_t::where_t::unknown) || (essence_->ptr_state != state_t::normal))
{ {
if(essence_->ptr_state != state_t::grabed) if(essence_->ptr_state != state_t::grabbed)
{ {
essence_->pointer_where.first = essence_t::where_t::unknown; essence_->pointer_where.first = essence_t::where_t::unknown;
essence_->ptr_state = state_t::normal; essence_->ptr_state = state_t::normal;
@ -2892,7 +2908,7 @@ namespace nana
} }
} }
} }
else if(prev_state == state_t::grabed) else if(prev_state == state_t::grabbed)
{ {
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);

View File

@ -108,14 +108,12 @@ namespace nana
case item_renderer::state_highlight: case item_renderer::state_highlight:
border = colors::highlight; border = colors::highlight;
body.from_rgb(0xC0, 0xDD, 0xFC); body.from_rgb(0xC0, 0xDD, 0xFC);
corner = body; corner = body.blend(bground, 0.5);
corner.blend(bground, 0.5);
break; break;
case item_renderer::state_selected: case item_renderer::state_selected:
border = colors::dark_border; border = colors::dark_border;
body = colors::white; body = colors::white;
corner = body; corner = body.blend(bground, 0.5);
corner.blend(bground, 0.5);
break; break;
default: //Don't process other states. default: //Don't process other states.
return; return;
@ -541,8 +539,8 @@ namespace nana
{ {
int x = item_pos.x + item_s.width; int x = item_pos.x + item_s.width;
int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1; int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1;
graph_->line({ x, y1 }, { x, y2 }, ::nana::color(colors::gray_border).blend(bgcolor, 0.6)); graph_->line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.4));
graph_->line({ x + 1, y1 }, { x + 1, y2 }, ::nana::color(colors::button_face_shadow_end).blend(bgcolor, 0.5)); graph_->line({ x + 1, y1 }, { x + 1, y2 }, bgcolor.blend(colors::button_face_shadow_end, 0.5));
} }
//Draw text, the text is transformed from orignal for hotkey character //Draw text, the text is transformed from orignal for hotkey character

View File

@ -208,7 +208,8 @@ namespace nana
graph.rectangle(r, false, clr); graph.rectangle(r, false, clr);
graph.set_color(clr.blend(colors::white, 0.5)); clr = clr.blend(colors::white, 0.5);
graph.set_color(clr);
r.pare_off(2); r.pare_off(2);

View File

@ -1528,7 +1528,7 @@ namespace nana{ namespace widgets
API::caret_visible(window_, visible); API::caret_visible(window_, visible);
if(visible) if(visible)
API::caret_pos(window_, pos.x, pos.y); API::caret_pos(window_, pos);
} }
} }

View File

@ -40,9 +40,10 @@ namespace nana
if(bgcolor_ != bgcolor) if(bgcolor_ != bgcolor)
{ {
bgcolor_ = bgcolor; bgcolor_ = bgcolor;
dark_bgcolor_ = ::nana::color{ colors::black }.blend(bgcolor, 0.1);
blcolor_ = ::nana::color{ colors::black }.blend(bgcolor, 0.5); dark_bgcolor_ = bgcolor.blend(colors::black, 0.9);
ilcolor_ = ::nana::color{ colors::white }.blend(bgcolor, 0.1); blcolor_ = bgcolor.blend(colors::black, 0.5);
ilcolor_ = bgcolor.blend(colors::white, 0.9);
} }
graph.rectangle(true, bgcolor); graph.rectangle(true, bgcolor);
@ -65,8 +66,8 @@ namespace nana
else else
{ {
bgcolor = m.bgcolor; bgcolor = m.bgcolor;
blcolor = color{ colors::black }.blend(m.bgcolor, 0.5); blcolor = m.bgcolor.blend(colors::black, 0.5);
dark_bgcolor = color{ colors::black }.blend(m.bgcolor, 0.1); dark_bgcolor = m.bgcolor.blend(colors::black, 0.9);
} }
auto round_r = r; auto round_r = r;
@ -81,12 +82,12 @@ namespace nana
if (m.bgcolor.invisible()) if (m.bgcolor.invisible())
beg = ilcolor_; beg = ilcolor_;
else else
beg = color{ m.bgcolor }.blend(colors::white, 0.5); beg = m.bgcolor.blend(colors::white, 0.5);
end = bgcolor; end = bgcolor;
} }
if (sta == item_renderer::highlight) if (sta == item_renderer::highlight)
beg.blend(colors::white, 0.5); beg = beg.blend(colors::white, 0.5);
graph.gradual_rectangle(round_r.pare_off(2), beg, end, true); graph.gradual_rectangle(round_r.pare_off(2), beg, end, true);
} }
@ -131,9 +132,9 @@ namespace nana
::nana::color rect_clr{0x9d, 0xa3, 0xab}; ::nana::color rect_clr{0x9d, 0xa3, 0xab};
graph.round_rectangle(r, 1, 1, rect_clr, false, {}); graph.round_rectangle(r, 1, 1, rect_clr, false, {});
nana::rectangle draw_r(r); nana::rectangle draw_r(r);
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.8)); graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.8));
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.4)); graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.4));
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.2)); graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.2));
} }
else if (!active) else if (!active)
clr = ::nana::color{ 0x92, 0x99, 0xA4 }; clr = ::nana::color{ 0x92, 0x99, 0xA4 };

View File

@ -395,7 +395,7 @@ namespace nana
void drawer::_m_draw_background(const ::nana::color& clr) void drawer::_m_draw_background(const ::nana::color& clr)
{ {
graph_->gradual_rectangle(graph_->size(), ::nana::color(colors::white).blend(clr, 0.1), ::nana::color(colors::black).blend(clr, 0.05), true); graph_->gradual_rectangle(graph_->size(), clr.blend(colors::white, 0.9), clr.blend(colors::black, 0.95), true);
} }
void drawer::_m_draw() void drawer::_m_draw()

View File

@ -302,8 +302,7 @@ namespace gadget
ps[11].x = x + gap; ps[11].x = x + gap;
ps[11].y = y + gap; ps[11].y = y + gap;
::nana::color darker(0, 0, 0); auto darker = color.blend(colors::black, true);
darker.blend(color, true);
graph.set_color(darker); graph.set_color(darker);
for (int i = 0; i < 11; ++i) for (int i = 0; i < 11; ++i)