1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/***********************************************************************
* busy.cpp - Shows the use of the FBusyIndicator *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2020-2022 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FRect;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Dialog
//----------------------------------------------------------------------
class Dialog final : public finalcut::FDialog
{
public:
explicit Dialog (FWidget* parent = nullptr);
private:
void initLayout() override;
void adjustSize() override;
// Event handler
void onTimer (finalcut::FTimerEvent*) override;
// Callback method
void cb_start();
// Data members
finalcut::FSpinBox seconds{this};
finalcut::FButton start{"&Start", this};
finalcut::FButton quit{"&Quit", this};
finalcut::FBusyIndicator busy_indicator{this};
};
//----------------------------------------------------------------------
Dialog::Dialog (FWidget* parent)
: finalcut::FDialog{parent}
{
seconds.setLabelText ("Seconds");
seconds.setRange (0, 60);
seconds.setValue (3);
// Add button callbacks
seconds.addCallback
(
"activate",
this, &Dialog::cb_start
);
start.addCallback
(
"clicked",
this, &Dialog::cb_start
);
quit.addCallback
(
"clicked",
finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
);
}
//----------------------------------------------------------------------
void Dialog::initLayout()
{
FDialog::setText ("Dialog");
FDialog::setGeometry (FPoint{26, 5}, FSize{28, 10});
seconds.setGeometry (FPoint{10, 2}, FSize{10, 1});
start.setGeometry (FPoint{2, 6}, FSize{10, 1});
quit.setGeometry (FPoint{15, 6}, FSize{10, 1});
FDialog::initLayout();
}
//----------------------------------------------------------------------
void Dialog::adjustSize()
{
finalcut::FDialog::adjustSize();
auto x = int((getDesktopWidth() - getWidth()) / 2);
const int y = 5;
if ( x < 1 )
x = 1;
setPos (FPoint{x, y}, false);
}
//----------------------------------------------------------------------
void Dialog::onTimer (finalcut::FTimerEvent*)
{
delOwnTimers();
busy_indicator.stop();
}
//----------------------------------------------------------------------
void Dialog::cb_start()
{
if ( seconds.getValue() < 1 )
return;
busy_indicator.start();
addTimer(int(seconds.getValue() * 1000));
}
//----------------------------------------------------------------------
// main part
//----------------------------------------------------------------------
auto main (int argc, char* argv[]) -> int
{
finalcut::FApplication app(argc, argv);
Dialog dialog(&app);
finalcut::FWidget::setMainWidget(&dialog);
dialog.show();
return app.exec();
}
|