Sequencer - Track labels

This commit is contained in:
Emmanuel BENOîT 2017-11-30 09:18:13 +01:00
parent 048cc1c966
commit 382138e5d2

View file

@ -263,6 +263,7 @@ struct T_SyncViewImpl_
static constexpr float BarWidth = 40.f;
static constexpr float TrackHeight = 15.f;
static constexpr float TrackPadding = 2.f;
static constexpr float TrackLabelHeight = 15.f;
static constexpr float PointRadius = ( TrackHeight - 2.f ) * .5f;
static constexpr float PointRadiusSqr = PointRadius * PointRadius;
@ -344,7 +345,6 @@ struct T_SyncViewImpl_
void sequencerHeader( ImRect const& bb ) noexcept;
void sequencerBody( ImRect const& bb ) noexcept;
void sequencerTracks(
ImRect& bb ,
ImRect const& container ) noexcept;
void sequencerTrack(
float& hue ,
@ -399,6 +399,7 @@ struct T_SyncViewImpl_
float zoomLevel{ 0.f };
float startPos{ 0.f };
bool followTime{ true };
bool showLabels{ true };
// Misc stuff
T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell
@ -632,17 +633,17 @@ void T_SyncViewImpl_::displayToolbar( ) noexcept
using namespace ImGui;
auto& sync{ Common::Sync( ) };
if ( sync.playing( ) ) {
UI::Main( ).actionButton( "Stop" );
} else {
UI::Main( ).actionButton( "Play" );
}
UI::Main( ).actionButton( sync.playing( ) ? "Stop" : "Play" );
SameLine( );
if ( ToolbarButton( ICON_FA_BACKWARD , BtSize , "Rewind to 00:00.000" ) ) {
sync.setTime( 0 );
}
SameLine( );
{
char tBuffer[ 12 ];
TimeToString_( tBuffer , sizeof( tBuffer ) , sync.time( ) );
Text( "%s" , tBuffer );
}
ToolbarSeparator( );
@ -675,8 +676,12 @@ void T_SyncViewImpl_::displayToolbar( ) noexcept
ToolbarSeparator( );
if ( ToolbarButton( ICON_FA_LINE_CHART , BtSize ,
"Select curves or sets thereof to display & edit." ) ) {
if ( ToolbarButton( ICON_FA_TAGS , BtSize , "Toggle track labels." ) ) {
showLabels = !showLabels;
}
SameLine( );
if ( ToolbarButton( ICON_FA_BARS , BtSize ,
"Select inputs or sets thereof to display & edit." ) ) {
const bool displaySelector{ sub == SW_INPUT_SELECTOR
|| sub == SW_OVERRIDE_SELECTOR };
sub = displaySelector ? SW_NONE : SW_INPUT_SELECTOR;
@ -736,7 +741,9 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
}
// Vertical scrollbar - tracks
const float totalHeight{ sTracks.size( ) * ( TrackHeight + TrackPadding * 2.f ) };
const float thMul{ ( showLabels ? ( TrackLabelHeight + TrackPadding ) : 0 )
+ TrackHeight + TrackPadding * 2.f };
const float totalHeight{ sTracks.size( ) * thMul + TrackPadding };
if ( vScroll > totalHeight - bbDisplay.GetHeight( ) ) {
vScroll = ImMax( 0.f , totalHeight - bbDisplay.GetHeight( ) );
}
@ -1005,10 +1012,7 @@ void T_SyncViewImpl_::sequencerBody(
dspSegments.clear( );
dspPoints.clear( );
if ( sTracks.size( ) != 0 ) {
ImRect subBb{ inner };
subBb.Min.y += TrackPadding - vScroll;
subBb.Max.y = subBb.Min.y + TrackHeight;
sequencerTracks( subBb , inner );
sequencerTracks( inner );
}
if ( cursorPos >= 0 && cursorPos <= inner.GetWidth( ) ) {
@ -1020,9 +1024,12 @@ void T_SyncViewImpl_::sequencerBody(
}
void T_SyncViewImpl_::sequencerTracks(
ImRect& subBb ,
ImRect const& container ) noexcept
{
ImRect bb{ container };
bb.Min.y += TrackPadding - vScroll;
bb.Max.y = bb.Min.y + TrackHeight;
float hue{ 0.12f };
auto& sync{ Common::Sync( ) };
@ -1033,9 +1040,33 @@ void T_SyncViewImpl_::sequencerTracks(
sTracks[ i ].isOverride
? sync.getOverride( id.id )->inputNames( )[ 0 ]
: id.id ) };
sequencerTrack( hue , subBb , container , id , curve );
subBb.Min.y += TrackHeight + 2 * TrackPadding;
subBb.Max.y += TrackHeight + 2 * TrackPadding;
if ( showLabels ) {
using namespace ImGui;
stringBuffer.clear( );
if ( id.isOverride ) {
stringBuffer << "[O] "
<< Common::Sync( ).getOverride( id.id )->title( );
} else {
stringBuffer << "[I] " << id.id;
}
PushStyleColor( ImGuiCol_Text ,
ColorHSVAToU32( hue , .05f , 1.f , 1.f ) );
char const* const tStart{ stringBuffer.data( ) };
char const* const taEnd{ tStart + stringBuffer.size( ) };
const ImVec2 ts{ CalcTextSize( tStart , taEnd ) };
RenderTextClipped( bb.Min + ImVec2{ 20 , 0 } ,
bb.Min + ImVec2{ 20 + ts.x , TrackLabelHeight } ,
tStart , taEnd , &ts , ImVec2{ 0.f , .5f } ,
&container );
PopStyleColor( );
bb.Min.y += TrackLabelHeight + TrackPadding;
bb.Max.y += TrackLabelHeight + TrackPadding;
}
sequencerTrack( hue , bb , container , id , curve );
bb.Min.y += TrackHeight + 2 * TrackPadding;
bb.Max.y += TrackHeight + 2 * TrackPadding;
hue = fmodf( hue + .17f , 1.f );
}
}
@ -1070,7 +1101,8 @@ void T_SyncViewImpl_::sequencerTrack(
using namespace ImGui;
auto const& mp{ GetIO( ).MousePos };
const bool sCurve{ selId && id == *selId };
const float scv{ sCurve ? 1.f : ( bar.Contains( mp ) ? .85f : .7f ) };
const bool barHovered{ bar.Contains( mp ) };
const float scv{ sCurve ? 1.f : ( barHovered ? .85f : .7f ) };
const auto bgColor{ ColorHSVAToU32( hue , .25f , scv , .25f ) } ,
borderColor{ ColorHSVAToU32( hue , .5f , scv , 1.f ) };
const uint32_t segColors[] = {
@ -1130,8 +1162,9 @@ void T_SyncViewImpl_::sequencerTrack(
// Add segment to displayed list
const bool sSegment{ sCurve && selSegment && *selSegment == i };
const bool segHovered{ segFull.Contains( mp ) };
const auto color{ segColors[ i % 2 + ( sSegment ? 4
: ( segFull.Contains( mp ) ? 2 : 0 ) ) ] };
: ( segHovered ? 2 : 0 ) ) ] };
auto dSegIdx{ dspSegments.size( ) };
auto& dSeg{ dspSegments.addNew( ) };
dSeg.area = segFull;
@ -1159,7 +1192,7 @@ void T_SyncViewImpl_::sequencerTrack(
ym
};
const bool sPoint{ sSegment && selPoint && *selPoint == j };
const bool hpt{ !sPoint && segFull.Contains( mp )
const bool hpt{ !sPoint && segHovered
&& ImLengthSqr( mp - ctr ) <= 2.25 * PointRadiusSqr };
dl->AddCircleFilled( ctr , PointRadius ,
sPoint ? ColPointSelected