explorer: introducing new explorer based on ede::FileSystemBox
[ede] / newexplorer / src / ExplorerWindow.ec
diff --git a/newexplorer/src/ExplorerWindow.ec b/newexplorer/src/ExplorerWindow.ec
new file mode 100644 (file)
index 0000000..0bd9c17
--- /dev/null
@@ -0,0 +1,208 @@
+import "Explorer"
+import "IconBag"
+import "ToolBar"
+
+enum ExplorerToolId
+{
+   none,
+   newWindow, goBack, goForward, goUp, goHome,
+   browse,
+   panelTree, panelSearch,
+   addressBar,
+   refreshView,
+   viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
+   previewPictures
+};
+
+class ExplorerWindow : Window
+{
+   text = "Ecere Explorer";
+   background = activeBorder;
+   borderStyle = sizable;
+   hasMaximize = true;
+   hasMinimize = true;
+   hasClose = true;
+   size = { 840, 480 };
+   nativeDecorations = true;
+
+   IconBag<ExplorerToolId> iconBag
+   {
+      //window = guiApp.desktop;
+      window = this;
+      alphaBlend = true;
+      iconNames =
+      [
+         "<: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 */
+      ];
+   };
+
+   Stacker stack
+   {
+      this;
+      gap = 0;
+      direction = vertical;
+      background = activeBorder;
+      //opacity = 1.0f;
+      
+      anchor = { left = 0, top = 0, right = 0, bottom = 0 };
+      //moveable = false;
+   };
+
+   ToolBar<ExplorerToolId> toolBar
+   {
+      stack, this;
+      iconBag = iconBag;
+      size = { h = 32 };
+      //moveable = false;
+   };
+
+   Window s1 { toolBar, size = { w = 8 } };
+   ToolButton goBack    { toolBar, this, id = ExplorerToolId::goBack };
+   Window s2 { toolBar, size = { w = 2 } };
+   ToolButton goForward { toolBar, this, id = ExplorerToolId::goForward };
+   Window s3 { toolBar, size = { w = 2 } };
+   ToolButton refreshView
+   {
+      toolBar, this, id = ExplorerToolId::refreshView;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         fsb.Refresh();
+         return true;
+      }
+   };
+   Window s4 { toolBar, size = { w = 2 } };
+   ToolButton goHome    { toolBar, this, id = ExplorerToolId::goHome };
+   Window s5 { toolBar, size = { w = 8 } };
+   PathBox addressBar
+   {
+      toolBar, this;
+      size = { 300, 23 }, id = ExplorerToolId::addressBar;
+      typeExpected = directory;
+
+      bool OnKeyDown(Key key, unichar ch)
+      {
+         if((SmartKey)key == enter)
+         {
+            // how to make enter effect a modification
+            // how to implement in PathBox
+         }
+         return true;
+      }
+
+      bool NotifyModified(PathBox pathBox)
+      {
+         fsb.path = pathBox.path;
+         return true;
+      }
+   };
+   Window s6 { toolBar, size = { w = 8 } };
+   ToolButton goUp
+   {
+      toolBar, this, id = ExplorerToolId::goUp;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         char * path = fsb.path;
+         char * newPath = new char[strlen(path)];
+         StripLastDirectory(path, newPath);
+         fsb.path = newPath;
+         delete newPath;
+         return true;
+      }
+   };
+   Window s7 { toolBar, size = { w = 8 } };
+   GroupToggleToolButton selectedPanel;
+   GroupToggleToolButton panelTree   { toolBar, this, id = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
+   GroupToggleToolButton panelSearch { toolBar, this, id = ExplorerToolId::panelSearch, selected = &selectedPanel };
+   selectedPanel = panelTree;
+   Window s8 { toolBar, size = { w = 8 } };
+   OptionToolButton selectedView;
+   OptionToolButton viewList     { toolBar, this, id = ExplorerToolId::viewList, selected = &selectedView, checked = true };
+   OptionToolButton viewDetails  { toolBar, this, id = ExplorerToolId::viewDetails, selected = &selectedView };
+   OptionToolButton viewIcons    { toolBar, this, id = ExplorerToolId::viewIcons, selected = &selectedView };
+   OptionToolButton viewTiles    { toolBar, this, id = ExplorerToolId::viewCards, selected = &selectedView };
+   OptionToolButton viewShowcase { toolBar, this, id = ExplorerToolId::viewShowcase, selected = &selectedView };
+   selectedView = viewList;
+   Window s9 { toolBar, size = { w = 8 } };
+   ToggleToolButton previewPictures
+   {
+      toolBar, this, id = ExplorerToolId::previewPictures;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         fsb.previewPictures = button.checked;
+         return true;
+      }
+   };
+
+   Window s10 { toolBar, size = { w = 8 } };
+   ToolButton newWindow
+   {
+      toolBar, this, id = ExplorerToolId::newWindow;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         ExplorerWindow { }.Create();
+         return true;
+      }
+   };
+
+   /*void OnDestroy()
+   {
+      iconBag.window = null;
+      delete iconBag;
+   }*/
+
+   bool OnLoadGraphics()
+   {
+      iconBag.Load();
+      return true;
+   }
+
+   void OnUnloadGraphics()
+   {
+      iconBag.Unload();
+   }
+
+   FileSystemBox fsb
+   {
+      stack, this;
+      //anchor = { left = 0, top = 4, right = 0, bottom = 0 };
+      anchor.left = 0;
+      anchor.bottom = 0;
+      anchor.right = 0;
+      locationBox = addressBar;
+      navigateFolders = true;
+   };
+
+   bool OnPostCreate()
+   {
+      addressBar.path = fsb.path;
+      return true;
+   }
+}