demotool/ui-sync.hh

60 lines
1.6 KiB
C++
Raw Permalink Normal View History

#pragma once
#include "c-sync.hh"
#include "ui-mousectrl.hh"
namespace sov { class A_SyncData; }
class T_UISync : public A_MouseCtrl
{
public:
T_UISync( );
~T_UISync( );
//----------------------------------------------------------------------
bool& overridesWindowEnabled( ) noexcept
{ return ovWindow_; }
void makeOverridesWindow( );
using F_Override = std::function<
bool( A_SyncOverride& , sov::A_SyncData& , uint32_t& ,
T_StringBuilder& ) >;
F_Override uiFor( A_SyncOverride& target ) const noexcept;
//----------------------------------------------------------------------
void updateTime( ) noexcept;
//----------------------------------------------------------------------
void delegateMouse( T_String const& id ,
P_MouseCtrl delegate ) noexcept;
void clearMouseDelegate( ) noexcept;
bool isCurrentDelegate( T_String const& delegate ) noexcept
{ return mouseDelegateName_ == delegate; }
//----------------------------------------------------------------------
void handleDragAndDrop(
ImVec2 const& move ,
T_KbdMods modifiers ,
T_MouseButtons buttons ) noexcept override;
void handleWheel(
float wheel ,
T_KbdMods modifiers ,
T_MouseButtons buttons ) noexcept override;
private:
bool ovWindow_{ false }; // Overrides window open
T_KeyValueTable< T_String , F_Override > sovuis_; // Override UI table
T_String mouseDelegateName_{ }; // Name and pointer for mouse delegation
T_OwnPtr< A_MouseCtrl > mouseDelegate_{ };
bool playingPrevious_{ false }; // Was it playing before?
float lastFrame_{ 0 }; // Time of last frame
};