2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// DateTimeComponent.h
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Provides the date and time, in absolute (actual date) or relative
|
|
|
|
// (delta from current date and time) form.
|
|
|
|
// Used by the gamelist views.
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
#include "TextComponent.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "utils/TimeUtil.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
class ThemeData;
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2020-06-06 20:04:05 +00:00
|
|
|
// Used to display date and time.
|
2018-10-13 01:08:15 +00:00
|
|
|
class DateTimeComponent : public TextComponent
|
2013-09-28 22:35:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-19 17:01:54 +00:00
|
|
|
DateTimeComponent();
|
|
|
|
DateTimeComponent(const std::string& text,
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::shared_ptr<Font>& font,
|
|
|
|
unsigned int color = 0x000000FF,
|
2022-09-24 19:37:00 +00:00
|
|
|
Alignment horizontalAlignment = ALIGN_LEFT,
|
|
|
|
glm::vec3 pos = {0.0f, 0.0f, 0.0f},
|
|
|
|
glm::vec2 size = {0.0f, 0.0f},
|
2021-07-07 18:31:46 +00:00
|
|
|
unsigned int bgcolor = 0x00000000);
|
2014-03-21 16:10:19 +00:00
|
|
|
|
2021-08-15 17:30:31 +00:00
|
|
|
void render(const glm::mat4& parentTrans) override;
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void setValue(const std::string& val) override;
|
|
|
|
std::string getValue() const override;
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void setFormat(const std::string& format);
|
|
|
|
void setDisplayRelative(bool displayRelative);
|
2013-10-16 23:11:43 +00:00
|
|
|
|
2022-01-18 16:40:47 +00:00
|
|
|
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties) override;
|
2014-01-19 22:06:13 +00:00
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
protected:
|
2020-06-21 12:25:28 +00:00
|
|
|
void onTextChanged() override;
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string getDisplayString() const;
|
2013-09-28 22:35:38 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
Utils::Time::DateTime mTime;
|
|
|
|
std::string mFormat;
|
|
|
|
bool mDisplayRelative;
|
2013-09-28 22:35:38 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
|