Merge branch 'hotfix-1.6.2' into develop-1.7
This commit is contained in:
commit
1c03cd500d
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Widget Geometrics
|
* Widget Geometrics
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 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
|
||||||
@ -22,12 +22,17 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
color_proxy(const color_proxy&);
|
color_proxy(const color_proxy&);
|
||||||
color_proxy(color_rgb);
|
color_proxy(color_rgb);
|
||||||
|
color_proxy(color_argb);
|
||||||
|
color_proxy(color_rgba);
|
||||||
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=(color_rgb);
|
||||||
|
color_proxy& operator=(color_argb);
|
||||||
|
color_proxy& operator=(color_rgba);
|
||||||
color_proxy& operator=(colors);
|
color_proxy& operator=(colors);
|
||||||
color get_color() const;
|
color get_color() const;
|
||||||
|
color get(const color& default_color) const;
|
||||||
operator color() const;
|
operator color() const;
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<color> color_;
|
std::shared_ptr<color> color_;
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* A Button Implementation
|
* A Button Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2017 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
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/widgets/button.hpp
|
* @file: nana/gui/widgets/button.hpp
|
||||||
|
* @contributor
|
||||||
|
* besh81(pr#361)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_BUTTON_HPP
|
#ifndef NANA_GUI_WIDGET_BUTTON_HPP
|
||||||
@ -90,7 +92,12 @@ namespace nana{
|
|||||||
button(window, const char* caption, bool visible = true);
|
button(window, const char* caption, bool visible = true);
|
||||||
button(window, const nana::rectangle& = rectangle(), bool visible = true);
|
button(window, const nana::rectangle& = rectangle(), bool visible = true);
|
||||||
|
|
||||||
button& icon(const nana::paint::image&);
|
/// Shows an icon in front of caption
|
||||||
|
/**
|
||||||
|
* @param image Icon to be shown. If image is empty, the current icon is erased from the button.
|
||||||
|
* @return the reference of *this.
|
||||||
|
*/
|
||||||
|
button& icon(const nana::paint::image& image);
|
||||||
button& enable_pushed(bool);
|
button& enable_pushed(bool);
|
||||||
bool pushed() const;
|
bool pushed() const;
|
||||||
button& pushed(bool);
|
button& pushed(bool);
|
||||||
|
|||||||
@ -37,6 +37,13 @@ namespace drawerbase
|
|||||||
{
|
{
|
||||||
namespace checkbox
|
namespace checkbox
|
||||||
{
|
{
|
||||||
|
struct scheme
|
||||||
|
: public widget_geometrics
|
||||||
|
{
|
||||||
|
color_proxy square_bgcolor{ static_cast<color_argb>(0x0) };
|
||||||
|
color_proxy square_border_color{ colors::black };
|
||||||
|
};
|
||||||
|
|
||||||
struct events_type
|
struct events_type
|
||||||
: public general_events
|
: public general_events
|
||||||
{
|
{
|
||||||
@ -67,7 +74,7 @@ namespace drawerbase
|
|||||||
|
|
||||||
|
|
||||||
class checkbox
|
class checkbox
|
||||||
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type>
|
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type, drawerbase::checkbox::scheme>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
checkbox();
|
checkbox();
|
||||||
|
|||||||
@ -63,7 +63,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
if (child->owner == this)
|
if (child == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
child = child->owner;
|
child = child->owner;
|
||||||
|
|||||||
@ -67,30 +67,30 @@ namespace nana
|
|||||||
class drawer
|
class drawer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct states
|
enum class states
|
||||||
{
|
{
|
||||||
enum{ none, highlight, actived, selected };
|
none, highlight, actived, selected
|
||||||
};
|
};
|
||||||
|
|
||||||
using graph_reference = paint::graphics&;
|
using graph_reference = paint::graphics&;
|
||||||
const static unsigned fixedsize = 16; // make it part of a new "metric" in the widget_scheme
|
const static unsigned fixedsize = 16; // make it part of a new "metric" in the widget_scheme
|
||||||
|
|
||||||
drawer(metrics_type& m);
|
drawer(bool vert);
|
||||||
void set_vertical(bool);
|
|
||||||
buttons what(graph_reference, const point&);
|
buttons what(graph_reference, const point&);
|
||||||
void scroll_delta_pos(graph_reference, int);
|
void scroll_delta_pos(graph_reference, int);
|
||||||
void auto_scroll();
|
void auto_scroll();
|
||||||
void draw(graph_reference, buttons);
|
void draw(graph_reference);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _m_check() const;
|
bool _m_check() const;
|
||||||
void _m_adjust_scroll(graph_reference);
|
void _m_adjust_scroll(graph_reference);
|
||||||
void _m_background(graph_reference);
|
void _m_background(graph_reference);
|
||||||
void _m_button_frame(graph_reference, ::nana::rectangle, int state);
|
void _m_button_frame(graph_reference, ::nana::rectangle, states state);
|
||||||
void _m_draw_scroll(graph_reference, int state);
|
void _m_draw_scroll(graph_reference, states state);
|
||||||
void _m_draw_button(graph_reference, ::nana::rectangle, buttons what, int state);
|
void _m_draw_button(graph_reference, ::nana::rectangle, buttons what, states state);
|
||||||
private:
|
public:
|
||||||
metrics_type &metrics_;
|
metrics_type metrics;
|
||||||
bool vertical_;
|
bool const vert;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool Vertical>
|
template<bool Vertical>
|
||||||
@ -101,35 +101,34 @@ namespace nana
|
|||||||
typedef metrics_type::size_type size_type;
|
typedef metrics_type::size_type size_type;
|
||||||
|
|
||||||
trigger()
|
trigger()
|
||||||
: graph_(nullptr), drawer_(metrics_)
|
: graph_(nullptr), drawer_(Vertical)
|
||||||
{
|
{
|
||||||
drawer_.set_vertical(Vertical);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const metrics_type& metrics() const
|
const metrics_type& metrics() const
|
||||||
{
|
{
|
||||||
return metrics_;
|
return drawer_.metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
void peak(size_type s)
|
void peak(size_type s)
|
||||||
{
|
{
|
||||||
if (graph_ && (metrics_.peak != s))
|
if (graph_ && (drawer_.metrics.peak != s))
|
||||||
{
|
{
|
||||||
metrics_.peak = s;
|
drawer_.metrics.peak = s;
|
||||||
API::refresh_window(widget_->handle());
|
API::refresh_window(widget_->handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void value(size_type s)
|
void value(size_type s)
|
||||||
{
|
{
|
||||||
if (metrics_.range > metrics_.peak)
|
if (drawer_.metrics.range > drawer_.metrics.peak)
|
||||||
s = 0;
|
s = 0;
|
||||||
else if (s + metrics_.range > metrics_.peak)
|
else if (s + drawer_.metrics.range > drawer_.metrics.peak)
|
||||||
s = metrics_.peak - metrics_.range;
|
s = drawer_.metrics.peak - drawer_.metrics.range;
|
||||||
|
|
||||||
if (graph_ && (metrics_.value != s))
|
if (graph_ && (drawer_.metrics.value != s))
|
||||||
{
|
{
|
||||||
metrics_.value = s;
|
drawer_.metrics.value = s;
|
||||||
_m_emit_value_changed();
|
_m_emit_value_changed();
|
||||||
|
|
||||||
API::refresh_window(*widget_);
|
API::refresh_window(*widget_);
|
||||||
@ -138,16 +137,16 @@ namespace nana
|
|||||||
|
|
||||||
void range(size_type s)
|
void range(size_type s)
|
||||||
{
|
{
|
||||||
if (graph_ && (metrics_.range != s))
|
if (graph_ && (drawer_.metrics.range != s))
|
||||||
{
|
{
|
||||||
metrics_.range = s;
|
drawer_.metrics.range = s;
|
||||||
API::refresh_window(widget_->handle());
|
API::refresh_window(widget_->handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void step(size_type s)
|
void step(size_type s)
|
||||||
{
|
{
|
||||||
metrics_.step = (s ? s : 1);
|
drawer_.metrics.step = (s ? s : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool make_step(bool forward, unsigned multiple)
|
bool make_step(bool forward, unsigned multiple)
|
||||||
@ -155,12 +154,12 @@ namespace nana
|
|||||||
if (!graph_)
|
if (!graph_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_type step = (multiple > 1 ? metrics_.step * multiple : metrics_.step);
|
size_type step = (multiple > 1 ? drawer_.metrics.step * multiple : drawer_.metrics.step);
|
||||||
size_type value = metrics_.value;
|
size_type value = drawer_.metrics.value;
|
||||||
if (forward)
|
if (forward)
|
||||||
{
|
{
|
||||||
size_type maxv = metrics_.peak - metrics_.range;
|
size_type maxv = drawer_.metrics.peak - drawer_.metrics.range;
|
||||||
if (metrics_.peak > metrics_.range && value < maxv)
|
if (drawer_.metrics.peak > drawer_.metrics.range && value < maxv)
|
||||||
{
|
{
|
||||||
if (maxv - value >= step)
|
if (maxv - value >= step)
|
||||||
value += step;
|
value += step;
|
||||||
@ -175,8 +174,8 @@ namespace nana
|
|||||||
else
|
else
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
size_type cmpvalue = metrics_.value;
|
size_type cmpvalue = drawer_.metrics.value;
|
||||||
metrics_.value = value;
|
drawer_.metrics.value = value;
|
||||||
if (value != cmpvalue)
|
if (value != cmpvalue)
|
||||||
{
|
{
|
||||||
_m_emit_value_changed();
|
_m_emit_value_changed();
|
||||||
@ -191,6 +190,9 @@ namespace nana
|
|||||||
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
||||||
widget.caption("nana scroll");
|
widget.caption("nana scroll");
|
||||||
|
|
||||||
|
//scroll doesn't want the keyboard focus.
|
||||||
|
API::take_active(widget, false, widget.parent());
|
||||||
|
|
||||||
timer_.stop();
|
timer_.stop();
|
||||||
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
||||||
}
|
}
|
||||||
@ -202,47 +204,42 @@ namespace nana
|
|||||||
|
|
||||||
void refresh(graph_reference graph) override
|
void refresh(graph_reference graph) override
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resized(graph_reference graph, const ::nana::arg_resized&) override
|
void resized(graph_reference graph, const ::nana::arg_resized&) override
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_enter(graph_reference graph, const ::nana::arg_mouse& arg) override
|
void mouse_enter(graph_reference graph, const ::nana::arg_mouse& arg) override
|
||||||
{
|
{
|
||||||
metrics_.what = drawer_.what(graph, arg.pos);
|
drawer_.metrics.what = drawer_.what(graph, arg.pos);
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
|
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
|
||||||
{
|
{
|
||||||
bool redraw = false;
|
if (drawer_.metrics.pressed && (drawer_.metrics.what == buttons::scroll))
|
||||||
if (metrics_.pressed && (metrics_.what == buttons::scroll))
|
|
||||||
{
|
{
|
||||||
size_type cmpvalue = metrics_.value;
|
size_type cmpvalue = drawer_.metrics.value;
|
||||||
drawer_.scroll_delta_pos(graph, (Vertical ? arg.pos.y : arg.pos.x));
|
drawer_.scroll_delta_pos(graph, (Vertical ? arg.pos.y : arg.pos.x));
|
||||||
if (cmpvalue != metrics_.value)
|
if (cmpvalue != drawer_.metrics.value)
|
||||||
_m_emit_value_changed();
|
_m_emit_value_changed();
|
||||||
redraw = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buttons what = drawer_.what(graph, arg.pos);
|
buttons what = drawer_.what(graph, arg.pos);
|
||||||
if (metrics_.what != what)
|
if (drawer_.metrics.what == what)
|
||||||
{
|
return; //no change, don't redraw
|
||||||
redraw = true;
|
|
||||||
metrics_.what = what;
|
drawer_.metrics.what = what;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (redraw)
|
|
||||||
{
|
|
||||||
drawer_.draw(graph, metrics_.what);
|
|
||||||
API::dev::lazy_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawer_.draw(graph);
|
||||||
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbl_click(graph_reference graph, const arg_mouse& arg) override
|
void dbl_click(graph_reference graph, const arg_mouse& arg) override
|
||||||
@ -254,33 +251,33 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if (arg.left_button)
|
if (arg.left_button)
|
||||||
{
|
{
|
||||||
metrics_.pressed = true;
|
drawer_.metrics.pressed = true;
|
||||||
metrics_.what = drawer_.what(graph, arg.pos);
|
drawer_.metrics.what = drawer_.what(graph, arg.pos);
|
||||||
switch (metrics_.what)
|
switch (drawer_.metrics.what)
|
||||||
{
|
{
|
||||||
case buttons::first:
|
case buttons::first:
|
||||||
case buttons::second:
|
case buttons::second:
|
||||||
make_step(metrics_.what == buttons::second, 1);
|
make_step(drawer_.metrics.what == buttons::second, 1);
|
||||||
timer_.interval(1000);
|
timer_.interval(1000);
|
||||||
timer_.start();
|
timer_.start();
|
||||||
break;
|
break;
|
||||||
case buttons::scroll:
|
case buttons::scroll:
|
||||||
widget_->set_capture(true);
|
widget_->set_capture(true);
|
||||||
metrics_.scroll_mouse_offset = (Vertical ? arg.pos.y : arg.pos.x) - metrics_.scroll_pos;
|
drawer_.metrics.scroll_mouse_offset = (Vertical ? arg.pos.y : arg.pos.x) - drawer_.metrics.scroll_pos;
|
||||||
break;
|
break;
|
||||||
case buttons::forward:
|
case buttons::forward:
|
||||||
case buttons::backward:
|
case buttons::backward:
|
||||||
{
|
{
|
||||||
size_type cmpvalue = metrics_.value;
|
size_type cmpvalue = drawer_.metrics.value;
|
||||||
drawer_.auto_scroll();
|
drawer_.auto_scroll();
|
||||||
if (cmpvalue != metrics_.value)
|
if (cmpvalue != drawer_.metrics.value)
|
||||||
_m_emit_value_changed();
|
_m_emit_value_changed();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: //Ignore buttons::none
|
default: //Ignore buttons::none
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,18 +288,18 @@ namespace nana
|
|||||||
|
|
||||||
widget_->release_capture();
|
widget_->release_capture();
|
||||||
|
|
||||||
metrics_.pressed = false;
|
drawer_.metrics.pressed = false;
|
||||||
metrics_.what = drawer_.what(graph, arg.pos);
|
drawer_.metrics.what = drawer_.what(graph, arg.pos);
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_leave(graph_reference graph, const arg_mouse&) override
|
void mouse_leave(graph_reference graph, const arg_mouse&) override
|
||||||
{
|
{
|
||||||
if (metrics_.pressed) return;
|
if (drawer_.metrics.pressed) return;
|
||||||
|
|
||||||
metrics_.what = buttons::none;
|
drawer_.metrics.what = buttons::none;
|
||||||
drawer_.draw(graph, buttons::none);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +307,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if (make_step(arg.upwards == false, 3))
|
if (make_step(arg.upwards == false, 3))
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,14 +319,13 @@ namespace nana
|
|||||||
|
|
||||||
void _m_tick()
|
void _m_tick()
|
||||||
{
|
{
|
||||||
make_step(metrics_.what == buttons::second, 1);
|
make_step(drawer_.metrics.what == buttons::second, 1);
|
||||||
API::refresh_window(widget_->handle());
|
API::refresh_window(widget_->handle());
|
||||||
timer_.interval(100);
|
timer_.interval(100);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
::nana::scroll<Vertical> * widget_;
|
::nana::scroll<Vertical> * widget_;
|
||||||
nana::paint::graphics * graph_;
|
nana::paint::graphics * graph_;
|
||||||
metrics_type metrics_;
|
|
||||||
drawer drawer_;
|
drawer drawer_;
|
||||||
timer timer_;
|
timer timer_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -29,18 +29,44 @@ namespace nana
|
|||||||
{
|
{
|
||||||
tabbar<T> & widget;
|
tabbar<T> & widget;
|
||||||
T & value;
|
T & value;
|
||||||
|
std::size_t item_pos; ///< position of the item
|
||||||
|
|
||||||
arg_tabbar(tabbar<T>& wdg, T& v)
|
arg_tabbar(tabbar<T>& wdg, T& v, std::size_t p)
|
||||||
: widget(wdg), value{ v }
|
: widget(wdg), value{ v }, item_pos(p)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct arg_tabbar_click : public arg_tabbar<T>
|
||||||
|
{
|
||||||
|
arg_tabbar_click(tabbar<T>& wdg, T& v, std::size_t p)
|
||||||
|
: arg_tabbar<T>({wdg, v, p})
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool left_button = false; ///< true if mouse left button is pressed
|
||||||
|
bool mid_button = false; ///< true if mouse middle button is pressed
|
||||||
|
bool right_button = false; ///< true if mouse right button is pressed
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct arg_tabbar_mouse
|
||||||
|
: public arg_mouse
|
||||||
|
{
|
||||||
|
arg_tabbar_mouse(const arg_mouse& arg, tabbar<T>& wdg, T& v, std::size_t p)
|
||||||
|
: arg_mouse{ arg }, widget(wdg), value{ v }, item_pos(p)
|
||||||
|
{}
|
||||||
|
|
||||||
|
tabbar<T> & widget;
|
||||||
|
T & value;
|
||||||
|
std::size_t item_pos; ///< position of the item
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct arg_tabbar_adding
|
struct arg_tabbar_adding
|
||||||
: public event_arg
|
: public event_arg
|
||||||
{
|
{
|
||||||
arg_tabbar_adding(tabbar<T>& wdg, std::size_t pos)
|
arg_tabbar_adding(tabbar<T>& wdg, std::size_t p)
|
||||||
: widget(wdg), where(pos)
|
: widget(wdg), where(p)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
tabbar<T> & widget;
|
tabbar<T> & widget;
|
||||||
@ -51,8 +77,8 @@ namespace nana
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct arg_tabbar_removed : public arg_tabbar<T>
|
struct arg_tabbar_removed : public arg_tabbar<T>
|
||||||
{
|
{
|
||||||
arg_tabbar_removed(tabbar<T>& wdg, T& v)
|
arg_tabbar_removed(tabbar<T>& wdg, T& v, std::size_t p)
|
||||||
: arg_tabbar<T>({wdg, v})
|
: arg_tabbar<T>({wdg, v, p})
|
||||||
{}
|
{}
|
||||||
|
|
||||||
mutable bool remove = true; ///< determines whether to remove the item
|
mutable bool remove = true; ///< determines whether to remove the item
|
||||||
@ -71,6 +97,7 @@ namespace nana
|
|||||||
|
|
||||||
basic_event<arg_tabbar_adding<value_type>> adding;
|
basic_event<arg_tabbar_adding<value_type>> adding;
|
||||||
basic_event<arg_tabbar<value_type>> added;
|
basic_event<arg_tabbar<value_type>> added;
|
||||||
|
basic_event<arg_tabbar_mouse<value_type>> tab_click;
|
||||||
basic_event<arg_tabbar<value_type>> activated;
|
basic_event<arg_tabbar<value_type>> activated;
|
||||||
basic_event<arg_tabbar_removed<value_type>> removed;
|
basic_event<arg_tabbar_removed<value_type>> removed;
|
||||||
};
|
};
|
||||||
@ -81,6 +108,7 @@ namespace nana
|
|||||||
virtual ~event_agent_interface() = default;
|
virtual ~event_agent_interface() = default;
|
||||||
virtual bool adding(std::size_t) = 0;
|
virtual bool adding(std::size_t) = 0;
|
||||||
virtual void added(std::size_t) = 0;
|
virtual void added(std::size_t) = 0;
|
||||||
|
virtual bool click(const arg_mouse&, std::size_t) = 0;
|
||||||
virtual void activated(std::size_t) = 0;
|
virtual void activated(std::size_t) = 0;
|
||||||
virtual bool removed(std::size_t, bool & close_attached) = 0;
|
virtual bool removed(std::size_t, bool & close_attached) = 0;
|
||||||
};
|
};
|
||||||
@ -124,9 +152,9 @@ namespace nana
|
|||||||
|
|
||||||
bool adding(std::size_t pos) override
|
bool adding(std::size_t pos) override
|
||||||
{
|
{
|
||||||
::nana::arg_tabbar_adding<T> arg(tabbar_, pos);
|
::nana::arg_tabbar_adding<T> arg_ta(tabbar_, pos);
|
||||||
tabbar_.events().adding.emit(arg, tabbar_);
|
tabbar_.events().adding.emit(arg_ta, tabbar_);
|
||||||
return arg.add;
|
return arg_ta.add;
|
||||||
}
|
}
|
||||||
|
|
||||||
void added(std::size_t pos) override
|
void added(std::size_t pos) override
|
||||||
@ -134,21 +162,28 @@ namespace nana
|
|||||||
if(pos != npos)
|
if(pos != npos)
|
||||||
{
|
{
|
||||||
drawer_trigger_.at_no_bound_check(pos) = T();
|
drawer_trigger_.at_no_bound_check(pos) = T();
|
||||||
tabbar_.events().added.emit(arg_tabbar({ tabbar_, tabbar_[pos] }), tabbar_);
|
tabbar_.events().added.emit(arg_tabbar({ tabbar_, tabbar_[pos], pos }), tabbar_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool click(const arg_mouse& arg, std::size_t pos) override
|
||||||
|
{
|
||||||
|
::nana::arg_tabbar_mouse<T> arg_tm(arg, tabbar_, tabbar_[pos], pos);
|
||||||
|
tabbar_.events().tab_click.emit(arg_tm, tabbar_);
|
||||||
|
return arg_tm.propagation_stopped();
|
||||||
|
}
|
||||||
|
|
||||||
void activated(std::size_t pos) override
|
void activated(std::size_t pos) override
|
||||||
{
|
{
|
||||||
if(pos != npos)
|
if(pos != npos)
|
||||||
tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos]}), tabbar_);
|
tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos], pos}), tabbar_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool removed(std::size_t pos, bool & close_attach) override
|
bool removed(std::size_t pos, bool & close_attach) override
|
||||||
{
|
{
|
||||||
if (pos != npos)
|
if(pos != npos)
|
||||||
{
|
{
|
||||||
::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos]);
|
::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos], pos);
|
||||||
tabbar_.events().removed.emit(arg, tabbar_);
|
tabbar_.events().removed.emit(arg, tabbar_);
|
||||||
close_attach = arg.close_attach_window;
|
close_attach = arg.close_attach_window;
|
||||||
return arg.remove;
|
return arg.remove;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Color Schemes
|
* Color Schemes
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 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
|
||||||
@ -24,6 +24,14 @@ namespace nana
|
|||||||
: color_(std::make_shared<color>(clr))
|
: color_(std::make_shared<color>(clr))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
color_proxy::color_proxy(color_argb clr)
|
||||||
|
: color_(std::make_shared<color>(clr))
|
||||||
|
{}
|
||||||
|
|
||||||
|
color_proxy::color_proxy(color_rgba clr)
|
||||||
|
: color_(std::make_shared<color>(clr))
|
||||||
|
{}
|
||||||
|
|
||||||
color_proxy::color_proxy(colors clr)
|
color_proxy::color_proxy(colors clr)
|
||||||
: color_(std::make_shared<color>(clr))
|
: color_(std::make_shared<color>(clr))
|
||||||
{}
|
{}
|
||||||
@ -47,6 +55,18 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color_proxy& color_proxy::operator = (color_argb clr)
|
||||||
|
{
|
||||||
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
color_proxy& color_proxy::operator = (color_rgba clr)
|
||||||
|
{
|
||||||
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
color_proxy& color_proxy::operator = (colors clr)
|
color_proxy& color_proxy::operator = (colors clr)
|
||||||
{
|
{
|
||||||
color_ = std::make_shared<::nana::color>(clr);
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
@ -58,6 +78,13 @@ namespace nana
|
|||||||
return *color_;
|
return *color_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color color_proxy::get(const color& default_color) const
|
||||||
|
{
|
||||||
|
if (color_->invisible())
|
||||||
|
return default_color;
|
||||||
|
return *color_;
|
||||||
|
}
|
||||||
|
|
||||||
color_proxy::operator color() const
|
color_proxy::operator color() const
|
||||||
{
|
{
|
||||||
return *color_;
|
return *color_;
|
||||||
|
|||||||
@ -379,7 +379,12 @@ namespace nana{ namespace drawerbase
|
|||||||
|
|
||||||
void trigger::icon(const nana::paint::image& img)
|
void trigger::icon(const nana::paint::image& img)
|
||||||
{
|
{
|
||||||
if(img.empty()) return;
|
if(img.empty())
|
||||||
|
{
|
||||||
|
delete attr_.icon;
|
||||||
|
attr_.icon = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(nullptr == attr_.icon)
|
if(nullptr == attr_.icon)
|
||||||
attr_.icon = new paint::image;
|
attr_.icon = new paint::image;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace nana{ namespace drawerbase
|
|||||||
struct drawer::implement
|
struct drawer::implement
|
||||||
{
|
{
|
||||||
widget * widget_ptr;
|
widget * widget_ptr;
|
||||||
|
scheme * scheme_ptr;
|
||||||
bool react;
|
bool react;
|
||||||
bool radio;
|
bool radio;
|
||||||
facade<element::crook> crook;
|
facade<element::crook> crook;
|
||||||
@ -47,6 +48,7 @@ namespace nana{ namespace drawerbase
|
|||||||
void drawer::attached(widget_reference widget, graph_reference)
|
void drawer::attached(widget_reference widget, graph_reference)
|
||||||
{
|
{
|
||||||
impl_->widget_ptr = &widget;
|
impl_->widget_ptr = &widget;
|
||||||
|
impl_->scheme_ptr =static_cast<scheme*>(API::dev::get_scheme(widget));
|
||||||
API::dev::enable_space_click(widget, true);
|
API::dev::enable_space_click(widget, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,12 +80,14 @@ namespace nana{ namespace drawerbase
|
|||||||
}
|
}
|
||||||
|
|
||||||
//draw crook
|
//draw crook
|
||||||
#ifdef _nana_std_has_string_view
|
|
||||||
auto txt_px = graph.text_extent_size(std::wstring_view( L"jN", 2 )).height + 2;
|
unsigned txt_px = 0, descent = 0, ileading = 0;
|
||||||
#else
|
graph.text_metrics(txt_px, descent, ileading);
|
||||||
auto txt_px = graph.text_extent_size(L"jN", 2).height + 2;
|
txt_px += (descent + 2);
|
||||||
#endif
|
|
||||||
impl_->crook.draw(graph, wdg->bgcolor(), wdg->fgcolor(), rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg));
|
impl_->crook.draw(graph,
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
||||||
|
|||||||
@ -33,21 +33,16 @@ namespace nana
|
|||||||
//end struct metrics_type
|
//end struct metrics_type
|
||||||
|
|
||||||
//class drawer
|
//class drawer
|
||||||
drawer::drawer(metrics_type& m)
|
drawer::drawer(bool vert) :
|
||||||
:metrics_(m)
|
vert(vert)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void drawer::set_vertical(bool v)
|
|
||||||
{
|
|
||||||
vertical_ = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons drawer::what(graph_reference graph, const point& screen_pos)
|
buttons drawer::what(graph_reference graph, const point& screen_pos)
|
||||||
{
|
{
|
||||||
unsigned scale;
|
unsigned scale;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
if(vertical_)
|
if(vert)
|
||||||
{
|
{
|
||||||
scale = graph.height();
|
scale = graph.height();
|
||||||
pos = screen_pos.y;
|
pos = screen_pos.y;
|
||||||
@ -64,15 +59,15 @@ namespace nana
|
|||||||
if (pos > static_cast<int>(scale) - bound_pos)
|
if (pos > static_cast<int>(scale) - bound_pos)
|
||||||
return buttons::second;
|
return buttons::second;
|
||||||
|
|
||||||
if(metrics_.scroll_length)
|
if(metrics.scroll_length)
|
||||||
{
|
{
|
||||||
if(metrics_.scroll_pos + static_cast<int>(fixedsize) <= pos && pos < metrics_.scroll_pos + static_cast<int>(fixedsize + metrics_.scroll_length))
|
if(metrics.scroll_pos + static_cast<int>(fixedsize) <= pos && pos < metrics.scroll_pos + static_cast<int>(fixedsize + metrics.scroll_length))
|
||||||
return buttons::scroll;
|
return buttons::scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(static_cast<int>(fixedsize) <= pos && pos < metrics_.scroll_pos)
|
if(static_cast<int>(fixedsize) <= pos && pos < metrics.scroll_pos)
|
||||||
return buttons::forward;
|
return buttons::forward;
|
||||||
else if(metrics_.scroll_pos + static_cast<int>(metrics_.scroll_length) <= pos && pos < static_cast<int>(scale - fixedsize))
|
else if(metrics.scroll_pos + static_cast<int>(metrics.scroll_length) <= pos && pos < static_cast<int>(scale - fixedsize))
|
||||||
return buttons::backward;
|
return buttons::backward;
|
||||||
|
|
||||||
return buttons::none;
|
return buttons::none;
|
||||||
@ -80,39 +75,39 @@ namespace nana
|
|||||||
|
|
||||||
void drawer::scroll_delta_pos(graph_reference graph, int mouse_pos)
|
void drawer::scroll_delta_pos(graph_reference graph, int mouse_pos)
|
||||||
{
|
{
|
||||||
if(mouse_pos + metrics_.scroll_mouse_offset == metrics_.scroll_pos) return;
|
if(mouse_pos + metrics.scroll_mouse_offset == metrics.scroll_pos) return;
|
||||||
|
|
||||||
unsigned scale = vertical_ ? graph.height() : graph.width();
|
unsigned scale = vert ? graph.height() : graph.width();
|
||||||
|
|
||||||
if(scale > fixedsize * 2)
|
if(scale > fixedsize * 2)
|
||||||
{
|
{
|
||||||
int pos = mouse_pos - metrics_.scroll_mouse_offset;
|
int pos = mouse_pos - metrics.scroll_mouse_offset;
|
||||||
const unsigned scroll_area = static_cast<unsigned>(scale - fixedsize * 2 - metrics_.scroll_length);
|
const unsigned scroll_area = static_cast<unsigned>(scale - fixedsize * 2 - metrics.scroll_length);
|
||||||
|
|
||||||
if(pos < 0)
|
if(pos < 0)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
else if(pos > static_cast<int>(scroll_area))
|
else if(pos > static_cast<int>(scroll_area))
|
||||||
pos = static_cast<int>(scroll_area);
|
pos = static_cast<int>(scroll_area);
|
||||||
|
|
||||||
metrics_.scroll_pos = pos;
|
metrics.scroll_pos = pos;
|
||||||
auto value_max = metrics_.peak - metrics_.range;
|
auto value_max = metrics.peak - metrics.range;
|
||||||
|
|
||||||
//Check scroll_area to avoiding division by zero.
|
//Check scroll_area to avoiding division by zero.
|
||||||
if (scroll_area)
|
if (scroll_area)
|
||||||
metrics_.value = static_cast<std::size_t>(pos * (static_cast<double>(value_max) / scroll_area)); //converting to double to avoid overflow.
|
metrics.value = static_cast<std::size_t>(pos * (static_cast<double>(value_max) / scroll_area)); //converting to double to avoid overflow.
|
||||||
|
|
||||||
if (metrics_.value < value_max)
|
if (metrics.value < value_max)
|
||||||
{
|
{
|
||||||
//converting to double to avoid overflow.
|
//converting to double to avoid overflow.
|
||||||
auto const px_per_value = static_cast<double>(scroll_area) / value_max;
|
auto const px_per_value = static_cast<double>(scroll_area) / value_max;
|
||||||
int selfpos = static_cast<int>(metrics_.value * px_per_value);
|
int selfpos = static_cast<int>(metrics.value * px_per_value);
|
||||||
int nextpos = static_cast<int>((metrics_.value + 1) * px_per_value);
|
int nextpos = static_cast<int>((metrics.value + 1) * px_per_value);
|
||||||
|
|
||||||
if(selfpos != nextpos && (pos - selfpos > nextpos - pos))
|
if(selfpos != nextpos && (pos - selfpos > nextpos - pos))
|
||||||
++metrics_.value;
|
++metrics.value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
metrics_.value = value_max;
|
metrics.value = value_max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,46 +116,46 @@ namespace nana
|
|||||||
if (!_m_check())
|
if (!_m_check())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(buttons::forward == metrics_.what)
|
if(buttons::forward == metrics.what)
|
||||||
{ //backward
|
{ //backward
|
||||||
if(metrics_.value <= metrics_.range)
|
if(metrics.value <= metrics.range)
|
||||||
metrics_.value = 0;
|
metrics.value = 0;
|
||||||
else
|
else
|
||||||
metrics_.value -= (metrics_.range-1);
|
metrics.value -= (metrics.range-1);
|
||||||
}
|
}
|
||||||
else if(buttons::backward == metrics_.what)
|
else if(buttons::backward == metrics.what)
|
||||||
{
|
{
|
||||||
if(metrics_.peak - metrics_.range - metrics_.value <= metrics_.range)
|
if(metrics.peak - metrics.range - metrics.value <= metrics.range)
|
||||||
metrics_.value = metrics_.peak - metrics_.range;
|
metrics.value = metrics.peak - metrics.range;
|
||||||
else
|
else
|
||||||
metrics_.value += (metrics_.range-1);
|
metrics.value += (metrics.range-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::draw(graph_reference graph, buttons what)
|
void drawer::draw(graph_reference graph)
|
||||||
{
|
{
|
||||||
if(false == metrics_.pressed || metrics_.what != buttons::scroll)
|
if(false == metrics.pressed || metrics.what != buttons::scroll)
|
||||||
_m_adjust_scroll(graph);
|
_m_adjust_scroll(graph);
|
||||||
|
|
||||||
_m_background(graph);
|
_m_background(graph);
|
||||||
|
|
||||||
rectangle_rotator r(vertical_, ::nana::rectangle{ graph.size() });
|
rectangle_rotator r(vert, ::nana::rectangle{ graph.size() });
|
||||||
r.x_ref() = static_cast<int>(r.w() - fixedsize);
|
r.x_ref() = static_cast<int>(r.w() - fixedsize);
|
||||||
r.w_ref() = fixedsize;
|
r.w_ref() = fixedsize;
|
||||||
|
|
||||||
int state = ((_m_check() == false || what == buttons::none) ? states::none : states::highlight);
|
auto state = ((_m_check() == false || metrics.what == buttons::none) ? states::none : states::highlight);
|
||||||
int moused_state = (_m_check() ? (metrics_.pressed ? states::selected : states::actived) : states::none);
|
auto moused_state = (_m_check() ? (metrics.pressed ? states::selected : states::actived) : states::none);
|
||||||
|
|
||||||
auto result = r.result();
|
auto result = r.result();
|
||||||
|
|
||||||
//draw first
|
//draw first
|
||||||
_m_draw_button(graph, { 0, 0, result.width, result.height }, buttons::first, (buttons::first == what ? moused_state : state));
|
_m_draw_button(graph, { 0, 0, result.width, result.height }, buttons::first, (buttons::first == metrics.what ? moused_state : state));
|
||||||
|
|
||||||
//draw second
|
//draw second
|
||||||
_m_draw_button(graph, result, buttons::second, (buttons::second == what ? moused_state : state));
|
_m_draw_button(graph, result, buttons::second, (buttons::second == metrics.what ? moused_state : state));
|
||||||
|
|
||||||
//draw scroll
|
//draw scroll
|
||||||
_m_draw_scroll(graph, (buttons::scroll == what ? moused_state : states::highlight));
|
_m_draw_scroll(graph, (buttons::scroll == metrics.what ? moused_state : states::highlight));
|
||||||
|
|
||||||
}
|
}
|
||||||
//private:
|
//private:
|
||||||
@ -168,19 +163,19 @@ namespace nana
|
|||||||
{
|
{
|
||||||
graph.rectangle(true, {0xf0, 0xf0, 0xf0});
|
graph.rectangle(true, {0xf0, 0xf0, 0xf0});
|
||||||
|
|
||||||
if (!metrics_.pressed || !_m_check())
|
if (!metrics.pressed || !_m_check())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nana::rectangle_rotator r(vertical_, ::nana::rectangle{ graph.size() });
|
nana::rectangle_rotator r(vert, ::nana::rectangle{ graph.size() });
|
||||||
if(metrics_.what == buttons::forward)
|
if(metrics.what == buttons::forward)
|
||||||
{
|
{
|
||||||
r.x_ref() = static_cast<int>(fixedsize);
|
r.x_ref() = static_cast<int>(fixedsize);
|
||||||
r.w_ref() = metrics_.scroll_pos;
|
r.w_ref() = metrics.scroll_pos;
|
||||||
}
|
}
|
||||||
else if(buttons::backward == metrics_.what)
|
else if(buttons::backward == metrics.what)
|
||||||
{
|
{
|
||||||
r.x_ref() = static_cast<int>(fixedsize + metrics_.scroll_pos + metrics_.scroll_length);
|
r.x_ref() = static_cast<int>(fixedsize + metrics.scroll_pos + metrics.scroll_length);
|
||||||
r.w_ref() = static_cast<unsigned>((vertical_ ? graph.height() : graph.width()) - (fixedsize * 2 + metrics_.scroll_pos + metrics_.scroll_length));
|
r.w_ref() = static_cast<unsigned>((vert ? graph.height() : graph.width()) - (fixedsize * 2 + metrics.scroll_pos + metrics.scroll_length));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -190,9 +185,9 @@ namespace nana
|
|||||||
graph.rectangle(result, true, static_cast<color_rgb>(0xDCDCDC));
|
graph.rectangle(result, true, static_cast<color_rgb>(0xDCDCDC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::_m_button_frame(graph_reference graph, rectangle r, int state)
|
void drawer::_m_button_frame(graph_reference graph, rectangle r, states state)
|
||||||
{
|
{
|
||||||
if (!state)
|
if (states::none == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
::nana::color clr{0x97, 0x97, 0x97}; //highlight
|
::nana::color clr{0x97, 0x97, 0x97}; //highlight
|
||||||
@ -210,7 +205,7 @@ namespace nana
|
|||||||
graph.palette(false, clr);
|
graph.palette(false, clr);
|
||||||
|
|
||||||
r.pare_off(2);
|
r.pare_off(2);
|
||||||
if(vertical_)
|
if(vert)
|
||||||
{
|
{
|
||||||
unsigned half = r.width / 2;
|
unsigned half = r.width / 2;
|
||||||
graph.rectangle({ r.x + static_cast<int>(r.width - half), r.y, half, r.height }, true);
|
graph.rectangle({ r.x + static_cast<int>(r.width - half), r.y, half, r.height }, true);
|
||||||
@ -222,19 +217,19 @@ namespace nana
|
|||||||
graph.rectangle({r.x, r.y + static_cast<int>(r.height - half), r.width, half}, true);
|
graph.rectangle({r.x, r.y + static_cast<int>(r.height - half), r.width, half}, true);
|
||||||
r.height -= half;
|
r.height -= half;
|
||||||
}
|
}
|
||||||
graph.gradual_rectangle(r, colors::white, clr, !vertical_);
|
graph.gradual_rectangle(r, colors::white, clr, !vert);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool drawer::_m_check() const
|
bool drawer::_m_check() const
|
||||||
{
|
{
|
||||||
return (metrics_.scroll_length && metrics_.range && (metrics_.peak > metrics_.range));
|
return (metrics.scroll_length && metrics.range && (metrics.peak > metrics.range));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::_m_adjust_scroll(graph_reference graph)
|
void drawer::_m_adjust_scroll(graph_reference graph)
|
||||||
{
|
{
|
||||||
if(metrics_.range == 0 || metrics_.peak <= metrics_.range) return;
|
if(metrics.range == 0 || metrics.peak <= metrics.range) return;
|
||||||
|
|
||||||
unsigned pixels = vertical_ ? graph.height() : graph.width();
|
unsigned pixels = vert ? graph.height() : graph.width();
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
@ -242,38 +237,38 @@ namespace nana
|
|||||||
if(pixels > fixedsize * 2)
|
if(pixels > fixedsize * 2)
|
||||||
{
|
{
|
||||||
pixels -= (fixedsize * 2);
|
pixels -= (fixedsize * 2);
|
||||||
len = static_cast<unsigned>(pixels * metrics_.range / metrics_.peak);
|
len = static_cast<unsigned>(pixels * metrics.range / metrics.peak);
|
||||||
|
|
||||||
if(len < fixedsize)
|
if(len < fixedsize)
|
||||||
len = fixedsize;
|
len = fixedsize;
|
||||||
|
|
||||||
if(metrics_.value)
|
if(metrics.value)
|
||||||
{
|
{
|
||||||
pos = static_cast<int>(pixels - len);
|
pos = static_cast<int>(pixels - len);
|
||||||
if(metrics_.value + metrics_.range >= metrics_.peak)
|
if(metrics.value + metrics.range >= metrics.peak)
|
||||||
metrics_.value = metrics_.peak - metrics_.range;
|
metrics.value = metrics.peak - metrics.range;
|
||||||
else
|
else
|
||||||
pos = static_cast<int>((metrics_.value * pos) /(metrics_.peak - metrics_.range));
|
pos = static_cast<int>((metrics.value * pos) /(metrics.peak - metrics.range));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics_.scroll_pos = pos;
|
metrics.scroll_pos = pos;
|
||||||
metrics_.scroll_length = len;
|
metrics.scroll_length = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::_m_draw_scroll(graph_reference graph, int state)
|
void drawer::_m_draw_scroll(graph_reference graph, states state)
|
||||||
{
|
{
|
||||||
if(_m_check())
|
if(_m_check())
|
||||||
{
|
{
|
||||||
rectangle_rotator r(vertical_, rectangle{ graph.size() });
|
rectangle_rotator r(vert, rectangle{ graph.size() });
|
||||||
r.x_ref() = static_cast<int>(fixedsize + metrics_.scroll_pos);
|
r.x_ref() = static_cast<int>(fixedsize + metrics.scroll_pos);
|
||||||
r.w_ref() = static_cast<unsigned>(metrics_.scroll_length);
|
r.w_ref() = static_cast<unsigned>(metrics.scroll_length);
|
||||||
|
|
||||||
_m_button_frame(graph, r.result(), state);
|
_m_button_frame(graph, r.result(), state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::_m_draw_button(graph_reference graph, rectangle r, buttons what, int state)
|
void drawer::_m_draw_button(graph_reference graph, rectangle r, buttons what, states state)
|
||||||
{
|
{
|
||||||
if(_m_check())
|
if(_m_check())
|
||||||
_m_button_frame(graph, r, state);
|
_m_button_frame(graph, r, state);
|
||||||
@ -287,7 +282,7 @@ namespace nana
|
|||||||
direction dir;
|
direction dir;
|
||||||
if (buttons::second == what)
|
if (buttons::second == what)
|
||||||
{
|
{
|
||||||
if (vertical_)
|
if (vert)
|
||||||
{
|
{
|
||||||
r.y = top;
|
r.y = top;
|
||||||
dir = direction::south;
|
dir = direction::south;
|
||||||
@ -299,9 +294,9 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dir = vertical_ ? direction::north : direction::west;
|
dir = vert ? direction::north : direction::west;
|
||||||
|
|
||||||
if (vertical_)
|
if (vert)
|
||||||
r.x = left / 2;
|
r.x = left / 2;
|
||||||
else
|
else
|
||||||
r.y = top / 2;
|
r.y = top / 2;
|
||||||
|
|||||||
@ -230,7 +230,6 @@ namespace nana {
|
|||||||
{
|
{
|
||||||
cv_scroll->vert.create(window_handle);
|
cv_scroll->vert.create(window_handle);
|
||||||
cv_scroll->vert.events().value_changed.connect_unignorable(event_fn);
|
cv_scroll->vert.events().value_changed.connect_unignorable(event_fn);
|
||||||
API::take_active(cv_scroll->vert, false, window_handle);
|
|
||||||
this->passive = false;
|
this->passive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +260,6 @@ namespace nana {
|
|||||||
{
|
{
|
||||||
cv_scroll->horz.create(window_handle);
|
cv_scroll->horz.create(window_handle);
|
||||||
cv_scroll->horz.events().value_changed.connect_unignorable(event_fn);
|
cv_scroll->horz.events().value_changed.connect_unignorable(event_fn);
|
||||||
API::take_active(cv_scroll->horz, false, window_handle);
|
|
||||||
this->passive = false;
|
this->passive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -492,9 +492,17 @@ namespace nana
|
|||||||
return (trace_.what != trace_.null);
|
return (trace_.what != trace_.null);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool active_by_trace()
|
bool active_by_trace(const arg_mouse& arg)
|
||||||
{
|
{
|
||||||
return ((trace_.what == trace_.item) && (trace_.item_part != trace_.close)? activate(trace_.u.index) : false);
|
if((trace_.what == trace_.item) && (trace_.item_part != trace_.close))
|
||||||
|
{
|
||||||
|
if(false == evt_agent_->click(arg, trace_.u.index))
|
||||||
|
return activate(trace_.u.index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool release()
|
bool release()
|
||||||
@ -1285,7 +1293,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if(layouter_->press())
|
if(layouter_->press())
|
||||||
{
|
{
|
||||||
if(false == layouter_->active_by_trace())
|
if(false == layouter_->active_by_trace(arg))
|
||||||
layouter_->toolbox_answer(arg);
|
layouter_->toolbox_answer(arg);
|
||||||
layouter_->render();
|
layouter_->render();
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user