| 1 | //============================================================================ |
| 2 | // |
| 3 | // SSSS tt lll lll |
| 4 | // SS SS tt ll ll |
| 5 | // SS tttttt eeee ll ll aaaa |
| 6 | // SSSS tt ee ee ll ll aa |
| 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
| 8 | // SS SS tt ee ll ll aa aa |
| 9 | // SSSS ttt eeeee llll llll aaaaa |
| 10 | // |
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
| 12 | // and the Stella Team |
| 13 | // |
| 14 | // See the file "License.txt" for information on usage and redistribution of |
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 16 | //============================================================================ |
| 17 | |
| 18 | #include "Dialog.hxx" |
| 19 | #include "FrameBufferConstants.hxx" |
| 20 | #include "TimeMachineDialog.hxx" |
| 21 | #include "TimeMachine.hxx" |
| 22 | |
| 23 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 24 | TimeMachine::TimeMachine(OSystem& osystem) |
| 25 | : DialogContainer(osystem), |
| 26 | myBaseDialog(nullptr), |
| 27 | myWidth(FBMinimum::Width) |
| 28 | { |
| 29 | myBaseDialog = new TimeMachineDialog(myOSystem, *this, myWidth); |
| 30 | } |
| 31 | |
| 32 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 33 | TimeMachine::~TimeMachine() |
| 34 | { |
| 35 | delete myBaseDialog; myBaseDialog = nullptr; |
| 36 | } |
| 37 | |
| 38 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 39 | void TimeMachine::requestResize() |
| 40 | { |
| 41 | uInt32 w = 0, h = 0; |
| 42 | myBaseDialog->getDynamicBounds(w, h); |
| 43 | |
| 44 | // Only re-create when absolutely necessary |
| 45 | if(myWidth != w) |
| 46 | { |
| 47 | myWidth = w; |
| 48 | Dialog* oldPtr = myBaseDialog; |
| 49 | Int32 enterWinds = static_cast<TimeMachineDialog*>(myBaseDialog)->getEnterWinds(); |
| 50 | delete myBaseDialog; |
| 51 | myBaseDialog = new TimeMachineDialog(myOSystem, *this, myWidth); |
| 52 | setEnterWinds(enterWinds); |
| 53 | Dialog* newPtr = myBaseDialog; |
| 54 | |
| 55 | // Update the container stack; it may contain a reference to the old pointer |
| 56 | if(oldPtr != newPtr) |
| 57 | { |
| 58 | myDialogStack.applyAll([&oldPtr,&newPtr](Dialog*& d){ |
| 59 | if(d == oldPtr) |
| 60 | d = newPtr; |
| 61 | }); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 67 | Dialog* TimeMachine::baseDialog() |
| 68 | { |
| 69 | return myBaseDialog; |
| 70 | } |
| 71 | |
| 72 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 73 | void TimeMachine::setEnterWinds(Int32 numWinds) |
| 74 | { |
| 75 | static_cast<TimeMachineDialog*>(myBaseDialog)->setEnterWinds(numWinds); |
| 76 | } |
| 77 | |