void ShowImageWindow::_SetToolBarVisible(bool visible, bool animate) { if (visible == fToolBarVisible) return; fToolBarVisible = visible; float diff = fToolBar->Bounds().Height() + 2; if (!visible) diff = -diff; else fToolBar->Show(); if (animate) { // Slide the controls into view. We do this with messages in order // not to block the window thread. const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 }; const int32 steps = sizeof(kAnimationOffsets) / sizeof(float); for (int32 i = 0; i < steps; i++) { BMessage message(kMsgSlideToolBar); message.AddFloat("offset", floorf(diff * kAnimationOffsets[i])); PostMessage(&message, this); } BMessage finalMessage(kMsgFinishSlidingToolBar); finalMessage.AddFloat("offset", visible ? 0 : diff); finalMessage.AddBool("show", visible); PostMessage(&finalMessage, this); } else { fScrollView->ResizeBy(0, -diff); fScrollView->MoveBy(0, diff); fToolBar->MoveBy(0, diff); if (!visible) fToolBar->Hide(); } }
// FUNCTION: run // Handles the main flow of control for the Converter class, including I/O void Converter::run() { welcomeMessage(); // Loop to allow for multiple conversions bool loop = true; while (loop) { // Receive user input input = receiveInput(); // Convert number to string output = convertToOutput(); // Display the output printOutput(); loop = repeat(); } finalMessage(); }