void CGUIControl::QueueAnimation(ANIMATION_TYPE animType) { MarkDirtyRegion(); if (!CheckAnimation(animType)) return; CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false); CAnimation *forwardAnim = GetAnimation(animType); // we first check whether the reverse animation is in progress (and reverse it) // then we check for the normal animation, and queue it if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED)) { reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE); if (forwardAnim) forwardAnim->ResetAnimation(); } else if (forwardAnim) { forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL); if (reverseAnim) reverseAnim->ResetAnimation(); } else { // hidden and visible animations delay the change of state. If there is no animations // to perform, then we should just change the state straightaway if (reverseAnim) reverseAnim->ResetAnimation(); UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED); } }
void CGUIControl::SetVisible(bool bVisible, bool setVisState) { if (bVisible && setVisState) { // TODO: currently we only update m_visible from GUI_MSG_VISIBLE (SET_CONTROL_VISIBLE) // otherwise we just set m_forceHidden GUIVISIBLE visible; if (m_visibleCondition) visible = m_visibleCondition->Get() ? VISIBLE : HIDDEN; else visible = VISIBLE; if (visible != m_visible) { m_visible = visible; SetInvalid(); } } if (m_forceHidden == bVisible) { m_forceHidden = !bVisible; SetInvalid(); if (m_forceHidden) MarkDirtyRegion(); } if (m_forceHidden) { // reset any visible animations that are in process if (IsAnimating(ANIM_TYPE_VISIBLE)) { // CLog::Log(LOGDEBUG, "Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden"); CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE); if (visibleAnim) visibleAnim->ResetAnimation(); } } }
void CGUIControl::QueueAnimation(ANIMATION_TYPE animType) { // rule out the animations we shouldn't perform if (!IsVisible() || !HasRendered()) { // hidden or never rendered - don't allow exit or entry animations for this control if (animType == ANIM_TYPE_WINDOW_CLOSE) { // could be animating a (delayed) window open anim, so reset it ResetAnimation(ANIM_TYPE_WINDOW_OPEN); return; } } if (!IsVisible()) { // hidden - only allow hidden anims if we're animating a visible anim if (animType == ANIM_TYPE_HIDDEN && !IsAnimating(ANIM_TYPE_VISIBLE)) { // update states to force it hidden UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED); return; } if (animType == ANIM_TYPE_WINDOW_OPEN) return; } CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false); CAnimation *forwardAnim = GetAnimation(animType); // we first check whether the reverse animation is in progress (and reverse it) // then we check for the normal animation, and queue it if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED)) { reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE); if (forwardAnim) forwardAnim->ResetAnimation(); } else if (forwardAnim) { forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL); if (reverseAnim) reverseAnim->ResetAnimation(); } else { // hidden and visible animations delay the change of state. If there is no animations // to perform, then we should just change the state straightaway if (reverseAnim) reverseAnim->ResetAnimation(); UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED); } }
bool CGUIControl::OnMessage(CGUIMessage& message) { if ( message.GetControlId() == GetID() ) { switch (message.GetMessage() ) { case GUI_MSG_SETFOCUS: // if control is disabled then move 2 the next control if ( !CanFocus() ) { CLog::Log(LOGERROR, "Control %u in window %u has been asked to focus, " "but it can't", GetID(), GetParentID()); return false; } SetFocus(true); { // inform our parent window that this has happened CGUIMessage message(GUI_MSG_FOCUSED, GetParentID(), GetID()); if (m_parentControl) m_parentControl->OnMessage(message); else SendWindowMessage(message); } return true; break; case GUI_MSG_LOSTFOCUS: { SetFocus(false); // and tell our parent so it can unfocus if (m_parentControl) m_parentControl->OnMessage(message); return true; } break; case GUI_MSG_VISIBLE: if (m_visibleCondition) m_visible = g_infoManager.GetBool(m_visibleCondition, m_dwParentID) ? VISIBLE : HIDDEN; else m_visible = VISIBLE; m_forceHidden = false; return true; break; case GUI_MSG_HIDDEN: m_forceHidden = true; // reset any visible animations that are in process if (IsAnimating(ANIM_TYPE_VISIBLE)) { // CLog::DebugLog("Resetting visible animation on control %i (we are %s)", m_dwControlID, m_visible ? "visible" : "hidden"); CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE); if (visibleAnim) visibleAnim->ResetAnimation(); } return true; // Note that the skin <enable> tag will override these messages case GUI_MSG_ENABLED: SetEnabled(true); return true; case GUI_MSG_DISABLED: SetEnabled(false); return true; } } return false; }