1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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>
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/>.
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"
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()
54 _Instance
= new CTaskBarManager
;
58 // ***************************************************************************
59 void CTaskBarManager::releaseInstance()
68 // ***************************************************************************
69 void CTaskBarManager::CShortcutInfo::serial(NLMISC::IStream
&f
)
72 f
.serialEnum(SheetType
);
77 // ***************************************************************************
78 void CTaskBarManager::serial(NLMISC::IStream
&f
)
83 for(uint tbIndex
=0;tbIndex
<TBM_NUM_BARS
;tbIndex
++)
85 for(uint scut
=0;scut
<TBM_NUM_SHORTCUT_PER_BAR
;scut
++)
97 // ***************************************************************************
98 // CGroupContainerWindows
99 // ***************************************************************************
101 // ***************************************************************************
102 void CGroupContainerWindows::serialConfig(NLMISC::IStream
&f
)
105 f
.serial(_ShowDesktops
);
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
);
123 pIG
->setActive(true);
131 pIG
->setActive(false);
139 // ***************************************************************************
140 class CHandlerTaskbarExpandOnOff
: public IActionHandler
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
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
));
183 if (it
!= acmap
.end())
184 pVT
->setText(it
->second
.toString());
186 pVT
->setText(CI18N::get("uiNotAssigned"));
191 REGISTER_ACTION_HANDLER( CHandlerGWUpdateKeys
, "gestion_windows_update_key_binding");