void CGUIControllerWindow::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) { /* * Apply the faded focus texture to the current controller when unfocused */ CGUIControl* control = nullptr; // The controller button bool bAlphaFaded = false; // True if the controller button has been focused and faded this frame if (m_controllerList && m_controllerList->GetFocusedController() >= 0) { control = GetFirstFocusableControl(CONTROL_CONTROLLER_BUTTONS_START + m_controllerList->GetFocusedController()); if (control && !control->HasFocus()) { if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) { control->SetFocus(true); static_cast<CGUIButtonControl*>(control)->SetAlpha(0x80); bAlphaFaded = true; } } } CGUIDialog::DoProcess(currentTime, dirtyregions); if (control && bAlphaFaded) { control->SetFocus(false); if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) static_cast<CGUIButtonControl*>(control)->SetAlpha(0xFF); } }
void CGUIDialogSettingsBase::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) { // update alpha status of current button bool bAlphaFaded = false; CGUIControl *control = GetFirstFocusableControl(CONTROL_SETTINGS_START_BUTTONS + m_iCategory); if (control && !control->HasFocus()) { if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) { control->SetFocus(true); ((CGUIButtonControl *)control)->SetAlpha(0x80); bAlphaFaded = true; } else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) { control->SetFocus(true); ((CGUIButtonControl *)control)->SetSelected(true); bAlphaFaded = true; } } CGUIDialog::DoProcess(currentTime, dirtyregions); if (control && bAlphaFaded) { control->SetFocus(false); if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) ((CGUIButtonControl *)control)->SetAlpha(0xFF); else ((CGUIButtonControl *)control)->SetSelected(false); } }
void CGUIDialogAddonSettings::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) { // update status of current section button bool alphaFaded = false; CGUIControl *control = GetFirstFocusableControl(CONTROL_START_SECTION + m_currentSection); if (control && !control->HasFocus()) { if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) { control->SetFocus(true); ((CGUIButtonControl *)control)->SetAlpha(0x80); alphaFaded = true; } else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) { control->SetFocus(true); ((CGUIButtonControl *)control)->SetSelected(true); alphaFaded = true; } } CGUIDialogBoxBase::DoProcess(currentTime, dirtyregions); if (alphaFaded && m_active) // dialog may close { control->SetFocus(false); if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) ((CGUIButtonControl *)control)->SetAlpha(0xFF); else ((CGUIButtonControl *)control)->SetSelected(false); } }
bool CGUIWindow::OnAction(const CAction &action) { if (action.IsMouse() || action.IsGesture()) return EVENT_RESULT_UNHANDLED != OnMouseAction(action); CGUIControl *focusedControl = GetFocusedControl(); if (focusedControl) { if (focusedControl->OnAction(action)) return true; } else { // no control has focus? // set focus to the default control then CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl); OnMessage(msg); } // default implementations switch(action.GetID()) { case ACTION_NAV_BACK: case ACTION_PREVIOUS_MENU: return OnBack(action.GetID()); case ACTION_SHOW_INFO: return OnInfo(action.GetID()); case ACTION_MENU: if (m_menuControlID > 0) { CGUIControl *menu = GetControl(m_menuControlID); if (menu) { int focusControlId; if (!menu->HasFocus()) { // focus the menu control focusControlId = m_menuControlID; // To support a toggle behaviour we store the last focused control id // to restore (focus) this control if the menu control has the focus // while you press the menu button again. m_menuLastFocusedControlID = GetFocusedControlID(); } else { // restore the last focused control or if not exists use the default control focusControlId = m_menuLastFocusedControlID > 0 ? m_menuLastFocusedControlID : m_defaultControl; } CGUIMessage msg = CGUIMessage(GUI_MSG_SETFOCUS, GetID(), focusControlId); return OnMessage(msg); } } break; } return false; }
bool CGUIControlGroup::HasFocus() const { for (ciControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; if (control->HasFocus()) return true; } return false; }
void CGUIControlGroupList::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { if (m_scroller.Update(currentTime)) MarkDirtyRegion(); // first we update visibility of all our items, to ensure our size and // alignment computations are correct. for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; GUIPROFILER_VISIBILITY_BEGIN(control); control->UpdateVisibility(); GUIPROFILER_VISIBILITY_END(control); } ValidateOffset(); if (m_pageControl && m_lastScrollerValue != m_scroller.GetValue()) { CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (int)Size(), (int)m_totalSize); SendWindowMessage(message); CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (int)m_scroller.GetValue()); SendWindowMessage(message2); m_lastScrollerValue = m_scroller.GetValue(); } // we run through the controls, rendering as we go int index = 0; float pos = GetAlignOffset(); for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_scroller.GetValue()); else g_graphicsContext.SetOrigin(m_posX + pos - m_scroller.GetValue(), m_posY); control->DoProcess(currentTime, dirtyregions); if (control->IsVisible()) { if (IsControlOnScreen(pos, control)) { if (control->HasFocus()) m_focusedPosition = index; index++; } pos += Size(control) + m_itemGap; } g_graphicsContext.RestoreOrigin(); } CGUIControl::Process(currentTime, dirtyregions); }
void CGUIControlGroup::Render() { CPoint pos(GetPosition()); g_graphicsContext.SetOrigin(pos.x, pos.y); CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; if (m_renderFocusedLast && control->HasFocus()) focusedControl = control; else control->DoRender(); } if (focusedControl) focusedControl->DoRender(); CGUIControl::Render(); g_graphicsContext.RestoreOrigin(); }
void CGUIControlGroup::Render() { g_graphicsContext.SetOrigin(m_posX, m_posY); CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; control->UpdateVisibility(); if (m_renderFocusedLast && control->HasFocus()) focusedControl = control; else control->DoRender(m_renderTime); } if (focusedControl) focusedControl->DoRender(m_renderTime); CGUIControl::Render(); g_graphicsContext.RestoreOrigin(); }
void CGUIControlGroup::Render() { CPoint pos(GetPosition()); g_graphicsContext.SetOrigin(pos.x, pos.y); CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; GUIPROFILER_VISIBILITY_BEGIN(control); control->UpdateVisibility(); GUIPROFILER_VISIBILITY_END(control); if (m_renderFocusedLast && control->HasFocus()) focusedControl = control; else control->DoRender(m_renderTime); } if (focusedControl) focusedControl->DoRender(m_renderTime); CGUIControl::Render(); g_graphicsContext.RestoreOrigin(); }
void CGUIControlGroupList::Render() { // we run through the controls, rendering as we go bool render(g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height)); float pos = GetAlignOffset(); float focusedPos = 0; CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; if (m_renderFocusedLast && control->HasFocus()) { focusedControl = control; focusedPos = pos; } else { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_scroller.GetValue()); else g_graphicsContext.SetOrigin(m_posX + pos - m_scroller.GetValue(), m_posY); control->DoRender(); } if (control->IsVisible()) pos += Size(control) + m_itemGap; g_graphicsContext.RestoreOrigin(); } if (focusedControl) { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + focusedPos - m_scroller.GetValue()); else g_graphicsContext.SetOrigin(m_posX + focusedPos - m_scroller.GetValue(), m_posY); focusedControl->DoRender(); } if (render) g_graphicsContext.RestoreClipRegion(); CGUIControl::Render(); }
// returns true if the control group with id groupID has controlID as // its focused control bool CGUIWindow::ControlGroupHasFocus(int groupID, int controlID) { // 1. Run through and get control with groupID (assume unique) // 2. Get it's selected item. CGUIControl *group = GetFirstFocusableControl(groupID); if (!group) group = (CGUIControl *)GetControl(groupID); if (group && group->IsGroup()) { if (controlID == 0) { // just want to know if the group is focused return group->HasFocus(); } else { CGUIMessage message(GUI_MSG_ITEM_SELECTED, GetID(), group->GetID()); group->OnMessage(message); return (controlID == (int) message.GetParam1()); } } return false; }
void CGUIViewControl::SetCurrentView(int viewMode, bool bRefresh /* = false */) { // grab the previous control CGUIControl *previousView = NULL; if (m_currentView >= 0 && m_currentView < (int)m_visibleViews.size()) previousView = m_visibleViews[m_currentView]; UpdateViewVisibility(); // viewMode is of the form TYPE << 16 | ID VIEW_TYPE type = (VIEW_TYPE)(viewMode >> 16); int id = viewMode & 0xffff; // first find a view that matches this view, if possible... int newView = GetView(type, id); if (newView < 0) // no suitable view that matches both id and type, so try just type newView = GetView(type, 0); if (newView < 0 && type == VIEW_TYPE_BIG_ICON) // try icon view if they want big icon newView = GetView(VIEW_TYPE_ICON, 0); if (newView < 0 && type == VIEW_TYPE_BIG_INFO) newView = GetView(VIEW_TYPE_INFO, 0); if (newView < 0) // try a list view newView = GetView(VIEW_TYPE_LIST, 0); if (newView < 0) // try anything! newView = GetView(VIEW_TYPE_NONE, 0); if (newView < 0) return; m_currentView = newView; CGUIControl *pNewView = m_visibleViews[m_currentView]; // make only current control visible... for (ciViews view = m_allViews.begin(); view != m_allViews.end(); ++view) (*view)->SetVisible(false); pNewView->SetVisible(true); if (!bRefresh && pNewView == previousView) return; // no need to actually update anything (other than visibility above) // CLog::Log(LOGDEBUG,"SetCurrentView: Oldview: %i, Newview :%i", m_currentView, viewMode); bool hasFocus(false); int item = -1; if (previousView) { // have an old view - let's clear it out and hide it. hasFocus = previousView->HasFocus(); item = GetSelectedItem(previousView); CGUIMessage msg(GUI_MSG_LABEL_RESET, m_parentWindow, previousView->GetID()); previousView->OnMessage(msg); } // Update it with the contents UpdateContents(pNewView, item); // and focus if necessary if (hasFocus) { CGUIMessage msg(GUI_MSG_SETFOCUS, m_parentWindow, pNewView->GetID(), 0); g_windowManager.SendMessage(msg, m_parentWindow); } UpdateViewAsControl(((IGUIContainer *)pNewView)->GetLabel()); }
void CGUIControlGroupList::Render() { if (m_scrollSpeed != 0) { m_offset += m_scrollSpeed * (m_renderTime - m_scrollTime); if (m_scrollSpeed < 0 && m_offset < m_scrollOffset || m_scrollSpeed > 0 && m_offset > m_scrollOffset) { m_offset = m_scrollOffset; m_scrollSpeed = 0; } } m_scrollTime = m_renderTime; ValidateOffset(); if (m_pageControl) { CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (DWORD)m_height, (DWORD)m_totalSize); SendWindowMessage(message); CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (DWORD)m_offset); SendWindowMessage(message2); } // we run through the controls, rendering as we go bool render(g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height)); float pos = 0; float focusedPos = 0; CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; control->UpdateVisibility(); if (m_renderFocusedLast && control->HasFocus()) { focusedControl = control; focusedPos = pos; } else { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_offset); else g_graphicsContext.SetOrigin(m_posX + pos - m_offset, m_posY); control->DoRender(m_renderTime); } if (control->IsVisible()) pos += Size(control) + m_itemGap; g_graphicsContext.RestoreOrigin(); } if (focusedControl) { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + focusedPos - m_offset); else g_graphicsContext.SetOrigin(m_posX + focusedPos - m_offset, m_posY); focusedControl->DoRender(m_renderTime); } if (render) g_graphicsContext.RestoreClipRegion(); CGUIControl::Render(); }