@@ -78,6 +78,7 @@ wxDocChildFrame(doc, view, parent, wxID_ANY, wxT("CalChart Viewer"), wxDefaultPo
7878#else
7979wxFrame (parent, wxID_ANY, wxT(" CalChart Viewer" ), wxDefaultPosition, size),
8080#endif
81+ mAnimationView (),
8182mCanvas(NULL ),
8283mOmniViewCanvas(NULL ),
8384mTimer(new wxTimer(this , CALCHART__anim_next_beat_timer)),
@@ -87,9 +88,8 @@ mWhenClosed(onClose)
8788{
8889// Give it an icon
8990 // give this a view so it can pick up document changes
90- mAnimationView = new AnimationView ();
91- mAnimationView ->SetDocument (doc);
92- mAnimationView ->SetFrame (this );
91+ mAnimationView .SetDocument (doc);
92+ mAnimationView .SetFrame (this );
9393 SetBandIcon (this );
9494
9595 // this frame has 2 status bars at the bottom
@@ -131,8 +131,8 @@ mWhenClosed(onClose)
131131 mSplitter ->SetWindowStyleFlag (mSplitter ->GetWindowStyleFlag () | wxSP_LIVE_UPDATE);
132132 mSplitter ->SetMinSize (wxSize (300 , 400 ));
133133
134- mOmniViewCanvas = new CCOmniView_Canvas (mAnimationView , mSplitter );
135- mCanvas = new AnimationCanvas (mAnimationView , mSplitter );
134+ mOmniViewCanvas = new CCOmniView_Canvas (& mAnimationView , mSplitter );
135+ mCanvas = new AnimationCanvas (& mAnimationView , mSplitter );
136136
137137 mSplitA = mOmniViewCanvas ;
138138 mSplitB = mCanvas ;
@@ -175,7 +175,7 @@ mWhenClosed(onClose)
175175 wxT (" Ignore" ), wxT (" Show" ), wxT (" Beep" )
176176 };
177177 wxChoice *collis = new wxChoice (this , CALCHART__anim_collisions, wxDefaultPosition, wxDefaultSize, sizeof (collis_text)/sizeof (const wxString), collis_text);
178- collis->SetSelection (mAnimationView -> GetCollisionType ());
178+ collis->SetSelection (mAnimationView . GetCollisionType ());
179179 sizer1->Add (collis, centerWidget);
180180 toprow->Add (sizer1, topRowSizerFlags);
181181
@@ -222,7 +222,7 @@ mWhenClosed(onClose)
222222 topsizer->SetSizeHints (this ); // set size hints to honour minimum size
223223 this ->Layout ();
224224
225- mAnimationView -> Generate ();
225+ mAnimationView . Generate ();
226226
227227 UpdatePanel ();
228228
@@ -242,7 +242,6 @@ AnimationFrame::~AnimationFrame()
242242 if (mOmniViewCanvas )
243243 mOmniViewCanvas ->SetView (NULL );
244244 mTimer ->Stop ();
245- delete mAnimationView ;
246245}
247246
248247
@@ -263,20 +262,14 @@ AnimationFrame::OnCmdReanimate(wxCommandEvent& event)
263262{
264263 StopTimer ();
265264 mErrorMarkers .clear ();
266- if (mAnimationView )
267- {
268- mAnimationView ->Generate ();
269- }
265+ mAnimationView .Generate ();
270266}
271267
272268
273269void
274270AnimationFrame::OnCmdSelectCollisions (wxCommandEvent& event)
275271{
276- if (mAnimationView )
277- {
278- mAnimationView ->SelectCollisions ();
279- }
272+ mAnimationView .SelectCollisions ();
280273}
281274
282275
@@ -312,28 +305,22 @@ AnimationFrame::OnCmd_anim_play(wxCommandEvent& event)
312305void
313306AnimationFrame::OnCmd_anim_prev_beat (wxCommandEvent& event)
314307{
315- if (mAnimationView )
316- {
317- mAnimationView ->PrevBeat ();
318- }
308+ mAnimationView .PrevBeat ();
319309}
320310
321311
322312void
323313AnimationFrame::OnCmd_anim_next_beat (wxCommandEvent& event)
324314{
325- if (mAnimationView )
326- {
327- mAnimationView ->NextBeat ();
328- }
315+ mAnimationView .NextBeat ();
329316}
330317
331318
332319void
333320AnimationFrame::OnCmd_anim_next_beat_timer (wxTimerEvent& event)
334321{
335322 // next_beat could come from the timer. If so, stop the timer.
336- if (mAnimationView && !mAnimationView -> NextBeat ())
323+ if (!mAnimationView . NextBeat ())
337324 {
338325 StopTimer ();
339326 }
@@ -343,30 +330,21 @@ AnimationFrame::OnCmd_anim_next_beat_timer(wxTimerEvent& event)
343330void
344331AnimationFrame::OnCmd_anim_prev_sheet (wxCommandEvent& event)
345332{
346- if (mAnimationView )
347- {
348- mAnimationView ->PrevSheet ();
349- }
333+ mAnimationView .PrevSheet ();
350334}
351335
352336
353337void
354338AnimationFrame::OnCmd_anim_next_sheet (wxCommandEvent& event)
355339{
356- if (mAnimationView )
357- {
358- mAnimationView ->NextSheet ();
359- }
340+ mAnimationView .NextSheet ();
360341}
361342
362343
363344void
364345AnimationFrame::OnCmd_anim_collisions (wxCommandEvent& event)
365346{
366- if (mAnimationView )
367- {
368- mAnimationView ->SetCollisionType (static_cast <CollisionWarning>(event.GetSelection ()));
369- }
347+ mAnimationView .SetCollisionType (static_cast <CollisionWarning>(event.GetSelection ()));
370348 Refresh ();
371349}
372350
@@ -378,11 +356,11 @@ AnimationFrame::OnCmd_anim_errors(wxCommandEvent& event)
378356 size_t which = mErrorList ->GetSelection () - 1 ;
379357 if (which < mErrorMarkers .size ())
380358 {
381- mAnimationView -> SetSelection (mErrorMarkers .at (which).first .pntgroup );
382- mAnimationView -> GotoSheet (mErrorMarkers .at (which).second );
359+ mAnimationView . SetSelection (mErrorMarkers .at (which).first .pntgroup );
360+ mAnimationView . GotoSheet (mErrorMarkers .at (which).second );
383361
384362 mErrorText ->Clear ();
385- CC_continuity c = mAnimationView -> GetContinuityOnSheet (mErrorMarkers .at (which).second , mErrorMarkers .at (which).first .contsymbol );
363+ CC_continuity c = mAnimationView . GetContinuityOnSheet (mErrorMarkers .at (which).second , mErrorMarkers .at (which).first .contsymbol );
386364 if (!c.GetText ().empty ())
387365 {
388366 mErrorText ->WriteText (c.GetText ());
@@ -408,47 +386,41 @@ AnimationFrame::OnSlider_anim_tempo(wxSpinEvent& event)
408386void
409387AnimationFrame::OnSlider_anim_gotosheet (wxScrollEvent& event)
410388{
411- if (mAnimationView )
412- {
413- mAnimationView ->GotoAnimationSheet (event.GetPosition ()-1 );
414- }
389+ mAnimationView .GotoAnimationSheet (event.GetPosition ()-1 );
415390}
416391
417392
418393void
419394AnimationFrame::OnSlider_anim_gotobeat (wxScrollEvent& event)
420395{
421- if (mAnimationView )
422- {
423- // False if the change in the slider should cause the animation to transition to the next/previous stunt sheet
424- // true otherwise
425- bool beatChangeIsInternal = true ;
426- if (OnSlider_shouldTransitionToNextSheet (event)) {
427- beatChangeIsInternal = false ;
428- TransitionToNextSheet ();
429- }
430- else if (OnSlider_shouldTransitionToPreviousSheet (event)) {
431- beatChangeIsInternal = false ;
432- TransitionToPreviousSheet ();
433- }
434- if (beatChangeIsInternal) {
435- mAnimationView ->GotoBeat (event.GetPosition ());
436- }
396+ // False if the change in the slider should cause the animation to transition to the next/previous stunt sheet
397+ // true otherwise
398+ bool beatChangeIsInternal = true ;
399+ if (OnSlider_shouldTransitionToNextSheet (event)) {
400+ beatChangeIsInternal = false ;
401+ TransitionToNextSheet ();
402+ }
403+ else if (OnSlider_shouldTransitionToPreviousSheet (event)) {
404+ beatChangeIsInternal = false ;
405+ TransitionToPreviousSheet ();
406+ }
407+ if (beatChangeIsInternal) {
408+ mAnimationView .GotoBeat (event.GetPosition ());
437409 }
438410}
439411
440412bool
441413AnimationFrame::OnSlider_shouldTransitionToNextSheet (wxScrollEvent& event) {
442414 if (OnSlider_isNextBeatEvent (event)) {
443- return (mAnimationView -> GetCurrentBeat () == mAnimationView -> GetNumberBeats () - 1 );
415+ return (mAnimationView . GetCurrentBeat () == mAnimationView . GetNumberBeats () - 1 );
444416 }
445417 return false ;
446418}
447419
448420bool
449421AnimationFrame::OnSlider_shouldTransitionToPreviousSheet (wxScrollEvent& event) {
450422 if (OnSlider_isPreviousBeatEvent (event)) {
451- return (mAnimationView -> GetCurrentBeat () == 0 );
423+ return (mAnimationView . GetCurrentBeat () == 0 );
452424 }
453425 return false ;
454426}
@@ -467,14 +439,14 @@ AnimationFrame::OnSlider_isNextBeatEvent(wxScrollEvent& event) {
467439
468440void
469441AnimationFrame::TransitionToNextSheet () {
470- mAnimationView -> GotoBeat (mAnimationView -> GetNumberBeats () - 1 );
471- mAnimationView -> NextBeat ();
442+ mAnimationView . GotoBeat (mAnimationView . GetNumberBeats () - 1 );
443+ mAnimationView . NextBeat ();
472444}
473445
474446void
475447AnimationFrame::TransitionToPreviousSheet () {
476- mAnimationView -> GotoBeat (0 );
477- mAnimationView -> PrevBeat ();
448+ mAnimationView . GotoBeat (0 );
449+ mAnimationView . PrevBeat ();
478450}
479451
480452void
@@ -488,7 +460,7 @@ AnimationFrame::OnCmd_FollowMarcher(wxCommandEvent& event)
488460 if (dialog.ShowModal () == wxID_OK)
489461 {
490462 wxString value = dialog.GetValue ();
491- auto & labels = mAnimationView -> GetShow ()->GetPointLabels ();
463+ auto & labels = mAnimationView . GetShow ()->GetPointLabels ();
492464 auto which = std::find (labels.begin (), labels.end (), value);
493465 if (which == labels.end ())
494466 {
@@ -507,7 +479,7 @@ AnimationFrame::OnCmd_FollowMarcher(wxCommandEvent& event)
507479 }
508480 SelectionList sl;
509481 sl.insert (std::distance (labels.begin (), which));
510- mAnimationView -> SetSelection (sl);
482+ mAnimationView . SetSelection (sl);
511483 }
512484 Refresh ();
513485}
@@ -593,8 +565,8 @@ AnimationFrame::ToggleTimer()
593565void
594566AnimationFrame::UpdatePanel ()
595567{
596- int num = ( mAnimationView ) ? mAnimationView -> GetNumberSheets () : 1 ;
597- int curr = ( mAnimationView ) ? mAnimationView -> GetCurrentSheet ()+1 : 1 ;
568+ int num = mAnimationView . GetNumberSheets ();
569+ int curr = mAnimationView . GetCurrentSheet ()+1 ;
598570
599571 if (num > 1 )
600572 {
@@ -610,8 +582,8 @@ AnimationFrame::UpdatePanel()
610582 mSheetSlider ->Enable (false );
611583 }
612584
613- num = ( mAnimationView ) ? mAnimationView -> GetNumberBeats ()-1 : 1 ;
614- curr = ( mAnimationView ) ? mAnimationView -> GetCurrentBeat () : 1 ;
585+ num = mAnimationView . GetNumberBeats ()-1 ;
586+ curr = mAnimationView . GetCurrentBeat ();
615587
616588 if (num > 0 )
617589 {
@@ -626,10 +598,7 @@ AnimationFrame::UpdatePanel()
626598 {
627599 mBeatSlider ->Enable (false );
628600 }
629- if (mAnimationView )
630- {
631- SetStatusText (mAnimationView ->GetStatusText (), 1 );
632- }
601+ SetStatusText (mAnimationView .GetStatusText (), 1 );
633602}
634603
635604
0 commit comments