4 import "ExplorerTree" // meant to be called ExplorerTools
6 import "Search" // meant to be called ExplorerSearch
20 newWindow, goBack, goForward, goUp, goHome,
22 panelTree, panelSearch,
25 viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
29 static char * toolIconNames[] =
31 "<:ecere>emblems/unreadable.png", /* none */
33 "<:ecere>actions/windowNew.png", /* newWindow */
34 "<:ecere>actions/goPrevious.png", /* goBack */
35 "<:ecere>actions/goNext.png", /* goForward */
36 "<:ecere>actions/goUp.png", /* goUp */
37 "<:ecere>actions/goHome.png", /* goHome */
39 ":browse.png", /* browse */
41 ":panel-tree.png", /* panelTree */
42 "<:ecere>actions/editFind.png", /* panelSearch */
44 "<:ecere>emblems/unreadable.png", /* addressBar */
46 "<:ecere>actions/viewRefresh.png", /* refreshView */
48 ":view-list.png", /* viewList */
49 ":view-details.png", /* viewDetails */
50 ":view-icons.png", /* viewIcons */
51 ":view-cards.png", /* viewCards */
52 ":view-showcase-right.png", /* viewShowcase */
53 ":view-custom.png", /* viewCustom */
55 "<:ecere>mimetypes/image.png", /* previewPictures */
60 class ToolButton : Button
62 size = Size { 24, 24 };
68 bitmap = BitmapResource { fileName = toolIconNames[value], alphaBlend = true };
73 bool TestToolBar::NotifyClicked(ToolButton button, int x, int y, Modifiers mods)
75 NotifyToolClick(this.parent, this, button.id);
80 class ToggleToolButton : ToolButton
83 size = Size { 24, 24 };
85 bool TestToolBar::NotifyClicked(ToggleToolButton button, int x, int y, Modifiers mods)
87 NotifyToolClick(this.parent, this, button.id);
92 class GroupToggleToolButton : ToolButton
95 size = Size { 24, 24 };
96 GroupToggleToolButton * selected;
97 bool TestToolBar::NotifyClicked(GroupToggleToolButton button, int x, int y, Modifiers mods)
99 bool configured = (bool)button.selected;
100 bool preselection = (configured && (*button.selected));
101 bool reclick = preselection ? (*button.selected == button) : false;
102 if(configured && preselection && !reclick)
104 (*button.selected).checked = false;
105 *button.selected = button;
107 NotifyToolClick(this.parent, this, button.id);
112 class OptionToolButton : ToolButton
115 size = Size { 24, 24 };
116 OptionToolButton * selected;
117 bool TestToolBar::NotifyClicked(OptionToolButton button, int x, int y, Modifiers mods)
119 bool configured = (bool)button.selected;
120 bool preselection = (configured && (*button.selected));
121 bool reclick = preselection ? (*button.selected == button) : false;
122 if(configured && !preselection)
123 *button.selected = button;
124 else if(configured && !reclick)
126 (*button.selected).checked = false;
127 *button.selected = button;
129 button.checked = true;
131 NotifyToolClick(this.parent, this, button.id);
136 class TestToolBar : Window
142 background = activeBorder;
143 size = Size { h = 32 };
144 anchor = Anchor { left = 0, top = 0, right = 0 };
146 virtual void Window::NotifyToolClick(TestToolBar toolBar, int id);
150 ToolButton newWindow { this, anchor = { left = (xL += 20) }, toolId = ExplorerToolId::newWindow };
152 ToolButton goBack { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::goBack };
153 ToolButton goForward { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::goForward };
154 ToolButton goUp { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goUp };
155 ToolButton goHome { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goHome };
157 GroupToggleToolButton panelTree { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
158 GroupToggleToolButton panelSearch { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::panelSearch, selected = &selectedPanel };
159 GroupToggleToolButton selectedPanel;
160 selectedPanel = panelTree;
164 OptionToolButton viewList { this, anchor = { right = (xR += 20) }, toolId = ExplorerToolId::viewList, selected = &selectedView, checked = true };
165 OptionToolButton viewDetails { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewDetails, selected = &selectedView };
166 OptionToolButton viewIcons { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewIcons, selected = &selectedView };
167 OptionToolButton viewTiles { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewCards, selected = &selectedView };
168 OptionToolButton viewShowcase { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewShowcase, selected = &selectedView };
169 OptionToolButton selectedView;
170 selectedView = viewList;
172 ToggleToolButton previewPictures { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::previewPictures };
174 ToolButton refreshView { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::refreshView };
179 size = { w = 250 }, anchor = { left = (xL += 30), right = (xR += 30) }, id = ExplorerToolId::addressBar;
185 anchor = { left = (xPos += 88) };
188 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
196 /*tileSet.AddString("Forest").tag = 0;
197 tileSet.AddString("Winter").tag = 0;
198 tileSet.AddString("Wasteland").tag = 0;*/
202 class ExplorerWindow : Window
204 text = "Ecere Explorer";
205 background = activeBorder;
206 borderStyle = sizable;
212 size = Size { 888, 840 };
213 nativeDecorations = true;
221 ExplorerToolId lastViewId;
225 Menu fileMenu { menu, "File", f };
226 Menu windowMenu { menu, "Window", w };
229 windowMenu, "New Window", n;
231 bool NotifySelect(MenuItem selection, Modifiers mods)
233 ExplorerWindow { }.Create();
242 void NotifyToolClick(TestToolBar toolBar, int id)
244 ExplorerToolId toolId = (ExplorerToolId)id;
250 ExplorerWindow { }.Create();
257 ExplorerFileBranch branch = tree.branch;
258 if(branch && branch.parent)
259 tree.Select(branch.parent);
265 split.leftPane = null;
266 split.visible = false;
267 tree.visible = false;
268 treeSplit = split.split;
269 split.OnResize(split.size.w, split.size.h);
275 search.visible = false;
276 searchSplit = split.split;
279 split.leftPane = tree;
280 split.visible = true;
281 split.split = treeSplit;
282 split.OnResize(split.size.w, split.size.h);
283 SwitchViews(lastViewId);
289 split.leftPane = null;
290 split.visible = false;
291 search.visible = false;
292 searchSplit = split.split;
293 split.OnResize(split.size.w, split.size.h);
294 SwitchViews(lastViewId);
300 tree.visible = false;
301 treeSplit = split.split;
303 search.visible = true;
304 split.leftPane = search;
305 split.visible = true;
306 split.split = searchSplit;
308 view = ExplorerSearchViewTree { viewHolder, this };
309 view.previewPictures = toolBar.previewPictures.checked;
310 view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
311 view.NotifyItemOpen = ViewNotifyItemOpen;
313 search.view = (ExplorerSearchViewTree)view;
315 split.OnResize(split.size.w, split.size.h);
322 case previewPictures:
324 view.previewPictures = toolBar.previewPictures.checked;
337 void SwitchViews(ExplorerToolId viewId)
339 ExplorerFileBranch branch = tree.branch;
343 case viewList: view = ExplorerViewList { parent = viewHolder, master = this }; break;
344 case viewDetails: view = ExplorerViewDetails { parent = viewHolder, master = this }; break;
345 case viewIcons: view = ExplorerViewIcons { parent = viewHolder, master = this }; break;
346 case viewCards: view = ExplorerViewCards { parent = viewHolder, master = this }; break;
347 case viewShowcase: view = ExplorerViewShowcase { parent = viewHolder, master = this }; break;
349 view.tabCycle = true;
350 view.previewPictures = toolBar.previewPictures.checked;
351 view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
352 view.NotifyItemOpen = ViewNotifyItemOpen;
363 anchor = Anchor { left = 0, top = 34, right = 0, bottom = 0 };
371 size = Size { 624, 268 };
372 anchor = Anchor { left = 0, top = 0, bottom = 0 };
373 text = "Browser", hotKey = Key { e, alt = true };
374 NotifyBranchSelect = TreeNotifyBranchSelect;
379 ExplorerSearch search
384 size = Size { 624, 268 };
385 anchor = Anchor { left = 0, top = 0, bottom = 0 };
388 ExplorerViewSearch results;
390 bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch)
394 char path[MAX_LOCATION];
395 branch.GetPath(path);
396 toolBar.addressBar.contents = path;
402 bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
404 ExplorerFileBranch branch = tree.branch;
407 if(item.type.isFolderType)
409 ExplorerFileBranch child;
411 if(!branch.loaded || !branch.childrenLoaded)
412 BranchLoad(branch, tree.tree);
414 for(child = branch.children.first; child; child = child.next)
415 if(!strcmp(child.name, item.name))
420 if(branch.row.collapsed)
421 child.row.collapsed = true;
422 child.EnsureVisible(false);
428 char path[MAX_LOCATION];
429 branch.GetPath(path);
430 PathCat(path, item.name);
438 parent = deep, master = this;
440 anchor = Anchor { top = 0, bottom = 0, right = 0 };
446 leftPane = tree, rightPane = viewHolder;
450 void GoToLocation(char * location)
454 char step[MAX_LOCATION];
456 StringArray steps { growingFactor = 4 };
457 ExplorerFileBranch last = null;
459 temp = CopyString(location);
462 GetLastDirectory(temp, step);
463 StripLastDirectory(temp, temp);
464 steps.Add(CopyString(step));
467 for(c = steps._count - 1; c >= 0; c--)
469 last = tree.Find(steps._[c], last);
479 void SearchLocation(char * location)
481 GoToLocation(location);
482 search.location.editBox.contents = location;
498 view = ExplorerViewList
500 parent = viewHolder, master = this;
502 previewPictures = toolBar.previewPictures.checked;
503 anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
504 NotifyItemOpen = ViewNotifyItemOpen;
506 lastViewId = viewList;
509 view.Load(tree.root);
521 class ExplorerApp : GuiApplication
527 QuickPathTool goPath { };
528 QuickPathTool searchPath { };
529 char * findWhat = null;
530 SetLoggingMode(debug, null);
533 if(!strcmpi(argv[1], "go") && argc > 2)
535 else if(!strcmpi(argv[1], "find") && argc > 2)
538 if(argv[2][0] == '\"')
539 StripQuotes(argv[2], unquoted);
542 findWhat = CopyString(unquoted);
545 if(!strcmpi(argv[3], "in") && argc > 4)
546 searchPath = argv[4];
548 searchPath = ""; // this should make it current dir
551 searchPath = ""; // same
553 else if(!strcmpi(argv[1], "search") && argc > 2)
554 searchPath = argv[2];
555 else if(!strcmpi(argv[1], "image") && argc > 2)
557 else if(!strcmpi(argv[1], "slides") && argc > 2)
566 ExplorerWindow explorerWnd { };
567 explorerWnd.Create();
568 explorerWnd.GoToLocation(goPath);
572 ExplorerWindow explorerWnd { };
573 explorerWnd.Create();
574 explorerWnd.SearchLocation(searchPath);
582 char path[MAX_LOCATION];
589 GetWorkingDir(path, MAX_LOCATION);
591 StripQuotes(value, unquoted);
594 PathCat(path, unquoted);
595 if(!FileExists(path))
597 // this incomplete functionality is not quite at it's place in this class
599 char * original = CopyString(path);
600 while((len = strlen(path)))
602 StripLastDirectory(path, path);
605 // TODO: message location does not exist,
606 // this higher location exists though
613 // TODO: message location does not exist,
614 // unable to select alternate location
620 get { return path[0] ? path : null; }
622 property bool { get { return (bool)path[0]; } }
625 define app = ((ExplorerApp)__thisModule);