bunch of changes, unfortunate lack of commits
[ede] / explorer / src / Explorer.ec
index 96958ab..8bfeaa8 100644 (file)
@@ -1,10 +1,10 @@
-public import "ecere"
-import "SplitWindow"
+import "ecere"
+import "EDE"
+import "ExplorerWindow"
 
-import "ExplorerTree" // meant to be called ExplorerTools
-import "Finder"
-import "Search"       // meant to be called ExplorerSearch
-import "Panels"
+//import "Finder"
+//import "Search"
+//import "Panels"
 
 /*
 #ifdef __WIN32__
@@ -14,511 +14,7 @@ import "Panels"
 #endif
 */
 
-enum ExplorerToolId
-{
-   none,
-   newWindow, goBack, goForward, goUp, goHome,
-   browse,
-   panelTree, panelSearch,
-   addressBar,
-   refreshView,
-   viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
-   previewPictures
-};
-
-static char * toolIconNames[] = 
-{
-   "<:ecere>emblems/unreadable.png",     /* none */
-
-   "<:ecere>actions/windowNew.png",            /* newWindow */
-   "<:ecere>actions/goPrevious.png",           /* goBack */
-   "<:ecere>actions/goNext.png",               /* goForward */
-   "<:ecere>actions/goUp.png",                 /* goUp */
-   "<:ecere>actions/goHome.png",               /* goHome */
-
-   ":browse.png",                                           /* browse */
-
-   ":panel-tree.png",                                       /* panelTree */
-   "<:ecere>actions/editFind.png",             /* panelSearch */
-
-   "<:ecere>emblems/unreadable.png",     /* addressBar */
-
-   "<:ecere>actions/viewRefresh.png",          /* refreshView */
-
-   ":view-list.png",                                        /* viewList */
-   ":view-details.png",                                     /* viewDetails */
-   ":view-icons.png",                                       /* viewIcons */
-   ":view-cards.png",                                       /* viewCards */
-   ":view-showcase-right.png",                              /* viewShowcase */
-   ":view-custom.png",                                      /* viewCustom */
-   
-   "<:ecere>mimetypes/image.png",     /* previewPictures */
-   
-   ""
-};
-
-class ToolButton : Button
-{
-   size = Size { 24, 24 };
-
-   property int toolId
-   {
-      set
-      {
-         bitmap = BitmapResource { fileName = toolIconNames[value], alphaBlend = true };
-         id = value;
-      }
-   }
-
-   bool TestToolBar::NotifyClicked(ToolButton button, int x, int y, Modifiers mods)
-   {
-      NotifyToolClick(this.parent, this, button.id);
-      return true;
-   }
-}
-
-class ToggleToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   
-   bool TestToolBar::NotifyClicked(ToggleToolButton button, int x, int y, Modifiers mods)
-   {
-      NotifyToolClick(this.parent, this, button.id);
-      return true;
-   }
-}
-
-class GroupToggleToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   GroupToggleToolButton * selected;
-   bool TestToolBar::NotifyClicked(GroupToggleToolButton button, int x, int y, Modifiers mods)
-   {
-      bool configured = (bool)button.selected;
-      bool preselection = (configured && (*button.selected));
-      bool reclick = preselection ? (*button.selected == button) : false;
-      if(configured && preselection && !reclick)
-      {
-         (*button.selected).checked = false;
-         *button.selected = button;
-      }
-      NotifyToolClick(this.parent, this, button.id);
-      return true;
-   }
-}
-
-class OptionToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   OptionToolButton * selected;
-   bool TestToolBar::NotifyClicked(OptionToolButton button, int x, int y, Modifiers mods)
-   {
-      bool configured = (bool)button.selected;
-      bool preselection = (configured && (*button.selected));
-      bool reclick = preselection ? (*button.selected == button) : false;
-      if(configured && !preselection)
-         *button.selected = button;
-      else if(configured && !reclick)
-      {
-         (*button.selected).checked = false;
-         *button.selected = button;
-      }
-      button.checked = true;
-      if(!reclick)
-         NotifyToolClick(this.parent, this, button.id);
-      return true;
-   }
-}
-
-class TestToolBar : Window
-{
-   int xL, xR;
-
-   borderStyle = bevel;
-   inactive = true;
-   background = activeBorder;
-   size = Size { h = 32 };
-   anchor = Anchor { left = 0, top = 0, right = 0 };
-
-   virtual void Window::NotifyToolClick(TestToolBar toolBar, int id);
-
-   xL = 0;
-
-   ToolButton newWindow { this, anchor = { left = (xL += 20) }, toolId = ExplorerToolId::newWindow };
-
-   ToolButton goBack    { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::goBack };
-   ToolButton goForward { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::goForward };
-   ToolButton goUp      { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goUp };
-   ToolButton goHome    { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goHome };
-
-   GroupToggleToolButton panelTree   { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
-   GroupToggleToolButton panelSearch { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::panelSearch, selected = &selectedPanel };
-   GroupToggleToolButton selectedPanel;
-   selectedPanel = panelTree;
-
-   xR = 0;
-
-   OptionToolButton viewList     { this, anchor = { right = (xR += 20) }, toolId = ExplorerToolId::viewList, selected = &selectedView, checked = true };
-   OptionToolButton viewDetails  { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewDetails, selected = &selectedView };
-   OptionToolButton viewIcons    { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewIcons, selected = &selectedView };
-   OptionToolButton viewTiles    { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewCards, selected = &selectedView };
-   OptionToolButton viewShowcase { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewShowcase, selected = &selectedView };
-   OptionToolButton selectedView;
-   selectedView = viewList;
-
-   ToggleToolButton previewPictures { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::previewPictures };
-
-   ToolButton refreshView { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::refreshView };
-
-   EditBox addressBar
-   {
-      this, master;
-      size = { w = 250 }, anchor = { left = (xL += 30), right = (xR += 30) }, id = ExplorerToolId::addressBar;
-   };
-
-   /*DropBox tileSet
-   {
-      this,
-      anchor = { left = (xPos += 88) };
-      inactive = true;
-
-      bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
-      {
-         return true;
-      }
-   };*/
-
-   TestToolBar()
-   {
-      /*tileSet.AddString("Forest").tag = 0;
-      tileSet.AddString("Winter").tag = 0;
-      tileSet.AddString("Wasteland").tag = 0;*/
-   }
-};
-
-class ExplorerWindow : Window
-{
-   text = "Ecere Explorer";
-   background = activeBorder;
-   borderStyle = sizable;
-   hasMaximize = true;
-   hasMinimize = true;
-   hasClose = true;
-   hasMenuBar = true;
-   tabCycle = true;
-   size = Size { 888, 840 };
-   nativeDecorations = true;
-
-   bool userMode;
-   bool clipboard;
-
-   int treeSplit;
-   int searchSplit;
-   
-   ExplorerToolId lastViewId;
-
-   menu = Menu { };
-   
-   Menu fileMenu { menu, "File", f };
-   Menu windowMenu { menu, "Window", w };
-      MenuItem newWindow
-      {
-         windowMenu, "New Window", n;
-         
-         bool NotifySelect(MenuItem selection, Modifiers mods)
-         {
-            ExplorerWindow { }.Create();
-            return true;
-         }
-      };
-
-   TestToolBar toolBar
-   {
-      this;
-
-      void NotifyToolClick(TestToolBar toolBar, int id)
-      {
-         ExplorerToolId toolId = (ExplorerToolId)id;
-         switch(toolId)
-         {
-            case none:
-               break;
-            case newWindow:
-               ExplorerWindow { }.Create();
-               break;
-            case goBack:
-            case goForward:
-               break;
-            case goUp:
-            {
-               ExplorerFileBranch branch = tree.branch;
-               if(branch && branch.parent)
-                  tree.Select(branch.parent);
-               break;
-            }
-            case panelTree:
-               if(tree.visible)
-               {
-                  split.leftPane = null;
-                  split.visible = false;
-                  tree.visible = false;
-                  treeSplit = split.split;
-                  split.OnResize(split.size.w, split.size.h);
-               }
-               else
-               {
-                  if(search.visible)
-                  {
-                     search.visible = false;
-                     searchSplit = split.split;
-                  }
-                  tree.visible = true;
-                  split.leftPane = tree;
-                  split.visible = true;
-                  split.split = treeSplit;
-                  split.OnResize(split.size.w, split.size.h);
-                  SwitchViews(lastViewId);
-               }
-               break;
-            case panelSearch:
-               if(search.visible)
-               {
-                  split.leftPane = null;
-                  split.visible = false;
-                  search.visible = false;
-                  searchSplit = split.split;
-                  split.OnResize(split.size.w, split.size.h);
-                  SwitchViews(lastViewId);
-               }
-               else
-               {
-                  if(tree.visible)
-                  {
-                     tree.visible = false;
-                     treeSplit = split.split;
-                  }
-                  search.visible = true;
-                  split.leftPane = search;
-                  split.visible = true;
-                  split.split = searchSplit;
-
-                  view = ExplorerSearchViewTree { viewHolder, this };
-                  view.previewPictures = toolBar.previewPictures.checked;
-                  view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
-                  view.NotifyItemOpen = ViewNotifyItemOpen;
-                  view.Create();
-                  search.view = (ExplorerSearchViewTree)view;
-
-                  split.OnResize(split.size.w, split.size.h);
-               }
-               break;
-            case refreshView:
-               if(view)
-                  view.Refresh();
-               break;
-            case previewPictures:
-               if(view)
-                  view.previewPictures = toolBar.previewPictures.checked;
-               break;
-            case viewList:
-            case viewDetails:
-            case viewIcons:
-            case viewCards:
-            case viewShowcase:
-               SwitchViews(toolId);
-               break;
-         }
-      }
-   };
-
-   void SwitchViews(ExplorerToolId viewId)
-   {
-      ExplorerFileBranch branch = tree.branch;
-      view.Destroy(0);
-      switch(viewId)
-      {
-         case viewList:     view = ExplorerViewList     { parent = viewHolder, master = this }; break;
-         case viewDetails:  view = ExplorerViewDetails  { parent = viewHolder, master = this }; break;
-         case viewIcons:    view = ExplorerViewIcons    { parent = viewHolder, master = this }; break;
-         case viewCards:    view = ExplorerViewCards    { parent = viewHolder, master = this }; break;
-         case viewShowcase: view = ExplorerViewShowcase { parent = viewHolder, master = this }; break;
-      }
-      view.tabCycle = true;
-      view.previewPictures = toolBar.previewPictures.checked;
-      view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
-      view.NotifyItemOpen = ViewNotifyItemOpen;
-      view.Create();
-      view.Load(branch);
-      lastViewId = viewId;
-   }
-
-   Window deep
-   {
-      this;
-      borderStyle = deep;
-      tabCycle = true;
-      anchor = Anchor { left = 0, top = 34, right = 0, bottom = 0 };
-   };
-
-   ExplorerTree tree
-   {
-      deep, this;
-      //visible = false;
-      tabCycle = true;
-      size = Size { 624, 268 };
-      anchor = Anchor { left = 0, top = 0, bottom = 0 };
-      text = "Browser", hotKey = Key { e, alt = true };
-      NotifyBranchSelect = TreeNotifyBranchSelect;
-   };
-   
-   ExplorerView view;
-
-   ExplorerSearch search
-   {
-      deep, this;
-      visible = false;
-      tabCycle = true;
-      size = Size { 624, 268 };
-      anchor = Anchor { left = 0, top = 0, bottom = 0 };
-   };
-
-   ExplorerViewSearch results;
-
-   bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch)
-   {
-      if(branch)
-      {
-         char path[MAX_LOCATION];
-         branch.GetPath(path);
-         toolBar.addressBar.contents = path;
-         view.Load(branch);
-      }
-      return true;
-   }
-   
-   bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
-   {
-      ExplorerFileBranch branch = tree.branch;
-      if(item && branch)
-      {
-         if(item.type.isFolderType)
-         {
-            ExplorerFileBranch child;
-            
-            if(!branch.loaded || !branch.childrenLoaded)
-               BranchLoad(branch, tree.tree);
-
-            for(child = branch.children.first; child; child = child.next)
-               if(!strcmp(child.name, item.name))
-                  break;
-            
-            if(child)
-            {
-               if(branch.row.collapsed)
-                  child.row.collapsed = true;
-               child.EnsureVisible(false);
-               tree.Select(child);
-            }
-         }
-         else
-         {
-            char path[MAX_LOCATION];
-            branch.GetPath(path);
-            PathCat(path, item.name);
-            ShellOpen(path);
-         }
-      }
-   }
-
-   Window viewHolder
-   {
-      parent = deep, master = this;
-      tabCycle = true;
-      anchor = Anchor { top = 0, bottom = 0, right = 0 };
-   };
-
-   SplitWindow split
-   {
-      deep, this;
-      leftPane = tree, rightPane = viewHolder;
-      split = 300;
-   };
-
-   void GoToLocation(char * location)
-   {
-      int c;
-      char * temp;
-      char step[MAX_LOCATION];
-      
-      StringArray steps { growingFactor = 4 };
-      ExplorerFileBranch last = null;
-      
-      temp = CopyString(location);
-      while(strlen(temp))
-      {
-         GetLastDirectory(temp, step);
-         StripLastDirectory(temp, temp);
-         steps.Add(CopyString(step));
-      }
-      
-      for(c = steps._count - 1; c >= 0; c--)
-      {
-         last = tree.Find(steps._[c], last);
-         if(!last)
-            break;
-         tree.Select(last);
-      }
-      
-      delete temp;
-      delete steps;
-   }
-
-   void SearchLocation(char * location)
-   {
-      GoToLocation(location);
-      search.location.editBox.contents = location;
-   }
-
-   bool OnPostCreate()
-   {
-      userMode = true;
-      return true;
-   }
-
-   ExplorerWindow()
-   {
-      userMode = false;
-
-      treeSplit = 300;
-      searchSplit = 200;
-
-      view = ExplorerViewList
-      {
-         parent = viewHolder, master = this;
-         tabCycle = true;
-         previewPictures = toolBar.previewPictures.checked;
-         anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
-         NotifyItemOpen = ViewNotifyItemOpen;
-      };
-      lastViewId = viewList;
-      
-      tree.Load();
-      view.Load(tree.root);
-   }
-
-   void InitTree()
-   {
-   }
-
-   void InitSearch()
-   {
-   }
-}
-
-class ExplorerApp : GuiApplication
+class Explorer : GuiApplication
 {
    //skin = "Acovel";
 
@@ -527,7 +23,9 @@ class ExplorerApp : GuiApplication
       QuickPathTool goPath { };
       QuickPathTool searchPath { };
       char * findWhat = null;
+
       SetLoggingMode(debug, null);
+
       if(argc > 1)
       {
          if(!strcmpi(argv[1], "go") && argc > 2)
@@ -565,13 +63,13 @@ class ExplorerApp : GuiApplication
       {
          ExplorerWindow explorerWnd { };
          explorerWnd.Create();
-         explorerWnd.GoToLocation(goPath);
+         explorerWnd.GoTo(goPath, false, false);
       }
       else if(searchPath)
       {
          ExplorerWindow explorerWnd { };
          explorerWnd.Create();
-         explorerWnd.SearchLocation(searchPath);
+         //explorerWnd.SearchLocation(searchPath);
       }
       return true;
    }
@@ -619,7 +117,7 @@ struct QuickPathTool
       }
       get { return path[0] ? path : null; }
    }
-   property bool { get { return (bool)path[0]; } }
+   property bool { get { return path[0] != '\0'; } }
 };
 
-define app = ((ExplorerApp)__thisModule);
+define app = ((Explorer)__thisModule);