2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "ardour_ui.h"
20 #include "dsp_load_gauge.h"
26 DiskSpaceGauge::DiskSpaceGauge ()
27 : ArdourGauge (">24h")
33 DiskSpaceGauge::set_available_disk_sec (float sec)
47 update (_("Rec: >24h"));
49 } else if (_sec > 32400 /* 9 hours */) {
50 snprintf (buf, sizeof (buf), "Rec: %.0fh", _sec / 3600.f);
51 } else if (_sec > 5940 /* 99 mins */) {
52 snprintf (buf, sizeof (buf), "Rec: %.1fh", _sec / 3600.f);
54 snprintf (buf, sizeof (buf), "Rec: %.0fm", _sec / 60.f);
56 update (std::string (buf));
60 DiskSpaceGauge::level () const {
61 static const float six_hours = 6.f * 3600.f;
62 if (_sec < 0) return 1.0;
63 if (_sec > six_hours) return 0.0;
64 return (1.0 - (_sec / six_hours));
68 DiskSpaceGauge::alert () const
70 return _sec >=0 && _sec < 60.f * 10.f;
74 DiskSpaceGauge::indicator () const
77 return ArdourGauge::Level_OK;
78 } else if (_sec > 1800.f) {
79 return ArdourGauge::Level_WARN;
81 return ArdourGauge::Level_CRIT;
85 DiskSpaceGauge::tooltip_text ()
91 int sec = floor (_sec);
94 int mins = (sec / 60) % 60;
97 snprintf (buf, sizeof(buf), _("%02dh:%02dm:%02ds"), hrs, mins, secs);
98 return _("Available capture disk-space: ") + std::string (buf);