use lambda instead of std::bind
This commit is contained in:
parent
90533b3a83
commit
2f47e89af1
@ -88,8 +88,8 @@ namespace drawerbase
|
||||
std::size_t checked() const; ///< Retrieves the index of the checkbox which is checked.
|
||||
std::size_t size() const;
|
||||
private:
|
||||
void _m_checked(const arg_click&);
|
||||
void _m_destroy(const arg_destroy&);
|
||||
//void _m_checked(const arg_click&); //deprecated
|
||||
//void _m_destroy(const arg_destroy&); //deprecated
|
||||
private:
|
||||
std::vector<element_tag> ui_container_;
|
||||
};
|
||||
|
@ -167,7 +167,7 @@ namespace nana
|
||||
void key_press(graph_reference, const arg_keyboard&) override;
|
||||
void key_char(graph_reference, const arg_keyboard&) override;
|
||||
private:
|
||||
void _m_deal_adjust();
|
||||
//void _m_deal_adjust(); //deprecated
|
||||
private:
|
||||
implement * const impl_;
|
||||
}; //end class trigger
|
||||
|
@ -65,7 +65,66 @@ namespace nana
|
||||
{
|
||||
trigger_t tg;
|
||||
tg.wd = wd;
|
||||
auto fn = std::bind(&dragger_impl_t::_m_trace, this, std::placeholders::_1);
|
||||
//auto fn = std::bind(&dragger_impl_t::_m_trace, this, std::placeholders::_1); //deprecated
|
||||
auto fn = [this](const arg_mouse& arg)
|
||||
{
|
||||
switch (arg.evt_code)
|
||||
{
|
||||
case event_code::mouse_down:
|
||||
dragging_ = true;
|
||||
API::capture_window(arg.window_handle, true);
|
||||
origin_ = API::cursor_position();
|
||||
for (auto & t : targets_)
|
||||
{
|
||||
t.origin = API::window_position(t.wd);
|
||||
window owner = API::get_owner_window(t.wd);
|
||||
if (owner)
|
||||
API::calc_screen_point(owner, t.origin);
|
||||
}
|
||||
break;
|
||||
case event_code::mouse_move:
|
||||
if (dragging_ && arg.left_button)
|
||||
{
|
||||
auto pos = API::cursor_position();
|
||||
pos -= origin_;
|
||||
|
||||
for (auto & t : targets_)
|
||||
{
|
||||
if (API::is_window_zoomed(t.wd, true) == false)
|
||||
{
|
||||
auto owner = API::get_owner_window(t.wd);
|
||||
auto wdps = t.origin;
|
||||
if (owner)
|
||||
API::calc_window_point(owner, wdps);
|
||||
|
||||
switch (t.move_direction)
|
||||
{
|
||||
case nana::arrange::horizontal:
|
||||
wdps.x += pos.x;
|
||||
break;
|
||||
case nana::arrange::vertical:
|
||||
wdps.y += pos.y;
|
||||
break;
|
||||
default:
|
||||
wdps += pos;
|
||||
}
|
||||
|
||||
if (!t.restrict_area.empty())
|
||||
_m_check_restrict_area(wdps, API::window_size(t.wd), t.restrict_area);
|
||||
|
||||
API::move_window(t.wd, wdps);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case event_code::mouse_up:
|
||||
API::capture_window(arg.window_handle, false);
|
||||
dragging_ = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
auto & events = API::events(wd);
|
||||
tg.press = events.mouse_down.connect(fn);
|
||||
tg.over = events.mouse_move.connect(fn);
|
||||
@ -117,8 +176,8 @@ namespace nana
|
||||
if (pos.y < restr_area.y)
|
||||
pos.y = restr_area.y;
|
||||
}
|
||||
|
||||
void _m_trace(const arg_mouse& arg)
|
||||
/*
|
||||
void _m_trace(const arg_mouse& arg) //deprecated
|
||||
{
|
||||
switch(arg.evt_code)
|
||||
{
|
||||
@ -177,7 +236,7 @@ namespace nana
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
private:
|
||||
bool dragging_;
|
||||
nana::point origin_;
|
||||
|
@ -147,7 +147,6 @@ namespace nana
|
||||
timer_.reset();
|
||||
this->close();
|
||||
}
|
||||
|
||||
private:
|
||||
timer timer_;
|
||||
nana::label label_;
|
||||
@ -256,7 +255,8 @@ namespace nana
|
||||
instance(true);
|
||||
}
|
||||
private:
|
||||
void _m_enter(const arg_mouse& arg)
|
||||
/*
|
||||
void _m_enter(const arg_mouse& arg) //deprecated
|
||||
{
|
||||
pair_t & pr = _m_get(arg.window_handle);
|
||||
if(pr.second.size())
|
||||
@ -264,16 +264,21 @@ namespace nana
|
||||
this->show(pr.second);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void _m_leave(const arg_mouse&)
|
||||
/*
|
||||
void _m_leave(const arg_mouse&) //deprecated
|
||||
{
|
||||
close();
|
||||
}
|
||||
*/
|
||||
|
||||
void _m_destroy(const arg_destroy& arg)
|
||||
/*
|
||||
void _m_destroy(const arg_destroy& arg) //deprecated
|
||||
{
|
||||
_m_untip(arg.window_handle);
|
||||
}
|
||||
*/
|
||||
|
||||
void _m_untip(window wd)
|
||||
{
|
||||
@ -303,15 +308,21 @@ namespace nana
|
||||
|
||||
auto & events = API::events(wd);
|
||||
events.mouse_enter.connect([this](const arg_mouse& arg){
|
||||
_m_enter(arg);
|
||||
auto & pr = _m_get(arg.window_handle);
|
||||
if (pr.second.size())
|
||||
this->show(pr.second);
|
||||
});
|
||||
|
||||
auto leave_fn = std::bind(&controller::_m_leave, this, std::placeholders::_1);
|
||||
//auto leave_fn = std::bind(&controller::_m_leave, this, std::placeholders::_1); //deprecated
|
||||
|
||||
auto leave_fn = [this]{
|
||||
this->close();
|
||||
};
|
||||
events.mouse_leave.connect(leave_fn);
|
||||
events.mouse_down.connect(leave_fn);
|
||||
|
||||
events.destroy.connect([this](const arg_destroy& arg){
|
||||
_m_destroy(arg);
|
||||
_m_untip(arg.window_handle);
|
||||
});
|
||||
|
||||
cont_.emplace_back(wd, nana::string());
|
||||
|
@ -213,8 +213,35 @@ namespace checkbox
|
||||
element_tag el;
|
||||
|
||||
el.uiobj = &uiobj;
|
||||
el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true);
|
||||
el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1));
|
||||
//el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true); //deprecated
|
||||
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
|
||||
{
|
||||
for (auto & i : ui_container_)
|
||||
i.uiobj->check(arg.window_handle == i.uiobj->handle());
|
||||
}, true);
|
||||
|
||||
//el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1)); //deprecated
|
||||
el.eh_destroy = uiobj.events().destroy.connect_unignorable([this](const arg_destroy& arg)
|
||||
{
|
||||
/*
|
||||
auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x)
|
||||
{
|
||||
return (arg.window_handle == x.uiobj->handle());
|
||||
});
|
||||
if (i != ui_container_.end())
|
||||
ui_container_.erase(i);
|
||||
*/
|
||||
|
||||
for (auto i = ui_container_.begin(); i != ui_container_.end(); ++i)
|
||||
{
|
||||
if (arg.window_handle == i->uiobj->handle())
|
||||
{
|
||||
ui_container_.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ui_container_.push_back(el);
|
||||
}
|
||||
|
||||
@ -231,14 +258,16 @@ namespace checkbox
|
||||
{
|
||||
return ui_container_.size();
|
||||
}
|
||||
|
||||
void radio_group::_m_checked(const arg_click& arg)
|
||||
/*
|
||||
void radio_group::_m_checked(const arg_click& arg) //deprecated
|
||||
{
|
||||
for (auto & i : ui_container_)
|
||||
i.uiobj->check(arg.window_handle == i.uiobj->handle());
|
||||
}
|
||||
*/
|
||||
|
||||
void radio_group::_m_destroy(const arg_destroy& arg)
|
||||
/*
|
||||
void radio_group::_m_destroy(const arg_destroy& arg) //deprecated
|
||||
{
|
||||
auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x)
|
||||
{
|
||||
@ -247,5 +276,6 @@ namespace checkbox
|
||||
if(i != ui_container_.end())
|
||||
ui_container_.erase(i);
|
||||
}
|
||||
*/
|
||||
//end class radio_group
|
||||
}//end namespace nana
|
||||
|
@ -172,10 +172,31 @@ namespace nana
|
||||
{
|
||||
editor_->editable(enb);
|
||||
|
||||
/*
|
||||
if(enb)
|
||||
editor_->ext_renderer().background = nullptr;
|
||||
else
|
||||
editor_->ext_renderer().background = std::bind(&drawer_impl::_m_draw_background, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
editor_->ext_renderer().background = std::bind(&drawer_impl::_m_draw_background, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); //deprecated
|
||||
*/
|
||||
if (!enb)
|
||||
{
|
||||
editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&)
|
||||
{
|
||||
auto clr_from = colors::button_face_shadow_start;
|
||||
auto clr_to = colors::button_face_shadow_end;
|
||||
|
||||
int pare_off_px = 1;
|
||||
if (element_state::pressed == state_.button_state)
|
||||
{
|
||||
pare_off_px = 2;
|
||||
std::swap(clr_from, clr_to);
|
||||
}
|
||||
|
||||
graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true);
|
||||
};
|
||||
}
|
||||
else
|
||||
editor_->ext_renderer().background = nullptr;
|
||||
|
||||
editor_->enable_background(enb);
|
||||
editor_->enable_background_counterpart(!enb);
|
||||
@ -433,8 +454,8 @@ namespace nana
|
||||
API::refresh_window(*widget_);
|
||||
}
|
||||
}
|
||||
|
||||
void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&)
|
||||
/*
|
||||
void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&) //deprecated
|
||||
{
|
||||
auto clr_from = colors::button_face_shadow_start;
|
||||
auto clr_to = colors::button_face_shadow_end;
|
||||
@ -448,7 +469,7 @@ namespace nana
|
||||
|
||||
graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true);
|
||||
}
|
||||
|
||||
*/
|
||||
void _m_draw_push_button(bool enabled)
|
||||
{
|
||||
::nana::rectangle r{graph_->size()};
|
||||
|
@ -767,20 +767,28 @@ namespace nana
|
||||
{
|
||||
menulister_.clear();
|
||||
|
||||
auto f = std::bind(&layouter::_m_click_menulister, this, std::placeholders::_1);
|
||||
//auto f = std::bind(&layouter::_m_click_menulister, this, std::placeholders::_1); //deprecated
|
||||
auto fn = [this](::nana::menu::item_proxy& ipx)
|
||||
{
|
||||
if (this->activate(ipx.index()))
|
||||
API::refresh_window(basis_.wd);
|
||||
};
|
||||
|
||||
for(auto & m : list_)
|
||||
menulister_.append(m.text, f);
|
||||
menulister_.append(m.text, fn);
|
||||
|
||||
auto r = toolbox_.area(toolbox_.ButtonList, basis_.graph->height());
|
||||
r.x += _m_toolbox_pos();
|
||||
menulister_.popup(basis_.wd, r.x, r.bottom());
|
||||
}
|
||||
|
||||
void _m_click_menulister(nana::menu::item_proxy& ip)
|
||||
/*
|
||||
void _m_click_menulister(nana::menu::item_proxy& ip) //deprecated
|
||||
{
|
||||
if(this->activate(ip.index()))
|
||||
API::refresh_window(basis_.wd);
|
||||
}
|
||||
*/
|
||||
|
||||
//the begin pos of toolbox
|
||||
int _m_toolbox_pos() const
|
||||
|
@ -1491,7 +1491,60 @@ namespace nana
|
||||
impl_->data.trigger_ptr = this;
|
||||
impl_->data.renderer = nana::pat::cloneable<renderer_interface>(internal_renderer());
|
||||
impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer());
|
||||
impl_->adjust.timer.elapse(std::bind(&trigger::_m_deal_adjust, this));
|
||||
//impl_->adjust.timer.elapse(std::bind(&trigger::_m_deal_adjust, this)); //deprecated
|
||||
impl_->adjust.timer.elapse([this]
|
||||
{
|
||||
auto & adjust = impl_->adjust;
|
||||
if (adjust.scroll_timestamp && (nana::system::timestamp() - adjust.scroll_timestamp >= 500))
|
||||
{
|
||||
if (0 == adjust.offset_x_adjust)
|
||||
{
|
||||
if (!impl_->make_adjust(adjust.node ? adjust.node : impl_->shape.first, 1))
|
||||
{
|
||||
adjust.offset_x_adjust = 0;
|
||||
adjust.node = nullptr;
|
||||
adjust.scroll_timestamp = 0;
|
||||
adjust.timer.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto & shape = impl_->shape;
|
||||
const int delta = 5;
|
||||
int old = shape.offset_x;
|
||||
|
||||
if (shape.offset_x < adjust.offset_x_adjust)
|
||||
{
|
||||
shape.offset_x += delta;
|
||||
if (shape.offset_x > adjust.offset_x_adjust)
|
||||
shape.offset_x = adjust.offset_x_adjust;
|
||||
}
|
||||
else if (shape.offset_x > adjust.offset_x_adjust)
|
||||
{
|
||||
shape.offset_x -= delta;
|
||||
if (shape.offset_x < adjust.offset_x_adjust)
|
||||
shape.offset_x = adjust.offset_x_adjust;
|
||||
}
|
||||
|
||||
impl_->draw(false);
|
||||
API::update_window(impl_->data.widget_ptr->handle());
|
||||
|
||||
if (impl_->node_state.tooltip)
|
||||
{
|
||||
nana::point pos = impl_->node_state.tooltip->pos();
|
||||
impl_->node_state.tooltip->move(pos.x - shape.offset_x + old, pos.y);
|
||||
}
|
||||
|
||||
if (shape.offset_x == adjust.offset_x_adjust)
|
||||
{
|
||||
adjust.offset_x_adjust = 0;
|
||||
adjust.node = nullptr;
|
||||
adjust.scroll_timestamp = 0;
|
||||
adjust.timer.stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
impl_->adjust.timer.interval(16);
|
||||
impl_->adjust.timer.start();
|
||||
}
|
||||
@ -2099,7 +2152,8 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void trigger::_m_deal_adjust()
|
||||
/*
|
||||
void trigger::_m_deal_adjust() //deprecated
|
||||
{
|
||||
auto & adjust = impl_->adjust;
|
||||
if(adjust.scroll_timestamp && (nana::system::timestamp() - adjust.scroll_timestamp >= 500))
|
||||
@ -2151,6 +2205,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
}
|
||||
//*/
|
||||
//end class trigger
|
||||
}//end namespace treebox
|
||||
}//end namespace drawerbase
|
||||
|
Loading…
x
Reference in New Issue
Block a user