@@ -45,18 +45,19 @@ using namespace CalChart;
4545
4646BEGIN_EVENT_TABLE (AnimationPanel, AnimationPanel::super)
4747EVT_SPINCTRL(CALCHART__anim_tempo, AnimationPanel::OnSlider_anim_tempo)
48+ EVT_COMMAND_SCROLL(CALCHART__anim_gotosheet, AnimationPanel::OnSlider_anim_gotosheet)
4849EVT_COMMAND_SCROLL(CALCHART__anim_gotobeat, AnimationPanel::OnSlider_anim_gotobeat)
4950EVT_TIMER(CALCHART__anim_next_beat_timer, AnimationPanel::OnCmd_anim_next_beat_timer)
5051END_EVENT_TABLE()
5152
52- AnimationPanel::AnimationPanel(CalChart::Configuration& config, wxWindow* parent, wxWindowID winid, wxPoint const & pos, wxSize const & size, long style, wxString const & name)
53+ AnimationPanel::AnimationPanel(CalChart::Configuration& config, wxWindow* parent, bool miniMode, wxWindowID winid, wxPoint const & pos, wxSize const & size, long style, wxString const & name)
5354 : super(parent, winid, pos, size, style, name)
5455 , mCanvas(new AnimationCanvas(config, this , wxID_ANY, wxDefaultPosition, wxSize(-1 , GetAnimationCanvasMinY())))
5556 , mOmniCanvas(new CCOmniviewCanvas(this , config))
5657 , mTimer(new wxTimer(this , CALCHART__anim_next_beat_timer))
5758 , mTempo(120 )
5859 , mTimerOn(false )
59- , mInMiniMode(true )
60+ , mInMiniMode(miniMode )
6061 , mConfig(config)
6162{
6263 Init ();
@@ -92,6 +93,14 @@ void AnimationPanel::CreateControls()
9293 OnCmd_PlayButton ();
9394 })
9495 .withProxy (mPlayPauseButton ),
96+ wxUI::LayoutIf{
97+ !mInMiniMode && mConfig .Get_AnimationFrameSheetSlider (),
98+ wxUI::Text{ " Sheet" },
99+ wxUI::Slider{ CALCHART__anim_gotosheet, std::pair{ 1 , 2 }, 1 }
100+ .withStyle (wxSL_HORIZONTAL | wxSL_LABELS)
101+ .withProxy (mSheetSlider ),
102+ wxUI::Text{ " Beat" },
103+ },
95104 wxUI::Slider{ CALCHART__anim_gotobeat, std::pair{ 1 , 2 }, 1 }
96105 .withStyle (wxSL_HORIZONTAL | wxSL_LABELS)
97106 .withFlags (ExpandSizerFlags ())
@@ -147,15 +156,6 @@ void AnimationPanel::CreateControls()
147156 mCanvas ->Show ();
148157 mOmniCanvas ->Hide ();
149158
150- for (auto && i : mItemsToHide ) {
151- i->Show (!mInMiniMode );
152- }
153- SetInMiniMode (mInMiniMode );
154- }
155-
156- void AnimationPanel::SetInMiniMode (bool miniMode)
157- {
158- mInMiniMode = miniMode;
159159 for (auto && i : mItemsToHide ) {
160160 i->Show (!mInMiniMode );
161161 }
@@ -218,7 +218,19 @@ void AnimationPanel::OnSlider_anim_tempo(wxSpinEvent& event)
218218
219219void AnimationPanel::OnSlider_anim_gotobeat (wxScrollEvent& event)
220220{
221- mView ->GotoTotalBeat (event.GetPosition ());
221+ if (mSheetSlider .control ()) {
222+ mView ->GotoSheetBeat (*mSheetSlider - 1 , event.GetPosition ());
223+ } else {
224+ mView ->GotoTotalBeat (event.GetPosition ());
225+ }
226+ }
227+
228+ void AnimationPanel::OnSlider_anim_gotosheet (wxScrollEvent& event)
229+ {
230+ if (mSheetSlider .control ()) {
231+ // because we want to show the sheets with offset 1, we need -1.
232+ mView ->GotoSheetBeat (event.GetPosition () - 1 , 0 );
233+ }
222234}
223235
224236void AnimationPanel::ToggleTimer ()
@@ -231,31 +243,61 @@ void AnimationPanel::ToggleTimer()
231243 UpdatePanel ();
232244}
233245
246+ namespace {
247+ auto disableSlider (auto & slider)
248+ {
249+ if (slider.control () == nullptr ) {
250+ return ;
251+ }
252+ slider.control ()->Enable (false );
253+ }
254+
255+ auto updateController (auto & slider, int num, int curr, bool zeroOffset = true )
256+ {
257+ if (slider.control () == nullptr ) {
258+ return ;
259+ }
260+ if (num > 0 ) {
261+ slider.control ()->SetRange (zeroOffset ? 0 : 1 , num);
262+ if (*slider != curr) {
263+ *slider = curr;
264+ }
265+ slider.control ()->Enable (true );
266+ } else {
267+ slider.control ()->Enable (false );
268+ }
269+ }
270+ }
271+
234272void AnimationPanel::UpdatePanel ()
235273{
236274 if (!mView ) {
237275 return ;
238276 }
239- // TODO Update this.
240- auto num = mView ->GetTotalNumberBeats () - 1 ;
241- auto curr = mView ->GetTotalCurrentBeat ();
277+ auto totalBeats = mView ->GetTotalNumberBeats () - 1 ;
278+ auto currentBeat = mView ->GetTotalCurrentBeat ();
279+ auto totalSheets = mView ->GetNumSheets () - 1 ; // gives us the total number sheets
280+ auto sheetBeatStuff = mView ->BeatToSheetOffsetAndBeat (currentBeat);
281+ if (!sheetBeatStuff) {
282+ disableSlider (mBeatSlider );
283+ disableSlider (mSheetSlider );
284+ return ;
285+ }
286+ auto [currentSheet, sheetBeat] = *sheetBeatStuff; // gives us which shee we are on and beat
287+ auto beatsForCurrentSheet = mView ->BeatForSheet (currentSheet) - 1 ; // gives us which shee we are on and beat
242288
243- if (num > 0 ) {
244- mBeatSlider .control ()->Enable (true );
245- if (mBeatSlider .control ()->GetMax () != num)
246- *mBeatSlider = 0 ; // So Motif doesn't complain about value
247- mBeatSlider .control ()->SetRange (0 , num);
248- if (*mBeatSlider != curr)
249- *mBeatSlider = curr;
289+ if (mSheetSlider .control ()) {
290+ updateController (mBeatSlider , static_cast <int >(beatsForCurrentSheet), static_cast <int >(sheetBeat));
250291 } else {
251- mBeatSlider . control ()-> Enable ( false );
292+ updateController ( mBeatSlider , static_cast < int >(totalBeats), static_cast < int >(currentBeat) );
252293 }
294+ updateController (mSheetSlider , totalSheets + 1 , currentSheet + 1 , false );
253295 *mPlayPauseButton = mTimerOn ;
254296}
255297
256298bool AnimationPanel::OnBeat () const
257299{
258- return * mBeatSlider & 1 ;
300+ return mView -> GetTotalCurrentBeat () & 1 ;
259301}
260302
261303void AnimationPanel::SetPlayState (bool playState)
0 commit comments