Sequencer - Scroll bars

This commit is contained in:
Emmanuel BENOîT 2017-11-27 13:54:06 +01:00
parent 8d2aac85b3
commit 56416abdb8
2 changed files with 43 additions and 15 deletions

2
TODO
View file

@ -32,7 +32,7 @@ Sync / inputs:
* Support for overrides
* Fix the various remaining issues
* Zooming issues on the right side
* Scrollbars
* Mouse wheel
* Add curve display
Misc:

View file

@ -282,6 +282,8 @@ struct T_SyncViewImpl_
T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell
// Computed metrics
bool checkLockMode{ false };
float vScroll{ 0 };
float barWidth;
float cursorPos;
uint32_t startBar;
@ -297,7 +299,6 @@ struct T_SyncViewImpl_
// Zoom area selection
bool zoomInProgress{ false };
bool justZoomed{ false };
float firstZoomPixel;
float curZoomPixel;
@ -550,16 +551,25 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
using namespace ImGui;
const auto width{ CalcItemWidth( ) };
auto* const win( GetCurrentWindow( ) );
auto* const win{ GetCurrentWindow( ) };
const auto seqId{ win->GetID( "##sequencer" ) };
const ImVec2 cPos( win->DC.CursorPos );
const ImVec2 ws( GetWindowContentRegionMax( ) );
const ImVec2 cPos{ win->DC.CursorPos };
const ImVec2 ws{ GetWindowContentRegionMax( ) };
auto& style( ImGui::GetStyle( ) );
const ImRect bbHeader{ cPos , cPos + ImVec2( width , SeqHeaderHeight ) };
const ImRect bbDisplay{ ImVec2{ cPos.x , bbHeader.Max.y } ,
ImVec2{ cPos.x + width , GetWindowPos( ).y + ws.y - style.FramePadding.y * 2 } };
const float widgetWidth{ width - style.ScrollbarSize };
const ImRect bbHeader{
cPos ,
cPos + ImVec2( widgetWidth , SeqHeaderHeight )
};
const ImRect bbDisplay{
ImVec2{ cPos.x , bbHeader.Max.y } ,
ImVec2{ cPos.x + widgetWidth ,
GetWindowPos( ).y + ws.y
- style.FramePadding.y * 2
- style.ScrollbarSize }
};
const ImRect bbAll{ bbHeader.Min , bbDisplay.Max };
ItemSize( bbAll , style.FramePadding.y );
@ -567,12 +577,13 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
return;
}
const bool hovered{ ItemHoverable( bbAll , seqId ) };
computeMetrics( std::max( 0.f , width - 2.f ) );
computeMetrics( std::max( 0.f , widgetWidth - 2.f ) );
BeginGroup( );
const auto hdrId{ win->GetID( "##header" ) };
const auto dspId{ win->GetID( "##display" ) };
PushID( seqId );
if ( ItemAdd( bbHeader , hdrId ) ) {
PushID( hdrId );
sequencerHeader( bbHeader );
@ -583,6 +594,25 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
sequencerBody( bbDisplay );
PopID( );
}
// Vertical scrollbar - tracks
const float totalHeight{ sCurves.size( ) * ( TrackHeight + TrackPadding * 2.f ) };
if ( vScroll > totalHeight - bbDisplay.GetHeight( ) ) {
vScroll = ImMax( 0.f , totalHeight - bbDisplay.GetHeight( ) );
}
// FIXME overrides
UserScrollbar( false , totalHeight , bbDisplay.GetHeight( ) , &vScroll ,
bbHeader.GetTR( ) , bbAll.GetHeight( ) );
// Horizontal scrollbar - time
auto& sync( Common::Sync( ) );
float rsPos = startPixel;
if ( UserScrollbar( true , totalPixels , widgetWidth , &rsPos ,
bbDisplay.GetBL( ) , bbDisplay.GetWidth( ) ) ) {
startPos = sync.durationUnits( ) * rsPos / totalPixels;
checkLockMode = true;
}
PopID( );
EndGroup( );
@ -593,7 +623,6 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
}
const bool active( GetCurrentContext( )->ActiveId == seqId );
auto& sync( Common::Sync( ) );
const float mPixels{ io.MousePos.x - bbAll.Min.x + startPixel };
const float mTime{ mPixels * sync.duration( ) / totalPixels };
@ -612,7 +641,7 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
if ( zoomInProgress && !io.MouseDown[ 1 ] ) {
zoomInProgress = false;
justZoomed = true;
checkLockMode = true;
const auto zMin{ std::min( firstZoomPixel , curZoomPixel ) } ,
zMax{ std::max( firstZoomPixel , curZoomPixel ) } ,
diff{ zMax - zMin };
@ -715,7 +744,7 @@ void T_SyncViewImpl_::computeMetrics(
const float spp{ startPos * totalPixels / units };
const float epp{ endPos * totalPixels / units };
if ( absCursorPos < spp || absCursorPos > epp ) {
if ( justZoomed ) {
if ( checkLockMode ) {
followTime = false;
} else {
startPos = std::max( 0.f , sync.time( ) / uSize - unitsPerBar * .5f );
@ -738,7 +767,7 @@ void T_SyncViewImpl_::computeMetrics(
assert( startBarPos <= 0 );
assert( totalPixels >= innerWidth );
justZoomed = false;
checkLockMode = false;
}
void T_SyncViewImpl_::sequencerHeader(
@ -819,8 +848,7 @@ void T_SyncViewImpl_::sequencerBody(
if ( sCurves.size( ) != 0 ) {
ImRect subBb{ inner };
// FIXME scroll
subBb.Min.y += TrackPadding;
subBb.Min.y += TrackPadding - vScroll;
subBb.Max.y = subBb.Min.y + TrackHeight;
float hue{ 0.12f };