void CGUIDialogContextMenu::SetupButtons() { if (!m_buttons.size()) return; // disable the template button control CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE); if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE); if (!pButtonTemplate) return; pButtonTemplate->SetVisible(false); // add our buttons for (unsigned int i = 0; i < m_buttons.size(); i++) { CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate); if (pButton) { // set the button's ID and position int id = BUTTON_START + i; pButton->SetID(id); pButton->SetPosition(pButtonTemplate->GetXPosition(), i*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS)); pButton->SetVisible(true); pButton->SetNavigation(id - 1, id + 1, id, id); pButton->SetLabel(m_buttons[i].second); AddControl(pButton); } } // update the navigation of the first and last buttons CGUIControl *pControl = (CGUIControl *)GetControl(BUTTON_START); if (pControl) pControl->SetNavigation(BUTTON_END, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight()); pControl = (CGUIControl *)GetControl(BUTTON_END); if (pControl) pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_START, pControl->GetControlIdLeft(), pControl->GetControlIdRight()); // fix up the height of the background image pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE); if (pControl) { pControl->SetHeight(m_buttons.size() * (pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS)); CGUIControl *pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM); if (pControl2) pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight()); } // update our default control if (m_defaultControl < BUTTON_START || m_defaultControl > BUTTON_END) m_defaultControl = BUTTON_START; while (m_defaultControl <= BUTTON_END && !(GetControl(m_defaultControl)->CanFocus())) m_defaultControl++; }
void CGUIControlGroupList::AddControl(CGUIControl *control) { // NOTE: We override control navigation here, but we don't override the <onleft> etc. builtins // if specified. if (control) { // set the navigation of items so that they form a list if (m_orientation == VERTICAL) { DWORD upID = GetControlIdUp(); DWORD downID = GetControlIdDown(); if (m_children.size()) { CGUIControl *top = m_children[0]; if (downID == GetID()) downID = top->GetID(); if (upID == GetID()) top->SetNavigation(control->GetID(), top->GetControlIdDown(), GetControlIdLeft(), GetControlIdRight()); CGUIControl *prev = m_children[m_children.size() - 1]; upID = prev->GetID(); prev->SetNavigation(prev->GetControlIdUp(), control->GetID(), GetControlIdLeft(), GetControlIdRight()); } control->SetNavigation(upID, downID, GetControlIdLeft(), GetControlIdRight()); } else { DWORD leftID = GetControlIdLeft(); DWORD rightID = GetControlIdRight(); if (m_children.size()) { CGUIControl *left = m_children[0]; if (rightID == GetID()) rightID = left->GetID(); if (leftID == GetID()) left->SetNavigation(GetControlIdUp(), GetControlIdDown(), control->GetID(), left->GetControlIdRight()); CGUIControl *prev = m_children[m_children.size() - 1]; leftID = prev->GetID(); prev->SetNavigation(GetControlIdUp(), GetControlIdDown(), prev->GetControlIdLeft(), control->GetID()); } control->SetNavigation(GetControlIdUp(), GetControlIdDown(), leftID, rightID); } // old versions of the grouplist used to set the positions of all controls // directly. The new version (with <usecontrolcoords>true</usecontrolcoords>) // allows offsets to be set via the posx, posy coordinates. if (!m_useControlPositions) control->SetPosition(0,0); CGUIControlGroup::AddControl(control); } }
void CGUIDialogContextMenu::DoModal(int iWindowID /*= WINDOW_INVALID */, const CStdString ¶m) { // update the navigation of the first and last buttons CGUIControl *pControl = (CGUIControl *)GetControl(BUTTON_TEMPLATE + 1); if (pControl) pControl->SetNavigation(BUTTON_TEMPLATE + m_iNumButtons, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight()); pControl = (CGUIControl *)GetControl(BUTTON_TEMPLATE + m_iNumButtons); if (pControl) pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_TEMPLATE + 1, pControl->GetControlIdLeft(), pControl->GetControlIdRight()); // update our default control if (m_defaultControl <= BUTTON_TEMPLATE || m_defaultControl > (BUTTON_TEMPLATE + m_iNumButtons)) m_defaultControl = BUTTON_TEMPLATE + 1; // check the default control has focus... while (m_defaultControl <= (BUTTON_TEMPLATE + m_iNumButtons) && !(GetControl(m_defaultControl)->CanFocus())) m_defaultControl++; CGUIDialog::DoModal(); }
void CGUIDialogContextMenu::SetupButtons() { if (!m_buttons.size()) return; // disable the template button control CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE); if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE); if (!pButtonTemplate) return; pButtonTemplate->SetVisible(false); CGUIControlGroupList* pGroupList = NULL; { const CGUIControl* pControl = GetControl(GROUP_LIST); if (pControl && pControl->GetControlType() == GUICONTROL_GROUPLIST) pGroupList = (CGUIControlGroupList*)pControl; } // add our buttons for (unsigned int i = 0; i < m_buttons.size(); i++) { CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate); if (pButton) { // set the button's ID and position int id = BUTTON_START + i; pButton->SetID(id); pButton->SetVisible(true); pButton->SetLabel(m_buttons[i].second); if (pGroupList) { pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition()); pGroupList->AddControl(pButton); } #if PRE_SKIN_VERSION_11_COMPATIBILITY else { pButton->SetPosition(pButtonTemplate->GetXPosition(), i*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS)); pButton->SetNavigation(id - 1, id + 1, id, id); AddControl(pButton); } #endif } } CGUIControl *pControl = NULL; #if PRE_SKIN_VERSION_11_COMPATIBILITY if (!pGroupList) { // if we don't have grouplist update the navigation of the first and last buttons pControl = (CGUIControl *)GetControl(BUTTON_START); if (pControl) pControl->SetNavigation(BUTTON_END, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight()); pControl = (CGUIControl *)GetControl(BUTTON_END); if (pControl) pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_START, pControl->GetControlIdLeft(), pControl->GetControlIdRight()); } #endif // fix up background images placement and size pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE); if (pControl) { // first set size of background image if (pGroupList) { if (pGroupList->GetOrientation() == VERTICAL) { // keep gap between bottom edges of grouplist and background image pControl->SetHeight(pControl->GetHeight() - pGroupList->Size() + pGroupList->GetHeight()); } else { // keep gap between right edges of grouplist and background image pControl->SetWidth(pControl->GetWidth() - pGroupList->Size() + pGroupList->GetWidth()); } } #if PRE_SKIN_VERSION_11_COMPATIBILITY else pControl->SetHeight(m_buttons.size() * (pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS)); if (pGroupList && pGroupList->GetOrientation() == HORIZONTAL) { // if there is grouplist control with horizontal orientation - adjust width of top and bottom background CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_TOP); if (pControl2) pControl2->SetWidth(pControl->GetWidth()); pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM); if (pControl2) pControl2->SetWidth(pControl->GetWidth()); } else { // adjust position of bottom background CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM); if (pControl2) pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight()); } #endif } // update our default control if (m_defaultControl < BUTTON_START || m_defaultControl > BUTTON_END) m_defaultControl = BUTTON_START; while (m_defaultControl <= BUTTON_END && !(GetControl(m_defaultControl)->CanFocus())) m_defaultControl++; }
void CGUIControlGroupList::AddControl(CGUIControl *control, int position /*= -1*/) { // NOTE: We override control navigation here, but we don't override the <onleft> etc. builtins // if specified. if (position < 0 || position > (int)m_children.size()) // add at the end position = (int)m_children.size(); if (control) { // set the navigation of items so that they form a list int beforeID = (m_orientation == VERTICAL) ? GetControlIdUp() : GetControlIdLeft(); int afterID = (m_orientation == VERTICAL) ? GetControlIdDown() : GetControlIdRight(); if (m_children.size()) { // we're inserting at the given position, so grab the items above and below and alter // their navigation accordingly CGUIControl *before = NULL; CGUIControl *after = NULL; if (position == 0) { // inserting at the beginning after = m_children[0]; if (afterID == GetID()) // we're wrapping around bottom->top, so we have to update the last item before = m_children[m_children.size() - 1]; if (beforeID == GetID()) // we're wrapping around top->bottom beforeID = m_children[m_children.size() - 1]->GetID(); afterID = after->GetID(); } else if (position == (int)m_children.size()) { // inserting at the end before = m_children[m_children.size() - 1]; if (beforeID == GetID()) // we're wrapping around top->bottom, so we have to update the first item after = m_children[0]; if (afterID == GetID()) // we're wrapping around bottom->top afterID = m_children[0]->GetID(); beforeID = before->GetID(); } else { // inserting somewhere in the middle before = m_children[position - 1]; after = m_children[position]; beforeID = before->GetID(); afterID = after->GetID(); } if (m_orientation == VERTICAL) { if (before) // update the DOWN action to point to us before->SetNavigation(before->GetControlIdUp(), control->GetID(), GetControlIdLeft(), GetControlIdRight(), GetControlIdBack()); if (after) // update the UP action to point to us after->SetNavigation(control->GetID(), after->GetControlIdDown(), GetControlIdLeft(), GetControlIdRight(), GetControlIdBack()); } else { if (before) // update the RIGHT action to point to us before->SetNavigation(GetControlIdUp(), GetControlIdDown(), before->GetControlIdLeft(), control->GetID(), GetControlIdBack()); if (after) // update the LEFT action to point to us after->SetNavigation(GetControlIdUp(), GetControlIdDown(), control->GetID(), after->GetControlIdRight(), GetControlIdBack()); } } // now the control's nav std::vector<CGUIActionDescriptor> empty; if (m_orientation == VERTICAL) { control->SetNavigation(beforeID, afterID, GetControlIdLeft(), GetControlIdRight(), GetControlIdBack()); control->SetNavigationActions(empty, empty, m_leftActions, m_rightActions, empty, false); } else { control->SetNavigation(GetControlIdUp(), GetControlIdDown(), beforeID, afterID, GetControlIdBack()); control->SetNavigationActions(m_upActions, m_downActions, empty, empty, empty, false); } if (!m_useControlPositions) control->SetPosition(0,0); CGUIControlGroup::AddControl(control, position); } }
CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer) { // get the control type CStdString strType = GetType(pControlNode); CGUIControl::GUICONTROLTYPES type = TranslateControlType(strType); int id = 0; float posX = 0, posY = 0; float width = 0, height = 0; float minWidth = 0; int left = 0, right = 0, up = 0, down = 0, next = 0, prev = 0; vector<CGUIActionDescriptor> leftActions, rightActions, upActions, downActions, nextActions, prevActions; int pageControl = 0; CGUIInfoColor colorDiffuse(0xFFFFFFFF); int defaultControl = 0; bool defaultAlways = false; CStdString strTmp; int singleInfo = 0; CStdString strLabel; int iUrlSet=0; int iToggleSelect; float spinWidth = 16; float spinHeight = 16; float spinPosX = 0, spinPosY = 0; float checkWidth = 0, checkHeight = 0; CStdString strSubType; int iType = SPIN_CONTROL_TYPE_TEXT; int iMin = 0; int iMax = 100; int iInterval = 1; float fMin = 0.0f; float fMax = 1.0f; float fInterval = 0.1f; bool bReverse = true; bool bReveal = false; CTextureInfo textureBackground, textureLeft, textureRight, textureMid, textureOverlay; CTextureInfo textureNib, textureNibFocus, textureBar, textureBarFocus; CTextureInfo textureLeftFocus, textureRightFocus; CTextureInfo textureUp, textureDown; CTextureInfo textureUpFocus, textureDownFocus; CTextureInfo texture, borderTexture; CGUIInfoLabel textureFile; CTextureInfo textureCheckMark, textureCheckMarkNF; CTextureInfo textureFocus, textureNoFocus; CTextureInfo textureAltFocus, textureAltNoFocus; CTextureInfo textureRadioOn, textureRadioOff; CTextureInfo imageNoFocus, imageFocus; CGUIInfoLabel texturePath; CRect borderSize; float sliderWidth = 150, sliderHeight = 16; CPoint offset; bool bHasPath = false; vector<CGUIActionDescriptor> clickActions; vector<CGUIActionDescriptor> altclickActions; vector<CGUIActionDescriptor> focusActions; vector<CGUIActionDescriptor> unfocusActions; vector<CGUIActionDescriptor> textChangeActions; CStdString strTitle = ""; CStdString strRSSTags = ""; int iNumSlots = 7; float buttonGap = 5; int iDefaultSlot = 2; int iMovementRange = 0; bool bHorizontal = false; int iAlpha = 0; bool bWrapAround = true; bool bSmoothScrolling = true; CAspectRatio aspect; #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY if (insideContainer) // default for inside containers is keep aspect.ratio = CAspectRatio::AR_KEEP; #endif int iVisibleCondition = 0; CGUIInfoBool allowHiddenFocus(false); int enableCondition = 0; vector<CAnimation> animations; bool bScrollLabel = false; bool bPulse = true; unsigned int timePerImage = 0; unsigned int fadeTime = 0; unsigned int timeToPauseAtEnd = 0; bool randomized = false; bool loop = true; bool wrapMultiLine = false; ORIENTATION orientation = VERTICAL; bool showOnePage = true; bool scrollOut = true; int preloadItems = 0; CLabelInfo labelInfo; CLabelInfo spinInfo; CGUIInfoColor textColor3; CGUIInfoColor headlineColor; float radioWidth = 0; float radioHeight = 0; float radioPosX = 0; float radioPosY = 0; CStdString altLabel; CStdString strLabel2; int focusPosition = 0; int scrollTime = 200; bool useControlCoords = false; bool renderFocusedLast = false; CRect hitRect; CPoint camera; bool hasCamera = false; bool resetOnLabelChange = true; bool bPassword = false; ///////////////////////////////////////////////////////////////////////////// // Read control properties from XML // if (!pControlNode->Attribute("id", (int*) &id)) XMLUtils::GetInt(pControlNode, "id", (int&) id); // backward compatibility - not desired // TODO: Perhaps we should check here whether id is valid for focusable controls // such as buttons etc. For labels/fadelabels/images it does not matter XMLUtils::GetFloat(pControlNode, "posx", posX); XMLUtils::GetFloat(pControlNode, "posy", posY); // Convert these from relative coords CStdString pos; XMLUtils::GetString(pControlNode, "posx", pos); if (pos.Right(1) == "r") posX = rect.Width() - posX; XMLUtils::GetString(pControlNode, "posy", pos); if (pos.Right(1) == "r") posY = rect.Height() - posY; GetDimension(pControlNode, "width", width, minWidth); XMLUtils::GetFloat(pControlNode, "height", height); XMLUtils::GetFloat(pControlNode, "offsetx", offset.x); XMLUtils::GetFloat(pControlNode, "offsety", offset.y); // adjust width and height accordingly for groups. Groups should // take the width/height of the parent (adjusted for positioning) // if none is defined. if (type == CGUIControl::GUICONTROL_GROUP || type == CGUIControl::GUICONTROL_GROUPLIST) { if (!width) width = max(rect.x2 - posX, 0.0f); if (!height) height = max(rect.y2 - posY, 0.0f); } hitRect.SetRect(posX, posY, posX + width, posY + height); GetHitRect(pControlNode, hitRect); if (!GetNavigation(pControlNode, "onup", up, upActions)) up = id - 1; if (!GetNavigation(pControlNode, "ondown", down, downActions)) down = id + 1; if (!GetNavigation(pControlNode, "onleft", left, leftActions)) left = id; if (!GetNavigation(pControlNode, "onright", right, rightActions)) right = id; if (!GetNavigation(pControlNode, "onnext", next, nextActions)) next = id; if (!GetNavigation(pControlNode, "onprev", prev, prevActions)) prev = id; if (XMLUtils::GetInt(pControlNode, "defaultcontrol", defaultControl)) { const char *always = pControlNode->FirstChildElement("defaultcontrol")->Attribute("always"); if (always && strnicmp(always, "true", 4) == 0) defaultAlways = true; } XMLUtils::GetInt(pControlNode, "pagecontrol", pageControl); GetInfoColor(pControlNode, "colordiffuse", colorDiffuse); GetConditionalVisibility(pControlNode, iVisibleCondition, allowHiddenFocus); GetCondition(pControlNode, "enable", enableCondition); CRect animRect(posX, posY, posX + width, posY + height); GetAnimations(pControlNode, animRect, animations); GetInfoColor(pControlNode, "textcolor", labelInfo.textColor); GetInfoColor(pControlNode, "focusedcolor", labelInfo.focusedColor); GetInfoColor(pControlNode, "disabledcolor", labelInfo.disabledColor); GetInfoColor(pControlNode, "shadowcolor", labelInfo.shadowColor); GetInfoColor(pControlNode, "selectedcolor", labelInfo.selectedColor); XMLUtils::GetFloat(pControlNode, "textoffsetx", labelInfo.offsetX); XMLUtils::GetFloat(pControlNode, "textoffsety", labelInfo.offsetY); int angle = 0; // use the negative angle to compensate for our vertically flipped cartesian plane if (XMLUtils::GetInt(pControlNode, "angle", angle)) labelInfo.angle = (float)-angle; CStdString strFont; if (XMLUtils::GetString(pControlNode, "font", strFont)) labelInfo.font = g_fontManager.GetFont(strFont); GetAlignment(pControlNode, "align", labelInfo.align); uint32_t alignY = 0; if (GetAlignmentY(pControlNode, "aligny", alignY)) labelInfo.align |= alignY; if (XMLUtils::GetFloat(pControlNode, "textwidth", labelInfo.width)) labelInfo.align |= XBFONT_TRUNCATED; GetMultipleString(pControlNode, "onclick", clickActions); GetMultipleString(pControlNode, "ontextchange", textChangeActions); GetMultipleString(pControlNode, "onfocus", focusActions); GetMultipleString(pControlNode, "onunfocus", unfocusActions); GetMultipleString(pControlNode, "altclick", altclickActions); CStdString infoString; if (XMLUtils::GetString(pControlNode, "info", infoString)) singleInfo = g_infoManager.TranslateString(infoString); GetTexture(pControlNode, "texturefocus", textureFocus); GetTexture(pControlNode, "texturenofocus", textureNoFocus); GetTexture(pControlNode, "alttexturefocus", textureAltFocus); GetTexture(pControlNode, "alttexturenofocus", textureAltNoFocus); CStdString strToggleSelect; XMLUtils::GetString(pControlNode, "usealttexture", strToggleSelect); XMLUtils::GetString(pControlNode, "selected", strToggleSelect); iToggleSelect = g_infoManager.TranslateString(strToggleSelect); XMLUtils::GetBoolean(pControlNode, "haspath", bHasPath); GetTexture(pControlNode, "textureup", textureUp); GetTexture(pControlNode, "texturedown", textureDown); GetTexture(pControlNode, "textureupfocus", textureUpFocus); GetTexture(pControlNode, "texturedownfocus", textureDownFocus); GetTexture(pControlNode, "textureleft", textureLeft); GetTexture(pControlNode, "textureright", textureRight); GetTexture(pControlNode, "textureleftfocus", textureLeftFocus); GetTexture(pControlNode, "texturerightfocus", textureRightFocus); GetInfoColor(pControlNode, "spincolor", spinInfo.textColor); if (XMLUtils::GetString(pControlNode, "spinfont", strFont)) spinInfo.font = g_fontManager.GetFont(strFont); if (!spinInfo.font) spinInfo.font = labelInfo.font; XMLUtils::GetFloat(pControlNode, "spinwidth", spinWidth); XMLUtils::GetFloat(pControlNode, "spinheight", spinHeight); XMLUtils::GetFloat(pControlNode, "spinposx", spinPosX); XMLUtils::GetFloat(pControlNode, "spinposy", spinPosY); XMLUtils::GetFloat(pControlNode, "markwidth", checkWidth); XMLUtils::GetFloat(pControlNode, "markheight", checkHeight); XMLUtils::GetFloat(pControlNode, "sliderwidth", sliderWidth); XMLUtils::GetFloat(pControlNode, "sliderheight", sliderHeight); GetTexture(pControlNode, "texturecheckmark", textureCheckMark); GetTexture(pControlNode, "texturecheckmarknofocus", textureCheckMarkNF); GetTexture(pControlNode, "textureradiofocus", textureRadioOn); // backward compatibility GetTexture(pControlNode, "textureradionofocus", textureRadioOff); GetTexture(pControlNode, "textureradioon", textureRadioOn); GetTexture(pControlNode, "textureradiooff", textureRadioOff); GetTexture(pControlNode, "texturesliderbackground", textureBackground); GetTexture(pControlNode, "texturesliderbar", textureBar); GetTexture(pControlNode, "texturesliderbarfocus", textureBarFocus); GetTexture(pControlNode, "textureslidernib", textureNib); GetTexture(pControlNode, "textureslidernibfocus", textureNibFocus); XMLUtils::GetString(pControlNode, "title", strTitle); XMLUtils::GetString(pControlNode, "tagset", strRSSTags); GetInfoColor(pControlNode, "headlinecolor", headlineColor); GetInfoColor(pControlNode, "titlecolor", textColor3); if (XMLUtils::GetString(pControlNode, "subtype", strSubType)) { strSubType.ToLower(); if ( strSubType == "int") iType = SPIN_CONTROL_TYPE_INT; else if ( strSubType == "page") iType = SPIN_CONTROL_TYPE_PAGE; else if ( strSubType == "float") iType = SPIN_CONTROL_TYPE_FLOAT; else iType = SPIN_CONTROL_TYPE_TEXT; } if (!GetIntRange(pControlNode, "range", iMin, iMax, iInterval)) { GetFloatRange(pControlNode, "range", fMin, fMax, fInterval); } XMLUtils::GetBoolean(pControlNode, "reverse", bReverse); XMLUtils::GetBoolean(pControlNode, "reveal", bReveal); GetTexture(pControlNode, "texturebg", textureBackground); GetTexture(pControlNode, "lefttexture", textureLeft); GetTexture(pControlNode, "midtexture", textureMid); GetTexture(pControlNode, "righttexture", textureRight); GetTexture(pControlNode, "overlaytexture", textureOverlay); // the <texture> tag can be overridden by the <info> tag GetInfoTexture(pControlNode, "texture", texture, textureFile); GetTexture(pControlNode, "bordertexture", borderTexture); GetTexture(pControlNode, "imagefolder", imageNoFocus); GetTexture(pControlNode, "imagefolderfocus", imageFocus); // fade label can have a whole bunch, but most just have one vector<CGUIInfoLabel> infoLabels; GetInfoLabels(pControlNode, "label", infoLabels); GetString(pControlNode, "label", strLabel); GetString(pControlNode, "altlabel", altLabel); GetString(pControlNode, "label2", strLabel2); XMLUtils::GetBoolean(pControlNode, "wrapmultiline", wrapMultiLine); XMLUtils::GetInt(pControlNode,"urlset",iUrlSet); // stuff for button scroller if ( XMLUtils::GetString(pControlNode, "orientation", strTmp) ) { if (strTmp.ToLower() == "horizontal") { bHorizontal = true; orientation = HORIZONTAL; } } XMLUtils::GetFloat(pControlNode, "buttongap", buttonGap); XMLUtils::GetFloat(pControlNode, "itemgap", buttonGap); XMLUtils::GetInt(pControlNode, "numbuttons", iNumSlots); XMLUtils::GetInt(pControlNode, "movement", iMovementRange); XMLUtils::GetInt(pControlNode, "defaultbutton", iDefaultSlot); XMLUtils::GetInt(pControlNode, "alpha", iAlpha); XMLUtils::GetBoolean(pControlNode, "wraparound", bWrapAround); XMLUtils::GetBoolean(pControlNode, "smoothscrolling", bSmoothScrolling); GetAspectRatio(pControlNode, "aspectratio", aspect); XMLUtils::GetBoolean(pControlNode, "scroll", bScrollLabel); XMLUtils::GetBoolean(pControlNode,"pulseonselect", bPulse); GetInfoTexture(pControlNode, "imagepath", texture, texturePath); XMLUtils::GetUInt(pControlNode,"timeperimage", timePerImage); XMLUtils::GetUInt(pControlNode,"fadetime", fadeTime); XMLUtils::GetUInt(pControlNode,"pauseatend", timeToPauseAtEnd); XMLUtils::GetBoolean(pControlNode, "randomize", randomized); XMLUtils::GetBoolean(pControlNode, "loop", loop); XMLUtils::GetBoolean(pControlNode, "scrollout", scrollOut); XMLUtils::GetFloat(pControlNode, "radiowidth", radioWidth); XMLUtils::GetFloat(pControlNode, "radioheight", radioHeight); XMLUtils::GetFloat(pControlNode, "radioposx", radioPosX); XMLUtils::GetFloat(pControlNode, "radioposy", radioPosY); CStdString borderStr; if (XMLUtils::GetString(pControlNode, "bordersize", borderStr)) GetRectFromString(borderStr, borderSize); XMLUtils::GetBoolean(pControlNode, "showonepage", showOnePage); XMLUtils::GetInt(pControlNode, "focusposition", focusPosition); XMLUtils::GetInt(pControlNode, "scrolltime", scrollTime); XMLUtils::GetInt(pControlNode, "preloaditems", preloadItems, 0, 2); XMLUtils::GetBoolean(pControlNode, "usecontrolcoords", useControlCoords); XMLUtils::GetBoolean(pControlNode, "renderfocusedlast", renderFocusedLast); XMLUtils::GetBoolean(pControlNode, "resetonlabelchange", resetOnLabelChange); XMLUtils::GetBoolean(pControlNode, "password", bPassword); // view type VIEW_TYPE viewType = VIEW_TYPE_NONE; CStdString viewLabel; if (type == CGUIControl::GUICONTAINER_PANEL) { viewType = VIEW_TYPE_ICON; viewLabel = g_localizeStrings.Get(536); } else if (type == CGUIControl::GUICONTAINER_LIST) { viewType = VIEW_TYPE_LIST; viewLabel = g_localizeStrings.Get(535); } else { viewType = VIEW_TYPE_WRAP; viewLabel = g_localizeStrings.Get(541); } TiXmlElement *itemElement = pControlNode->FirstChildElement("viewtype"); if (itemElement && itemElement->FirstChild()) { CStdString type = itemElement->FirstChild()->Value(); if (type == "list") viewType = VIEW_TYPE_LIST; else if (type == "icon") viewType = VIEW_TYPE_ICON; else if (type == "biglist") viewType = VIEW_TYPE_BIG_LIST; else if (type == "bigicon") viewType = VIEW_TYPE_BIG_ICON; else if (type == "wide") viewType = VIEW_TYPE_WIDE; else if (type == "bigwide") viewType = VIEW_TYPE_BIG_WIDE; else if (type == "wrap") viewType = VIEW_TYPE_WRAP; else if (type == "bigwrap") viewType = VIEW_TYPE_BIG_WRAP; const char *label = itemElement->Attribute("label"); if (label) viewLabel = CGUIInfoLabel::GetLabel(FilterLabel(label)); } TiXmlElement *cam = pControlNode->FirstChildElement("camera"); if (cam) { hasCamera = true; cam->QueryFloatAttribute("x", &camera.x); cam->QueryFloatAttribute("y", &camera.y); } XMLUtils::GetInt(pControlNode, "scrollspeed", labelInfo.scrollSpeed); spinInfo.scrollSpeed = labelInfo.scrollSpeed; GetString(pControlNode, "scrollsuffix", labelInfo.scrollSuffix); spinInfo.scrollSuffix = labelInfo.scrollSuffix; ///////////////////////////////////////////////////////////////////////////// // Instantiate a new control using the properties gathered above // CGUIControl *control = NULL; if (type == CGUIControl::GUICONTROL_GROUP) { if (insideContainer) { control = new CGUIListGroup(parentID, id, posX, posY, width, height); } else { control = new CGUIControlGroup( parentID, id, posX, posY, width, height); ((CGUIControlGroup *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast); } } else if (type == CGUIControl::GUICONTROL_GROUPLIST) { control = new CGUIControlGroupList( parentID, id, posX, posY, width, height, buttonGap, pageControl, orientation, useControlCoords, labelInfo.align, scrollTime); ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast); } else if (type == CGUIControl::GUICONTROL_LABEL) { const CGUIInfoLabel &content = (infoLabels.size()) ? infoLabels[0] : CGUIInfoLabel(""); if (insideContainer) { // inside lists we use CGUIListLabel control = new CGUIListLabel(parentID, id, posX, posY, width, height, labelInfo, content, bScrollLabel); } else { control = new CGUILabelControl( parentID, id, posX, posY, width, height, labelInfo, wrapMultiLine, bHasPath); ((CGUILabelControl *)control)->SetInfo(content); ((CGUILabelControl *)control)->SetWidthControl(minWidth, bScrollLabel); } } else if (type == CGUIControl::GUICONTROL_EDIT) { control = new CGUIEditControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, strLabel); if (bPassword) ((CGUIEditControl *) control)->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD, 0); ((CGUIEditControl *) control)->SetTextChangeActions(textChangeActions); } else if (type == CGUIControl::GUICONTROL_VIDEO) { control = new CGUIVideoControl( parentID, id, posX, posY, width, height); } else if (type == CGUIControl::GUICONTROL_FADELABEL) { control = new CGUIFadeLabelControl( parentID, id, posX, posY, width, height, labelInfo, scrollOut, timeToPauseAtEnd, resetOnLabelChange); ((CGUIFadeLabelControl *)control)->SetInfo(infoLabels); } else if (type == CGUIControl::GUICONTROL_RSS) { control = new CGUIRSSControl( parentID, id, posX, posY, width, height, labelInfo, textColor3, headlineColor, strRSSTags); std::map<int,CSettings::RssSet>::iterator iter=g_settings.m_mapRssUrls.find(iUrlSet); if (iter != g_settings.m_mapRssUrls.end()) { ((CGUIRSSControl *)control)->SetUrls(iter->second.url,iter->second.rtl); ((CGUIRSSControl *)control)->SetIntervals(iter->second.interval); } else CLog::Log(LOGERROR,"invalid rss url set referenced in skin"); } else if (type == CGUIControl::GUICONTROL_BUTTON) { control = new CGUIButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo); ((CGUIButtonControl *)control)->SetLabel(strLabel); ((CGUIButtonControl *)control)->SetLabel2(strLabel2); ((CGUIButtonControl *)control)->SetClickActions(clickActions); ((CGUIButtonControl *)control)->SetFocusActions(focusActions); ((CGUIButtonControl *)control)->SetUnFocusActions(unfocusActions); } else if (type == CGUIControl::GUICONTROL_TOGGLEBUTTON) { control = new CGUIToggleButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, textureAltFocus, textureAltNoFocus, labelInfo); ((CGUIToggleButtonControl *)control)->SetLabel(strLabel); ((CGUIToggleButtonControl *)control)->SetAltLabel(altLabel); ((CGUIToggleButtonControl *)control)->SetClickActions(clickActions); ((CGUIToggleButtonControl *)control)->SetAltClickActions(altclickActions); ((CGUIToggleButtonControl *)control)->SetFocusActions(focusActions); ((CGUIToggleButtonControl *)control)->SetUnFocusActions(unfocusActions); ((CGUIToggleButtonControl *)control)->SetToggleSelect(iToggleSelect); } else if (type == CGUIControl::GUICONTROL_CHECKMARK) { control = new CGUICheckMarkControl( parentID, id, posX, posY, width, height, textureCheckMark, textureCheckMarkNF, checkWidth, checkHeight, labelInfo); ((CGUICheckMarkControl *)control)->SetLabel(strLabel); } else if (type == CGUIControl::GUICONTROL_RADIO) { control = new CGUIRadioButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, textureRadioOn, textureRadioOff); ((CGUIRadioButtonControl *)control)->SetLabel(strLabel); ((CGUIRadioButtonControl *)control)->SetRadioDimensions(radioPosX, radioPosY, radioWidth, radioHeight); ((CGUIRadioButtonControl *)control)->SetToggleSelect(iToggleSelect); ((CGUIRadioButtonControl *)control)->SetClickActions(clickActions); ((CGUIRadioButtonControl *)control)->SetFocusActions(focusActions); ((CGUIRadioButtonControl *)control)->SetUnFocusActions(unfocusActions); } else if (type == CGUIControl::GUICONTROL_MULTISELECT) { CGUIInfoLabel label; if (infoLabels.size()) label = infoLabels[0]; control = new CGUIMultiSelectTextControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, label); } else if (type == CGUIControl::GUICONTROL_SPIN) { control = new CGUISpinControl( parentID, id, posX, posY, width, height, textureUp, textureDown, textureUpFocus, textureDownFocus, labelInfo, iType); ((CGUISpinControl *)control)->SetReverse(bReverse); if (iType == SPIN_CONTROL_TYPE_INT) { ((CGUISpinControl *)control)->SetRange(iMin, iMax); } else if (iType == SPIN_CONTROL_TYPE_PAGE) { ((CGUISpinControl *)control)->SetRange(iMin, iMax); ((CGUISpinControl *)control)->SetShowRange(true); ((CGUISpinControl *)control)->SetReverse(false); ((CGUISpinControl *)control)->SetShowOnePage(showOnePage); } else if (iType == SPIN_CONTROL_TYPE_FLOAT) { ((CGUISpinControl *)control)->SetFloatRange(fMin, fMax); ((CGUISpinControl *)control)->SetFloatInterval(fInterval); } } else if (type == CGUIControl::GUICONTROL_SLIDER) { control = new CGUISliderControl( parentID, id, posX, posY, width, height, textureBar, textureNib, textureNibFocus, SPIN_CONTROL_TYPE_TEXT); ((CGUISliderControl *)control)->SetInfo(singleInfo); } else if (type == CGUIControl::GUICONTROL_SETTINGS_SLIDER) { labelInfo.align |= XBFONT_CENTER_Y; // always center text vertically control = new CGUISettingsSliderControl( parentID, id, posX, posY, width, height, sliderWidth, sliderHeight, textureFocus, textureNoFocus, textureBar, textureNib, textureNibFocus, labelInfo, SPIN_CONTROL_TYPE_TEXT); ((CGUISettingsSliderControl *)control)->SetText(strLabel); ((CGUISettingsSliderControl *)control)->SetInfo(singleInfo); } else if (type == CGUIControl::GUICONTROL_SCROLLBAR) { control = new CGUIScrollBar( parentID, id, posX, posY, width, height, textureBackground, textureBar, textureBarFocus, textureNib, textureNibFocus, orientation, showOnePage); } else if (type == CGUIControl::GUICONTROL_PROGRESS) { control = new CGUIProgressControl( parentID, id, posX, posY, width, height, textureBackground, textureLeft, textureMid, textureRight, textureOverlay, bReveal); ((CGUIProgressControl *)control)->SetInfo(singleInfo); } else if (type == CGUIControl::GUICONTROL_IMAGE) { if (strType == "largeimage") texture.useLarge = true; // use a bordered texture if we have <bordersize> or <bordertexture> specified. if (borderTexture.filename.IsEmpty() && borderStr.IsEmpty()) control = new CGUIImage( parentID, id, posX, posY, width, height, texture); else control = new CGUIBorderedImage( parentID, id, posX, posY, width, height, texture, borderTexture, borderSize); #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY if (insideContainer && textureFile.IsConstant()) aspect.ratio = CAspectRatio::AR_STRETCH; #endif ((CGUIImage *)control)->SetInfo(textureFile); ((CGUIImage *)control)->SetAspectRatio(aspect); ((CGUIImage *)control)->SetCrossFade(fadeTime); } else if (type == CGUIControl::GUICONTROL_MULTI_IMAGE) { control = new CGUIMultiImage( parentID, id, posX, posY, width, height, texture, timePerImage, fadeTime, randomized, loop, timeToPauseAtEnd); ((CGUIMultiImage *)control)->SetInfo(texturePath); ((CGUIMultiImage *)control)->SetAspectRatio(aspect); } else if (type == CGUIControl::GUICONTAINER_LIST) { control = new CGUIListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems); ((CGUIListContainer *)control)->LoadLayout(pControlNode); ((CGUIListContainer *)control)->LoadContent(pControlNode); ((CGUIListContainer *)control)->SetType(viewType, viewLabel); ((CGUIListContainer *)control)->SetPageControl(pageControl); ((CGUIListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_WRAPLIST) { control = new CGUIWrappingListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems, focusPosition); ((CGUIWrappingListContainer *)control)->LoadLayout(pControlNode); ((CGUIWrappingListContainer *)control)->LoadContent(pControlNode); ((CGUIWrappingListContainer *)control)->SetType(viewType, viewLabel); ((CGUIWrappingListContainer *)control)->SetPageControl(pageControl); ((CGUIWrappingListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_FIXEDLIST) { control = new CGUIFixedListContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems, focusPosition, iMovementRange); ((CGUIFixedListContainer *)control)->LoadLayout(pControlNode); ((CGUIFixedListContainer *)control)->LoadContent(pControlNode); ((CGUIFixedListContainer *)control)->SetType(viewType, viewLabel); ((CGUIFixedListContainer *)control)->SetPageControl(pageControl); ((CGUIFixedListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_PANEL) { control = new CGUIPanelContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems); ((CGUIPanelContainer *)control)->LoadLayout(pControlNode); ((CGUIPanelContainer *)control)->LoadContent(pControlNode); ((CGUIPanelContainer *)control)->SetType(viewType, viewLabel); ((CGUIPanelContainer *)control)->SetPageControl(pageControl); ((CGUIPanelContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTROL_TEXTBOX) { control = new CGUITextBox( parentID, id, posX, posY, width, height, labelInfo, scrollTime); ((CGUITextBox *)control)->SetPageControl(pageControl); if (infoLabels.size()) ((CGUITextBox *)control)->SetInfo(infoLabels[0]); ((CGUITextBox *)control)->SetAutoScrolling(pControlNode); } else if (type == CGUIControl::GUICONTROL_SELECTBUTTON) { control = new CGUISelectButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, textureBackground, textureLeft, textureLeftFocus, textureRight, textureRightFocus); ((CGUISelectButtonControl *)control)->SetLabel(strLabel); } else if (type == CGUIControl::GUICONTROL_MOVER) { control = new CGUIMoverControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus); } else if (type == CGUIControl::GUICONTROL_RESIZE) { control = new CGUIResizeControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus); } else if (type == CGUIControl::GUICONTROL_BUTTONBAR) { control = new CGUIButtonScroller( parentID, id, posX, posY, width, height, buttonGap, iNumSlots, iDefaultSlot, iMovementRange, bHorizontal, iAlpha, bWrapAround, bSmoothScrolling, textureFocus, textureNoFocus, labelInfo); ((CGUIButtonScroller *)control)->LoadButtons(pControlNode); } else if (type == CGUIControl::GUICONTROL_SPINEX) { control = new CGUISpinControlEx( parentID, id, posX, posY, width, height, spinWidth, spinHeight, labelInfo, textureFocus, textureNoFocus, textureUp, textureDown, textureUpFocus, textureDownFocus, labelInfo, iType); ((CGUISpinControlEx *)control)->SetSpinPosition(spinPosX); ((CGUISpinControlEx *)control)->SetText(strLabel); ((CGUISpinControlEx *)control)->SetReverse(bReverse); } else if (type == CGUIControl::GUICONTROL_VISUALISATION) { control = new CGUIVisualisationControl(parentID, id, posX, posY, width, height); } // things that apply to all controls if (control) { control->SetHitRect(hitRect); control->SetVisibleCondition(iVisibleCondition, allowHiddenFocus); control->SetEnableCondition(enableCondition); control->SetAnimations(animations); control->SetColorDiffuse(colorDiffuse); control->SetNavigation(up, down, left, right); control->SetTabNavigation(next,prev); control->SetNavigationActions(upActions, downActions, leftActions, rightActions); control->SetPulseOnSelect(bPulse); if (hasCamera) control->SetCamera(camera); } return control; }
void CGUIWindowMusicSongs::UpdateButtons() { CGUIWindowMusicBase::UpdateButtons(); bool bIsPlaying = g_application.IsPlayingAudio(); bool bCanRecord = false; bool bIsRecording = false; if (bIsPlaying) { bCanRecord = g_application.m_pPlayer->CanRecord(); bIsRecording = g_application.m_pPlayer->IsRecording(); } // Update Record button if (bIsPlaying && bCanRecord) { CONTROL_ENABLE(CONTROL_BTNREC); if (bIsRecording) { SET_CONTROL_LABEL(CONTROL_BTNREC, 265); //Stop Recording } else { SET_CONTROL_LABEL(CONTROL_BTNREC, 264); //Record } } else { SET_CONTROL_LABEL(CONTROL_BTNREC, 264); //Record CONTROL_DISABLE(CONTROL_BTNREC); } // Update CDDA Rip button CCdInfo *pCdInfo = CDetectDVDMedia::GetCdInfo(); if (CDetectDVDMedia::IsDiscInDrive() && pCdInfo && pCdInfo->IsAudio(1)) { CONTROL_ENABLE(CONTROL_BTNRIP); } else { CONTROL_DISABLE(CONTROL_BTNRIP); } // Disable scan button if shoutcast if (m_vecItems->IsVirtualDirectoryRoot() || m_vecItems->IsShoutCast() || m_vecItems->IsLastFM() || m_vecItems->IsMusicDb()) { CONTROL_DISABLE(CONTROL_BTNSCAN); } else { CONTROL_ENABLE(CONTROL_BTNSCAN); } static int iOldLeftControl=-1; if (m_vecItems->IsShoutCast() || m_vecItems->IsLastFM()) { CONTROL_DISABLE(CONTROL_BTNVIEWASICONS); CGUIControl* pControl = (CGUIControl*)GetControl(CONTROL_LIST); if (pControl) if (pControl->GetControlIdLeft() == CONTROL_BTNVIEWASICONS) { iOldLeftControl = pControl->GetControlIdLeft(); pControl->SetNavigation(pControl->GetControlIdUp(),pControl->GetControlIdDown(), CONTROL_BTNSORTBY,pControl->GetControlIdRight()); } } else { CONTROL_ENABLE(CONTROL_BTNVIEWASICONS); if (iOldLeftControl != -1) { CGUIControl* pControl = (CGUIControl*)GetControl(CONTROL_LIST); if (pControl) pControl->SetNavigation(pControl->GetControlIdUp(),pControl->GetControlIdDown(), CONTROL_BTNVIEWASICONS,pControl->GetControlIdRight()); } } CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); if (musicScan && musicScan->IsScanning()) { SET_CONTROL_LABEL(CONTROL_BTNSCAN, 14056); // Stop Scan } else { SET_CONTROL_LABEL(CONTROL_BTNSCAN, 102); // Scan } // Update object count label CStdString items; items.Format("%i %s", m_vecItems->GetObjectCount(), g_localizeStrings.Get(127).c_str()); SET_CONTROL_LABEL(CONTROL_LABELFILES, items); }