[Summary] Implemented Ok Dialog

[Reviewed] GZharun
This commit is contained in:
Nikolay 2014-11-12 13:06:43 +02:00
parent deeb2a17ef
commit 015d072bf2
5 changed files with 252 additions and 0 deletions

View file

@ -271,6 +271,11 @@
43B351ED194F04E00038C140 /* step_editing.bindings in Resources */ = {isa = PBXBuildFile; fileRef = 43B351C0194F04E00038C140 /* step_editing.bindings */; };
95176F7A1A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */; };
95176F7E1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */; };
95176F861A092A2900E32046 /* ok_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 95176F841A092A2900E32046 /* ok_dialog.xml */; };
95176F871A092A2900E32046 /* yes_no_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 95176F851A092A2900E32046 /* yes_no_dialog.xml */; };
95176F8F1A092A5B00E32046 /* ok_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 95176F8D1A092A5B00E32046 /* ok_dialog.cc */; };
95176F901A092A5B00E32046 /* yes_no_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 95176F8E1A092A5B00E32046 /* yes_no_dialog.cc */; };
952E0B3C1A0A1D7000F375D0 /* buildlog.txt in Resources */ = {isa = PBXBuildFile; fileRef = 952E0B3B1A0A1D7000F375D0 /* buildlog.txt */; };
954DCFBD1A0239DA00B7160E /* about_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 954DCFBC1A0239DA00B7160E /* about_dialog.cc */; };
954DCFC11A023AAB00B7160E /* about_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 954DCFBF1A023AAB00B7160E /* about_dialog.xml */; };
954DCFC21A023AAB00B7160E /* license_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 954DCFC01A023AAB00B7160E /* license_dialog.xml */; };
@ -1124,6 +1129,13 @@
95176F781A08E6D800E32046 /* file_sample_rate_mismatch_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file_sample_rate_mismatch_dialog.h; path = ../file_sample_rate_mismatch_dialog.h; sourceTree = "<group>"; };
95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = file_sample_rate_mismatch_dialog.cc; path = ../file_sample_rate_mismatch_dialog.cc; sourceTree = "<group>"; };
95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = file_sample_rate_mismatch_dialog.xml; sourceTree = "<group>"; };
95176F841A092A2900E32046 /* ok_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ok_dialog.xml; sourceTree = "<group>"; };
95176F851A092A2900E32046 /* yes_no_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = yes_no_dialog.xml; sourceTree = "<group>"; };
95176F8B1A092A4700E32046 /* ok_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ok_dialog.h; path = ../ok_dialog.h; sourceTree = "<group>"; };
95176F8C1A092A4700E32046 /* yes_no_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yes_no_dialog.h; path = ../yes_no_dialog.h; sourceTree = "<group>"; };
95176F8D1A092A5B00E32046 /* ok_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ok_dialog.cc; path = ../ok_dialog.cc; sourceTree = "<group>"; };
95176F8E1A092A5B00E32046 /* yes_no_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = yes_no_dialog.cc; path = ../yes_no_dialog.cc; sourceTree = "<group>"; };
952E0B3B1A0A1D7000F375D0 /* buildlog.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = buildlog.txt; path = ../../../buildlog.txt; sourceTree = "<group>"; };
954DCFBC1A0239DA00B7160E /* about_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = about_dialog.cc; path = ../about_dialog.cc; sourceTree = "<group>"; };
954DCFBE1A0239EC00B7160E /* about_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = about_dialog.h; path = ../about_dialog.h; sourceTree = "<group>"; };
954DCFBF1A023AAB00B7160E /* about_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = about_dialog.xml; sourceTree = "<group>"; };
@ -1202,6 +1214,7 @@
43279039194EFF24003C9FEA = {
isa = PBXGroup;
children = (
952E0B3B1A0A1D7000F375D0 /* buildlog.txt */,
4397599619CB06AC00740098 /* gtkmm2ext.xcodeproj */,
4397595019CADAFC00740098 /* canvas.xcodeproj */,
43B351FA194F131D0038C140 /* pbd.xcodeproj */,
@ -1222,6 +1235,8 @@
43279040194EFF38003C9FEA /* source */ = {
isa = PBXGroup;
children = (
95176F8D1A092A5B00E32046 /* ok_dialog.cc */,
95176F8E1A092A5B00E32046 /* yes_no_dialog.cc */,
95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */,
954DCFE01A07C70400B7160E /* sample_rate_mismatch_dialog.cc */,
954DCFDB1A07A07600B7160E /* read_only_session_dialog.cc */,
@ -1828,6 +1843,8 @@
43279429194F0062003C9FEA /* ui */ = {
isa = PBXGroup;
children = (
95176F841A092A2900E32046 /* ok_dialog.xml */,
95176F851A092A2900E32046 /* yes_no_dialog.xml */,
95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */,
954DCFE41A07D1C800B7160E /* sample_rate_mismatch_dialog.xml */,
954DCFDD1A07A14E00B7160E /* read_only_session_dialog.xml */,
@ -1875,6 +1892,8 @@
43279480194F00CB003C9FEA /* headers */ = {
isa = PBXGroup;
children = (
95176F8B1A092A4700E32046 /* ok_dialog.h */,
95176F8C1A092A4700E32046 /* yes_no_dialog.h */,
95176F781A08E6D800E32046 /* file_sample_rate_mismatch_dialog.h */,
954DCFDF1A07C6F200B7160E /* sample_rate_mismatch_dialog.h */,
954DCFD71A07A06300B7160E /* read_only_session_dialog.h */,
@ -2399,6 +2418,7 @@
4327939E194F003A003C9FEA /* record-normal-enabled.png in Resources */,
4327939F194F003A003C9FEA /* record-normal-in-progress.png in Resources */,
432793A0194F003A003C9FEA /* record-step.png in Resources */,
95176F861A092A2900E32046 /* ok_dialog.xml in Resources */,
432793A1194F003A003C9FEA /* record_disabled_grey.png in Resources */,
432793A2194F003A003C9FEA /* record_normal_red.png in Resources */,
432793A3194F003A003C9FEA /* record_tape_red.png in Resources */,
@ -2468,6 +2488,7 @@
432793E0194F003A003C9FEA /* transport_loop_prelight.png in Resources */,
432793E1194F003A003C9FEA /* transport_play.png in Resources */,
432793E2194F003A003C9FEA /* transport_play_active.png in Resources */,
95176F871A092A2900E32046 /* yes_no_dialog.xml in Resources */,
432793E3194F003A003C9FEA /* transport_play_prelight.png in Resources */,
432793E4194F003A003C9FEA /* transport_range.png in Resources */,
432793E5194F003A003C9FEA /* transport_record.png in Resources */,
@ -2550,6 +2571,7 @@
CEB9D791197516BE00B21780 /* audio_time_axis.xml in Resources */,
CEB9D792197516BE00B21780 /* automation_time_axis.xml in Resources */,
CEB9D793197516BE00B21780 /* editor_mixer.xml in Resources */,
952E0B3C1A0A1D7000F375D0 /* buildlog.txt in Resources */,
CEB9D794197516BE00B21780 /* inspector_gain_meter.xml in Resources */,
CEB9D795197516BE00B21780 /* master_ui_gain_meter.xml in Resources */,
CEB9D796197516BE00B21780 /* master_ui.xml in Resources */,
@ -2576,9 +2598,11 @@
buildActionMask = 2147483647;
files = (
43279254194EFFF1003C9FEA /* main.m in Sources */,
95176F8F1A092A5B00E32046 /* ok_dialog.cc in Sources */,
4327925B194EFFF1003C9FEA /* AppDelegate.m in Sources */,
CEAFC770195445560016ACF0 /* bbt_time.cc in Sources */,
CEAFC771195445560016ACF0 /* time.cc in Sources */,
95176F901A092A5B00E32046 /* yes_no_dialog.cc in Sources */,
CEB0A9F219583F96006D269A /* session_close_dialog.cc in Sources */,
CE1C6DCE19879F04006BDB03 /* compact_meter_bridge.cc in Sources */,
CE1C6DCF19879F04006BDB03 /* compact_meter_strip.cc in Sources */,

139
gtk2_ardour/ok_dialog.cc Normal file
View file

@ -0,0 +1,139 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "i18n.h"
#include "ok_dialog.h"
#include <vector>
using namespace Gtk;
using namespace Gdk;
using namespace std;
using namespace ARDOUR;
using namespace PBD;
using namespace Pango;
namespace {
const size_t button_left_padding = 10;
const size_t button_bottom_padding = 10;
const size_t font_size = 12;
const size_t label_top_padding = 10;
size_t count_lines(const std::string& str)
{
std::string::const_iterator beg = str.begin();
std::string::const_iterator end = str.end();
std::string::size_type count = 0;
std::string delimeter = "\n";
while ((beg + (delimeter.size() - 1)) != end)
{
std::string tmp(beg, beg + delimeter.size());
if (tmp == delimeter)
{
++count;
}
++beg;
}
return count+1;
}
int calculate_window_height (size_t current_window_height, size_t button_height, size_t font_size, size_t current_lines_number)
{
int label_max_height = (current_window_height - label_top_padding - button_height - button_bottom_padding);
int max_lines_number = label_max_height / font_size;
if ( current_lines_number > max_lines_number )
{
return current_window_height + (current_lines_number - max_lines_number) * font_size;
} else
return current_window_height;
}
}
/*
*/
OkDialog::OkDialog (std::string window_title, std::string info_lines)
: WavesDialog ( _("ok_dialog.xml"), true, false )
, _ok_button ( get_waves_button ("ok_button") )
, _info_label ( get_label("info_label") )
, _layout ( get_layout("layout") )
{
set_modal (true);
set_resizable (false);
_info_label.set_text( info_lines );
this->set_title(window_title);
// Recalculate window height if needed
std::size_t new_window_height = 0;
size_t current_window_height;
this->realize();
current_window_height = this->get_allocation().get_height();
size_t button_height = _ok_button.get_allocation().get_height();
new_window_height = calculate_window_height( current_window_height, button_height, font_size, count_lines(info_lines) );
// end recalculating
// Resize window height
if ( new_window_height > current_window_height ) {
this->realize(); // must be for correct work of get_width,height functions
guint layout_width, layout_height;
layout_width = _layout.get_allocation().get_width();
_layout.set_size_request (layout_width, new_window_height);
guint button_width, button_height;
button_width = _ok_button.get_allocation().get_width();
button_height = _ok_button.get_allocation().get_height();
_layout.put( _ok_button, layout_width - button_width - button_left_padding, new_window_height - button_height - button_bottom_padding);
}
_ok_button.signal_clicked.connect (sigc::mem_fun (*this, &OkDialog::ok_button_pressed));
show_all ();
}
void
OkDialog::on_esc_pressed ()
{
hide ();
response (Gtk::RESPONSE_OK);
}
void
OkDialog::on_enter_pressed ()
{
hide ();
response (Gtk::RESPONSE_OK);
}
void
OkDialog::ok_button_pressed (WavesButton*)
{
hide ();
response (Gtk::RESPONSE_OK);
}
OkDialog::~OkDialog ()
{
}

44
gtk2_ardour/ok_dialog.h Normal file
View file

@ -0,0 +1,44 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ok_dialog_h__
#define __ok_dialog_h__
#include "waves_dialog.h"
#include "ardour_button.h"
class OkDialog : public WavesDialog
{
public:
OkDialog(std::string window_title, std::string info_lines);
~OkDialog();
protected:
void on_esc_pressed ();
void on_enter_pressed ();
private:
void ok_button_pressed (WavesButton*);
WavesButton& _ok_button;
Gtk::Label& _info_label;
Gtk::Layout& _layout;
};
#endif /* __ok_dialog_h__ */

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<Dialog title=""
resizeable="False"
winfont ="Arial Bold 12"
macfont ="Helvetica Bold 12"
fgnormal="#6D6E72">
<style name="generic_control"
winfont ="Arial Bold 12"
macfont ="Helvetica Bold 12"
fgnormal="#6D6E72"
horzalignment="center"
justify="center"/>
<Layout id="layout"
width="350"
height="120"
bgnormal="#EDECE8">
<VBox x="0"
y="10"
width="350">
<Label id="info_label"
style="generic_control"
vertalignment="center"
text=""/>
</VBox>
<Button id="ok_button"
style="generic_control"
text="OK"
fgnormal="#6D6E72"
bgnormal="#CACAC5"
fgactive="#EDECE8"
bgactive="#6D6E72"
borderwidth="0 0 0 0"
bordercolor="#6D6E72"
width="80"
height="22"
x="260"
y="93"/>
</Layout>
</Dialog>

View file

@ -176,6 +176,7 @@ gtk2_ardour_sources = [
'note_player.cc',
'nsm.cc',
'nsmclient.cc',
'ok_dialog.cc',
'option_editor.cc',
'opts.cc',
'panner2d.cc',