demotool/ui-sync.hh
2017-11-23 23:38:05 +01:00

55 lines
1.3 KiB
C++

#pragma once
#include "c-sync.hh"
#include "ui-mousectrl.hh"
class T_UISync : public A_MouseCtrl
{
public:
using F_Override = std::function<
void( A_SyncOverride& , uint32_t& , T_StringBuilder& ) >;
T_UISync( );
bool& overridesWindowEnabled( ) noexcept
{ return ovWindow_; }
void makeOverridesWindow( );
F_Override uiFor( A_SyncOverride& target ) const noexcept;
//----------------------------------------------------------------------
void delegateMouse( T_String const& id ,
P_MouseCtrl delegate ) noexcept
{
mouseDelegateName_ = id;
mouseDelegate_ = std::move( delegate );
}
void clearMouseDelegate( ) noexcept
{
mouseDelegateName_ = T_String{ };
mouseDelegate_ = P_MouseCtrl{ };
}
bool isCurrentDelegate( T_String const& delegate ) noexcept
{ return mouseDelegateName_ == delegate; }
//----------------------------------------------------------------------
void handleDragAndDrop(
ImVec2 const& move ,
T_KeyboardModifiers modifiers ,
T_MouseButtons buttons ) noexcept override;
void handleWheel(
float wheel ,
T_KeyboardModifiers modifiers ,
T_MouseButtons buttons ) noexcept override;
private:
bool ovWindow_{ false };
T_String mouseDelegateName_{ };
T_OwnPtr< A_MouseCtrl > mouseDelegate_{ };
T_KeyValueTable< T_String , F_Override > sovuis_;
};