From fe9648fa1cdc8f9cf5216a88fadb8b96604047fd Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 3 Apr 2015 20:27:27 +0200 Subject: base/time: Replaces by std::chrono. --- src/menu/mouse_event.cpp | 8 ++++---- src/menu/software_mouse_pointer.cpp | 2 +- src/menu/timer.cpp | 2 +- src/menu/timer.hpp | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/menu') diff --git a/src/menu/mouse_event.cpp b/src/menu/mouse_event.cpp index 814e179c..3f4104a0 100644 --- a/src/menu/mouse_event.cpp +++ b/src/menu/mouse_event.cpp @@ -25,7 +25,6 @@ #include #include "mouse_event.hpp" -#include "base/time.hpp" namespace usdx { @@ -49,16 +48,17 @@ namespace usdx { if (direction == UP) { if (this->direction == DOWN) { - if (time.since(5000)) + if (time.since(std::chrono::milliseconds{5000})) return CLICK; } else if (this->direction == CLICK) { - if (time.since(5000)) + if (time.since(std::chrono::milliseconds{5000})) return DBL_CLICK; } } else if (direction == DOWN) { - if (this->direction == CLICK && time.since(5000)) + if (this->direction == CLICK && + time.since(std::chrono::milliseconds{5000})) return CLICK; } } diff --git a/src/menu/software_mouse_pointer.cpp b/src/menu/software_mouse_pointer.cpp index 39ee1318..2708917c 100644 --- a/src/menu/software_mouse_pointer.cpp +++ b/src/menu/software_mouse_pointer.cpp @@ -34,7 +34,7 @@ namespace usdx SoftwareMousePointer::SoftwareMousePointer(Container* parent, EventManager* event_manager) : DrawableControl(parent), color(255,255,255,100), down(false) { - fade_inactive = new Timer(this, 2, true); + fade_inactive = new Timer(this, std::chrono::seconds{2}, true); this->vertices[0] = 0.0f; this->vertices[1] = 40.0f; diff --git a/src/menu/timer.cpp b/src/menu/timer.cpp index 567860c2..884b8548 100644 --- a/src/menu/timer.cpp +++ b/src/menu/timer.cpp @@ -26,7 +26,7 @@ namespace usdx { - Timer::Timer(Control* owner, float duration, bool init) : + Timer::Timer(Control* owner, std::chrono::milliseconds duration, bool init) : Control(owner), duration(duration), ready(init), last_update() { } diff --git a/src/menu/timer.hpp b/src/menu/timer.hpp index d2cd700b..fc595dc7 100644 --- a/src/menu/timer.hpp +++ b/src/menu/timer.hpp @@ -25,7 +25,8 @@ #ifndef TIMER_HPP #define TIMER_HPP -#include +#include + #include "control.hpp" #include "base/timestamp.hpp" @@ -34,13 +35,13 @@ namespace usdx class Timer : public Control { private: - float duration; + std::chrono::milliseconds duration; bool ready; Timestamp last_update; public: - Timer(Control*, float, bool = false); + Timer(Control*, std::chrono::milliseconds, bool = false); virtual ~Timer(); void update(void); -- cgit v1.2.3