Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
tab_frame.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019-2021 natinusala
3 Copyright 2019 p-sam
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16*/
17
18#pragma once
19
20#include <functional>
21#include <map>
22#include <aurore/core/bind.hpp>
25
26namespace aurore
27{
28
29typedef std::function<View*(void)> TabViewCreator;
30
31// An applet frame containing a sidebar on the left with multiple tabs which content is showing on the right.
32// Only one tab is kept in memory at all times : when switching, the current tab is freed before the the new one is instantiated.
33class TabFrame : public Box
34{
35 public:
37
38 void handleXMLElement(tinyxml2::XMLElement* element) override;
39
40 void addTab(std::string label, TabViewCreator creator);
41 void focusTab(int position);
42 void clearTabs();
44
50 void setKeepTabs(bool keep);
51
53
54 static View* create();
55
56 private:
57 AURORE_BIND(Sidebar, sidebar, "aurore/tab_frame/sidebar");
58
59 View* activeTab = nullptr;
60 bool keepTabs = false;
61 int tabCount = 0;
62 std::map<int, View*> keptTabs;
63
64 void freeKeptTabs();
65};
66
67} // namespace aurore
#define AURORE_BIND(type, name, id)
Definition bind.hpp:39
Generic FlexBox layout.
Definition box.hpp:74
Definition sidebar.hpp:84
Definition tab_frame.hpp:34
void focusTab(int position)
void setKeepTabs(bool keep)
static View * create()
void handleXMLElement(tinyxml2::XMLElement *element) override
void addTab(std::string label, TabViewCreator creator)
Definition view.hpp:232
Definition actions.hpp:25
std::function< View *(void)> TabViewCreator
Definition tab_frame.hpp:29