1 |
/* |
2 |
Copyright (c) 2014-2017 Christian Schoenebeck |
3 |
|
4 |
This file is part of "gigedit" and released under the terms of the |
5 |
GNU General Public License version 2. |
6 |
*/ |
7 |
|
8 |
#ifndef GIGEDIT_COMBINEINSTRUMENTSDIALOG |
9 |
#define GIGEDIT_COMBINEINSTRUMENTSDIALOG |
10 |
|
11 |
#ifdef LIBGIG_HEADER_FILE |
12 |
# include LIBGIG_HEADER_FILE(gig.h) |
13 |
#else |
14 |
# include <gig.h> |
15 |
#endif |
16 |
|
17 |
#include <gtkmm/buttonbox.h> |
18 |
#include <gtkmm/window.h> |
19 |
#include <gtkmm/dialog.h> |
20 |
#include <gtkmm/treeview.h> |
21 |
#include <gtkmm/liststore.h> |
22 |
#include <gtkmm/iconview.h> |
23 |
#include <gtkmm/table.h> |
24 |
#include <gtkmm/comboboxtext.h> |
25 |
#include <gtkmm/scrolledwindow.h> |
26 |
|
27 |
#include "wrapLabel.hh" |
28 |
#include "ManagedWindow.h" |
29 |
|
30 |
#include <set> |
31 |
|
32 |
/** |
33 |
* @brief Modal dialog which allows to merge instruments. |
34 |
* |
35 |
* This dialog shows a list of all instruments of the currently open .gig file |
36 |
* in gigedit and allows the user to shift select a set of instruments to be |
37 |
* combined. |
38 |
* |
39 |
* If the user successfully combined instruments in this dialog, then |
40 |
* newCombinedInstrument() will return a pointer to that new instrument. |
41 |
*/ |
42 |
class CombineInstrumentsDialog : public ManagedDialog { |
43 |
public: |
44 |
CombineInstrumentsDialog(Gtk::Window& parent, gig::File* gig); |
45 |
bool fileWasChanged() const; |
46 |
gig::Instrument* newCombinedInstrument() const; |
47 |
void setSelectedInstruments(const std::set<int>& instrumentIndeces); |
48 |
|
49 |
// implementation for abstract methods of interface class "ManagedDialog" |
50 |
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->combineInstrumentsWindowX; } |
51 |
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->combineInstrumentsWindowY; } |
52 |
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->combineInstrumentsWindowW; } |
53 |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->combineInstrumentsWindowH; } |
54 |
|
55 |
protected: |
56 |
gig::File* m_gig; |
57 |
bool m_fileWasChanged; |
58 |
gig::Instrument* m_newCombinedInstrument; |
59 |
|
60 |
Gtk::HButtonBox m_buttonBox; |
61 |
Gtk::ScrolledWindow m_scrolledWindow; |
62 |
Gtk::TreeView m_treeView; |
63 |
Gtk::IconView m_iconView; |
64 |
Gtk::Button m_cancelButton; |
65 |
Gtk::Button m_OKButton; |
66 |
#if GTKMM_MAJOR_VERSION < 3 |
67 |
view::WrapLabel m_descriptionLabel; |
68 |
#else |
69 |
Gtk::Label m_descriptionLabel; |
70 |
#endif |
71 |
Gtk::Table m_tableDimCombo; |
72 |
Gtk::ComboBox m_comboDimType; |
73 |
Gtk::Label m_labelDimType; |
74 |
Gtk::Label m_labelOrder; |
75 |
|
76 |
class ComboDimsModel : public Gtk::TreeModel::ColumnRecord { |
77 |
public: |
78 |
ComboDimsModel() { |
79 |
add(m_type_id); |
80 |
add(m_type_name); |
81 |
} |
82 |
|
83 |
Gtk::TreeModelColumn<int> m_type_id; |
84 |
Gtk::TreeModelColumn<Glib::ustring> m_type_name; |
85 |
} m_comboDimsModel; |
86 |
|
87 |
class ListModel : public Gtk::TreeModel::ColumnRecord { |
88 |
public: |
89 |
ListModel() { |
90 |
add(m_col_index); |
91 |
add(m_col_name); |
92 |
add(m_col_instr); |
93 |
} |
94 |
|
95 |
Gtk::TreeModelColumn<int> m_col_index; |
96 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
97 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
98 |
} m_columns; |
99 |
|
100 |
class OrderListModel : public Gtk::TreeModel::ColumnRecord { |
101 |
public: |
102 |
OrderListModel() { |
103 |
add(m_col_name); |
104 |
add(m_col_markup); |
105 |
add(m_col_instr); |
106 |
} |
107 |
|
108 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
109 |
Gtk::TreeModelColumn<Glib::ustring> m_col_markup; |
110 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
111 |
} m_orderColumns; |
112 |
|
113 |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
114 |
Glib::RefPtr<Gtk::ListStore> m_refOrderModel; |
115 |
bool first_call_to_drag_data_get; |
116 |
|
117 |
void combineSelectedInstruments(); |
118 |
void onSelectionChanged(); |
119 |
void on_order_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context); |
120 |
void on_order_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
121 |
Gtk::SelectionData& selection_data, guint, guint); |
122 |
void on_order_drop_drag_data_received( |
123 |
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
124 |
const Gtk::SelectionData& selection_data, guint, guint time |
125 |
); |
126 |
}; |
127 |
|
128 |
#endif // GIGEDIT_COMBINEINSTRUMENTSDIALOG |