void PLAYBACK::stopSeeking() { pauseFrame = 0; turbo = false; pauseEmulation(); setProgressbar(1, 1); }
// called after saving the project, because saving uses the progressbar for itself void PLAYBACK::updateProgressbar() { if (pauseFrame) { setProgressbar(currFrameCounter - seekingBeginningFrame, pauseFrame - seekingBeginningFrame); } else { if (emuPausedState) // full progressbar setProgressbar(1, 1); else // cleared progressbar setProgressbar(0, 1); } RedrawWindow(hwndProgressbar, NULL, NULL, RDW_INVALIDATE); }
int main(void) { GEvent * pe; // Initialize the display gfxInit(); // Set the widget defaults font = gdispOpenFont("*"); // Get the first defined font. gwinSetDefaultFont(font); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); // Create the gwin windows/widgets createWidgets(); // Assign toggles and dials to specific buttons & sliders etc. #if GINPUT_NEED_TOGGLE gwinAttachToggle(ghButton1, 0, 0); gwinAttachToggle(ghButton2, 0, 1); #endif #if GINPUT_NEED_DIAL gwinAttachDial(ghSlider1, 0, 0); gwinAttachDial(ghSlider3, 0, 1); #endif // Make the console visible gwinShow(ghConsole); gwinClear(ghConsole); // We want to listen for widget events geventListenerInit(&gl); gwinAttachListener(&gl); gtimerInit(&FlashTimer); #if !GWIN_NEED_TABSET // Press the Tab we want visible gwinRadioPress(ghTabButtons); #endif while(1) { // Get an Event pe = geventEventWait(&gl, TIME_INFINITE); switch(pe->type) { case GEVENT_GWIN_BUTTON: gwinPrintf(ghConsole, "Button %s\n", gwinGetText(((GEventGWinButton *)pe)->gwin)); break; case GEVENT_GWIN_SLIDER: gwinPrintf(ghConsole, "Slider %s=%d\n", gwinGetText(((GEventGWinSlider *)pe)->gwin), ((GEventGWinSlider *)pe)->position); break; case GEVENT_GWIN_CHECKBOX: gwinPrintf(ghConsole, "Checkbox %s=%s\n", gwinGetText(((GEventGWinCheckbox *)pe)->gwin), ((GEventGWinCheckbox *)pe)->isChecked ? "Checked" : "UnChecked"); // If it is the Disable All checkbox then do that. if (((GEventGWinCheckbox *)pe)->gwin == ghCheckDisableAll) { gwinPrintf(ghConsole, "%s All\n", ((GEventGWinCheckbox *)pe)->isChecked ? "Disable" : "Enable"); setEnabled(!((GEventGWinCheckbox *)pe)->isChecked); // If it is the toggle button checkbox start the flash. } else if (((GEventGWinCheckbox *)pe)->gwin == ghCheckbox3) { gwinFlash(ghCheckbox3); gtimerStart(&FlashTimer, FlashOffFn, 0, FALSE, 3000); } break; case GEVENT_GWIN_LIST: gwinPrintf(ghConsole, "List %s Item %d %s\n", gwinGetText(((GEventGWinList *)pe)->gwin), ((GEventGWinList *)pe)->item, gwinListItemIsSelected(((GEventGWinList *)pe)->gwin, ((GEventGWinList *)pe)->item) ? "Selected" : "Unselected"); break; case GEVENT_GWIN_RADIO: gwinPrintf(ghConsole, "Radio Group %u=%s\n", ((GEventGWinRadio *)pe)->group, gwinGetText(((GEventGWinRadio *)pe)->gwin)); switch(((GEventGWinRadio *)pe)->group) { #if !GWIN_NEED_TABSET case GROUP_TABS: // Set control visibility depending on the tab selected setTab(((GEventGWinRadio *)pe)->gwin); // We show the state of some of the GUI elements here setProgressbar(((GEventGWinRadio *)pe)->gwin == ghTabProgressbar); if (((GEventGWinRadio *)pe)->gwin == ghTabLabels) setLabels(); break; #endif case GROUP_COLORS: { const GWidgetStyle *pstyle; gwinPrintf(ghConsole, "Change Color Scheme\n"); if (((GEventGWinRadio *)pe)->gwin == ghRadioYellow) pstyle = &YellowWidgetStyle; else if (((GEventGWinRadio *)pe)->gwin == ghRadioBlack) pstyle = &BlackWidgetStyle; else pstyle = &WhiteWidgetStyle; // Clear the screen to the new color gdispClear(pstyle->background); // Update the style on all controls gwinSetDefaultStyle(pstyle, TRUE); } break; } break; #if GWIN_NEED_TABSET case GEVENT_GWIN_TABSET: gwinPrintf(ghConsole, "TabPage %u (%s)\n", ((GEventGWinTabset *)pe)->nPage, gwinTabsetGetTitle(((GEventGWinTabset *)pe)->ghPage)); // We show the state of some of the GUI elements here setProgressbar(((GEventGWinTabset *)pe)->ghPage == ghPgProgressbars); if (((GEventGWinTabset *)pe)->ghPage == ghPgLabels) setLabels(); break; #endif default: gwinPrintf(ghConsole, "Unknown %d\n", pe->type); break; } } return 0; }
void PLAYBACK::update() { // controls: // update < and > buttons rewindButtonOldState = rewindButtonState; rewindButtonState = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || mustRewindNow); if (rewindButtonState) { if (!rewindButtonOldState) { buttonHoldTimer = clock(); handleRewindFrame(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleRewindFrame(); } } forwardButtonOldState = forwardButtonState; forwardButtonState = (Button_GetState(hwndForward) & BST_PUSHED) != 0; if (forwardButtonState && !rewindButtonState) { if (!forwardButtonOldState) { buttonHoldTimer = clock(); handleForwardFrame(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleForwardFrame(); } } // update << and >> buttons rewindFullButtonOldState = rewindFullButtonState; rewindFullButtonState = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0); if (rewindFullButtonState && !rewindButtonState && !forwardButtonState) { if (!rewindFullButtonOldState) { buttonHoldTimer = clock(); handleRewindFull(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleRewindFull(); } } forwardFullButtonOldState = forwardFullButtonState; forwardFullButtonState = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0; if (forwardFullButtonState && !rewindButtonState && !forwardButtonState && !rewindFullButtonState) { if (!forwardFullButtonOldState) { buttonHoldTimer = clock(); handleForwardFull(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleForwardFull(); } } // update the Playback cursor if (currFrameCounter != lastCursorPos) { // update gfx of the old and new rows pianoRoll.redrawRow(lastCursorPos); bookmarks.redrawChangedBookmarks(lastCursorPos); pianoRoll.redrawRow(currFrameCounter); bookmarks.redrawChangedBookmarks(currFrameCounter); lastCursorPos = currFrameCounter; // follow the Playback cursor, but in case of seeking don't follow it pianoRoll.followPlaybackCursorIfNeeded(false); //pianoRoll.updatePlaybackCursorPositionInPianoRoll(); // an unfinished experiment // enforce redrawing now UpdateWindow(pianoRoll.hwndList); // lazy update of "Playback's Marker text" int current_marker = markersManager.getMarkerAboveFrame(currFrameCounter); if (displayedMarkerNumber != current_marker) { markersManager.updateEditedMarkerNote(); displayedMarkerNumber = current_marker; redrawMarkerData(); mustFindCurrentMarker = false; } } // [non-lazy] update "Playback's Marker text" if needed if (mustFindCurrentMarker) { markersManager.updateEditedMarkerNote(); displayedMarkerNumber = markersManager.getMarkerAboveFrame(currFrameCounter); redrawMarkerData(); mustFindCurrentMarker = false; } // pause when seeking hits pause_frame if (pauseFrame && currFrameCounter + 1 >= pauseFrame) stopSeeking(); else if (currFrameCounter >= getLastPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && mustAutopauseAtTheEnd && taseditorConfig.autopauseAtTheEndOfMovie && !isTaseditorRecording()) // pause at the end of the movie pauseEmulation(); // update flashing pauseframe if (oldPauseFrame != pauseFrame && oldPauseFrame) { // pause_frame was changed, clear old_pauseframe gfx pianoRoll.redrawRow(oldPauseFrame-1); bookmarks.redrawChangedBookmarks(oldPauseFrame-1); } oldPauseFrame = pauseFrame; oldStateOfShowPauseFrame = showPauseFrame; if (pauseFrame) { if (emuPausedState) showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_PAUSED) & 1; else showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_SEEKING) & 1; } else showPauseFrame = false; if (oldStateOfShowPauseFrame != showPauseFrame) { // update pauseframe gfx pianoRoll.redrawRow(pauseFrame - 1); bookmarks.redrawChangedBookmarks(pauseFrame - 1); } // update seeking progressbar emuPausedOldState = emuPausedState; emuPausedState = (FCEUI_EmulationPaused() != 0); if (pauseFrame) { if (oldStateOfShowPauseFrame != showPauseFrame) // update progressbar from time to time // display seeking progress setProgressbar(currFrameCounter - seekingBeginningFrame, pauseFrame - seekingBeginningFrame); } else if (emuPausedOldState != emuPausedState) { // emulator got paused/unpaused externally if (emuPausedOldState && !emuPausedState) { // externally unpaused - show empty progressbar setProgressbar(0, 1); } else { // externally paused - progressbar should be full setProgressbar(1, 1); } } // prepare to stop at the end of the movie in case user unpauses emulator if (emuPausedState) { if (currFrameCounter < currMovieData.getNumRecords() - 1) mustAutopauseAtTheEnd = true; else mustAutopauseAtTheEnd = false; } // this little statement is very important for adequate work of the "green arrow" and "Restore last position" if (!emuPausedState) // when emulating, lost_position_frame becomes unstable (which means that it's probably not equal to the end of current segment anymore) lastPositionIsStable = false; }