diff --git a/include/nana/gui/detail/basic_window.hpp b/include/nana/gui/detail/basic_window.hpp index 6c66b709..6d44a936 100644 --- a/include/nana/gui/detail/basic_window.hpp +++ b/include/nana/gui/detail/basic_window.hpp @@ -16,7 +16,7 @@ #include #include "drawer.hpp" #include "events_holder.hpp" -#include "widget_colors.hpp" +#include "widget_geometrics.hpp" #include "widget_notifier_interface.hpp" #include #include @@ -180,7 +180,7 @@ namespace detail std::shared_ptr events_ptr; }together; - widget_colors* scheme{ nullptr }; + widget_geometrics* scheme{ nullptr }; struct { diff --git a/include/nana/gui/detail/bedrock.hpp b/include/nana/gui/detail/bedrock.hpp index e6d2e0e7..32a812ad 100644 --- a/include/nana/gui/detail/bedrock.hpp +++ b/include/nana/gui/detail/bedrock.hpp @@ -82,8 +82,8 @@ namespace detail void define_state_cursor(core_window_t*, nana::cursor, thread_context*); void undefine_state_cursor(core_window_t*, thread_context*); - widget_colors& get_scheme_template(scheme_factory_interface&&); - widget_colors* make_scheme(scheme_factory_interface&&); + widget_geometrics& get_scheme_template(scheme_factory_interface&&); + widget_geometrics* make_scheme(scheme_factory_interface&&); events_operation& evt_operation(); window_manager& wd_manager(); diff --git a/include/nana/gui/detail/color_schemes.hpp b/include/nana/gui/detail/color_schemes.hpp index 2d177c17..79e09775 100644 --- a/include/nana/gui/detail/color_schemes.hpp +++ b/include/nana/gui/detail/color_schemes.hpp @@ -13,7 +13,7 @@ #ifndef NANA_DETAIL_COLOR_SCHEMES_HPP #define NANA_DETAIL_COLOR_SCHEMES_HPP -#include "widget_colors.hpp" +#include "widget_geometrics.hpp" namespace nana { @@ -26,8 +26,8 @@ namespace nana virtual ~scheme_factory_interface() = default; virtual factory_identifier* get_id() const = 0; - virtual widget_colors* create() = 0; - virtual widget_colors* create(widget_colors&) = 0; + virtual widget_geometrics* create() = 0; + virtual widget_geometrics* create(widget_geometrics&) = 0; }; @@ -41,12 +41,12 @@ namespace nana return &fid_; } - widget_colors* create() override + widget_geometrics* create() override { return (new Scheme); } - widget_colors* create(widget_colors& other) override + widget_geometrics* create(widget_geometrics& other) override { return (new Scheme(static_cast(other))); } @@ -65,7 +65,7 @@ namespace nana color_schemes& operator=(const color_schemes&) = delete; color_schemes& operator=(color_schemes&&) = delete; public: - using scheme = widget_colors; + using scheme = widget_geometrics; color_schemes(); ~color_schemes(); diff --git a/include/nana/gui/detail/widget_colors.hpp b/include/nana/gui/detail/widget_colors.hpp deleted file mode 100644 index d4d81e1a..00000000 --- a/include/nana/gui/detail/widget_colors.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Color Schemes -* Nana C++ Library(http://www.nanapro.org) -* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) -* -* Distributed under the Boost Software License, Version 1.0. -* (See accompanying file LICENSE_1_0.txt or copy at -* http://www.boost.org/LICENSE_1_0.txt) -* -* @file: nana/gui/widget_colors.hpp -* @description: -*/ -#ifndef NANA_DETAIL_WIDGET_COLORS_HPP -#define NANA_DETAIL_WIDGET_COLORS_HPP - -#include -#include -namespace nana -{ - class color_proxy - { - public: - color_proxy(const color_proxy&); - color_proxy(color_rgb); - color_proxy(colors); - color_proxy& operator=(const color_proxy&); - color_proxy& operator=(const ::nana::color&); - color_proxy& operator=(color_rgb); - color_proxy& operator=(colors); - color get_color() const; - operator color() const; - private: - std::shared_ptr color_; - };//end namespace color_proxy - - struct widget_colors - { - virtual ~widget_colors() = default; - - color_proxy activated{ static_cast(0x60C8FD) }; - color_proxy background{colors::button_face}; - color_proxy foreground{colors::black}; - }; -} - -#endif \ No newline at end of file diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index c89508b4..23d5aee8 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -38,7 +38,7 @@ namespace nana struct widget_traits { using event_type = ::nana::general_events; - using scheme_type = ::nana::widget_colors; + using scheme_type = ::nana::widget_geometrics; }; } @@ -46,7 +46,7 @@ namespace API { namespace detail { - ::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_interface&&); + ::nana::widget_geometrics* make_scheme(::nana::detail::scheme_factory_interface&&); } void effects_edge_nimbus(window, effects::edge_nimbus); @@ -70,8 +70,8 @@ namespace API return std::unique_ptr{static_cast(API::detail::make_scheme(::nana::detail::scheme_factory()))}; } - void set_scheme(window, widget_colors*); - widget_colors* get_scheme(window); + void set_scheme(window, widget_geometrics*); + widget_geometrics* get_scheme(window); void attach_drawer(widget&, drawer_trigger&); ::nana::detail::native_string_type window_caption(window) throw(); @@ -250,7 +250,7 @@ namespace API if (nullptr == wdg_colors) throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle."); - if (std::is_same<::nana::widget_colors, scheme_type>::value) + if (std::is_same<::nana::widget_geometrics, scheme_type>::value) return *static_cast(wdg_colors); auto * comp_wdg_colors = dynamic_cast(wdg_colors); diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 66dd726e..a9e7f423 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -520,7 +520,7 @@ namespace nana }; struct scheme - : public widget_colors + : public widget_geometrics { color_proxy header_bgcolor{static_cast(0xf1f2f4)}; color_proxy header_grabbed{ static_cast(0x8BD6F6)}; diff --git a/include/nana/gui/widgets/skeletons/text_editor_part.hpp b/include/nana/gui/widgets/skeletons/text_editor_part.hpp index 8cf1c389..71d8f525 100644 --- a/include/nana/gui/widgets/skeletons/text_editor_part.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor_part.hpp @@ -2,7 +2,7 @@ #ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP #define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP -#include "../../detail/widget_colors.hpp" +#include "../../detail/widget_geometrics.hpp" #include namespace nana @@ -24,7 +24,7 @@ namespace nana class text_editor; struct text_editor_scheme - : public ::nana::widget_colors + : public ::nana::widget_geometrics { color_proxy selection{static_cast(0x3399FF)}; color_proxy selection_text{colors::white}; diff --git a/include/nana/gui/widgets/slider.hpp b/include/nana/gui/widgets/slider.hpp index 911accbd..fb15bc34 100644 --- a/include/nana/gui/widgets/slider.hpp +++ b/include/nana/gui/widgets/slider.hpp @@ -33,6 +33,23 @@ namespace nana { namespace slider { + + struct scheme_impl + : public widget_geometrics + { + /// Colors + color_proxy color_adorn{ static_cast(0x3da3ce) }; + color_proxy color_bar{ static_cast(0x878787) }; + color_proxy color_slider{ static_cast(0x606060) }; + color_proxy color_slider_highlighted{ static_cast(0x2d93be) }; + color_proxy color_vernier{ colors::red }; + color_proxy color_vernier_text{ colors::white }; + + /// Geometrical parameters + unsigned vernier_text_margin{ 8 }; + + }; + struct slider_events : public general_events { @@ -49,6 +66,7 @@ namespace nana { public: using graph_reference = ::nana::paint::graphics&; + using scheme = scheme_impl; struct data_bar { @@ -86,11 +104,11 @@ namespace nana virtual ~renderer_interface() = default; - virtual void background(window, graph_reference, bool isglass) = 0; - virtual void adorn(window, graph_reference, const data_adorn&) = 0; - virtual void vernier(window, graph_reference, const data_vernier&) = 0; - virtual void bar(window, graph_reference, const data_bar&) = 0; - virtual void slider(window, graph_reference, mouse_action, const data_slider&) = 0; + virtual void background(window, graph_reference, bool transparent, const scheme&) = 0; + virtual void adorn(window, graph_reference, const data_adorn&, const scheme&) = 0; + virtual void vernier(window, graph_reference, const data_vernier&, const scheme&) = 0; + virtual void bar(window, graph_reference, const data_bar&, const scheme&) = 0; + virtual void slider(window, graph_reference, mouse_action, const data_slider&, const scheme&) = 0; }; class trigger @@ -118,7 +136,7 @@ namespace nana /// A slider widget wich the user can drag for tracking \todo add scheme ? class slider - : public widget_object + : public widget_object { public: using renderer_interface = drawerbase::slider::renderer_interface; ///< The interface for customized renderer. diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index f2515e00..ae70b77b 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -160,7 +160,7 @@ namespace nana } /// Base class of all the classes defined as a widget window. Defaultly a widget_tag - template + template class widget_object: public detail::widget_base { protected: diff --git a/source/gui/detail/bedrock_pi.cpp b/source/gui/detail/bedrock_pi.cpp index e3fb1c6b..087fed6d 100644 --- a/source/gui/detail/bedrock_pi.cpp +++ b/source/gui/detail/bedrock_pi.cpp @@ -353,12 +353,12 @@ namespace nana return pi_data_->shortkey_occurred; } - widget_colors& bedrock::get_scheme_template(scheme_factory_interface&& factory) + widget_geometrics& bedrock::get_scheme_template(scheme_factory_interface&& factory) { return pi_data_->scheme.scheme_template(std::move(factory)); } - widget_colors* bedrock::make_scheme(scheme_factory_interface&& factory) + widget_geometrics* bedrock::make_scheme(scheme_factory_interface&& factory) { return pi_data_->scheme.create(std::move(factory)); } diff --git a/source/gui/detail/color_schemes.cpp b/source/gui/detail/color_schemes.cpp index 6cfa41d4..d9fca610 100644 --- a/source/gui/detail/color_schemes.cpp +++ b/source/gui/detail/color_schemes.cpp @@ -93,7 +93,7 @@ namespace nana return *tmpl_scheme.get(); } - widget_colors* color_schemes::create(scheme_factory_interface&& factory) + widget_geometrics* color_schemes::create(scheme_factory_interface&& factory) { return factory.create(scheme_template(std::move(factory))); } diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 133b8326..ffcec9a0 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -55,7 +55,7 @@ namespace API namespace detail { - ::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_interface&& factory) + ::nana::widget_geometrics* make_scheme(::nana::detail::scheme_factory_interface&& factory) { return restrict::bedrock.make_scheme(static_cast<::nana::detail::scheme_factory_interface&&>(factory)); } @@ -195,15 +195,15 @@ namespace API } - void set_scheme(window wd, widget_colors* wdg_colors) + void set_scheme(window wd, widget_geometrics* wdg_geom) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) - iwd->scheme = wdg_colors; + iwd->scheme = wdg_geom; } - widget_colors* get_scheme(window wd) + widget_geometrics* get_scheme(window wd) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index 28f6dcd5..f2b38b75 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -17,13 +17,13 @@ namespace nana : public renderer_interface { private: - void background(window wd, graph_reference graph, bool isglass) override + void background(window wd, graph_reference graph, bool transparent, const scheme& schm) override { - if(!isglass) - graph.rectangle(true, API::bgcolor(wd)); + if (!transparent) + graph.rectangle(true, schm.background); } - void bar(window, graph_reference graph, const data_bar& data) override + void bar(window, graph_reference graph, const data_bar& data, const scheme& schm) override { auto area = data.area; @@ -38,10 +38,10 @@ namespace nana area.height = 4; } - graph.rectangle(area, false, static_cast(0x878787)); + graph.rectangle(area, false, schm.color_bar); } - void adorn(window, graph_reference graph, const data_adorn& data) override + void adorn(window, graph_reference graph, const data_adorn& data, const scheme& schm) override { rectangle area{ data.bound.x, data.fixedpos + static_cast(data.block / 2) - 1, @@ -51,19 +51,19 @@ namespace nana if (data.vert) area.shift(); - graph.rectangle(area, true, static_cast(0x3DA3CE)); + graph.rectangle(area, true, schm.color_adorn); } - void vernier(window, graph_reference graph, const data_vernier& data) override + void vernier(window, graph_reference graph, const data_vernier& data, const scheme& schm) override { if (data.vert) - _m_draw_vernier_vert(graph, data); + _m_draw_vernier_vert(graph, data, schm); else - _m_draw_vernier_horz(graph, data); + _m_draw_vernier_horz(graph, data, schm); } - void slider(window, graph_reference graph, mouse_action mouse_act, const data_slider& data) override + void slider(window, graph_reference graph, mouse_action mouse_act, const data_slider& data, const scheme& schm) override { nana::rectangle area{ graph.size() }; @@ -78,9 +78,9 @@ namespace nana area.width = data.weight; } - color rgb{ static_cast(0x606060) }; + color rgb = schm.color_slider; if (mouse_action::normal != mouse_act) - rgb = static_cast(0x2d93be); + rgb = schm.color_slider_highlighted; graph.frame_rectangle(area, rgb + static_cast(0x0d0d0d), 1); graph.rectangle(area.pare_off(1), true, rgb); @@ -89,7 +89,7 @@ namespace nana graph.rectangle(area, true, rgb + static_cast(0x101010)); } private: - void _m_draw_vernier_horz(graph_reference graph, const data_vernier& data) + void _m_draw_vernier_horz(graph_reference graph, const data_vernier& data, const scheme& schm) { const unsigned arrow_weight = 5; @@ -107,12 +107,10 @@ namespace nana const size arrow_size{ arrow_weight, 9 }; - - const unsigned text_margin = 8; - const auto label_size = graph.text_extent_size(data.text) + size{ text_margin * 2, 0 }; + const auto label_size = graph.text_extent_size(data.text) + size{ schm.vernier_text_margin * 2, 0 }; paint::graphics graph_vern{ label_size }; - graph_vern.rectangle(true, colors::red); + graph_vern.rectangle(true, schm.color_vernier); int arrow_pos; @@ -132,10 +130,11 @@ namespace nana graph_vern.blend(rectangle{ label_size }, graph, label_pos, 0.5); + unsigned arrow_color = 0x7F | schm.color_vernier.get_color().argb().value; for (auto & color : arrow_pxbuf) { if (color == 0x7F) - color = 0x7FFF0000; + color = arrow_color; } if (label_pos.x > data.position) @@ -155,12 +154,11 @@ namespace nana pxbuf.paste(rectangle{ arrow_size }, graph.handle(), { arrow_pos, label_pos.y + static_cast(label_size.height - arrow_size.height) / 2 }); - label_pos.x += text_margin; - graph.palette(true, colors::white); - graph.string(label_pos, data.text); + label_pos.x += static_cast(schm.vernier_text_margin); + graph.string(label_pos, data.text, schm.color_vernier_text); } - void _m_draw_vernier_vert(graph_reference graph, const data_vernier& data) + void _m_draw_vernier_vert(graph_reference graph, const data_vernier& data, const scheme& schm) { const unsigned arrow_weight = 5; @@ -174,15 +172,13 @@ namespace nana const size arrow_size{ 9, arrow_weight}; - - const unsigned text_margin = 8; - const size label_size = (graph.text_extent_size(data.text) + size{ text_margin * 2, 0 }).shift(); + const size label_size = (graph.text_extent_size(data.text) + size{ schm.vernier_text_margin * 2, 0 }).shift(); paint::graphics graph_vern{ label_size }; paint::graphics graph_horz{ size(label_size).shift() }; - graph_horz.rectangle(true, colors::red); - graph_horz.string({static_cast(text_margin), static_cast(graph_horz.height() - label_size.width) / 2}, data.text, colors::white); + graph_horz.rectangle(true, schm.color_vernier); + graph_horz.string({ static_cast(schm.vernier_text_margin), static_cast(graph_horz.height() - label_size.width) / 2 }, data.text, schm.color_vernier_text); paint::pixel_buffer{ graph_horz.handle(), 0, graph_horz.height() }.rotate(90, colors::white).paste(graph_vern.handle(), {}); @@ -216,14 +212,13 @@ namespace nana graph_vern.blend(rectangle{ label_size }, graph, label_pos, 0.5); + unsigned arrow_color = 0x7F | schm.color_vernier.get_color().argb().value; for (auto & color : arrow_pxbuf) { if (color == 0x7F) - color = 0x7FFF0000; + color = arrow_color; } - /* - */ paint::pixel_buffer pxbuf{ arrow_size.width, arrow_size.height }; pxbuf.alpha_channel(true); @@ -231,11 +226,7 @@ namespace nana pxbuf.paste(rectangle{ arrow_size }, graph.handle(), { label_pos.x + static_cast(label_size.width - arrow_size.width) / 2, arrow_pos }); - label_pos.y += text_margin; - /* - graph.palette(true, colors::white); - graph.string(label_pos, data.text); - */ + label_pos.y += static_cast(schm.vernier_text_margin); } }; @@ -308,7 +299,7 @@ namespace nana { if(!graph.size().empty()) { - proto_.renderer->background(other_.wd, graph, (bground_mode::basic == API::effects_bground_mode(other_.wd))); + proto_.renderer->background(other_.wd, graph, (bground_mode::basic == API::effects_bground_mode(other_.wd)), other_.widget->scheme()); _m_draw_elements(graph); } } @@ -634,6 +625,8 @@ namespace nana void _m_draw_elements(graph_reference graph) { + auto & scheme = other_.widget->scheme(); + renderer_interface::data_bar bar; bar.vert = attr_.slider.vert; @@ -643,7 +636,7 @@ namespace nana if (bar.area.empty()) return; - proto_.renderer->bar(other_.wd, graph, bar); + proto_.renderer->bar(other_.wd, graph, bar, scheme); //adorn renderer_interface::data_adorn adorn; @@ -664,10 +657,10 @@ namespace nana adorn.block = (bar.vert ? bar.area.width : bar.area.height) - attr_.slider.border_weight * 2; adorn.fixedpos = static_cast((bar.vert ? bar.area.x : bar.area.y) + attr_.slider.border_weight); - proto_.renderer->adorn(other_.wd, graph, adorn); + proto_.renderer->adorn(other_.wd, graph, adorn, scheme); //Draw slider - proto_.renderer->slider(other_.wd, graph, slider_state_.mouse_state, attr_.slider); + proto_.renderer->slider(other_.wd, graph, slider_state_.mouse_state, attr_.slider, scheme); //adorn textbox if (proto_.vernier && attr_.is_draw_adorn) @@ -685,7 +678,7 @@ namespace nana vern.position += static_cast(attr_.adorn_pos); vern.end_position = adorn.bound.y; - proto_.renderer->vernier(other_.wd, graph, vern); + proto_.renderer->vernier(other_.wd, graph, vern, scheme); } } }