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 };
220 ExplorerToolId lastViewId;
224 Menu fileMenu { menu, "File", f };
225 Menu windowMenu { menu, "Window", w };
228 windowMenu, "New Window", n;
230 bool NotifySelect(MenuItem selection, Modifiers mods)
232 ExplorerWindow { }.Create();
241 void NotifyToolClick(TestToolBar toolBar, int id)
243 ExplorerToolId toolId = (ExplorerToolId)id;
249 ExplorerWindow { }.Create();
256 ExplorerFileBranch branch = tree.branch;
257 if(branch && branch.parent)
258 tree.Select(branch.parent);
264 split.leftPane = null;
265 split.visible = false;
266 tree.visible = false;
267 treeSplit = split.split;
268 split.OnResize(split.size.w, split.size.h);
274 search.visible = false;
275 searchSplit = split.split;
278 split.leftPane = tree;
279 split.visible = true;
280 split.split = treeSplit;
281 split.OnResize(split.size.w, split.size.h);
282 SwitchViews(lastViewId);
288 split.leftPane = null;
289 split.visible = false;
290 search.visible = false;
291 searchSplit = split.split;
292 split.OnResize(split.size.w, split.size.h);
293 SwitchViews(lastViewId);
299 tree.visible = false;
300 treeSplit = split.split;
302 search.visible = true;
303 split.leftPane = search;
304 split.visible = true;
305 split.split = searchSplit;
307 view = ExplorerSearchViewTree { viewHolder, this };
308 view.previewPictures = toolBar.previewPictures.checked;
309 view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
310 view.NotifyItemOpen = ViewNotifyItemOpen;
312 search.view = (ExplorerSearchViewTree)view;
314 split.OnResize(split.size.w, split.size.h);
321 case previewPictures:
323 view.previewPictures = toolBar.previewPictures.checked;
336 void SwitchViews(ExplorerToolId viewId)
338 ExplorerFileBranch branch = tree.branch;
342 case viewList: view = ExplorerViewList { parent = viewHolder, master = this }; break;
343 case viewDetails: view = ExplorerViewDetails { parent = viewHolder, master = this }; break;
344 case viewIcons: view = ExplorerViewIcons { parent = viewHolder, master = this }; break;
345 case viewCards: view = ExplorerViewCards { parent = viewHolder, master = this }; break;
346 case viewShowcase: view = ExplorerViewShowcase { parent = viewHolder, master = this }; break;
348 view.tabCycle = true;
349 view.previewPictures = toolBar.previewPictures.checked;
350 view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
351 view.NotifyItemOpen = ViewNotifyItemOpen;
362 anchor = Anchor { left = 0, top = 34, right = 0, bottom = 0 };
370 size = Size { 624, 268 };
371 anchor = Anchor { left = 0, top = 0, bottom = 0 };
372 text = "Browser", hotKey = Key { e, alt = true };
373 NotifyBranchSelect = TreeNotifyBranchSelect;
378 ExplorerSearch search
383 size = Size { 624, 268 };
384 anchor = Anchor { left = 0, top = 0, bottom = 0 };
387 ExplorerViewSearch results;
389 bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch)
393 char path[MAX_LOCATION];
394 branch.GetPath(path);
395 toolBar.addressBar.contents = path;
401 bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
403 ExplorerFileBranch branch = tree.branch;
406 if(item.type.isFolderType)
408 ExplorerFileBranch child;
410 if(!branch.loaded || !branch.childrenLoaded)
411 BranchLoad(branch, tree.tree);
413 for(child = branch.children.first; child; child = child.next)
414 if(!strcmp(child.name, item.name))
419 if(branch.row.collapsed)
420 child.row.collapsed = true;
421 child.EnsureVisible(false);
427 char path[MAX_LOCATION];
428 branch.GetPath(path);
429 PathCat(path, item.name);
437 parent = deep, master = this;
439 anchor = Anchor { top = 0, bottom = 0, right = 0 };
445 leftPane = tree, rightPane = viewHolder;
449 void GoToLocation(char * location)
453 char step[MAX_LOCATION];
455 StringArray steps { growingFactor = 4 };
456 ExplorerFileBranch last = null;
458 temp = CopyString(location);
461 GetLastDirectory(temp, step);
462 StripLastDirectory(temp, temp);
463 steps.Add(CopyString(step));
466 for(c = steps._count - 1; c >= 0; c--)
468 last = tree.Find(steps._[c], last);
478 void SearchLocation(char * location)
480 GoToLocation(location);
481 search.location.editBox.contents = location;
497 view = ExplorerViewList
499 parent = viewHolder, master = this;
501 previewPictures = toolBar.previewPictures.checked;
502 anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
503 NotifyItemOpen = ViewNotifyItemOpen;
505 lastViewId = viewList;
508 view.Load(tree.root);
520 class ExplorerApp : GuiApplication
526 QuickPathTool goPath { };
527 QuickPathTool searchPath { };
528 char * findWhat = null;
529 SetLoggingMode(debug, null);
532 if(!strcmpi(argv[1], "go") && argc > 2)
534 else if(!strcmpi(argv[1], "find") && argc > 2)
537 if(argv[2][0] == '\"')
538 StripQuotes(argv[2], unquoted);
541 findWhat = CopyString(unquoted);
544 if(!strcmpi(argv[3], "in") && argc > 4)
545 searchPath = argv[4];
547 searchPath = ""; // this should make it current dir
550 searchPath = ""; // same
552 else if(!strcmpi(argv[1], "search") && argc > 2)
553 searchPath = argv[2];
554 else if(!strcmpi(argv[1], "image") && argc > 2)
556 else if(!strcmpi(argv[1], "slides") && argc > 2)
565 ExplorerWindow explorerWnd { };
566 explorerWnd.Create();
567 explorerWnd.GoToLocation(goPath);
571 ExplorerWindow explorerWnd { };
572 explorerWnd.Create();
573 explorerWnd.SearchLocation(searchPath);
581 char path[MAX_LOCATION];
588 GetWorkingDir(path, MAX_LOCATION);
590 StripQuotes(value, unquoted);
593 PathCat(path, unquoted);
594 if(!FileExists(path))
596 // this incomplete functionality is not quite at it's place in this class
598 char * original = CopyString(path);
599 while((len = strlen(path)))
601 StripLastDirectory(path, path);
604 // TODO: message location does not exist,
605 // this higher location exists though
612 // TODO: message location does not exist,
613 // unable to select alternate location
619 get { return path[0] ? path : null; }
621 property bool { get { return (bool)path[0]; } }
624 define app = ((ExplorerApp)__thisModule);