uses std::chrono
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Implementation of Notifier
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -351,13 +351,14 @@ namespace nana
|
||||
#endif
|
||||
}
|
||||
|
||||
void notifier::period(unsigned ms)
|
||||
void notifier::period(std::chrono::milliseconds ms)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if (ms && impl_->icons.size())
|
||||
if (ms.count() && impl_->icons.size())
|
||||
{
|
||||
ms /= static_cast<unsigned>(impl_->icons.size());
|
||||
impl_->ani_timer.interval(ms < 16 ? 16 : ms);
|
||||
auto frame_ms = (std::max)(ms.count() / static_cast<long long>(impl_->icons.size()), static_cast<long long>(16));
|
||||
|
||||
impl_->ani_timer.interval(std::chrono::milliseconds{frame_ms});
|
||||
impl_->ani_timer.start();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Timer Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -174,6 +174,12 @@ namespace nana
|
||||
: impl_(new implement)
|
||||
{
|
||||
}
|
||||
|
||||
timer::timer(std::chrono::milliseconds ms):
|
||||
timer()
|
||||
{
|
||||
this->interval(ms);
|
||||
}
|
||||
|
||||
timer::~timer()
|
||||
{
|
||||
@@ -220,17 +226,17 @@ namespace nana
|
||||
timer_driver::instance().destroy(tmid);
|
||||
}
|
||||
|
||||
void timer::interval_(unsigned ms)
|
||||
void timer::interval(std::chrono::milliseconds ms)
|
||||
{
|
||||
if (ms != impl_->interval)
|
||||
if (ms.count() != static_cast<long long>(impl_->interval))
|
||||
{
|
||||
impl_->interval = ms;
|
||||
impl_->interval = static_cast<unsigned>(ms.count());
|
||||
if (impl_->tm_core)
|
||||
impl_->tm_core->interval(ms);
|
||||
impl_->tm_core->interval(impl_->interval);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned timer::interval() const
|
||||
unsigned timer::_m_interval() const
|
||||
{
|
||||
return impl_->interval;
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ namespace nana
|
||||
timer_.reset();
|
||||
if (duration_)
|
||||
{
|
||||
timer_.interval(static_cast<unsigned>(duration_));
|
||||
timer_.interval(std::chrono::milliseconds{ duration_ });
|
||||
timer_.elapse(std::bind(&tip_form::_m_tick_duration, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
timer_.interval(500);
|
||||
timer_.interval(std::chrono::milliseconds{ 500 });
|
||||
timer_.elapse(std::bind(&tip_form::_m_tick, this));
|
||||
}
|
||||
timer_.start();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Menu implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2009-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2009-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -819,7 +819,7 @@ namespace nana
|
||||
events.mouse_down.connect_unignorable(fn);
|
||||
events.mouse_up.connect_unignorable(fn);
|
||||
|
||||
timer_.interval(100);
|
||||
timer_.interval(std::chrono::milliseconds{ 100 });
|
||||
timer_.elapse([this]{
|
||||
this->_m_open_sub(500); //Try to open submenu
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Content View Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2017-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2017-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -132,7 +132,7 @@ namespace nana {
|
||||
}
|
||||
else if (this->drag_view_move && this->drive(arg.pos))
|
||||
{
|
||||
tmr.interval(16);
|
||||
tmr.interval(std::chrono::milliseconds{ 16 });
|
||||
tmr.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,11 +275,11 @@ namespace nana
|
||||
API::update_window(editor_->window_handle());
|
||||
|
||||
auto intv = timer_.interval();
|
||||
if (intv > 50)
|
||||
if (intv.count() > 50)
|
||||
timer_.interval(intv / 2);
|
||||
});
|
||||
|
||||
timer_.interval(600);
|
||||
timer_.interval(std::chrono::milliseconds{ 600 });
|
||||
}
|
||||
|
||||
void attach(::nana::widget& wdg, ::nana::paint::graphics& graph)
|
||||
@@ -396,7 +396,7 @@ namespace nana
|
||||
API::release_capture(editor_->window_handle());
|
||||
|
||||
timer_.stop();
|
||||
timer_.interval(600);
|
||||
timer_.interval(std::chrono::milliseconds{ 600 });
|
||||
}
|
||||
|
||||
if (buttons::none != spin_stated_)
|
||||
|
||||
@@ -1735,7 +1735,7 @@ namespace nana
|
||||
}
|
||||
});
|
||||
|
||||
impl_->adjust.timer.interval(16);
|
||||
impl_->adjust.timer.interval(std::chrono::milliseconds{ 16 });
|
||||
impl_->adjust.timer.start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user