xemu/ui/xui/animation.hh
Matt Borgerson 9c06980275 ui: Redesign user interface
Introduces a new user interface that looks much nicer, is easier to
navigate with controllers, provides more context to users, and is
scalable. Some additional features are included.

* Adds 'popup menu' with actions that can be used easily from controller
* Adds 'main menu', unifying other configuration dialogs
* Adds port-forwarding user interface
* Adds screenshot feature
* Adds volume control feature
* Adds gamepad auto-bind option
* Adds vsync configuration option
* Adds auto UI scaling
* Adds preferred window size selection
* Adds AV pack selection
* Exposes some existing config items in GUI
2022-05-07 16:09:34 -07:00

74 lines
1.9 KiB
C++

//
// xemu User Interface
//
// Copyright (C) 2020-2022 Matt Borgerson
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#pragma once
#include "common.hh"
const ImVec2 EASE_VECTOR_DOWN = ImVec2(0, -25);
const ImVec2 EASE_VECTOR_LEFT = ImVec2(25, 0);
const ImVec2 EASE_VECTOR_RIGHT = ImVec2(-25, 0);
enum AnimationState
{
PreEasingIn,
EasingIn,
Idle,
EasingOut,
PostEasingOut
};
// Step a value from 0 to 1 over some duration of time.
class Animation
{
protected:
float m_duration;
float m_acc;
public:
Animation(float duration = 0);
void Reset();
void SetDuration(float duration);
void Step();
bool IsComplete();
float GetLinearValue();
void SetLinearValue(float t);
float GetSinInterpolatedValue();
};
// Stateful animation sequence for easing in and out: 0->1->0
class EasingAnimation
{
protected:
AnimationState m_state;
Animation m_animation;
float m_duration_out;
float m_duration_in;
public:
EasingAnimation(float ease_in_duration = 1.0, float ease_out_duration = 1.0);
void EaseIn();
void EaseIn(float duration);
void EaseOut();
void EaseOut(float duration);
void Step();
float GetLinearValue();
float GetSinInterpolatedValue();
bool IsAnimating();
bool IsComplete();
};