Sequencer - Toolbar code clean-up

This commit is contained in:
Emmanuel BENOîT 2017-11-22 16:17:24 +01:00
parent fc75f81ff3
commit c2860a7d02

View file

@ -11,7 +11,7 @@ using namespace ebcl;
namespace { namespace {
/*= FAKE TABS HELPER =========================================================*/ /*= VARIOUS IMGUI HELPERS ====================================================*/
bool FakeTab_( bool FakeTab_(
char const* const name , char const* const name ,
@ -32,6 +32,29 @@ bool FakeTab_(
return rv; return rv;
} }
void ToolbarSeparator_( ) noexcept
{
using namespace ImGui;
SameLine( );
VerticalSeparator( );
SameLine( );
}
bool ToolbarButton_(
char const* const string ,
ImVec2 const& size ,
char const* const tooltip = nullptr ) noexcept
{
using namespace ImGui;
const bool rv{ Button( string , size ) };
if ( tooltip && IsItemHovered( ) ) {
BeginTooltip( );
Text( tooltip );
EndTooltip( );
}
return rv;
}
/*= T_ChangeDurationDialog_ ==================================================*/ /*= T_ChangeDurationDialog_ ==================================================*/
@ -145,6 +168,8 @@ struct T_SyncViewImpl_
bool display( ) noexcept; bool display( ) noexcept;
void displayToolbar( ) noexcept;
void computeMetrics( float innerWidth ) noexcept; void computeMetrics( float innerWidth ) noexcept;
void sequencerWidget( ) noexcept; void sequencerWidget( ) noexcept;
void sequencerHeader( ImRect const& bb ) noexcept; void sequencerHeader( ImRect const& bb ) noexcept;
@ -192,7 +217,6 @@ bool T_SyncViewImpl_::display( ) noexcept
{ {
using namespace ImGui; using namespace ImGui;
auto const& dspSize( GetIO( ).DisplaySize ); auto const& dspSize( GetIO( ).DisplaySize );
auto& sync( Globals::Sync( ) );
// Window set-up // Window set-up
SetNextWindowSize( ImVec2( dspSize.x , dspSize.y * .34f ) , ImGuiSetCond_Appearing ); SetNextWindowSize( ImVec2( dspSize.x , dspSize.y * .34f ) , ImGuiSetCond_Appearing );
@ -205,86 +229,7 @@ bool T_SyncViewImpl_::display( ) noexcept
return false; return false;
} }
//---------------------------------------------------------------------- displayToolbar( );
// Toolbar
if ( Button( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ) ) {
sync.playing( ) = !sync.playing( ) && !sync.finished( );
}
if ( IsItemHovered( ) ) {
BeginTooltip( );
Text( sync.playing( ) ? "Stop" : "Play" );
EndTooltip( );
}
SameLine( );
if ( Button( ICON_FA_BACKWARD , BtSize ) ) {
sync.setTime( 0 );
}
if ( IsItemHovered( ) ) {
BeginTooltip( );
Text( "Rewind to 00:00.000" );
EndTooltip( );
}
SameLine( );
VerticalSeparator( );
SameLine( );
Text( ICON_FA_SEARCH );
bool zoomHovered{ IsItemHovered( ) };
SameLine( );
PushItemWidth( 100 );
SliderFloat( "##zoom" , &zoomLevel , 0 , 1 , "%.2f" );
if ( zoomHovered || IsItemHovered( ) ) {
BeginTooltip( );
Text( "Zoom level" );
EndTooltip( );
}
PopItemWidth( );
SameLine( );
if ( Button( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ) ) {
followTime = !followTime;
}
if ( IsItemHovered( ) ) {
BeginTooltip( );
Text( followTime ? "Follows the current position.\nClick to untie."
: "Not tied to the current position.\nClick to follow." );
EndTooltip( );
}
SameLine( );
VerticalSeparator( );
SameLine( );
if ( Button( ICON_FA_CLOCK_O , BtSize ) ) {
Globals::Window( ).pushDialog( NewOwned< T_ChangeDurationDialog_ >(
sync.durationUnits( ) , sync.durationUnitSize( ) ) );
}
if ( IsItemHovered( ) ) {
BeginTooltip( );
Text( "Change duration and time units." );
EndTooltip( );
}
SameLine( );
VerticalSeparator( );
SameLine( );
if ( Button( ICON_FA_LINE_CHART ) ) {
const bool displaySelector{ sub == SW_CURVE_SELECTOR
|| sub == SW_OVERRIDE_SELECTOR };
sub = displaySelector ? SW_NONE : SW_CURVE_SELECTOR;
curveFinder = T_String{};
}
if ( IsItemHovered( ) ) {
BeginTooltip( );
Text( "Select curves or sets thereof to display & edit." );
EndTooltip( );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Sequencer widget & subwindows // Sequencer widget & subwindows
@ -310,6 +255,62 @@ bool T_SyncViewImpl_::display( ) noexcept
return true; return true;
} }
void T_SyncViewImpl_::displayToolbar( ) noexcept
{
using namespace ImGui;
auto& sync( Globals::Sync( ) );
if ( ToolbarButton_( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ,
sync.playing( ) ? "Stop" : "Play" ) ) {
sync.playing( ) = !sync.playing( ) && !sync.finished( );
}
SameLine( );
if ( ToolbarButton_( ICON_FA_BACKWARD , BtSize , "Rewind to 00:00.000" ) ) {
sync.setTime( 0 );
}
ToolbarSeparator_( );
Text( ICON_FA_SEARCH );
bool zoomHovered{ IsItemHovered( ) };
SameLine( );
PushItemWidth( 100 );
SliderFloat( "##zoom" , &zoomLevel , 0 , 1 , "%.2f" );
if ( zoomHovered || IsItemHovered( ) ) {
BeginTooltip( );
Text( "Zoom level" );
EndTooltip( );
}
PopItemWidth( );
SameLine( );
if ( ToolbarButton_( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ,
followTime ? "Follows the current position.\nClick to untie."
: "Not tied to the current position.\nClick to follow." ) ) {
followTime = !followTime;
}
ToolbarSeparator_( );
if ( ToolbarButton_( ICON_FA_CLOCK_O , BtSize , "Change duration and time units." ) ) {
Globals::Window( ).pushDialog( NewOwned< T_ChangeDurationDialog_ >(
sync.durationUnits( ) , sync.durationUnitSize( ) ) );
}
ToolbarSeparator_( );
if ( ToolbarButton_( ICON_FA_LINE_CHART , BtSize ,
"Select curves or sets thereof to display & edit." ) ) {
const bool displaySelector{ sub == SW_CURVE_SELECTOR
|| sub == SW_OVERRIDE_SELECTOR };
sub = displaySelector ? SW_NONE : SW_CURVE_SELECTOR;
curveFinder = T_String{};
}
}
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
void T_SyncViewImpl_::sequencerWidget( ) noexcept void T_SyncViewImpl_::sequencerWidget( ) noexcept