Merge branch 'JamesBremner-hotfix-1.6.2' into hotfix-1.6.2
This commit is contained in:
commit
4fa1618f48
@ -3,8 +3,8 @@
|
|||||||
* Nana C++ Library(http://www.nanaro.org)
|
* Nana C++ Library(http://www.nanaro.org)
|
||||||
* Copyright(C) 2015-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2015-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/group.hpp
|
* @file: nana/gui/widgets/group.hpp
|
||||||
@ -85,6 +85,9 @@ namespace nana{
|
|||||||
/// Determines whether a specified option is checked, it throws an out_of_range if !(pos < number of options)
|
/// Determines whether a specified option is checked, it throws an out_of_range if !(pos < number of options)
|
||||||
bool option_checked(std::size_t pos) const;
|
bool option_checked(std::size_t pos) const;
|
||||||
|
|
||||||
|
/// Change typeface of caption label ( does not effect child widgets )
|
||||||
|
void typeface( const nana::paint::font& font );
|
||||||
|
|
||||||
group& enable_format_caption(bool format);
|
group& enable_format_caption(bool format);
|
||||||
|
|
||||||
group& collocate() noexcept;
|
group& collocate() noexcept;
|
||||||
@ -94,7 +97,7 @@ namespace nana{
|
|||||||
void field_display(const char* field_name, bool display); ///<Displays/Discards an existing field.
|
void field_display(const char* field_name, bool display); ///<Displays/Discards an existing field.
|
||||||
bool field_display(const char* field_name) const; ///<Determines whether the specified field is displayed.
|
bool field_display(const char* field_name) const; ///<Determines whether the specified field is displayed.
|
||||||
void erase(window handle); ///< Erases a window from field.
|
void erase(window handle); ///< Erases a window from field.
|
||||||
|
|
||||||
template<typename Widget, typename ...Args>
|
template<typename Widget, typename ...Args>
|
||||||
Widget* create_child(const char* field, Args && ... args)
|
Widget* create_child(const char* field, Args && ... args)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,13 @@ namespace nana
|
|||||||
bool vertical() const;
|
bool vertical() const;
|
||||||
void maximum(unsigned);
|
void maximum(unsigned);
|
||||||
unsigned maximum() const;
|
unsigned maximum() const;
|
||||||
void value(unsigned);
|
|
||||||
|
/** Set slider value
|
||||||
|
@param[in] v new value for slider.
|
||||||
|
v will be clipped to the range 0 to maximum
|
||||||
|
*/
|
||||||
|
void value(int );
|
||||||
|
|
||||||
unsigned value() const;
|
unsigned value() const;
|
||||||
unsigned move_step(bool forward); ///< Increase or decrease the value of slider.
|
unsigned move_step(bool forward); ///< Increase or decrease the value of slider.
|
||||||
unsigned adorn() const;
|
unsigned adorn() const;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
* Nana C++ Library(http://www.nanaro.org)
|
* Nana C++ Library(http://www.nanaro.org)
|
||||||
* Copyright(C) 2015-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2015-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/group.cpp
|
* @file: nana/gui/widgets/group.cpp
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* @brief group is a widget used to visually group and layout other widgets.
|
* @brief group is a widget used to visually group and layout other widgets.
|
||||||
*
|
*
|
||||||
* @contributor:
|
* @contributor:
|
||||||
* dankan1890(https://github.com/dankan1890)
|
* dankan1890(https://github.com/dankan1890)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -27,10 +27,11 @@
|
|||||||
if(empty()) \
|
if(empty()) \
|
||||||
throw std::logic_error("the group is invalid");
|
throw std::logic_error("the group is invalid");
|
||||||
|
|
||||||
namespace nana{
|
namespace nana
|
||||||
|
{
|
||||||
|
|
||||||
static const char* field_title = "__nana_group_title__";
|
static const char* field_title = "__nana_group_title__";
|
||||||
static const char* field_options = "__nana_group_options__";
|
static const char* field_options = "__nana_group_options__";
|
||||||
|
|
||||||
struct group::implement
|
struct group::implement
|
||||||
{
|
{
|
||||||
@ -41,108 +42,109 @@ namespace nana{
|
|||||||
unsigned gap{2};
|
unsigned gap{2};
|
||||||
std::string usr_div_str;
|
std::string usr_div_str;
|
||||||
|
|
||||||
nana::size caption_dimension;
|
nana::size caption_dimension;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<checkbox>> options;
|
std::vector<std::unique_ptr<checkbox>> options;
|
||||||
radio_group * radio_logic{nullptr};
|
radio_group * radio_logic{nullptr};
|
||||||
|
|
||||||
implement() = default;
|
implement() = default;
|
||||||
|
|
||||||
implement(window grp_panel, ::std::string titel, bool vsb, unsigned gap=2)
|
implement(window grp_panel, ::std::string titel, bool vsb, unsigned gap=2)
|
||||||
: caption (grp_panel, std::move(titel), vsb),
|
: caption (grp_panel, std::move(titel), vsb),
|
||||||
place_content{grp_panel},
|
place_content{grp_panel},
|
||||||
gap{gap}
|
gap{gap}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void create(window pnl)
|
void create(window pnl)
|
||||||
{
|
{
|
||||||
caption.create(pnl);
|
caption.create(pnl);
|
||||||
caption.caption("");
|
caption.caption("");
|
||||||
place_content.bind(pnl);
|
place_content.bind(pnl);
|
||||||
|
|
||||||
if (!radio_logic)
|
if (!radio_logic)
|
||||||
radio_logic = new radio_group;
|
radio_logic = new radio_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_div()
|
void update_div()
|
||||||
{
|
{
|
||||||
const std::size_t padding = 10;
|
const std::size_t padding = 10;
|
||||||
caption_dimension = caption.measure(1000);
|
caption_dimension = caption.measure(1000);
|
||||||
caption_dimension.width += 1;
|
caption_dimension.width += 1;
|
||||||
|
|
||||||
std::string div = "vert margin=[0," + std::to_string(gap) + "," + std::to_string(gap + 5) + "," + std::to_string(gap) + "]";
|
std::string div = "vert margin=[0," + std::to_string(gap) + "," + std::to_string(gap + 5) + "," + std::to_string(gap) + "]";
|
||||||
|
|
||||||
div += "<weight=" + std::to_string(caption_dimension.height) + " ";
|
div += "<weight=" + std::to_string(caption_dimension.height) + " ";
|
||||||
|
|
||||||
if (align::left == caption_align)
|
if (align::left == caption_align)
|
||||||
div += "<weight=" + std::to_string(padding) + ">";
|
div += "<weight=" + std::to_string(padding) + ">";
|
||||||
else
|
else
|
||||||
div += "<>"; //right or center
|
div += "<>"; //right or center
|
||||||
|
|
||||||
div += "<" + std::string{ field_title } + " weight=" + std::to_string(caption_dimension.width) + ">";
|
div += "<" + std::string{ field_title } + " weight=" + std::to_string(caption_dimension.width) + ">";
|
||||||
|
|
||||||
if (align::right == caption_align)
|
if (align::right == caption_align)
|
||||||
div += "<weight=" + std::to_string(padding) + ">";
|
div += "<weight=" + std::to_string(padding) + ">";
|
||||||
else if (align::center == caption_align)
|
else if (align::center == caption_align)
|
||||||
div += "<>";
|
div += "<>";
|
||||||
|
|
||||||
div += "><<vert margin=5 " + std::string(field_options) + ">";
|
div += "><<vert margin=5 " + std::string(field_options) + ">";
|
||||||
|
|
||||||
if (!usr_div_str.empty())
|
if (!usr_div_str.empty())
|
||||||
div += "<" + usr_div_str + ">>";
|
div += "<" + usr_div_str + ">>";
|
||||||
else
|
else
|
||||||
div += ">";
|
div += ">";
|
||||||
|
|
||||||
place_content.div(div.c_str());
|
place_content.div(div.c_str());
|
||||||
|
|
||||||
if (options.empty())
|
if (options.empty())
|
||||||
place_content.field_display(field_options, false);
|
place_content.field_display(field_options, false);
|
||||||
|
|
||||||
if (caption.caption().empty())
|
if (caption.caption().empty())
|
||||||
place_content.field_display(field_title, false);
|
place_content.field_display(field_title, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
group::group()
|
group::group()
|
||||||
: impl_(new implement)
|
: impl_(new implement)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
group::group(window parent, const rectangle& r, bool vsb)
|
group::group(window parent, const rectangle& r, bool vsb)
|
||||||
: group()
|
: group()
|
||||||
{
|
{
|
||||||
create(parent, r, vsb);
|
create(parent, r, vsb);
|
||||||
}
|
}
|
||||||
|
|
||||||
using groupbase_type = widget_object<category::widget_tag, drawerbase::panel::drawer, general_events, drawerbase::group::scheme>;
|
using groupbase_type = widget_object<category::widget_tag, drawerbase::panel::drawer, general_events, drawerbase::group::scheme>;
|
||||||
|
|
||||||
group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
|
||||||
: group(parent, r, vsb)
|
: group(parent, r, vsb)
|
||||||
{
|
{
|
||||||
this->bgcolor(API::bgcolor(parent));
|
this->bgcolor(API::bgcolor(parent));
|
||||||
|
|
||||||
impl_.reset(new implement(*this, std::move(titel), vsb, gap));
|
impl_.reset(new implement(*this, std::move(titel), vsb, gap));
|
||||||
|
|
||||||
impl_->caption.format(formatted);
|
impl_->caption.format(formatted);
|
||||||
_m_init();
|
_m_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
group::~group()
|
group::~group()
|
||||||
{
|
{
|
||||||
delete impl_->radio_logic;
|
delete impl_->radio_logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkbox& group::add_option(std::string text)
|
checkbox& group::add_option(std::string text)
|
||||||
{
|
{
|
||||||
_THROW_IF_EMPTY()
|
_THROW_IF_EMPTY()
|
||||||
|
|
||||||
#ifdef _nana_std_has_emplace_return_type
|
#ifdef _nana_std_has_emplace_return_type
|
||||||
auto & opt = impl_->options.emplace_back(new checkbox{ handle() });
|
auto & opt = impl_->options.emplace_back(new checkbox { handle() });
|
||||||
#else
|
#else
|
||||||
impl_->options.emplace_back(new checkbox(handle()));
|
impl_->options.emplace_back(new checkbox(handle()));
|
||||||
auto & opt = impl_->options.back();
|
auto & opt = impl_->options.back();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
opt->transparent(true);
|
opt->transparent(true);
|
||||||
opt->caption(std::move(text));
|
opt->caption(std::move(text));
|
||||||
impl_->place_content[field_options] << *opt;
|
impl_->place_content[field_options] << *opt;
|
||||||
@ -352,5 +354,6 @@ namespace nana{
|
|||||||
impl_->update_div();
|
impl_->update_div();
|
||||||
impl_->place_content.collocate();
|
impl_->place_content.collocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ namespace nana
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
enum class parts{none, bar, slider};
|
enum class parts{none, bar, slider};
|
||||||
|
|
||||||
using graph_reference = drawer_trigger::graph_reference;
|
using graph_reference = drawer_trigger::graph_reference;
|
||||||
|
|
||||||
model()
|
model()
|
||||||
@ -256,7 +256,7 @@ namespace nana
|
|||||||
proto_.renderer = pat::cloneable<renderer_interface>{interior_renderer{}};
|
proto_.renderer = pat::cloneable<renderer_interface>{interior_renderer{}};
|
||||||
|
|
||||||
attr_.seek_dir = seekdir::bilateral;
|
attr_.seek_dir = seekdir::bilateral;
|
||||||
|
|
||||||
attr_.is_draw_adorn = false;
|
attr_.is_draw_adorn = false;
|
||||||
attr_.vcur = 0;
|
attr_.vcur = 0;
|
||||||
attr_.vmax = 10;
|
attr_.vmax = 10;
|
||||||
@ -361,7 +361,7 @@ namespace nana
|
|||||||
parts seek_where(::nana::point pos) const
|
parts seek_where(::nana::point pos) const
|
||||||
{
|
{
|
||||||
nana::rectangle r = _m_bar_area();
|
nana::rectangle r = _m_bar_area();
|
||||||
|
|
||||||
if (attr_.slider.vert)
|
if (attr_.slider.vert)
|
||||||
{
|
{
|
||||||
std::swap(pos.x, pos.y);
|
std::swap(pos.x, pos.y);
|
||||||
@ -373,7 +373,7 @@ namespace nana
|
|||||||
return parts::slider;
|
return parts::slider;
|
||||||
|
|
||||||
sdpos = static_cast<int>(attr_.slider.weight) / 2;
|
sdpos = static_cast<int>(attr_.slider.weight) / 2;
|
||||||
|
|
||||||
if (sdpos <= pos.x && pos.x < sdpos + static_cast<int>(r.width))
|
if (sdpos <= pos.x && pos.x < sdpos + static_cast<int>(r.width))
|
||||||
{
|
{
|
||||||
if(pos.y < r.bottom())
|
if(pos.y < r.bottom())
|
||||||
@ -446,7 +446,7 @@ namespace nana
|
|||||||
bool move_slider(const ::nana::point& pos)
|
bool move_slider(const ::nana::point& pos)
|
||||||
{
|
{
|
||||||
int adorn_pos = slider_state_.snap_pos + (attr_.slider.vert ? pos.y : pos.x) - slider_state_.refpos.x;
|
int adorn_pos = slider_state_.snap_pos + (attr_.slider.vert ? pos.y : pos.x) - slider_state_.refpos.x;
|
||||||
|
|
||||||
if (adorn_pos > 0)
|
if (adorn_pos > 0)
|
||||||
{
|
{
|
||||||
int range = static_cast<int>(_m_range());
|
int range = static_cast<int>(_m_range());
|
||||||
@ -691,7 +691,7 @@ namespace nana
|
|||||||
window wd;
|
window wd;
|
||||||
nana::slider * widget;
|
nana::slider * widget;
|
||||||
}other_;
|
}other_;
|
||||||
|
|
||||||
struct prototype_tag
|
struct prototype_tag
|
||||||
{
|
{
|
||||||
pat::cloneable<slider::renderer_interface> renderer;
|
pat::cloneable<slider::renderer_interface> renderer;
|
||||||
@ -759,9 +759,9 @@ namespace nana
|
|||||||
void trigger::mouse_move(graph_reference graph, const arg_mouse& arg)
|
void trigger::mouse_move(graph_reference graph, const arg_mouse& arg)
|
||||||
{
|
{
|
||||||
// check if slider is disabled
|
// check if slider is disabled
|
||||||
if(!API::get_widget(arg.window_handle)->enabled())
|
if(!API::get_widget(arg.window_handle)->enabled())
|
||||||
return; // do nothing
|
return; // do nothing
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
if (model_ptr_->if_trace_slider())
|
if (model_ptr_->if_trace_slider())
|
||||||
{
|
{
|
||||||
@ -804,7 +804,7 @@ namespace nana
|
|||||||
|
|
||||||
//class slider
|
//class slider
|
||||||
slider::slider(){}
|
slider::slider(){}
|
||||||
|
|
||||||
slider::slider(window wd, bool visible)
|
slider::slider(window wd, bool visible)
|
||||||
{
|
{
|
||||||
create(wd, rectangle(), visible);
|
create(wd, rectangle(), visible);
|
||||||
@ -844,10 +844,14 @@ namespace nana
|
|||||||
return get_drawer_trigger().get_model()->attribute().vmax;
|
return get_drawer_trigger().get_model()->attribute().vmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slider::value(unsigned v)
|
void slider::value(int v)
|
||||||
{
|
{
|
||||||
if(handle())
|
if(handle())
|
||||||
{
|
{
|
||||||
|
// limit to positive values, vcur expects unsigned
|
||||||
|
if( v < 0 )
|
||||||
|
v = 0;
|
||||||
|
|
||||||
if(get_drawer_trigger().get_model()->vcur(v))
|
if(get_drawer_trigger().get_model()->vcur(v))
|
||||||
API::refresh_window(handle());
|
API::refresh_window(handle());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user