AeBinEditorNotify.c++
5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//
// AeBinEditorNotify.c++
//
// Contains notification routines that are called by the
// asset data base when something important happens to
// an asset (eg. created, modified, selected, etc).
//
#include <assert.h>
#include <Xm/Xm.h>
#include "Matrix.h"
#include "GList.h"
#include "AeBinEditor.h"
#include "AeAssetBase.h"
#include "AeAssetBin.h"
#include "AeAssetBinUI.h"
#include "AeAssetUI.h"
#include "AeFieldUI.h"
#include "AeBinView.h"
//
// Called by asset base's client dispatch routine to
// notify clients of a new asset.
//
void
AeBinEditor::CreateAsset (AeAsset * asset, Boolean suspended)
{
assert (asset);
if (createAssetUI (asset))
{
AeAssetBinUI * binUI;
// when adding a new asset, we must recalc all field widths
if (FindTypedBinUI (asset->GetType (), binUI))
binUI->SetNeedsWidthRecalc (True);
if (!suspended)
fView->ListUpdateUI ();
}
}
//
// Called by asset base's client dispatch routine to
// notify clients of a modified asset.
//
void
AeBinEditor::UpdateAsset (AeAsset * asset, Boolean suspended)
{
AeAsset * parent;
GList<AeAsset *> * parentList;
int i;
assert (asset);
// update the asset
updateAsset (asset);
// update any references to the asset
parentList = asset->GetParentList ();
parentList->Start (i);
while (parentList->Next (i, parent))
{
if (asset->IsParent (parent))
updateAsset (parent);
}
// make sure the column widths are up-to-date
updateWidths ();
}
//
// Called by asset base's client dispatch routine to
// notify clients of a deleted asset.
//
void
AeBinEditor::DeleteAsset (AeAsset * asset, Boolean suspended)
{
AeAssetUI * assetUI;
assert (asset);
if (asset->GetClientData (this, (void **)&assetUI))
{
AeAssetBinUI * binUI;
// when deleting an asset, we must recalc all field widths
if (FindTypedBinUI (asset->GetType (), binUI))
binUI->SetNeedsWidthRecalc (True);
// if asset is selected, deselect it and remove it from selection list
if (asset->IsSelected ())
{
asset->SetSelect (False);
fAssetBase->NotifySelect (asset);
}
// disassociate the assetUI from the asset
asset->SetClientData (this, NULL);
// delete the assetUI
delete assetUI;
if (!suspended)
fView->ListUpdateUI ();
}
}
//
// Called by asset base's client dispatch routine to
// notify clients of a selected asset.
//
void
AeBinEditor::SelectAsset (AeAsset * asset, Boolean suspended)
{
AeAssetUI * assetUI;
assert (asset);
if (asset->GetClientData (this, (void **)&assetUI))
{
if (asset->IsSelected ())
fSelectionList->Append (assetUI);
else
fSelectionList->Remove (assetUI);
if (!suspended && fView->ListAssetInView (asset))
fView->ListSelectRow (assetUI->GetRow (), asset->IsSelected ());
}
}
//
// Called by asset base's client dispatch routine to
// notify clients that the asset online status with a player
// has changed.
//
void
AeBinEditor::OnlineAsset (AeAsset * asset, Boolean suspended)
{
if (!suspended && fView->ListAssetInView (asset))
fView->ListRedraw ();
}
void
AeBinEditor::UpdateResume (void)
{
fView->ListUpdateUI ();
}
//
// There are several ways to update the UI corresponding to
// the given asset. The method used below is relatively
// straightforward and is list widget based as opposed to
// editor based. This makes sense since we need to update only
// the assets that are in the current view and only the view's
// list widget knows who is in the view and where it is. This
// information is not directly stored in the editor so we would have
// to recursively descend through the assetUI hierarchy to find the
// location of the assetUI in the list cell matrix. We could
// store this information directly in the assetUI objects but
// they would need to store both the row index and whether or
// not the assetUI is actually being displayed. Managing this
// is not worth the editor's time so just have the widget be in charge.
//
void
AeBinEditor::updateAsset (AeAsset * asset)
{
AeAssetBinUI * binUI;
AeAssetUI * assetUI;
Widget list;
int numRows;
int row;
assert (fView);
list = fView->ListGetWidget ();
assert (list);
numRows = XbaeMatrixNumRows (list);
for (row=0; row<numRows; row++)
{
assetUI = (AeAssetUI *)XbaeMatrixGetRowUserData (list, row);
if (assetUI->GetAsset () == asset)
{
if (FindTypedBinUI (asset->GetType (), binUI))
binUI->UpdateAssetUIFields (fView, assetUI, row);
}
}
}
void
AeBinEditor::updateWidths (void)
{
GList<AeFieldUI *> * fieldUIList;
AeFieldUI * fieldUI;
int i;
fieldUIList = fBinUI->GetFieldUIList ();
fieldUIList->Start (i);
while (fieldUIList->Next (i, fieldUI))
{
if (fieldUI->NeedsWidthUpdate ())
{
fView->ListUpdateUIWidths ();
break;
}
}
}
Boolean
AeBinEditor::FindTypedBinUI (TAssetType type, AeAssetBinUI* & binUI)
{
int i;
fBinUIList->Start (i);
while (fBinUIList->Next (i, binUI))
if (type == binUI->GetType ())
return True;
return False;
}