Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / interface_v3 / task_bar_manager.cpp
blob713a9d07b9de513da0f6561ad3daf5d28666b3bd
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "stdpch.h"
25 #include "task_bar_manager.h"
26 #include "interface_manager.h"
27 #include "dbctrl_sheet.h"
28 #include "macrocmd_manager.h"
29 #include "dbgroup_list_sheet.h"
31 #include "nel/gui/action_handler.h"
32 #include "nel/gui/group_container.h"
33 #include "../actions_client.h"
34 #include "nel/gui/ctrl_button.h"
36 #include "interface_options_ryzom.h"
38 using namespace std;
39 using namespace NLMISC;
41 NLMISC_REGISTER_OBJECT(CViewBase, CGroupContainerWindows, std::string, "container_windows");
43 // ***************************************************************************
44 CTaskBarManager::CTaskBarManager()
49 // ***************************************************************************
50 CTaskBarManager *CTaskBarManager::_Instance= NULL;
51 CTaskBarManager *CTaskBarManager::getInstance()
53 if(!_Instance)
54 _Instance= new CTaskBarManager;
55 return _Instance;
58 // ***************************************************************************
59 void CTaskBarManager::releaseInstance()
61 if( _Instance )
63 delete _Instance;
64 _Instance = NULL;
68 // ***************************************************************************
69 void CTaskBarManager::CShortcutInfo::serial(NLMISC::IStream &f)
71 f.serialVersion(0);
72 f.serialEnum(SheetType);
73 f.serial(DBSheet);
74 f.serial(MacroId);
77 // ***************************************************************************
78 void CTaskBarManager::serial(NLMISC::IStream &f)
80 f.serialVersion(0);
82 // For All Shortcuts
83 for(uint tbIndex=0;tbIndex<TBM_NUM_BARS;tbIndex++)
85 for(uint scut=0;scut<TBM_NUM_SHORTCUT_PER_BAR;scut++)
87 CShortcutInfo info;
89 // serial
90 f.serial(info);
97 // ***************************************************************************
98 // CGroupContainerWindows
99 // ***************************************************************************
101 // ***************************************************************************
102 void CGroupContainerWindows::serialConfig(NLMISC::IStream &f)
104 f.serialVersion(0);
105 f.serial(_ShowDesktops);
106 if (f.isReading())
108 update();
112 // ***************************************************************************
113 void CGroupContainerWindows::update(bool updatePos)
115 CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(getCtrl("expand"));
116 CInterfaceGroup *pIG = getGroup("mode_buttons");
117 if ((pCB == NULL) || (pIG == NULL)) return;
119 pCB->setPushed(_ShowDesktops);
121 if (_ShowDesktops)
123 pIG->setActive(true);
124 pCB->setX(124);
125 setW(488);
126 if (updatePos)
127 setX(getX()-120);
129 else
131 pIG->setActive(false);
132 pCB->setX(4);
133 setW(368);
134 if (updatePos)
135 setX(getX()+120);
139 // ***************************************************************************
140 class CHandlerTaskbarExpandOnOff: public IActionHandler
142 public:
143 virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */)
145 CInterfaceManager *pIM = CInterfaceManager::getInstance();
146 CGroupContainerWindows *pGCW = dynamic_cast<CGroupContainerWindows*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:windows"));
147 if (pGCW == NULL) return;
148 pGCW->setShowDesktops(!pGCW->getShowDesktops());
151 REGISTER_ACTION_HANDLER( CHandlerTaskbarExpandOnOff, "taskbar_expand_on_off");
155 // ***************************************************************************
156 // Called when we want the gestion_windows menu to update its key binding
157 class CHandlerGWUpdateKeys: public IActionHandler
159 public:
160 virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */)
162 CInterfaceManager *pIM = CInterfaceManager::getInstance();
163 CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows"));
164 if (pGC == NULL) return;
165 CActionsManager *pAM = &Actions;
166 const CActionsManager::TActionComboMap &acmap = pAM->getActionComboMap();
169 COptionsList *pOL = dynamic_cast<COptionsList*>(CWidgetManager::getInstance()->getOptions("gestion_windows_key_binding"));
170 if (pOL == NULL) return;
172 for (uint i = 0; i < pOL->getNumParams(); ++i)
174 string sTmp = pOL->getValue(i).getValStr();
175 string sTxt = sTmp.substr(0,sTmp.find('|'));
176 string sWin = sTmp.substr(sTmp.find('|')+1,sTmp.size());
178 CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName("show_hide",sWin.c_str()));
179 string sFullTxt = string("ui:interface:gestion_windows:") + sTxt + ":key";
180 CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sFullTxt));
181 if (pVT != NULL)
183 if (it != acmap.end())
184 pVT->setText(it->second.toString());
185 else
186 pVT->setText(CI18N::get("uiNotAssigned"));
191 REGISTER_ACTION_HANDLER( CHandlerGWUpdateKeys, "gestion_windows_update_key_binding");