protected override void OnLeft() { switch (_currentSelection) { case Selection.PageUpDown: base.OnLeft(); if (_listType == ListType.CONTROL_LIST) { _currentSelection = Selection.ListItem; } break; case Selection.ListItem: if (_cursorX >= 0) { GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[_cursorX]; GUIPlayListButtonControl.SuppressActiveButtonReset = false; if (btn.CurrentActiveButton != GUIPlayListButtonControl.ActiveButton.Main && btn.CanMoveLeft()) { Action action = new Action { wID = Action.ActionType.ACTION_MOVE_LEFT }; btn.OnAction(action); return; } } // select down.. _currentSelection = Selection.PageUpDown; base.OnLeft(); break; } }
protected override void OnRight() { Action action = new Action(); if (_listType == ListType.CONTROL_LIST) { if (_cursorX >= 0) { GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[_cursorX]; GUIPlayListButtonControl.SuppressActiveButtonReset = false; if (btn.CurrentActiveButton != GUIPlayListButtonControl.ActiveButton.Delete && btn.CanMoveRight()) { action.wID = Action.ActionType.ACTION_MOVE_RIGHT; btn.OnAction(action); return; } btn.CurrentActiveButton = GUIPlayListButtonControl.ActiveButton.None; if (!_spinCanFocus) { btn.CurrentActiveButton = GUIPlayListButtonControl.ActiveButton.Delete; return; } } action.wID = Action.ActionType.ACTION_MOVE_RIGHT; if (_listType == ListType.CONTROL_LIST) { if (_upDownControl.GetMaximum() > 1) { _listType = ListType.CONTROL_UPDOWN; _upDownControl.Focus = true; if (!_upDownControl.Focus) { _listType = ListType.CONTROL_LIST; } } } else { _upDownControl.OnAction(action); if (!_upDownControl.Focus) { if (_rightControlId != GetID) { base.OnAction(action); } _listType = ListType.CONTROL_LIST; } } } }
private void SetItemButtonState(GUIPlayListButtonControl.ActiveButton activeButton) { if (_cursorX < 0) { return; } GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[_cursorX]; if (btn != null) { btn.CurrentActiveButton = activeButton; } }
protected override void AllocButtons() { currentSelection = Selection.ListItem; for (int i = 0; i < _itemsPerPage; ++i) { GUIPlayListButtonControl cntl = new GUIPlayListButtonControl(_controlId, 0, 0, 0, _width, _itemHeight, _textureFocus, _textureNoFocus, _upBtnWidth, _downBtnWidth, _deleteBtnWidth, _upBtnHeight, _downBtnHeight, _deleteBtnHeight, _textureMoveUp, _textureMoveDown, _textureDelete, _textureMoveUpFocused, _textureMoveDownFocus, _textureDeleteFocused, _upBtnXOffset, _downBtnXOffset, _deleteBtnXOffset, _upBtnYOffset, _downBtnYOffset, _deleteBtnYOffset); cntl.ParentControl = this; cntl.FinalizeConstruction(); cntl.AllocResources(); cntl.DimColor = DimColor; _listButtons.Add(cntl); } }
protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus) { // if (buttonNr + _offset < 0 || buttonNr + _offset >= _listButtons.Count) return; if (buttonNr < 0 || buttonNr >= _listButtons.Count) { return; } GUIListItem pItem = _listItems[buttonNr + _offset]; long dwColor = _textColor; if (pItem.Shaded) { dwColor = ShadedColor; } if (pItem.Selected) { dwColor = _selectedColor; } dwPosX += _textOffsetX; bool bSelected = false; if (buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST) { bSelected = true; } GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr]; int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8)); if (btn != null) { dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8)); } if (_text2Visible && pItem.Label2.Length > 0) { if (_textOffsetY == _textOffsetY2) { dwColor = _textColor2; if (pItem.Selected) { dwColor = _selectedColor2; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } int xpos = dwPosX; int ypos = dwPosY; if (0 == _textOffsetX2) { xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8); } else { xpos = _positionX + _textOffsetX2; } if (_labelControls2 != null) { if (buttonNr >= 0 && buttonNr < _labelControls2.Count) { GUILabelControl label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2); if (gotFocus) { label2.TextColor = dwColor; } else { label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); } label2.Label = pItem.Label2; label2.TextAlignment = Alignment.ALIGN_RIGHT; label2.FontName = _fontName2Name; dMaxWidth = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20); } } } } } _textLine = pItem.Label; if (_text1Visible) { dwColor = _textColor; if (pItem.Selected) { dwColor = _selectedColor; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (!gotFocus) { dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); } RenderText(timePassed, buttonNr, (float)dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, (float)dMaxWidth, dwColor, _textLine, bSelected); } if (pItem.Label2.Length > 0) { dwColor = _textColor2; if (pItem.Selected) { dwColor = _selectedColor2; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (0 == _textOffsetX2) { dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8); } else { dwPosX = _positionX + _textOffsetX2; } _textLine = pItem.Label2; if (_text2Visible) { if (_labelControls2 != null) { if (buttonNr >= 0 && buttonNr < _labelControls2.Count) { GUILabelControl label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2); if (gotFocus) { label2.TextColor = dwColor; } else { label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); } label2.Label = _textLine; label2.TextAlignment = Alignment.ALIGN_RIGHT; label2.FontName = _fontName2Name; label2.Render(timePassed); label2 = null; } } } } } if (pItem.Label3.Length > 0) { dwColor = _textColor3; if (pItem.Selected) { dwColor = _selectedColor3; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (0 == _textOffsetX3) { dwPosX = _positionX + _textOffsetX; } else { dwPosX = _positionX + _textOffsetX3; } int ypos = dwPosY; if (0 == _textOffsetY3) { ypos += _textOffsetY2; } else { ypos += _textOffsetY3; } if (_text3Visible) { if (_labelControls3 != null) { if (buttonNr >= 0 && buttonNr < _labelControls3.Count) { GUILabelControl label3 = _labelControls3[buttonNr]; if (label3 != null) { label3.SetPosition(dwPosX, ypos); if (gotFocus) { label3.TextColor = dwColor; } else { label3.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); } label3.Label = pItem.Label3; label3.TextAlignment = Alignment.ALIGN_LEFT; label3.FontName = _fontName2Name; label3.Render(timePassed); label3 = null; } } } } } pItem = null; }
public override void OnAction(Action action) { switch (action.wID) { case Action.ActionType.ACTION_MOVE_DOWN: case Action.ActionType.ACTION_MOVE_UP: { GUIPlayListButtonControl.SuppressActiveButtonReset = false; break; } case Action.ActionType.ACTION_MOUSE_CLICK: case Action.ActionType.ACTION_SELECT_ITEM: { GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[_cursorX]; if (btn != null) { Action newAction = new Action(); if (btn.CurrentActiveButton == GUIPlayListButtonControl.ActiveButton.Up) { if (btn.UpButtonEnabled) { newAction.wID = Action.ActionType.ACTION_MOVE_SELECTED_ITEM_UP; GUIPlayListButtonControl.LastActiveButton = GUIPlayListButtonControl.ActiveButton.Up; GUIPlayListButtonControl.SuppressActiveButtonReset = true; } else { return; } } else if (btn.CurrentActiveButton == GUIPlayListButtonControl.ActiveButton.Down) { if (btn.DownButtonEnabled) { newAction.wID = Action.ActionType.ACTION_MOVE_SELECTED_ITEM_DOWN; GUIPlayListButtonControl.LastActiveButton = GUIPlayListButtonControl.ActiveButton.Down; GUIPlayListButtonControl.SuppressActiveButtonReset = true; } else { return; } } else if (btn.CurrentActiveButton == GUIPlayListButtonControl.ActiveButton.Delete) { if (btn.DownButtonEnabled) { newAction.wID = Action.ActionType.ACTION_DELETE_SELECTED_ITEM; GUIPlayListButtonControl.LastActiveButton = GUIPlayListButtonControl.ActiveButton.Delete; GUIPlayListButtonControl.SuppressActiveButtonReset = true; } else { return; } } else if (btn.CurrentActiveButton == GUIPlayListButtonControl.ActiveButton.Main) { GUIPlayListButtonControl.LastActiveButton = GUIPlayListButtonControl.ActiveButton.None; GUIPlayListButtonControl.SuppressActiveButtonReset = false; break; } else { break; } GUIGraphicsContext.OnAction(newAction); Console.WriteLine("\t**action modified:{0}", (Action.ActionType)newAction.wID); return; } break; } } base.OnAction(action); }
public override bool HitTest(int x, int y, out int controlID, out bool focused) { controlID = GetID; focused = Focus; int id; bool focus; if (_verticalScrollbar.HitTest(x, y, out id, out focus)) { return(true); } if (_upDownControl.HitTest(x, y, out id, out focus)) { if (_upDownControl.GetMaximum() > 1) { _listType = ListType.CONTROL_UPDOWN; _upDownControl.Focus = true; if (!_upDownControl.Focus) { _listType = ListType.CONTROL_LIST; } return(true); } return(true); } if (!base.HitTest(x, y, out id, out focus)) { return(false); } _listType = ListType.CONTROL_LIST; int posy = y - (int)_positionY; _cursorX = (posy / (_itemHeight + _spaceBetweenItems)); while (_offset + _cursorX >= _listItems.Count) { _cursorX--; } if (_cursorX >= _itemsPerPage) { _cursorX = _itemsPerPage - 1; } OnSelectionChanged(); _refresh = true; if (_listButtons != null) { int cntlId; bool gotFocus; for (int i = 0; i < _itemsPerPage; ++i) { GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[i]; btn.HitTest(x, y, out cntlId, out gotFocus); if (i == _cursorX) { currentSelection = Selection.ListItem; } } } return(true); }
protected override void AllocButtons() { _currentSelection = Selection.ListItem; for (int i = 0; i < _itemsPerPage; ++i) { GUIPlayListButtonControl cntl = new GUIPlayListButtonControl(_controlId, 0, 0, 0, _width, _itemHeight, _textureFocus, _textureNoFocus, _upBtnWidth, _downBtnWidth, _deleteBtnWidth, _upBtnHeight, _downBtnHeight, _deleteBtnHeight, _textureMoveUp, _textureMoveDown, _textureDelete, _textureMoveUpFocused, _textureMoveDownFocus, _textureDeleteFocused, _upBtnXOffset, _downBtnXOffset, _deleteBtnXOffset, _upBtnYOffset, _downBtnYOffset, _deleteBtnYOffset) { ParentControl = this }; cntl.FinalizeConstruction(); cntl.AllocResources(); cntl.DimColor = DimColor; _listButtons.Add(cntl); } }
protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus) { if (buttonNr < 0 || buttonNr >= _listButtons.Count) { return; } GUIListItem pItem = _listItems[buttonNr + _offset]; long dwColor; dwPosX += _textOffsetX; bool bSelected = buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST; GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr]; int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8)); if (btn != null) { dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8)); } if (_text2Visible && pItem.Label2.Length > 0) { if (_textOffsetY == _textOffsetY2) { dwColor = _textColor2; if (pItem.Selected) { dwColor = _selectedColor2; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (pItem.IsBdDvdFolder) { dwColor = _bdDvdDirectoryColor; } int xpos; int ypos = dwPosY; if (0 == _textOffsetX2) { xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8); } else { xpos = _positionX + _textOffsetX2; } if (_labelControls2 != null) { if (buttonNr >= 0 && buttonNr < _labelControls2.Count) { GUILabelControl label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2); label2.TextColor = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); label2.Label = pItem.Label2; label2.TextAlignment = Alignment.ALIGN_RIGHT; label2.FontName = _fontName2Name; dMaxWidth = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20); } } } } } if (_text1Visible) { dwColor = _textColor; if (pItem.Selected) { dwColor = _selectedColor; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (pItem.IsBdDvdFolder) { dwColor = _bdDvdDirectoryColor; } if (!gotFocus) { dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); } int maxWidth = dMaxWidth; if (_textPadding > 0) { maxWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding); } if (maxWidth <= 0) { base.Render(timePassed); } else { RenderText(timePassed, buttonNr, dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, maxWidth, dwColor, pItem.Label, bSelected); } } if (pItem.Label2.Length > 0) { dwColor = _textColor2; if (pItem.Selected) { dwColor = _selectedColor2; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (pItem.IsBdDvdFolder) { dwColor = _bdDvdDirectoryColor; } if (_textOffsetX2 == 0) { dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8); } else { dwPosX = _positionX + _textOffsetX2; } if (_text2Visible) { if (_labelControls2 != null && (buttonNr >= 0 && buttonNr < _labelControls2.Count)) { GUILabelControl label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2); label2.TextColor = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); label2.Label = pItem.Label2; label2.TextAlignment = Alignment.ALIGN_RIGHT; label2.FontName = _fontName2Name; float width = label2.Width; float height = label2.Height; _font.GetTextExtent(label2.Label, ref width, ref height); label2.Width = (int)width + 1; label2.Height = (int)height; if (_textPadding2 > 0) { label2.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding2); } if (label2.Width > 0) { label2.Render(timePassed); } } } } } if (pItem.Label3.Length > 0) { dwColor = _textColor3; if (pItem.Selected) { dwColor = _selectedColor3; } if (pItem.IsRemote) { dwColor = _remoteColor; if (pItem.IsDownloading) { dwColor = _downloadColor; } } if (pItem.IsBdDvdFolder) { dwColor = _bdDvdDirectoryColor; } if (0 == _textOffsetX3) { dwPosX = _positionX + _textOffsetX; } else { dwPosX = _positionX + _textOffsetX3; } int ypos = dwPosY; if (0 == _textOffsetY3) { ypos += _textOffsetY2; } else { ypos += _textOffsetY3; } if (_text3Visible) { if (_labelControls3 != null) { if (buttonNr >= 0 && buttonNr < _labelControls3.Count) { GUILabelControl label3 = _labelControls3[buttonNr]; if (label3 != null) { label3.SetPosition(dwPosX, ypos); label3.TextColor = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb(); label3.Label = pItem.Label3; label3.TextAlignment = Alignment.ALIGN_LEFT; label3.FontName = _fontName2Name; float width = label3.Width; float height = label3.Height; _font.GetTextExtent(label3.Label, ref width, ref height); label3.Width = (int)width + 1; label3.Height = (int)height; if (_textPadding3 > 0) { label3.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding3); } if (label3.Width > 0) { label3.Render(timePassed); } } } } } } }