overlays/osk: Add linear fade-in/out effect to OSK

This commit is contained in:
kd-11 2020-01-07 17:12:32 +03:00 committed by kd-11
parent ecf00be155
commit 3f34a0196c
2 changed files with 38 additions and 9 deletions

View file

@ -1,11 +1,18 @@
#include "stdafx.h" #include "stdafx.h"
#include "overlays.h" #include "overlays.h"
#include "Emu/RSX/RSXThread.h"
namespace rsx namespace rsx
{ {
namespace overlays namespace overlays
{ {
void osk_dialog::Close(bool ok) void osk_dialog::Close(bool ok)
{
fade_animation.current = color4f(1.f);
fade_animation.end = color4f(0.f);
fade_animation.duration = 0.5f;
fade_animation.on_finish = [this, ok]
{ {
if (on_osk_close) if (on_osk_close)
{ {
@ -17,6 +24,9 @@ namespace rsx
m_visible = false; m_visible = false;
close(); close();
};
fade_animation.active = true;
} }
void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text) void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text)
@ -172,6 +182,11 @@ namespace rsx
m_update = true; m_update = true;
exit = false; exit = false;
fade_animation.current = color4f(0.f);
fade_animation.end = color4f(1.f);
fade_animation.duration = 0.5f;
fade_animation.active = true;
thread_ctrl::spawn("osk input thread", [this] thread_ctrl::spawn("osk input thread", [this]
{ {
if (auto error = run_input_loop()) if (auto error = run_input_loop())
@ -469,6 +484,15 @@ namespace rsx
} }
} }
void osk_dialog::update()
{
if (fade_animation.active)
{
fade_animation.update(rsx::get_current_renderer()->vblank_count);
m_update = true;
}
}
compiled_resource osk_dialog::get_compiled() compiled_resource osk_dialog::get_compiled()
{ {
if (!m_visible) if (!m_visible)
@ -565,6 +589,7 @@ namespace rsx
m_update = false; m_update = false;
} }
fade_animation.apply(m_cached_resource);
return m_cached_resource; return m_cached_resource;
} }

View file

@ -394,6 +394,9 @@ namespace rsx
std::vector<cell> m_grid; std::vector<cell> m_grid;
// Fade in/out
animation_color_interpolate fade_animation;
bool m_visible = false; bool m_visible = false;
bool m_update = true; bool m_update = true;
compiled_resource m_cached_resource; compiled_resource m_cached_resource;
@ -408,6 +411,7 @@ namespace rsx
void Close(bool ok) override; void Close(bool ok) override;
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text); void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text);
void update() override;
void on_button_pressed(pad_button button_press) override; void on_button_pressed(pad_button button_press) override;
void on_text_changed(); void on_text_changed();