| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- #include "BsScriptGUIElementStyle.h"
- #include "BsScriptMeta.h"
- #include "BsMonoField.h"
- #include "BsMonoClass.h"
- #include "BsMonoManager.h"
- #include "BsScriptFont.h"
- #include "BsException.h"
- #include "BsGUIElementStyle.h"
- #include "BsScriptGUIElementStateStyle.h"
- #include "BsMonoUtil.h"
- namespace BansheeEngine
- {
- ScriptGUIElementStyle::ScriptGUIElementStyle(MonoObject* instance, const String& name)
- :ScriptObject(instance), mName(name), mFont(nullptr), mNormal(nullptr), mHover(nullptr),
- mActive(nullptr), mFocused(nullptr), mNormalOn(nullptr), mHoverOn(nullptr), mActiveOn(nullptr), mFocusedOn(nullptr)
- {
- }
- ScriptGUIElementStyle::ScriptGUIElementStyle(MonoObject* instance, const String& name, const GUIElementStyle& externalStyle)
- :ScriptObject(instance), mName(name), mElementStyle(externalStyle), mFont(nullptr), mNormal(nullptr), mHover(nullptr),
- mActive(nullptr), mFocused(nullptr), mNormalOn(nullptr), mHoverOn(nullptr), mActiveOn(nullptr), mFocusedOn(nullptr)
- {
- }
- ScriptGUIElementStyle::~ScriptGUIElementStyle()
- {
- }
- void ScriptGUIElementStyle::initRuntimeData()
- {
- metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIElementStyle::internal_createInstance);
- metaData.scriptClass->addInternalCall("Internal_AddSubStyle", &ScriptGUIElementStyle::internal_addSubStyle);
- metaData.scriptClass->addInternalCall("Internal_GetFont", &ScriptGUIElementStyle::internal_GetFont);
- metaData.scriptClass->addInternalCall("Internal_SetFont", &ScriptGUIElementStyle::internal_SetFont);
- metaData.scriptClass->addInternalCall("Internal_GetFontSize", &ScriptGUIElementStyle::internal_GetFontSize);
- metaData.scriptClass->addInternalCall("Internal_SetFontSize", &ScriptGUIElementStyle::internal_SetFontSize);
- metaData.scriptClass->addInternalCall("Internal_GetTextHorzAlign", &ScriptGUIElementStyle::internal_GetTextHorzAlign);
- metaData.scriptClass->addInternalCall("Internal_SetTextHorzAlign", &ScriptGUIElementStyle::internal_SetTextHorzAlign);
- metaData.scriptClass->addInternalCall("Internal_GetTextVertAlign", &ScriptGUIElementStyle::internal_GetTextVertAlign);
- metaData.scriptClass->addInternalCall("Internal_SetTextVertAlign", &ScriptGUIElementStyle::internal_SetTextVertAlign);
- metaData.scriptClass->addInternalCall("Internal_GetImagePosition", &ScriptGUIElementStyle::internal_GetImagePosition);
- metaData.scriptClass->addInternalCall("Internal_SetImagePosition", &ScriptGUIElementStyle::internal_SetImagePosition);
- metaData.scriptClass->addInternalCall("Internal_GetWordWrap", &ScriptGUIElementStyle::internal_GetWordWrap);
- metaData.scriptClass->addInternalCall("Internal_SetWordWrap", &ScriptGUIElementStyle::internal_SetWordWrap);
- metaData.scriptClass->addInternalCall("Internal_GetNormal", &ScriptGUIElementStyle::internal_GetNormal);
- metaData.scriptClass->addInternalCall("Internal_SetNormal", &ScriptGUIElementStyle::internal_SetNormal);
- metaData.scriptClass->addInternalCall("Internal_GetHover", &ScriptGUIElementStyle::internal_GetHover);
- metaData.scriptClass->addInternalCall("Internal_SetHover", &ScriptGUIElementStyle::internal_SetHover);
- metaData.scriptClass->addInternalCall("Internal_GetActive", &ScriptGUIElementStyle::internal_GetActive);
- metaData.scriptClass->addInternalCall("Internal_SetActive", &ScriptGUIElementStyle::internal_SetActive);
- metaData.scriptClass->addInternalCall("Internal_GetFocused", &ScriptGUIElementStyle::internal_GetFocused);
- metaData.scriptClass->addInternalCall("Internal_SetFocused", &ScriptGUIElementStyle::internal_SetFocused);
- metaData.scriptClass->addInternalCall("Internal_GetNormalOn", &ScriptGUIElementStyle::internal_GetNormalOn);
- metaData.scriptClass->addInternalCall("Internal_SetNormalOn", &ScriptGUIElementStyle::internal_SetNormalOn);
- metaData.scriptClass->addInternalCall("Internal_GetHoverOn", &ScriptGUIElementStyle::internal_GetHoverOn);
- metaData.scriptClass->addInternalCall("Internal_SetHoverOn", &ScriptGUIElementStyle::internal_SetHoverOn);
- metaData.scriptClass->addInternalCall("Internal_GetActiveOn", &ScriptGUIElementStyle::internal_GetActiveOn);
- metaData.scriptClass->addInternalCall("Internal_SetActiveOn", &ScriptGUIElementStyle::internal_SetActiveOn);
- metaData.scriptClass->addInternalCall("Internal_GetFocusedOn", &ScriptGUIElementStyle::internal_GetFocusedOn);
- metaData.scriptClass->addInternalCall("Internal_SetFocusedOn", &ScriptGUIElementStyle::internal_SetFocusedOn);
- metaData.scriptClass->addInternalCall("Internal_GetBorder", &ScriptGUIElementStyle::internal_GetBorder);
- metaData.scriptClass->addInternalCall("Internal_SetBorder", &ScriptGUIElementStyle::internal_SetBorder);
- metaData.scriptClass->addInternalCall("Internal_GetMargins", &ScriptGUIElementStyle::internal_GetMargins);
- metaData.scriptClass->addInternalCall("Internal_SetMargins", &ScriptGUIElementStyle::internal_SetMargins);
- metaData.scriptClass->addInternalCall("Internal_GetContentOffset", &ScriptGUIElementStyle::internal_GetContentOffset);
- metaData.scriptClass->addInternalCall("Internal_SetContentOffset", &ScriptGUIElementStyle::internal_SetContentOffset);
- metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptGUIElementStyle::internal_GetWidth);
- metaData.scriptClass->addInternalCall("Internal_SetWidth", &ScriptGUIElementStyle::internal_SetWidth);
- metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptGUIElementStyle::internal_GetHeight);
- metaData.scriptClass->addInternalCall("Internal_SetHeight", &ScriptGUIElementStyle::internal_SetHeight);
- metaData.scriptClass->addInternalCall("Internal_GetMinWidth", &ScriptGUIElementStyle::internal_GetMinWidth);
- metaData.scriptClass->addInternalCall("Internal_SetMinWidth", &ScriptGUIElementStyle::internal_SetMinWidth);
- metaData.scriptClass->addInternalCall("Internal_GetMaxWidth", &ScriptGUIElementStyle::internal_GetMaxWidth);
- metaData.scriptClass->addInternalCall("Internal_SetMaxWidth", &ScriptGUIElementStyle::internal_SetMaxWidth);
- metaData.scriptClass->addInternalCall("Internal_GetMinHeight", &ScriptGUIElementStyle::internal_GetMinHeight);
- metaData.scriptClass->addInternalCall("Internal_SetMinHeight", &ScriptGUIElementStyle::internal_SetMinHeight);
- metaData.scriptClass->addInternalCall("Internal_GetMaxHeight", &ScriptGUIElementStyle::internal_GetMaxHeight);
- metaData.scriptClass->addInternalCall("Internal_SetMaxHeight", &ScriptGUIElementStyle::internal_SetMaxHeight);
- metaData.scriptClass->addInternalCall("Internal_GetFixedWidth", &ScriptGUIElementStyle::internal_GetFixedWidth);
- metaData.scriptClass->addInternalCall("Internal_SetFixedWidth", &ScriptGUIElementStyle::internal_SetFixedWidth);
- metaData.scriptClass->addInternalCall("Internal_GetFixedHeight", &ScriptGUIElementStyle::internal_GetFixedHeight);
- metaData.scriptClass->addInternalCall("Internal_SetFixedHeight", &ScriptGUIElementStyle::internal_SetFixedHeight);
- }
- MonoObject* ScriptGUIElementStyle::create(const String& name, const GUIElementStyle& style)
- {
- bool dummy = false;
- void* params[1];
- params[0] = &dummy;;
- MonoObject* instance = metaData.scriptClass->createInstance(params, true);
- ScriptGUIElementStyle* nativeInstance = new (bs_alloc<ScriptGUIElementStyle>()) ScriptGUIElementStyle(instance, name, style);
- return instance;
- }
- void ScriptGUIElementStyle::internal_createInstance(MonoObject* instance, MonoString* name)
- {
- char* nativeName = mono_string_to_utf8(name);
- String styleName(nativeName);
- free(nativeName);
- ScriptGUIElementStyle* nativeInstance = new (bs_alloc<ScriptGUIElementStyle>()) ScriptGUIElementStyle(instance, styleName);
- }
- void ScriptGUIElementStyle::internal_addSubStyle(ScriptGUIElementStyle* nativeInstance, MonoString* guiType, MonoString* styleName)
- {
- String guiTypeStr = MonoUtil::monoToString(guiType);
- String styleNameStr = MonoUtil::monoToString(styleName);
- nativeInstance->getInternalValue().subStyles[guiTypeStr] = styleNameStr;
- }
- void ScriptGUIElementStyle::internal_GetFont(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mFont != nullptr)
- {
- *value = nativeInstance->mFont->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetFont(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptFont* nativeValue = ScriptFont::toNative(value);
- nativeInstance->mElementStyle.font = static_resource_cast<Font>(nativeValue->getNativeHandle());
- nativeInstance->mFont = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetFontSize(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.fontSize;
- }
- void ScriptGUIElementStyle::internal_SetFontSize(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.fontSize = value;
- }
- void ScriptGUIElementStyle::internal_GetTextHorzAlign(ScriptGUIElementStyle* nativeInstance, TextHorzAlign*value)
- {
- *value = nativeInstance->mElementStyle.textHorzAlign;
- }
- void ScriptGUIElementStyle::internal_SetTextHorzAlign(ScriptGUIElementStyle* nativeInstance, TextHorzAlign value)
- {
- nativeInstance->mElementStyle.textHorzAlign = value;
- }
- void ScriptGUIElementStyle::internal_GetTextVertAlign(ScriptGUIElementStyle* nativeInstance, TextVertAlign* value)
- {
- *value = nativeInstance->mElementStyle.textVertAlign;
- }
- void ScriptGUIElementStyle::internal_SetTextVertAlign(ScriptGUIElementStyle* nativeInstance, TextVertAlign value)
- {
- nativeInstance->mElementStyle.textVertAlign = value;
- }
- void ScriptGUIElementStyle::internal_GetImagePosition(ScriptGUIElementStyle* nativeInstance, GUIImagePosition* value)
- {
- *value = nativeInstance->mElementStyle.imagePosition;
- }
- void ScriptGUIElementStyle::internal_SetImagePosition(ScriptGUIElementStyle* nativeInstance, GUIImagePosition value)
- {
- nativeInstance->mElementStyle.imagePosition = value;
- }
- void ScriptGUIElementStyle::internal_GetWordWrap(ScriptGUIElementStyle* nativeInstance, bool* value)
- {
- *value = nativeInstance->mElementStyle.wordWrap;
- }
- void ScriptGUIElementStyle::internal_SetWordWrap(ScriptGUIElementStyle* nativeInstance, bool value)
- {
- nativeInstance->mElementStyle.wordWrap = value;
- }
- void ScriptGUIElementStyle::internal_GetNormal(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mNormal != nullptr)
- {
- *value = nativeInstance->mNormal->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetNormal(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.normal = nativeValue->getInternalValue();
- nativeInstance->mNormal = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetHover(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mHover != nullptr)
- {
- *value = nativeInstance->mHover->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetHover(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.hover = nativeValue->getInternalValue();
- nativeInstance->mHover = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetActive(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mActive != nullptr)
- {
- *value = nativeInstance->mActive->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetActive(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.active = nativeValue->getInternalValue();
- nativeInstance->mActive = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetFocused(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mFocused != nullptr)
- {
- *value = nativeInstance->mFocused->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetFocused(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.focused = nativeValue->getInternalValue();
- nativeInstance->mFocused = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetNormalOn(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mNormalOn != nullptr)
- {
- *value = nativeInstance->mNormalOn->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetNormalOn(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.normalOn = nativeValue->getInternalValue();
- nativeInstance->mNormalOn = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetHoverOn(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mHoverOn != nullptr)
- {
- *value = nativeInstance->mHoverOn->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetHoverOn(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.hoverOn = nativeValue->getInternalValue();
- nativeInstance->mHoverOn = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetActiveOn(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mActiveOn != nullptr)
- {
- *value = nativeInstance->mActiveOn->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetActiveOn(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.activeOn = nativeValue->getInternalValue();
- nativeInstance->mActiveOn = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetFocusedOn(ScriptGUIElementStyle* nativeInstance, MonoObject** value)
- {
- if (nativeInstance->mFocusedOn != nullptr)
- {
- *value = nativeInstance->mFocusedOn->getManagedInstance();
- return;
- }
- *value = nullptr;
- }
- void ScriptGUIElementStyle::internal_SetFocusedOn(ScriptGUIElementStyle* nativeInstance, MonoObject* value)
- {
- ScriptGUIElementStateStyle* nativeValue = ScriptGUIElementStateStyle::toNative(value);
- nativeInstance->mElementStyle.focusedOn = nativeValue->getInternalValue();
- nativeInstance->mFocusedOn = nativeValue;
- }
- void ScriptGUIElementStyle::internal_GetBorder(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- *value = nativeInstance->mElementStyle.border;
- }
- void ScriptGUIElementStyle::internal_SetBorder(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- nativeInstance->mElementStyle.border = *value;
- }
- void ScriptGUIElementStyle::internal_GetMargins(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- *value = nativeInstance->mElementStyle.margins;
- }
- void ScriptGUIElementStyle::internal_SetMargins(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- nativeInstance->mElementStyle.margins = *value;
- }
- void ScriptGUIElementStyle::internal_GetContentOffset(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- *value = nativeInstance->mElementStyle.contentOffset;
- }
- void ScriptGUIElementStyle::internal_SetContentOffset(ScriptGUIElementStyle* nativeInstance, RectOffset* value)
- {
- nativeInstance->mElementStyle.contentOffset = *value;
- }
- void ScriptGUIElementStyle::internal_GetWidth(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.width;
- }
- void ScriptGUIElementStyle::internal_SetWidth(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.width = value;
- }
- void ScriptGUIElementStyle::internal_GetHeight(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.height;
- }
- void ScriptGUIElementStyle::internal_SetHeight(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.height = value;
- }
- void ScriptGUIElementStyle::internal_GetMinWidth(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.minWidth;
- }
- void ScriptGUIElementStyle::internal_SetMinWidth(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.minWidth = value;
- }
- void ScriptGUIElementStyle::internal_GetMaxWidth(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.maxWidth;
- }
- void ScriptGUIElementStyle::internal_SetMaxWidth(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.maxWidth = value;
- }
- void ScriptGUIElementStyle::internal_GetMinHeight(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.minHeight;
- }
- void ScriptGUIElementStyle::internal_SetMinHeight(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.minHeight = value;
- }
- void ScriptGUIElementStyle::internal_GetMaxHeight(ScriptGUIElementStyle* nativeInstance, UINT32* value)
- {
- *value = nativeInstance->mElementStyle.maxHeight;
- }
- void ScriptGUIElementStyle::internal_SetMaxHeight(ScriptGUIElementStyle* nativeInstance, UINT32 value)
- {
- nativeInstance->mElementStyle.maxHeight = value;
- }
- void ScriptGUIElementStyle::internal_GetFixedWidth(ScriptGUIElementStyle* nativeInstance, bool* value)
- {
- *value = nativeInstance->mElementStyle.fixedWidth;
- }
- void ScriptGUIElementStyle::internal_SetFixedWidth(ScriptGUIElementStyle* nativeInstance, bool value)
- {
- nativeInstance->mElementStyle.fixedWidth = value;
- }
- void ScriptGUIElementStyle::internal_GetFixedHeight(ScriptGUIElementStyle* nativeInstance, bool* value)
- {
- *value = nativeInstance->mElementStyle.fixedHeight;
- }
- void ScriptGUIElementStyle::internal_SetFixedHeight(ScriptGUIElementStyle* nativeInstance, bool value)
- {
- nativeInstance->mElementStyle.fixedHeight = value;
- }
- }
|