// Initialize the control(s) attached. void UIButtonMetadata::InitializeControl(const String& controlName, const Vector2& position) { BaseMetadata::InitializeControl(controlName, position); int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { UIButton* button = dynamic_cast<UIButton*>(this->treeNodeParams[i].GetUIControl()); WideString controlText = StringToWString(button->GetName()); HierarchyTreeNode* activeNode = GetTreeNode(i); // Initialize the button for all states. int statesCount = UIControlStateHelper::GetUIControlStatesCount(); for (int stateID = 0; stateID < statesCount; stateID ++) { UIControl::eControlState state = UIControlStateHelper::GetUIControlState(stateID); button->SetStateFont(state, EditorFontManager::Instance()->GetDefaultFont()); button->SetStateText(state, controlText); // Button is state-aware. activeNode->GetExtraData().SetLocalizationKey(controlText, state); } // Define some properties for the reference state. button->SetStateDrawType(GetReferenceState(), UIControlBackground::DRAW_SCALE_TO_RECT); } }
void BaseMetadata::SetStateDirtyForProperty(UIControl::eControlState controlState, const QString& propertyName, bool value) { // Perform set for all nodes. int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { HierarchyTreeNode* treeNode = GetTreeNode(i); if (!treeNode) { continue; } treeNode->GetExtraData().SetStatePropertyDirty(controlState, propertyName, value); } }
void UIButtonMetadata::SetLocalizedTextKey(const QString& value) { if (!VerifyActiveParamID() || !this->GetActiveTreeNode()) { return; } // Update the control with the value. WideString localizationValue = LocalizationSystem::Instance()->GetLocalizedString(QStrint2WideString(value)); HierarchyTreeNode* node = this->GetActiveTreeNode(); for(uint32 i = 0; i < GetStatesCount(); ++i) { // Update both key and value for all the states requested. node->GetExtraData().SetLocalizationKey(QStrint2WideString(value), this->uiControlStates[i]); GetActiveUIButton()->SetStateText(this->uiControlStates[i], localizationValue); } UpdatePropertyDirtyFlagForLocalizedText(); }
bool BaseMetadata::IsStateDirtyForProperty(UIControl::eControlState controlState, const QString& propertyName) { // If at least one state for the Metadata attached is dirty - return true. int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { HierarchyTreeNode* treeNode = GetTreeNode(i); if (!treeNode) { continue; } if (treeNode->GetExtraData().IsStatePropertyDirty(controlState, propertyName)) { return true; } } return false; }
// Initialize the control(s) attached. void UITextFieldMetadata::InitializeControl(const String& controlName, const Vector2& position) { UIControlMetadata::InitializeControl(controlName, position); int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { UITextField* textField = dynamic_cast<UITextField*>(this->treeNodeParams[i].GetUIControl()); textField->SetFont(EditorFontManager::Instance()->GetDefaultFont()); textField->GetBackground()->SetDrawType(UIControlBackground::DRAW_ALIGNED); // Initialize both control text and localization key. WideString controlText = StringToWString(textField->GetName()); HierarchyTreeNode* activeNode = GetTreeNode(i); textField->SetText(controlText); activeNode->GetExtraData().SetLocalizationKey(controlText, this->GetReferenceState()); } }
bool BaseMetadata::IsStateDirty(UIControl::eControlState controlState) { // If at least one state for the Metadata attached is dirty - return true. int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { HierarchyTreeNode* treeNode = GetTreeNode(i); if (!treeNode) { continue; } // State is dirty if at least one property exist in the dirty map. if (treeNode->GetExtraData().IsStatePropertyDirtyMapEmpty(controlState) == false) { return true; } } return false; }