3 enum NodePropertiesMode { normal, newFile, newFolder };
5 class NodeProperties : Window
8 background = formColor;
10 borderStyle = sizable;
13 //size = { 280, 260 };
15 ProjectNode node, topNode;
16 NodePropertiesMode mode;
18 Label pathLabel { parent = this, position = { 10, 60 }, labeledWindow = path };
21 this, textHorzScroll = true, position = { 10, 80 }, size = { 260 }, text = $"Path";
22 anchor = { left = 10, top = 80, right = 10 };
23 NotifyModified = PathNotifyModified;
26 Label absolutePathLabel { parent = this, position = { 10, 110 }, labeledWindow = absolutePath };
29 this, background = formColor, textHorzScroll = true, readOnly = true;
30 position = { 10, 130 }, size = { 260 }, text = $"Absolute Path";
31 anchor = { left = 10, top = 130, right = 10 };
34 Label nameLabel { parent = this, position = { 10, 10 }, labeledWindow = name };
37 this, textHorzScroll = true, position = { 10, 30 }, size = { 260 }, text = $"Name";
38 anchor = { left = 10, top = 30, right = 10 };
39 NotifyModified = NameNotifyModified;
42 bool NameNotifyModified(EditBox editBox)
44 char filePath[MAX_LOCATION];
45 char * oldName = node.name;
48 GetLastDirectory(name.contents, filePath);
49 if(topNode.Find(filePath, false))
51 MessageBox { type = ok, master = this, text = filePath, contents = $"File with same name already in project." }.Modal();
56 node.name = CopyString(filePath);
58 node.icon = NodeIcons::SelectFileIcon(filePath);
61 text = (s = PrintString(node.name, $" Properties"));
64 if(node.type == folder)
66 strcpy(filePath, (node.parent.type == project) ? "" : node.parent.path);
67 PathCatSlash(filePath, node.name);
69 node.path = CopyString(filePath);
70 MakeSystemPath(filePath);
71 path.contents = filePath;
78 bool PathNotifyModified(EditBox editBox)
81 node.path = CopyUnixPath(path.contents);
83 if(node.type == resources)
85 master.modifiedDocument = true;
86 node.project.topNode.modified = true;
87 ide.projectView.Update(null);
94 property ProjectNode node
98 Size minSize = { 280, 260 };
100 // name { 10, 10 } { 10, 30 }
101 // path { 10, 60 } { 10, 80 }
102 // absolutePath { 10, 110 } { 10, 130 }
107 for(topNode = node; topNode && topNode.parent; topNode = topNode.parent);
126 absolutePath.visible = false;
127 absolutePathLabel.visible = false;
128 if(node.type == resources) QuickReadOnly(name);
133 // project: - name path absolute -
135 // in res: - name path absolute -
136 // not: - name path absolute -
138 // resources: - name path -
142 text = (s = PrintString(node.name, $" Properties"));
145 name.contents = node.name;
147 char temp[MAX_LOCATION];
148 path.contents = node.path ? GetSystemPathBuffer(temp, node.path) : "";
150 if(node.type != folder && node.type != resources)
152 char filePath[MAX_LOCATION];
153 GetSystemPathBuffer(filePath, topNode.path);
154 if(node.path) PathCat(filePath, node.path);
155 PathCat(filePath, node.name);
156 if(node.type == project)
157 ChangeExtension(filePath, ProjectExtension, filePath);
158 absolutePath.contents = filePath;
161 minClientSize = minSize;
165 void QuickReadOnly(EditBox editBox)
167 editBox.textHorzScroll = true;
168 editBox.readOnly = true;
169 editBox.background = formColor;
172 bool OnKeyDown(Key key, unichar ch)
174 if(key == escape || key.code == enter || key.code == keyPadEnter)
177 if(key.code == enter || key.code == keyPadEnter)
181 char filePath[MAX_LOCATION];
183 node.GetFullFilePath(filePath);
184 if(FileExists(filePath))
185 ide.projectView.OpenNode(node, key.ctrl && key.shift);
188 document = (Window)NewCodeEditor(ide, normal, false);
189 document.NotifySaved = ide.DocumentSaved;
190 MakeSystemPath(filePath);
191 document.fileName = filePath;
194 if(mode == newFile || mode == newFolder)
196 ide.projectView.modifiedDocument = true;
197 node.project.topNode.modified = true;
199 node.project.ModifiedAllConfigs(true, false, true, true);
202 else if(mode == newFile || mode == newFolder)
204 ide.projectView.DeleteNode(node);
213 bool OnClose(bool parentClosing)
221 // tocheck: do we have a better way of doing this?
223 name.OnActivate(false, null, &b, false);
224 path.OnActivate(false, null, &b, false);
227 void UpdateFileName()
229 char filePath[MAX_LOCATION];
230 Project prj = node.project;
232 GetSystemPathBuffer(filePath, topNode.path);
233 PathCat(filePath, node.path);
234 PathCat(filePath, node.name);
235 if(node.type == project)
237 ChangeExtension(filePath, ProjectExtension, filePath);
238 absolutePath.contents = filePath;
239 master.fileName = filePath;
242 absolutePath.contents = filePath;
244 name.modifiedDocument = false;
246 path.modifiedDocument = false;
248 absolutePath.modifiedDocument = false;
250 if(prj && mode == normal)
252 ide.projectView.modifiedDocument = true;
253 prj.topNode.modified = true;
254 ide.projectView.Update(null);
255 if(node.type == file)
256 prj.ModifiedAllConfigs(true, false, false, true);