add scheme to slider

rename widget_colors to widget_geometrics
This commit is contained in:
Jinhao
2016-05-22 18:00:05 +08:00
parent c775ef9f24
commit 50b982eca7
13 changed files with 84 additions and 119 deletions

View File

@@ -16,7 +16,7 @@
#include <nana/push_ignore_diagnostic>
#include "drawer.hpp"
#include "events_holder.hpp"
#include "widget_colors.hpp"
#include "widget_geometrics.hpp"
#include "widget_notifier_interface.hpp"
#include <nana/basic_types.hpp>
#include <nana/system/platform.hpp>
@@ -180,7 +180,7 @@ namespace detail
std::shared_ptr<general_events> events_ptr;
}together;
widget_colors* scheme{ nullptr };
widget_geometrics* scheme{ nullptr };
struct
{

View File

@@ -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();

View File

@@ -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<Scheme&>(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();

View File

@@ -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 <nana/gui/basis.hpp>
#include <memory>
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> color_;
};//end namespace color_proxy
struct widget_colors
{
virtual ~widget_colors() = default;
color_proxy activated{ static_cast<color_rgb>(0x60C8FD) };
color_proxy background{colors::button_face};
color_proxy foreground{colors::black};
};
}
#endif

View File

@@ -38,7 +38,7 @@ namespace nana
struct widget_traits<widget>
{
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<Scheme>{static_cast<Scheme*>(API::detail::make_scheme(::nana::detail::scheme_factory<Scheme>()))};
}
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<scheme_type*>(wdg_colors);
auto * comp_wdg_colors = dynamic_cast<scheme_type*>(wdg_colors);

View File

@@ -520,7 +520,7 @@ namespace nana
};
struct scheme
: public widget_colors
: public widget_geometrics
{
color_proxy header_bgcolor{static_cast<color_rgb>(0xf1f2f4)};
color_proxy header_grabbed{ static_cast<color_rgb>(0x8BD6F6)};

View File

@@ -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 <vector>
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<color_rgb>(0x3399FF)};
color_proxy selection_text{colors::white};

View File

@@ -33,6 +33,23 @@ namespace nana
{
namespace slider
{
struct scheme_impl
: public widget_geometrics
{
/// Colors
color_proxy color_adorn{ static_cast<color_rgb>(0x3da3ce) };
color_proxy color_bar{ static_cast<color_rgb>(0x878787) };
color_proxy color_slider{ static_cast<color_rgb>(0x606060) };
color_proxy color_slider_highlighted{ static_cast<color_rgb>(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<category::widget_tag, drawerbase::slider::trigger, drawerbase::slider::slider_events>
: public widget_object<category::widget_tag, drawerbase::slider::trigger, drawerbase::slider::slider_events, drawerbase::slider::scheme_impl>
{
public:
using renderer_interface = drawerbase::slider::renderer_interface; ///< The interface for customized renderer.

View File

@@ -160,7 +160,7 @@ namespace nana
}
/// Base class of all the classes defined as a widget window. Defaultly a widget_tag
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_colors>
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_geometrics>
class widget_object: public detail::widget_base
{
protected: