1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2019 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013-2014 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/>.
23 #include "nel/gui/action_handler.h"
24 #include "nel/gui/group_container_base.h"
25 #include "nel/gui/interface_property.h"
26 #include "nel/gui/interface_expr.h"
27 #include "nel/gui/db_manager.h"
28 #include "nel/gui/interface_link.h"
29 #include "nel/gui/widget_manager.h"
30 #include "nel/gui/view_renderer.h"
33 using namespace NLMISC
;
42 // ------------------------------------------------------------------------------------------------
43 CAHManager
*CAHManager::_GlobalInstance
= NULL
;
44 bool CAHManager::editorMode
= false;
45 CAHManager::CDeleter
CAHManager::s_Deleter
;
46 bool CAHManager::s_Deleted
= false;
47 // ------------------------------------------------------------------------------------------------
49 // ------------------------------------------------------------------------------------------------
50 static void skipBlankAtStart (string
&start
)
52 while (!start
.empty())
54 if ((start
[0] == ' ' || start
[0] == '\t' || start
[0] == '\r' || start
[0] == '\n'))
55 start
= start
.substr(1,start
.size());
61 // ------------------------------------------------------------------------------------------------
62 static void skipBlankAtEnd (string
&end
)
66 if ((end
[end
.size()-1] == ' ' || end
[end
.size()-1] == '\t' || end
[end
.size()-1] == '\r' || end
[end
.size()-1] == '\n'))
67 end
= end
.substr(0,end
.size()-1);
73 // ------------------------------------------------------------------------------------------------
74 std::string
IActionHandler::getParam (const string
&Params
, const string
&ParamName
)
76 string allparam
= Params
;
77 skipBlankAtStart (allparam
);
78 string param
= toLowerAscii (ParamName
);
79 while (!allparam
.empty())
81 std::string::size_type e
= allparam
.find('=');
82 if (e
== std::string::npos
|| e
== 0) break;
83 std::string::size_type p
= allparam
.find('|');
84 string tmp
= NLMISC::toLowerAscii(allparam
.substr(0,e
));
88 string tmp2
= allparam
.substr(e
+1,p
-e
-1);
89 skipBlankAtStart(tmp2
);
93 if (p
== std::string::npos
|| p
== 0) break;
94 allparam
= allparam
.substr(p
+1,allparam
.size());
95 skipBlankAtStart (allparam
);
100 // ------------------------------------------------------------------------------------------------
101 void IActionHandler::getAllParams (const string
&Params
, vector
< pair
<string
,string
> > &vAllParams
)
103 string allparam
= Params
;
104 skipBlankAtStart (allparam
);
105 while (!allparam
.empty())
107 std::string::size_type e
= allparam
.find('=');
108 if (e
== std::string::npos
|| e
== 0) break;
109 std::string::size_type p
= allparam
.find('|');
110 string tmp
= NLMISC::toLowerAscii(allparam
.substr(0,e
));
113 string tmp2
= allparam
.substr(e
+1,p
-e
-1);
114 skipBlankAtStart(tmp2
);
115 skipBlankAtEnd(tmp2
);
117 vAllParams
.push_back(pair
<string
,string
>(tmp
,tmp2
));
119 if (p
== std::string::npos
|| p
== 0) break;
120 allparam
= allparam
.substr(p
+1,allparam
.size());
121 skipBlankAtStart (allparam
);
125 void CAHManager::getActionHandlers( std::vector
< std::string
> &handlers
)
129 std::map
< string
, IActionHandler
* >::iterator itr
= FactoryMap
.begin();
130 while( itr
!= FactoryMap
.end() )
132 handlers
.push_back( itr
->first
);
137 // ------------------------------------------------------------------------------------------------
138 IActionHandler
* CAHManager::getAH(const std::string
&name
, std::string
¶ms
)
141 string::size_type i
= name
.find(':');
144 string ahName
= name
.substr(0, i
);
145 params
= name
.substr(i
+1);
146 return getActionHandler(ahName
);
150 return getActionHandler(name
);
153 // ------------------------------------------------------------------------------------------------
154 IActionHandler
* CAHManager::getAH(const std::string
&name
, CStringShared
¶ms
)
157 string::size_type i
= name
.find(':');
160 string ahName
= name
.substr(0, i
);
161 params
= name
.substr(i
+1);
162 return getActionHandler(ahName
);
166 return getActionHandler(name
);
169 // ------------------------------------------------------------------------------------------------
170 void CAHManager::parseAH(xmlNodePtr cur
, const char *ahId
, const char *paramId
, IActionHandler
*&ahRet
, std::string
¶mRet
)
174 // Read the action handler and any param he defines
175 bool paramSpecifiedInAH
= false;
178 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)ahId
);
181 string ahVal
= (const char*)prop
;
182 if(ahVal
.find(':')!= string::npos
)
183 paramSpecifiedInAH
= true;
184 ahRet
= getAH(ahVal
, paramRet
);
188 // Read parameter (if specified)
191 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)paramId
);
192 /* Precise stuff here (for legacy rules):
193 If the param is not specified in the ahId, then replace params.
194 But if it is specified, don't replace it if the prop is empty!!
195 Because this cause problems with template and parameter replacement.
197 if ((const char *)prop
&& (!paramSpecifiedInAH
|| strlen((const char*)prop
)>0) )
198 paramRet
= string((const char*)prop
);
202 void CAHManager::parseAH(xmlNodePtr cur
, const char *ahId
, const char *paramId
, IActionHandler
*&ahRet
, CStringShared
¶mRet
)
206 // Read the action handler and any param he defines
207 bool paramSpecifiedInAH
= false;
210 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)ahId
);
213 string ahVal
= (const char*)prop
;
214 if(ahVal
.find(':')!= string::npos
)
215 paramSpecifiedInAH
= true;
216 ahRet
= getAH(ahVal
, paramRet
);
220 // Read parameter (if specified)
223 prop
= (char*) xmlGetProp( cur
, (xmlChar
*)paramId
);
224 /* Precise stuff here (for legacy rules):
225 If the param is not specified in the ahId, then replace params.
226 But if it is specified, don't replace it if the prop is empty!!
227 Because this cause problems with template and parameter replacement.
229 if ((const char *)prop
&& (!paramSpecifiedInAH
|| strlen((const char*)prop
)>0) )
230 paramRet
= string((const char*)prop
);
234 // ------------------------------------------------------------------------------------------------
235 void CAHManager::runActionHandler (const string
&ahCmdLine
, CCtrlBase
*pCaller
, const string
&ahUserParams
)
237 if (ahCmdLine
.empty()) return;
242 // Special AH form ("ah:params") ?
243 string::size_type i
= ahCmdLine
.find(':');
248 ahName
= ahCmdLine
.substr(0, i
);
249 ahParams
= ahCmdLine
.substr(i
+1);
256 // Replace params if defined
257 if(!ahUserParams
.empty())
258 ahParams
= ahUserParams
;
260 // Execute the action handler
261 map
<string
, IActionHandler
*>::iterator it
= FactoryMap
.find (ahName
);
262 if (it
== FactoryMap
.end())
264 nlwarning ("not found action handler : %s",ahName
.c_str());
267 IActionHandler
*pAH
= it
->second
;
268 pAH
->execute (pCaller
, ahParams
);
271 const string submitQuickHelp
= "submit_quick_help";
272 it
= FactoryMap
.find(submitQuickHelp
);
273 if(it
== FactoryMap
.end())
275 nlwarning ("not found action handler : %s", submitQuickHelp
.c_str());
279 const std::string event
= ahName
+ ":" + ahParams
;
280 pAH
->execute(NULL
, event
);
283 // ------------------------------------------------------------------------------------------------
284 void CAHManager::runActionHandler (IActionHandler
*pAH
, CCtrlBase
*pCaller
, const std::string
&Params
)
288 nlwarning ("no action handler");
295 pAH
->execute (pCaller
, Params
);
296 string AHName
= CAHManager::getInstance()->getAHName(pAH
);
299 const string submitQuickHelp
= "submit_quick_help";
300 map
<string
, IActionHandler
*>::iterator it
= FactoryMap
.find (AHName
);
301 it
= FactoryMap
.find(submitQuickHelp
);
302 if(it
== FactoryMap
.end())
304 nlwarning ("not found action handler : %s", submitQuickHelp
.c_str());
308 const std::string event
= AHName
+ ":" + Params
;
309 pAH
->execute(NULL
, event
);
312 void CAHManager::submitEvent( const std::string
&evt
)
314 // Submit the event to the quick help system
315 runActionHandler( "submit_quick_help", NULL
, evt
);
319 // ------------------------------------------------------------------------------------------------
320 class CAHSet
: public IActionHandler
323 virtual void execute (CCtrlBase
*pCaller
, const string
&Params
)
325 string dblink
= getParam (Params
, "dblink");
326 string property
= getParam (Params
, "target_property");
327 string propertyToEval
= getParam (Params
, "target");
328 string expr
= getParam (Params
, "value");
329 //nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str());
330 CInterfaceExprValue value
;
331 if (CInterfaceExpr::eval(expr
, value
, NULL
))
335 // Do not allow Write on SERVER: or LOCAL:
336 static const std::string dbServer
= "SERVER:";
337 static const std::string dbLocal
= "LOCAL:";
338 static const std::string dbLocalR2
= "LOCAL:R2";
339 if( (0==dblink
.compare(0, dbServer
.size(), dbServer
)) ||
340 (0==dblink
.compare(0, dbLocal
.size(), dbLocal
))
343 if (0!=dblink
.compare(0, dbLocalR2
.size(), dbLocalR2
))
345 //nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
352 CInterfaceExpr::unpackDBentry(dblink
.c_str(), NULL
, dblinkeval
);
353 if (!value
.toInteger())
355 nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
357 CInterfaceProperty ip
;
359 if (!value
.toInteger())
361 nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
363 if (ip
.link (dblinkeval
.c_str()))
365 ip
.setSInt64(value
.getInteger());
369 if (!propertyToEval
.empty())
371 CInterfaceExprValue res
;
372 if (!CInterfaceExpr::eval(propertyToEval
, res
, NULL
)) return;
374 property
= res
.getString();
378 if (!property
.empty())
380 std::vector
<CInterfaceLink::CTargetInfo
> targets
;
381 // find first enclosing group
382 CCtrlBase
*currCtrl
= pCaller
;
383 CInterfaceGroup
*ig
= NULL
;
386 ig
= dynamic_cast<CInterfaceGroup
*>(currCtrl
);
387 if (ig
!= NULL
) break;
388 currCtrl
= currCtrl
->getParent();
392 string elt
= property
.substr(0,property
.rfind(':'));
393 CInterfaceElement
*pIE
= CWidgetManager::getInstance()->getElementFromId(elt
);
394 ig
= dynamic_cast<CInterfaceGroup
*>(pIE
);
395 if (ig
== NULL
&& pIE
!= NULL
)
396 ig
= pIE
->getParent();
401 CInterfaceLink::splitLinkTargets(property
, ig
, targets
);
402 for(uint k
= 0; k
< targets
.size(); ++k
)
404 if (targets
[k
].Elem
) targets
[k
].affect(value
);
411 nlwarning("<CAHSet::execute> Couldn't evaluate expression to affect, expr = %s", expr
.c_str());
415 REGISTER_ACTION_HANDLER (CAHSet
, "set");
418 // ------------------------------------------------------------------------------------------------
419 class CAHCopy
: public IActionHandler
422 virtual void execute (CCtrlBase
* /* pCaller */, const string
&Params
)
424 string dbdst
= getParam (Params
, "dbdst");
425 string dbsrc
= getParam (Params
, "dbsrc");
426 CCDBNodeBranch
*pNBdst
= NLGUI::CDBManager::getInstance()->getDbBranch(dbdst
);
427 CCDBNodeBranch
*pNBsrc
= NLGUI::CDBManager::getInstance()->getDbBranch(dbsrc
);
431 if ((pNBdst
!= NULL
) && (pNBsrc
!= NULL
))
433 //nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str());
435 // Parse all children of the src branch
436 uint nbLeaves
= pNBsrc
->countLeaves();
437 for (uint i
= 0; i
< nbLeaves
; ++i
)
440 CCDBNodeLeaf
*pNLsrc
= pNBsrc
->findLeafAtCount(count
);
441 // Find its access name
442 string sTmp
= *pNLsrc
->getName();
443 CCDBNodeBranch
*pParent
= pNLsrc
->getParent();
444 while (pParent
!= pNBsrc
)
446 sTmp
= *pParent
->getName() + ":" + sTmp
;
447 pParent
= pParent
->getParent();
449 // Find the correspondant node in the dst branch
450 CCDBNodeLeaf
*pNLdst
= dynamic_cast<CCDBNodeLeaf
*>(pNBdst
->getNode(ICDBNode::CTextId(sTmp
)));
453 nlwarning ("cannot find destination leaf %s",sTmp
.c_str());
457 pNLdst
->setValue64(pNLsrc
->getValue64());
459 //sint32 nVal = pNLsrc->getValue64();
460 //nlinfo("set value %d for node %s", nVal, sTmp.c_str());
466 // Not branch copy so leaf copy
468 CInterfaceProperty ipsrc
;
469 CInterfaceProperty ipdst
;
470 if (!ipsrc
.link (dbsrc
.c_str()))
472 nlwarning("cannot find leaf %s",dbsrc
.c_str());
475 if (!ipdst
.link (dbdst
.c_str()))
477 nlwarning("cannot find leaf %s",dbdst
.c_str());
481 ipdst
.setSInt64 (ipsrc
.getSInt64());
484 REGISTER_ACTION_HANDLER (CAHCopy
, "copy");
487 // ------------------------------------------------------------------------------------------------
488 class CAHResizeW
: public IActionHandler
491 virtual void execute (CCtrlBase
*pCaller
, const string
&Params
)
493 string elt
= getParam (Params
, "elt");
496 fromString(getParam(Params
, "value"), value
);
499 fromString(getParam(Params
, "limit"), limit
);
501 CInterfaceElement
*pIE
= CWidgetManager::getInstance()->getElementFromId (pCaller
->getId(), elt
);
502 if (pIE
== NULL
) return;
504 sint32 newW
= pIE
->getW();
517 pIE
->invalidateCoords();
520 REGISTER_ACTION_HANDLER (CAHResizeW
, "resize_w");
522 ////////////////////////////////
523 // EDITION OF CONTAINER ALPHA //
524 ////////////////////////////////
526 // the container whose alpha is being edited
527 static CGroupContainerBase
*AlphaChooserTarget
= NULL
;
528 static bool OldUseGlobalAlpha
;
529 static uint8 OldContentAlpha
;
530 static uint8 OldBgAlpha
;
531 static uint8 OldRolloverAlphaBG
;
532 static uint8 OldRolloverAlphaContent
;
534 // observer to change the container alpha
535 class CContainerAlphaObserver
: public ICDBNode::IPropertyObserver
539 enum TTargetAlpha
{ ContentAlpha
= 0, BgAlpha
, RolloverAlphaContent
, RolloverAlphaBG
};
541 virtual void update(ICDBNode
*node
)
544 if (!AlphaChooserTarget
) return;
545 CCDBNodeLeaf
*leaf
= safe_cast
<CCDBNodeLeaf
*>(node
);
548 case ContentAlpha
: AlphaChooserTarget
->setContentAlpha((uint8
) leaf
->getValue32()); break;
549 case BgAlpha
: AlphaChooserTarget
->setContainerAlpha((uint8
) leaf
->getValue32()); break;
550 case RolloverAlphaContent
: AlphaChooserTarget
->setRolloverAlphaContent((uint8
) (255 - (uint8
) leaf
->getValue32())); break;
551 case RolloverAlphaBG
: AlphaChooserTarget
->setRolloverAlphaContainer((uint8
) (255 - (uint8
) leaf
->getValue32())); break;
558 // ------------------------------------------------------------------------------------------------
559 class CAHChooseUIAlpha
: public IActionHandler
562 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
564 CGroupContainerBase
*gc
= NULL
;
565 CCtrlBase
*cb
= pCaller
;
568 gc
= dynamic_cast<CGroupContainerBase
*>(cb
);
570 cb
= cb
->getParent();
573 AlphaChooserTarget
= gc
;
574 if (!_AlphaObserversAdded
)
576 _UiVariableBGAlpha
= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_BG");
577 _UiVariableContentAlpha
= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_CONTENT");
578 _UiVariableRolloverAlphaBG
= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG");
579 _UiVariableRolloverAlphaContent
= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT");
580 ICDBNode::CTextId textIdBGAlpha
, textIdContentAlpha
, textIdRolloverAlphaBG
, textIdRolloverAlphaContent
;
581 _UiVariableBGAlpha
->addObserver(&_BgAlphaObs
, textIdBGAlpha
);
582 _UiVariableContentAlpha
->addObserver(&_ContentAlphaObs
, textIdContentAlpha
);
583 _UiVariableRolloverAlphaBG
->addObserver(&_RolloverAlphaBGObs
, textIdRolloverAlphaBG
);
584 _UiVariableRolloverAlphaContent
->addObserver(&_RolloverAlphaContentObs
, textIdRolloverAlphaContent
);
585 _AlphaObserversAdded
= true;
588 _ContentAlphaObs
.On
= false;
589 _BgAlphaObs
.On
= false;
590 _RolloverAlphaBGObs
.On
= false;
591 _RolloverAlphaContentObs
.On
= false;
592 // set alpha of current chosen container
593 _UiVariableBGAlpha
->setValue32(gc
->getContainerAlpha());
594 _UiVariableContentAlpha
->setValue32(gc
->getContentAlpha());
595 _UiVariableRolloverAlphaBG
->setValue32(255 - gc
->getRolloverAlphaContainer());
596 _UiVariableRolloverAlphaContent
->setValue32(255 - gc
->getRolloverAlphaContent());
598 _ContentAlphaObs
.On
= true;
599 _BgAlphaObs
.On
= true;
600 _RolloverAlphaBGObs
.On
= true;
601 _RolloverAlphaContentObs
.On
= true;
602 // backup current alpha (if the user cancel)
603 OldContentAlpha
= gc
->getContentAlpha();
604 OldBgAlpha
= gc
->getContainerAlpha();
605 OldRolloverAlphaBG
= gc
->getRolloverAlphaContainer();
606 OldRolloverAlphaContent
= gc
->getRolloverAlphaContent();
607 OldUseGlobalAlpha
= gc
->isUsingGlobalAlpha();
608 // Enable 'use global alpha' button
609 NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc
->isUsingGlobalAlpha() ? 0 : 1);
610 // show the modal box
611 CWidgetManager::getInstance()->enableModalWindow(gc
, "ui:interface:define_ui_transparency");
618 _UiVariableContentAlpha
= NULL
;
619 _UiVariableBGAlpha
= NULL
;
620 _UiVariableRolloverAlphaBG
= NULL
;
621 _UiVariableRolloverAlphaContent
= NULL
;
622 _AlphaObserversAdded
= false;
623 _BgAlphaObs
.Target
= CContainerAlphaObserver::BgAlpha
;
624 _ContentAlphaObs
.Target
= CContainerAlphaObserver::ContentAlpha
;
625 _RolloverAlphaBGObs
.Target
= CContainerAlphaObserver::RolloverAlphaBG
;
626 _RolloverAlphaContentObs
.Target
= CContainerAlphaObserver::RolloverAlphaContent
;
629 // instance of observer to copy alpha from db to a container
630 CContainerAlphaObserver _ContentAlphaObs
;
631 CContainerAlphaObserver _BgAlphaObs
;
632 CContainerAlphaObserver _RolloverAlphaContentObs
;
633 CContainerAlphaObserver _RolloverAlphaBGObs
;
634 // flag to know if observer have been added
635 bool _AlphaObserversAdded
;
636 // db leaf that contains alpha for the current container
637 CCDBNodeLeaf
*_UiVariableContentAlpha
;
638 CCDBNodeLeaf
*_UiVariableBGAlpha
;
639 CCDBNodeLeaf
*_UiVariableRolloverAlphaContent
;
640 CCDBNodeLeaf
*_UiVariableRolloverAlphaBG
;
642 REGISTER_ACTION_HANDLER (CAHChooseUIAlpha
, "choose_ui_alpha");
644 // ------------------------------------------------------------------------------------------------
645 class CAHCancelChooseUIAlpha
: public IActionHandler
647 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&/* Params */)
649 if (AlphaChooserTarget
)
651 AlphaChooserTarget
->setUseGlobalAlpha(OldUseGlobalAlpha
);
652 AlphaChooserTarget
->setContainerAlpha(OldBgAlpha
);
653 AlphaChooserTarget
->setContentAlpha(OldContentAlpha
);
654 AlphaChooserTarget
->setRolloverAlphaContainer(OldRolloverAlphaBG
);
655 AlphaChooserTarget
->setRolloverAlphaContent(OldRolloverAlphaContent
);
659 REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha
, "cancel_choose_ui_alpha");
661 // ------------------------------------------------------------------------------------------------
662 class CAHUseGlobalAlphaSettings
: public IActionHandler
664 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&/* Params */)
666 if (AlphaChooserTarget
)
668 AlphaChooserTarget
->setUseGlobalAlpha(!AlphaChooserTarget
->isUsingGlobalAlpha());
669 NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget
->isUsingGlobalAlpha() ? 0 : 1);
673 REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings
, "use_global_alpha_settings");
676 // ------------------------------------------------------------------------------------------------
677 class CAHLockUnlock
: public IActionHandler
679 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
681 CGroupContainerBase
*gc
= NULL
;
682 CCtrlBase
*cb
= pCaller
;
685 gc
= dynamic_cast< CGroupContainerBase
* >(cb
);
687 cb
= cb
->getParent();
690 //gc->setMovable(!gc->isMovable());
691 gc
->setLocked(!gc
->isLocked());
694 REGISTER_ACTION_HANDLER (CAHLockUnlock
, "lock_unlock");
696 // ------------------------------------------------------------------------------------------------
697 class CAHSetTransparent
: public IActionHandler
699 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&Params
)
701 CGroupContainerBase
*pGC
= dynamic_cast< CGroupContainerBase
* >(CWidgetManager::getInstance()->getElementFromId(Params
));
704 pGC
->setUseGlobalAlpha(false);
705 pGC
->setContainerAlpha((uint8
) 0);
706 pGC
->setContentAlpha((uint8
) 255);
707 pGC
->setRolloverAlphaContainer((uint8
) 255);
708 pGC
->setRolloverAlphaContent((uint8
) 0);
712 REGISTER_ACTION_HANDLER (CAHSetTransparent
, "set_transparent");
714 // ------------------------------------------------------------------------------------------------
715 class CAHSetAlpha
: public IActionHandler
717 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&Params
)
719 string ui
= getParam (Params
, "target");
722 fromString(getParam (Params
, "alpha"), alpha
);
724 CGroupContainerBase
*pGC
= dynamic_cast<CGroupContainerBase
*>(CWidgetManager::getInstance()->getElementFromId(ui
));
727 pGC
->setUseGlobalAlpha(false);
728 pGC
->setContainerAlpha((uint8
) alpha
);
729 pGC
->setContentAlpha((uint8
) 255);
730 pGC
->setRolloverAlphaContainer((uint8
) 0);
731 pGC
->setRolloverAlphaContent((uint8
) 0);
735 REGISTER_ACTION_HANDLER (CAHSetAlpha
, "set_alpha");
737 // ------------------------------------------------------------------------------------------------
738 class CAHUnlockAllContainer
: public IActionHandler
740 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
742 const vector
<CWidgetManager::SMasterGroup
> &rVMG
= CWidgetManager::getInstance()->getAllMasterGroup();
743 for (uint32 nMasterGroup
= 0; nMasterGroup
< rVMG
.size(); nMasterGroup
++)
745 // const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
746 CWidgetManager::getInstance()->getMasterGroup((uint8
)nMasterGroup
).unlockAllContainers();
750 REGISTER_ACTION_HANDLER (CAHUnlockAllContainer
, "unlock_all_container");
752 // ------------------------------------------------------------------------------------------------
753 class CAHCopyToClipboard
: public IActionHandler
755 virtual void execute (CCtrlBase
*pCaller
, const std::string
¶ms
)
757 if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params
))
759 nlwarning("Copy to clipboard failed: '%s'", params
.c_str());
763 REGISTER_ACTION_HANDLER(CAHCopyToClipboard
, "copy_to_clipboard");