ui_controller.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 namespace clan
33 {
36 
37 class DocumentEditor;
38 class DocumentEditorType;
39 class DockableComponent;
40 class SolutionModel;
41 class UIControllerListener;
42 
44 {
45 public:
46  UIController(Ribbon *ribbon, SolutionModel &solution_model);
47  ~UIController();
48 
49  void add_listener(std::shared_ptr<UIControllerListener> listener);
50 
51  Ribbon *get_ribbon() const { return ribbon; }
52 
53  void open(std::string filename, DocumentEditorType *editor_type);
54 
55  void set_active(DocumentEditor *editor);
56  void editor_destroyed(DocumentEditor *editor);
57 
58  void add_dockable(DockableComponent *dockable) { dockables.push_back(dockable); }
59  const std::vector<DockableComponent *> &get_dockables() const { return dockables; }
60 
63 
64  SolutionModel &get_solution_model() { return solution_model; }
65 
66 private:
67  RibbonSection *get_ribbon_section(const std::string &page_name, const std::string &section_name);
68 
69  void show_ribbon_section(const std::string &page_name, const std::string &section_name);
70  void hide_ribbon_section(const std::string &page_name, const std::string &section_name);
71 
72  struct OpenDocument
73  {
74  OpenDocument(DocumentEditor *editor, DocumentEditorType *type) : editor(editor), type(type) { }
75 
78  };
79 
80  struct RibbonSectionInfo
81  {
82  RibbonSectionInfo() : section(0), visible_count(0) { }
85  };
86 
87  struct RibbonPageInfo
88  {
89  RibbonPageInfo() : page(0), visible_count(0) { }
92  std::map<std::string, RibbonSectionInfo> sections;
93  };
94 
95  Ribbon *ribbon;
96  std::map<std::string, RibbonPageInfo> ribbon_pages;
97  SolutionModel &solution_model;
98  std::vector<OpenDocument> documents;
99  std::vector<DockableComponent *> dockables;
100  std::vector<std::shared_ptr<UIControllerListener> > listeners;
101 
102  friend class UIControllerListener;
103  friend class UIRibbonSection;
104 };
105 
106 }
107 
RibbonPageInfo()
Definition: ui_controller.h:89
void open(std::string filename, DocumentEditorType *editor_type)
int visible_count
Definition: ui_controller.h:84
void add_listener(std::shared_ptr< UIControllerListener > listener)
DocumentEditor * editor
Definition: ui_controller.h:76
DocumentEditorType * type
Definition: ui_controller.h:77
Definition: ribbon_section.h:40
UIController(Ribbon *ribbon, SolutionModel &solution_model)
Definition: ui_ribbon_section.h:42
SolutionModel & get_solution_model()
Definition: ui_controller.h:64
Definition: ribbon_page.h:42
OpenDocument(DocumentEditor *editor, DocumentEditorType *type)
Definition: ui_controller.h:74
Signal_v1.
Definition: signal_v1.h:110
void editor_destroyed(DocumentEditor *editor)
Definition: document_editor.h:41
const std::vector< DockableComponent * > & get_dockables() const
Definition: ui_controller.h:59
Definition: dockable_component.h:41
Ribbon component.
Definition: ribbon.h:46
RibbonSectionInfo()
Definition: ui_controller.h:82
Ribbon * get_ribbon() const
Definition: ui_controller.h:51
int visible_count
Definition: ui_controller.h:91
RibbonPage * page
Definition: ui_controller.h:90
Signal_v1< DocumentEditor * > sig_editor_destroyed
Definition: ui_controller.h:62
Definition: solution_model.h:41
void add_dockable(DockableComponent *dockable)
Definition: ui_controller.h:58
void set_active(DocumentEditor *editor)
RibbonSection * section
Definition: ui_controller.h:83
Definition: document_editor_type.h:40
std::map< std::string, RibbonSectionInfo > sections
Definition: ui_controller.h:92
Definition: ui_controller_listener.h:40
Definition: ui_controller.h:43
Signal_v1< DocumentEditor * > sig_editor_activated
Definition: ui_controller.h:61