= Single Window = ''The page about the graphical layout of the single window user interface.'' == Previous suggestions == Previously, ideas for this topic were collected at the [https://grasswiki.osgeo.org/wiki/WxPython-based_GUI_for_GRASS#General_GUI_Design WxPython-based GUI for GRASS] wiki page at GRASS user wiki. == Merging to trunk policy == * single window GUI should be `g.gui.*` module placed in addons * Q: Is this now technicaly possible? * duplicated code cannot be committed into trunk * code in addons which duplicates code in trunk is tolerated as a temporal solution * code which has to be changed in the trunk should be changed by a self-contained patches * changed means refactored in this case * it is critical that new code will work with the old GUI and the `g.gui.*` module in addons (this demonstrates also good code quality) * only finished single window GUI which will not cause any code duplication can be committed into trunk == **WIP** == == Background == After significant improvements of the Data Catalog [https://trac.osgeo.org/grass/wiki/GSoC/2020/StartupWindow], which led to the creation of a new startup mechanism and the removal of the startup screen, another topic enhancing the user experience comes into consideration - a Single-Window User Interface. All historical versions of GRASS GIS are spread across multiple screens. It can be beneficial for some, but it can be a bit annoying as well, e.g. tabs in Layer Manager can cause trouble to new users. The new design would therefore assume that all panels would be visible immediately after startup. The fact that a Single Window layout would really be appreciated by users can also be deduced from the surveys conducted in my master thesis [https://github.com/ctu-geoforall- lab-projects/dp-kladivova-2021/blob/master/text/linda-kladivova-dp-2021.pdf]. Of course, especially long-term users can prefer the existing multi-window layout, so the original option will be retained. The Single-Window GUI will therefore be built "next to" the existing Multi-Window GUI. As an example, the GIMP software works similarly. It is also left to the user the option to switch to multi-layout, but by default, it starts in a single layout. == State of Art in version 7.9 (Multiple-Window Layout) == First, let's look at the current solution in version 7.9 (Spring 2021). GRASS GIS consists of two windows (frames) after launch - Layer Manager and Map Display. Additional maps can be opened as separate Map Display windows. Each Map Display window corresponds to the Map Display tab defining the visual content of a particular Map Display window. [[Image(several_map_displays.PNG, 1100px, title=Figure 1: Illustration of several open Map Display windows and their associated Map Display tabs, align=center)]] GRASS GIS Layer Manager contains the Menu from the top, then three dockable toolbars Workspace, Tools, and Misc. [[Image(menu_toolbars.PNG, 500px, title=Figure 2: Menu bar and dockable toolbars in version 7.9, align=center)]] The most spatially extensive widget is a notebook, which in a standard 2D projection contains 5 tabs - Data, Display, Modules, Console, and Python. When switching to 3D projection, this number is increased by the 3D view tab. [[Image(tabs.png, 1400px, title=Figure 3: Individual tabs - Data; Display; Modules; Console; Python; and 3D view, align=center)]] In addition to the Data Catalog, the Data tab also contains the Data Catalog toolbar and the infobar object. Similarly, the Display tab now has its own group of buttons - Display toolbar. These tabs were created by moving some of the previously available buttons in the dockable toolbars at the top of the Layer Manager. Thus, in version 7.9, each tab forms a certain whole which will be further preserved for a single layout. == Proposal for Single-Window GUI Mode == The mock-up layout in Figure 4 is visually inspired by the layout in QGIS. Like QGIS or other GIS software, it contains a data catalog and layer catalog on the left, and a catalog of tools (modules) on the right. [[Image(single_window_layout.png, 1500px, title=Figure 4: Designed Single-Window GUI, align=center)]] The design is based on the ''wx.Aui.Manager'' class, which is the central class of the wx.lib.agw.aui framework - re-implementation of wx.aui framework using only Python code instead of c++. In this class, we create so-called panes i.e. panels with docking and floating behavior (more [https://wxpython.org/Phoenix/docs/html/wx.aui.AuiManager.html]). ''wx.Aui.Manager'' is not a new concept in GRASS. As we can see in Figure 2, it is already used for creating dockable toolbars in the upper part of the Layer Manager and in the Map Display. These tabs, as well as the Menu bar at the top of the software, will remain the same as in version 7.9. The designed Single-Window GUI consists of 1 window, in the middle of which are Map Displays as notebook tabs. Each Map Display tab, therefore, represents a Map Display window, as we know it from version 7.9. We cannot move with a tab containing Map Displays (it is not dockable), but we can divide the space so that more maps can be seen at once (see Figure 5). Depending on which Map Display is active, the correct tab in the Display tab is selected and vice versa. Around the central map notebook, there are 5 dockable panes in a standard 2D projection - Data Catalog and Display on the left, Modules, Console, and Python on the right. When switching to 3D projection, this number is increased by the 3D view tab - which is displayed in the left part under the Display panel. Dockable panes can be pulled out and rearranged according to the user's own preferences. One example can be seen in Figure 6. Panes can only be maximized and minimized. The situation after minimizing all panes can be seen in Figure 7. Closing panes in the case of GRASS does not bring any special plus in my opinion - after closing it is usually hard to find and reopen the tab (hopefully the reader will tell me the truth :-)) and it would also involve the implementation of a check box mechanism to the menu bar as e.g. in QGIS. GRASS has most functionalities in the form of separate modules, which means that the number of tabs is a maximum of 6 (unlike QGIS having almost 20 tabs). [[Image(split_displays.PNG, 1000px, title=Figure 5: AUI demo - display of Map Displays tabs side by side, align=center)]] [[Image(another_layout_option.PNG, 1000px, title=Figure 6: AUI demo - another arrangement of dockable panes, align=center)]] [[Image(all_panes_minimized.PNG, 1000px, title=Figure 7: AUI demo - panes minimization, align=center)]] As I have mentioned above, each tab in version 7.9 forms a certain whole. The buttons in the Data Catalog toolbar in the Data tab are used to organize the data in this tab. Similarly, the Display tab has its own toolbar, which is used to add, delete, and further organize the layers displayed in Map Display. However, the disadvantage of this solution is that the Data Catalog toolbar and Display toolbar cannot be part of the respective panel in their original length, as they are too long. Therefore, there would have to be either placed horizontal toolbars on top of each other in the given panel or inserted one vertical toolbar on the left. Personally, I am more inclined to the option of creating two horizontal toolbars. However, the implementation of a Single-Window GUI does not only involve a widget reorganization. To reach a truly user-friendly result, it should be possible to switch to the original multi-window layout. Then it would be also advantageous to have a button returning GRASS to the original Single Layout settings (useful in the situation when a user would significantly reorganize widgets and would not be able to go back). Both buttons related to the layout in GRASS GIS could be part of the new dockable Layout tab, which would be located next to the dockable Misc tab. A similar way of changing the layout using the buttons is implemented, for example, in the software jBEAM. [[Image(jbeam_layout.png, 750px, title=Figure 8: Example of layout toolbar from jBEAM software, align=center)]] The third important function is the ability to remember the Single-Window layout in user settings for the next session as well as within the saved workspaces. As part of the new Single-Window mode, it would also be good to reopen the question about tab (pane) names. The main GRASS GIS window is named Layer Manager, although in practice only the Display tab can be considered a Layer Manager. Similarly, in the surveys, the proposal was made to rename the Modules tab to Tools. == Single-Window GUI Roadmap == - Refactoring: Creation of a separate class for workspace management (Layer Manager needs to be lightened). - Refactoring: Creation of a separate file for the Display tab. Then the main script for creating a Layer Manager will no longer contain functions related to displaying layers in the Display tab. A separate file is also created for the Display toolbar. - Refactoring: Establishing all signals and solving the connection when creating a 3D tab. - Refactoring: The main script together with the relevant toolbars and other files will be moved to a new App directory. This means that the Layer Manager will take over the role of the Display tab. - Refactoring: Integrating and moving layout functions and superior functions and handlers into the basic GUI frame class in the App directory (Layer Manager will take over the role of the Display tab) - Adapting toolbars in Display and Data pane: Creating vertical toolbar in Data panel as well as creating vertical toolbar in the Display pane. - Map Display notebook pane: Defining a new Map Panel class whose instances will be elements of the new Map Display notebook pane. - Map Display notebook pane: Integration of Map Panel class to a new Map Display pane. - Map Display notebook pane: Linking the Map Display pane with Layer Manager tabs. - Simple Single-Window GUI: Creating of a new factory-pattern class. Features related to adding and removing the 3D tab and 3D toolbar will be adapted to the future option. - Single Single-Window GUI: Integration of all panes (Data, Display, Modules, Console, Python, Map Display notebook) to a basic Single Layout structure which represents the default setting when all panels are displayed. - Simple Single-Window GUI: Switching to the default Single-Window layout through a new Layout tab.