2020-09-17 20:00:07 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-28 16:39:18 +00:00
|
|
|
//
|
2020-09-17 20:00:07 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-28 16:39:18 +00:00
|
|
|
// ScrollableContainer.h
|
|
|
|
//
|
|
|
|
// Area containing scrollable information, for example the game description
|
|
|
|
// text container in the detailed, video and grid views.
|
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H
|
|
|
|
#define ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H
|
2013-07-03 01:01:58 +00:00
|
|
|
|
2021-01-17 09:17:41 +00:00
|
|
|
#define AUTO_SCROLL_DELAY 2400.0f // Time to wait before we start to scroll.
|
|
|
|
#define AUTO_SCROLL_RESET_DELAY 4000.0f // Time before resetting to top after we reach the bottom.
|
|
|
|
#define AUTO_SCROLL_SPEED 48 // Relative scrolling speed (lower is faster).
|
2021-01-05 11:52:21 +00:00
|
|
|
#define AUTO_WIDTH_MOD 350.0f // Line width modifier to use to calculate scrolling speed.
|
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "GuiComponent.h"
|
2013-07-03 01:01:58 +00:00
|
|
|
|
|
|
|
class ScrollableContainer : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-06-28 16:39:18 +00:00
|
|
|
ScrollableContainer(Window* window);
|
2013-07-03 01:01:58 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
Vector2f getScrollPos() const;
|
|
|
|
void setScrollPos(const Vector2f& pos);
|
|
|
|
void setAutoScroll(bool autoScroll);
|
2021-01-17 09:17:41 +00:00
|
|
|
void setScrollParameters(float autoScrollDelayConstant, float autoScrollResetDelayConstant,
|
2021-01-05 11:52:21 +00:00
|
|
|
int autoScrollSpeedConstant, float autoWidthModConstant) override;
|
2020-06-28 16:39:18 +00:00
|
|
|
void reset();
|
2013-07-03 01:01:58 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
void update(int deltaTime) override;
|
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
2013-07-03 01:01:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-28 16:39:18 +00:00
|
|
|
Vector2f getContentSize();
|
|
|
|
|
|
|
|
Vector2f mScrollPos;
|
|
|
|
Vector2f mScrollDir;
|
2021-01-05 11:52:21 +00:00
|
|
|
|
|
|
|
float mAutoScrollResetDelayConstant;
|
|
|
|
float mAutoScrollDelayConstant;
|
|
|
|
int mAutoScrollSpeedConstant;
|
|
|
|
float mAutoWidthModConstant;
|
|
|
|
|
2021-01-02 20:17:23 +00:00
|
|
|
float mResolutionModifier;
|
|
|
|
int mAutoScrollDelay;
|
|
|
|
int mAutoScrollSpeed;
|
2020-06-28 16:39:18 +00:00
|
|
|
int mAutoScrollAccumulator;
|
|
|
|
int mAutoScrollResetAccumulator;
|
2021-01-02 20:17:23 +00:00
|
|
|
bool mAtEnd;
|
2013-07-03 01:01:58 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H
|