2020-06-06 14:48:05 +00:00
|
|
|
//
|
|
|
|
// DateTimeEditComponent.h
|
|
|
|
//
|
|
|
|
// Date and time edit component.
|
|
|
|
//
|
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef ES_CORE_COMPONENTS_DATE_TIME_EDIT_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_DATE_TIME_EDIT_COMPONENT_H
|
|
|
|
|
|
|
|
#include "utils/TimeUtil.h"
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
|
|
|
|
class TextCache;
|
|
|
|
|
|
|
|
// Used to enter or display a specific point in time.
|
|
|
|
class DateTimeEditComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-06-06 14:48:05 +00:00
|
|
|
enum DisplayMode{
|
2018-10-13 01:08:15 +00:00
|
|
|
DISP_DATE,
|
|
|
|
DISP_DATE_TIME,
|
|
|
|
DISP_RELATIVE_TO_NOW
|
|
|
|
};
|
|
|
|
|
|
|
|
DateTimeEditComponent(Window* window, DisplayMode dispMode = DISP_DATE);
|
|
|
|
|
|
|
|
void setValue(const std::string& val) override;
|
|
|
|
std::string getValue() const override;
|
|
|
|
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void update(int deltaTime) override;
|
2020-06-10 17:54:37 +00:00
|
|
|
unsigned int getColor() const override { return mColor; };
|
2018-10-13 01:08:15 +00:00
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
|
|
|
void onSizeChanged() override;
|
|
|
|
|
|
|
|
// Set how the point in time will be displayed:
|
|
|
|
// * DISP_DATE - only display the date.
|
|
|
|
// * DISP_DATE_TIME - display both the date and the time on that date.
|
2020-06-06 14:48:05 +00:00
|
|
|
// * DISP_RELATIVE_TO_NOW - intelligently display the point in time relative to
|
|
|
|
// right now (e.g. "5 secs ago", "3 minutes ago", "1 day ago".
|
|
|
|
// Automatically updates as time marches on.
|
2018-10-13 01:08:15 +00:00
|
|
|
// The initial value is DISP_DATE.
|
|
|
|
void setDisplayMode(DisplayMode mode);
|
|
|
|
|
2020-06-06 14:48:05 +00:00
|
|
|
// Text color.
|
|
|
|
void setColor(unsigned int color);
|
|
|
|
// Font to use. Default is Font::get(FONT_SIZE_MEDIUM).
|
|
|
|
void setFont(std::shared_ptr<Font> font);
|
|
|
|
// Force text to be uppercase when in DISP_RELATIVE_TO_NOW mode.
|
|
|
|
void setUppercase(bool uppercase);
|
2018-10-13 01:08:15 +00:00
|
|
|
|
2020-06-06 14:48:05 +00:00
|
|
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view,
|
|
|
|
const std::string& element, unsigned int properties) override;
|
2018-10-13 01:08:15 +00:00
|
|
|
|
2020-06-09 18:03:31 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
private:
|
|
|
|
std::shared_ptr<Font> getFont() const;
|
|
|
|
|
|
|
|
std::string getDisplayString(DisplayMode mode) const;
|
|
|
|
DisplayMode getCurrentDisplayMode() const;
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2018-10-13 01:08:15 +00:00
|
|
|
void updateTextCache();
|
|
|
|
|
|
|
|
Utils::Time::DateTime mTime;
|
|
|
|
Utils::Time::DateTime mTimeBeforeEdit;
|
|
|
|
|
|
|
|
bool mEditing;
|
|
|
|
int mEditIndex;
|
|
|
|
DisplayMode mDisplayMode;
|
|
|
|
|
|
|
|
int mRelativeUpdateAccumulator;
|
|
|
|
|
|
|
|
std::unique_ptr<TextCache> mTextCache;
|
|
|
|
std::vector<Vector4f> mCursorBoxes;
|
|
|
|
|
|
|
|
unsigned int mColor;
|
|
|
|
std::shared_ptr<Font> mFont;
|
|
|
|
bool mUppercase;
|
|
|
|
bool mAutoSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_DATE_TIME_COMPONENT_H
|