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;
46 Map<Platform, SetBool> exclusionInfo { };
49 GetLastDirectory(name.contents, filePath);
50 topNode.CollectExclusionInfo(exclusionInfo, null);
51 if(topNode.FindSameNameConflict(name.contents, false, exclusionInfo, null))
53 MessageBox { type = ok, master = this, text = filePath, contents = $"File with same name already in project." }.Modal();
59 node.name = CopyString(filePath);
61 node.icon = NodeIcons::SelectFileIcon(filePath);
64 text = (s = PrintString(node.name, $" Properties"));
67 if(node.type == folder)
69 strcpy(filePath, (node.parent.type == project) ? "" : node.parent.path);
70 PathCatSlash(filePath, node.name);
72 node.path = CopyString(filePath);
73 MakeSystemPath(filePath);
74 path.contents = filePath;
81 bool PathNotifyModified(EditBox editBox)
84 node.path = CopyUnixPath(path.contents);
86 if(node.type == resources)
88 master.modifiedDocument = true;
89 node.project.topNode.modified = true;
90 ide.projectView.Update(null);
97 property ProjectNode node
101 Size minSize = { 280, 260 };
103 // name { 10, 10 } { 10, 30 }
104 // path { 10, 60 } { 10, 80 }
105 // absolutePath { 10, 110 } { 10, 130 }
110 for(topNode = node; topNode && topNode.parent; topNode = topNode.parent);
129 absolutePath.visible = false;
130 absolutePathLabel.visible = false;
131 if(node.type == resources) QuickReadOnly(name);
136 // project: - name path absolute -
138 // in res: - name path absolute -
139 // not: - name path absolute -
141 // resources: - name path -
145 text = (s = PrintString(node.name, $" Properties"));
148 name.contents = node.name;
150 char temp[MAX_LOCATION];
151 path.contents = node.path ? GetSystemPathBuffer(temp, node.path) : "";
153 if(node.type != folder && node.type != resources)
155 char filePath[MAX_LOCATION];
156 GetSystemPathBuffer(filePath, topNode.path);
157 if(node.path) PathCat(filePath, node.path);
158 PathCat(filePath, node.name);
159 if(node.type == project)
160 ChangeExtension(filePath, ProjectExtension, filePath);
161 absolutePath.contents = filePath;
164 minClientSize = minSize;
168 void QuickReadOnly(EditBox editBox)
170 editBox.textHorzScroll = true;
171 editBox.readOnly = true;
172 editBox.background = formColor;
175 bool OnKeyDown(Key key, unichar ch)
177 if(key == escape || key.code == enter || key.code == keyPadEnter)
180 if(key.code == enter || key.code == keyPadEnter)
184 char filePath[MAX_LOCATION];
186 node.GetFullFilePath(filePath, true, true);
187 if(FileExists(filePath))
188 ide.projectView.OpenNode(node, key.ctrl && key.shift);
191 document = (Window)NewCodeEditor(ide, normal, false);
192 document.NotifySaved = ide.DocumentSaved;
193 MakeSystemPath(filePath);
194 document.fileName = filePath;
197 if(mode == newFile || mode == newFolder)
199 ide.projectView.modifiedDocument = true;
200 node.project.topNode.modified = true;
202 node.project.ModifiedAllConfigs(true, false, true, true);
205 else if(mode == newFile || mode == newFolder)
207 ide.projectView.DeleteNode(node);
216 bool OnClose(bool parentClosing)
224 // tocheck: do we have a better way of doing this?
226 name.OnActivate(false, null, &b, false);
227 path.OnActivate(false, null, &b, false);
230 void UpdateFileName()
232 char filePath[MAX_LOCATION];
233 Project prj = node.project;
235 GetSystemPathBuffer(filePath, topNode.path);
236 PathCat(filePath, node.path);
237 PathCat(filePath, node.name);
238 if(node.type == project)
240 ChangeExtension(filePath, ProjectExtension, filePath);
241 absolutePath.contents = filePath;
242 master.fileName = filePath;
245 absolutePath.contents = filePath;
247 name.modifiedDocument = false;
249 path.modifiedDocument = false;
251 absolutePath.modifiedDocument = false;
253 if(prj && mode == normal)
255 ide.projectView.modifiedDocument = true;
256 prj.topNode.modified = true;
257 ide.projectView.Update(null);
258 if(node.type == file)
259 prj.ModifiedAllConfigs(true, false, false, true);