1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006, 2007 Andreas Persson |
* Copyright (C) 2006 - 2017 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#ifndef GIGEDIT_DIMENSIONMANAGER_H |
#ifndef GIGEDIT_DIMENSIONMANAGER_H |
21 |
#define GIGEDIT_DIMENSIONMANAGER_H |
#define GIGEDIT_DIMENSIONMANAGER_H |
22 |
|
|
23 |
|
#include "compat.h" |
24 |
|
#include <glibmm/property.h> |
25 |
|
#include <gtkmm/box.h> |
26 |
#include <gtkmm/window.h> |
#include <gtkmm/window.h> |
27 |
#include <gtkmm/layout.h> |
#include <gtkmm/layout.h> |
28 |
#include <gtkmm/button.h> |
#include <gtkmm/button.h> |
30 |
#include <gtkmm/treeview.h> |
#include <gtkmm/treeview.h> |
31 |
#include <gtkmm/liststore.h> |
#include <gtkmm/liststore.h> |
32 |
#include <gtkmm/scrolledwindow.h> |
#include <gtkmm/scrolledwindow.h> |
33 |
|
#include <gtkmm/checkbutton.h> |
34 |
|
|
35 |
#include <gig.h> |
#ifdef LIBGIG_HEADER_FILE |
36 |
|
# include LIBGIG_HEADER_FILE(gig.h) |
37 |
|
#else |
38 |
|
# include <gig.h> |
39 |
|
#endif |
40 |
|
|
41 |
class DimensionManager : public Gtk::Window { |
#include <set> |
42 |
|
#include "ManagedWindow.h" |
43 |
|
|
44 |
|
class DimTypeCellRenderer : public Gtk::CellRendererText { |
45 |
|
public: |
46 |
|
Glib::PropertyProxy<gig::dimension_t> propertyDimType() { |
47 |
|
return m_propertyDimType.get_proxy(); |
48 |
|
} |
49 |
|
|
50 |
|
Glib::PropertyProxy<int> propertyUsageCount() { |
51 |
|
return m_propertyUsageCount.get_proxy(); |
52 |
|
} |
53 |
|
|
54 |
|
Glib::PropertyProxy<int> propertyTotalRegions() { |
55 |
|
return m_propertyTotalRegions.get_proxy(); |
56 |
|
} |
57 |
|
|
58 |
|
DimTypeCellRenderer(); |
59 |
|
protected: |
60 |
|
void typeChanged(); |
61 |
|
void statsChanged(); |
62 |
|
private: |
63 |
|
Glib::Property<gig::dimension_t> m_propertyDimType; |
64 |
|
Glib::Property<int> m_propertyUsageCount; |
65 |
|
Glib::Property<int> m_propertyTotalRegions; |
66 |
|
}; |
67 |
|
|
68 |
|
class IntSetCellRenderer : public Gtk::CellRendererText { |
69 |
|
public: |
70 |
|
Glib::PropertyProxy<std::set<int> > propertyValue() { |
71 |
|
return m_propertyValue.get_proxy(); |
72 |
|
} |
73 |
|
|
74 |
|
IntSetCellRenderer(); |
75 |
|
protected: |
76 |
|
void valueChanged(); |
77 |
|
private: |
78 |
|
Glib::Property<std::set<int> > m_propertyValue; |
79 |
|
}; |
80 |
|
|
81 |
|
class DimensionManager : public ManagedWindow { |
82 |
public: |
public: |
83 |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
84 |
sigc::signal<void, gig::Region*> region_changed_signal; |
sigc::signal<void, gig::Region*> region_changed_signal; |
85 |
|
|
86 |
DimensionManager(); |
DimensionManager(); |
87 |
void show(gig::Region* region); |
void show(gig::Region* region); |
88 |
|
void set_region(gig::Region* region); |
89 |
|
|
90 |
|
// implementation for abstract methods of interface class "ManagedWindow" |
91 |
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->dimensionManagerWindowX; } |
92 |
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->dimensionManagerWindowY; } |
93 |
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->dimensionManagerWindowW; } |
94 |
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->dimensionManagerWindowH; } |
95 |
|
|
96 |
protected: |
protected: |
97 |
gig::Region* region; |
gig::Region* region; |
98 |
Gtk::VBox vbox; |
VBox vbox; |
99 |
Gtk::HButtonBox buttonBox; |
HButtonBox buttonBox; |
100 |
Gtk::ScrolledWindow scrolledWindow; |
Gtk::ScrolledWindow scrolledWindow; |
101 |
Gtk::TreeView treeView; |
Gtk::TreeView treeView; |
102 |
Gtk::Button addButton; |
Gtk::Button addButton; |
103 |
Gtk::Button removeButton; |
Gtk::Button removeButton; |
104 |
|
Gtk::CheckButton allRegionsCheckBox; |
105 |
|
|
106 |
|
DimTypeCellRenderer m_cellRendererDimType; |
107 |
|
IntSetCellRenderer m_cellRendererIntSet; |
108 |
|
|
109 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
110 |
public: |
public: |
111 |
ModelColumns() { |
ModelColumns() { |
112 |
add(m_dim_type); |
add(m_type); |
113 |
add(m_bits); |
add(m_bits); |
114 |
add(m_zones); |
add(m_zones); |
115 |
add(m_description); |
add(m_description); |
116 |
add(m_definition); |
add(m_usageCount); |
117 |
|
add(m_totalRegions); |
118 |
} |
} |
119 |
|
|
120 |
Gtk::TreeModelColumn<Glib::ustring> m_dim_type; |
Gtk::TreeModelColumn<gig::dimension_t> m_type; |
121 |
Gtk::TreeModelColumn<int> m_bits; |
Gtk::TreeModelColumn<std::set<int> > m_bits; |
122 |
Gtk::TreeModelColumn<int> m_zones; |
Gtk::TreeModelColumn<std::set<int> > m_zones; |
123 |
Gtk::TreeModelColumn<Glib::ustring> m_description; |
Gtk::TreeModelColumn<Glib::ustring> m_description; |
124 |
Gtk::TreeModelColumn<gig::dimension_def_t*> m_definition; |
Gtk::TreeModelColumn<int> m_usageCount; |
125 |
|
Gtk::TreeModelColumn<int> m_totalRegions; |
126 |
} tableModel; |
} tableModel; |
127 |
|
|
128 |
class ComboModelColumns : public Gtk::TreeModel::ColumnRecord { |
class ComboModelColumns : public Gtk::TreeModel::ColumnRecord { |
137 |
} comboModel; |
} comboModel; |
138 |
|
|
139 |
Glib::RefPtr<Gtk::ListStore> refTableModel; |
Glib::RefPtr<Gtk::ListStore> refTableModel; |
140 |
|
bool ignoreColumnClicked; //HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired |
141 |
|
|
142 |
|
void onAllRegionsCheckBoxToggled(); |
143 |
|
void onColumnClicked(); |
144 |
void refreshManager(); |
void refreshManager(); |
145 |
void addDimension(); |
void addDimension(); |
146 |
void removeDimension(); |
void removeDimension(); |
147 |
|
bool allRegions() const; |
148 |
}; |
}; |
149 |
|
|
150 |
#endif // GIGEDIT_DIMENSIONMANAGER_H |
#endif // GIGEDIT_DIMENSIONMANAGER_H |