| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #include "BsScriptGUIPanel.h"
- #include "BsScriptMeta.h"
- #include "BsMonoField.h"
- #include "BsMonoClass.h"
- #include "BsMonoManager.h"
- #include "BsScriptGUIArea.h"
- #include "BsGUIArea.h"
- #include "BsGUILayout.h"
- namespace BansheeEngine
- {
- ScriptGUIPanel::ScriptGUIPanel(MonoObject* instance)
- :ScriptObject(instance)
- {
- }
- void ScriptGUIPanel::initRuntimeData()
- {
- metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIPanel::internal_createInstance);
- metaData.scriptClass->addInternalCall("Internal_SetArea", &ScriptGUIPanel::internal_setArea);
- }
- void ScriptGUIPanel::internal_createInstance(MonoObject* instance)
- {
- ScriptGUIPanel* nativeInstance = new (bs_alloc<ScriptGUIPanel>()) ScriptGUIPanel(instance);
- }
- void ScriptGUIPanel::internal_setArea(ScriptGUIPanel* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, UINT16 depth)
- {
- thisPtr->mMyArea.x = x;
- thisPtr->mMyArea.y = y;
- thisPtr->mMyArea.width = width;
- thisPtr->mMyArea.height = height;
- thisPtr->updateArea();
- }
- void ScriptGUIPanel::setParentArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
- {
- mParentArea.x = x;
- mParentArea.y = y;
- mParentArea.width = width;
- mParentArea.height = height;
- updateArea();
- }
- void ScriptGUIPanel::setParentWidget(GUIWidget* widget)
- {
- mParentWidget = widget;
- for(auto& area : mAreas)
- {
- area->getInternalValue()->changeParentWidget(widget);
- }
- }
- void ScriptGUIPanel::registerArea(ScriptGUIArea* area)
- {
- mAreas.push_back(area);
- }
- void ScriptGUIPanel::unregisterArea(ScriptGUIArea* area)
- {
- auto iterFind = std::find(mAreas.begin(), mAreas.end(), area);
- if(iterFind != mAreas.end())
- mAreas.erase(iterFind);
- }
- void ScriptGUIPanel::updateArea()
- {
- mClippedArea = mMyArea;
- mClippedArea.x += mParentArea.x;
- mClippedArea.y += mParentArea.y;
- mClippedArea.clip(mParentArea);
- for(auto& area : mAreas)
- {
- area->updateArea();
- }
- }
- }
|