mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 19:13:40 +01:00
UI: Add a simple tween class.
This commit is contained in:
1 parent
7ab3e58dec
commit
b4b850bce8
8 files changed
+168
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#include "base/colorutil.h"
|
||||
#include "ui/ui_tween.h"
|
||||
#include "ui/view.h"
|
||||
|
||||
namespace UI {
|
||||
|
||||
uint32_t ColorTween::Current() {
|
||||
return colorBlend(to_, from_, Position());
|
||||
}
|
||||
|
||||
void TextColorTween::Apply(View *view) {
|
||||
// TODO: No validation without RTTI?
|
||||
TextView *tv = (TextView *)view;
|
||||
tv->SetTextColor(Current());
|
||||
}
|
||||
|
||||
void VisibilityTween::Apply(View *view) {
|
||||
view->SetVisibility(Current());
|
||||
}
|
||||
|
||||
Visibility VisibilityTween::Current() {
|
||||
// Prefer V_VISIBLE over V_GONE/V_INVISIBLE.
|
||||
float p = Position();
|
||||
if (from_ == V_VISIBLE && p < 1.0f)
|
||||
return from_;
|
||||
if (to_ == V_VISIBLE && p > 0.0f)
|
||||
return to_;
|
||||
return p >= 1.0f ? to_ : from_;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in new issue
Block a user