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