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); } } } } } } }
/// <summary> /// Renders the control. /// </summary> public override void Render(float timePassed) { if (_labelControl == null) { return; } if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } _isScrolling = false; if (_label != null && _label.Length > 0) { string strText = _label; if (_containsProperty) { strText = GUIPropertyManager.Parse(strText); if (strText == null) { strText = string.Empty; } } if (_previousText != strText) { _currentLabelIndex = 0; _scrollPosition = 0; _scrollPosititionX = 0; _scrollOffset = 0.0f; _currentFrame = 0; timeElapsed = 0.0f; _fadeIn = true && _allowFadeIn; _listLabels.DisposeAndClearList(); _previousText = strText; strText = strText.Replace("\\r", "\r"); int ipos = 0; do { ipos = strText.IndexOf("\r"); int ipos2 = strText.IndexOf("\n"); if (ipos >= 0 && ipos2 >= 0 && ipos2 < ipos) { ipos = ipos2; } if (ipos < 0 && ipos2 >= 0) { ipos = ipos2; } if (ipos >= 0) { string strLine = strText.Substring(0, ipos); if (strLine.Length > 1) { _listLabels.Add(strLine); } if (ipos + 1 >= strText.Length) { break; } strText = strText.Substring(ipos + 1); } else { _listLabels.Add(strText); } } while (ipos >= 0 && strText.Length > 0); } } else { _listLabels.DisposeAndClearList(); } // if there are no labels do not render if (_listLabels.Count == 0) { base.Render(timePassed); return; } // reset the current label is index is out of bounds if (_currentLabelIndex < 0 || _currentLabelIndex >= _listLabels.Count) { _currentLabelIndex = 0; } // get the current label string strLabel = (string)_listLabels[_currentLabelIndex]; // Add the wrap string (will be stripped later if not needed). // SE: why add here? add later, if label itself is wider than width //strLabel += _wrapString; _labelControl.Width = _width; _labelControl.Height = _height; _labelControl.Label = strLabel; _labelControl.SetPosition(_positionX, _positionY); _labelControl.TextAlignment = _textAlignment; _labelControl.TextVAlignment = _textVAlignment; _labelControl.TextColor = _textColor; if (_labelControl.TextWidth < _width) { _labelControl.CacheFont = true; } else { _labelControl.CacheFont = false; } if (GUIGraphicsContext.graphics != null) { _labelControl.Render(timePassed); base.Render(timePassed); return; } // if there is only one label just draw the text if (_listLabels.Count == 1) { if (_labelControl.TextWidth < _width) { // Remove the wrap string since we are not scrolling. // SE: not needed since we're adding wrap string later //if (WrapAround()) //{ // StripWrapString(_labelControl); //} _labelControl.Render(timePassed); base.Render(timePassed); return; } } strLabel += _wrapString; timeElapsed += timePassed; _currentFrame = (int)(timeElapsed / TimeSlice); if (_frameLimiter < GUIGraphicsContext.MaxFPS) { _frameLimiter++; } else { _frameLimiter = 1; } // More than one label _isScrolling = true; // Make the label fade in if (_fadeIn && _allowScrolling) { long dwAlpha = ((((uint)_textColor) >> 24) * _currentFrame) / 12; dwAlpha <<= 24; dwAlpha |= (_textColor & 0x00ffffff); _labelControl.TextColor = dwAlpha; dwAlpha = ((((uint)_shadowColor) >> 24) * _currentFrame) / 12; dwAlpha <<= 24; dwAlpha |= (_shadowColor & 0x00ffffff); _labelControl.ShadowColor = dwAlpha; float fwt = 0; _labelControl.Label = GetShortenedText(strLabel, _width, ref fwt); if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.Width = (int)(fwt); } _labelControl.Render(timePassed); if (_currentFrame >= 12) { _fadeIn = false; } } else if (_fadeIn && !_allowScrolling) { _fadeIn = false; } //no fading if (!_fadeIn) { long color = _textColor; if (Dimmed) { color &= DimColor; } if (!_allowScrolling) { _currentLabelIndex = 0; _scrollPosition = 0; _scrollPosititionX = 0; _scrollOffset = 0.0f; _currentFrame = 0; } // render the text bool bDone = RenderText(timePassed, (float)_positionX, (float)_positionY, (float)_width, color, strLabel); if (bDone) { _currentLabelIndex++; _scrollPosition = 0; _scrollPosititionX = 0; _scrollOffset = 0.0f; // SE: this looks stupid, don't fade in on each wrap //_fadeIn = true && _allowFadeIn; _currentFrame = 0; // SE: also don't wait on each wrap if not needed if (!WrapAround() || _listLabels.Count > 1) { timeElapsed = 0.0f; } _currentFrame = 0; } } base.Render(timePassed); }
/// <summary> /// Renders the control. /// </summary> public override void Render(float timePassed) { if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } if (Focus) { _showSelect = true; } else { _showSelect = false; } // Are we in selection mode if (_showSelect) { // Yes, render the select control // render background, left and right arrow _imageBackground.Render(timePassed); long dwTextColor = Focus ? _textColor : _textColorNoFocus; // User has moved left... if (_leftSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _leftSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageLeftFocus.Render(timePassed); // If we are moving left // render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageLeft.Render(timePassed); } // User has moved right... if (_rightSelected) { // ...render focused arrow _startFrame++; if (_autoHide && _startFrame >= 25) { _startFrame = 0; _rightSelected = false; GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null); GUIWindowManager.SendThreadMessage(message); _updateNeeded = true; } _imageRightFocus.Render(timePassed); // If we are moving right // render item text as disabled dwTextColor = _disabledColor; } else { // Render none focused arrow _imageRight.Render(timePassed); } // Render text if a current item is available if (SelectedItem >= 0 && null != _font && SelectedItem < _subItemList.Count) { _labelControl.FontName = _font.FontName; if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _imageLeft.Width - _textOffsetX, _textOffsetY + _positionY); } else { _labelControl.SetPosition(_positionX + _imageLeft.Width + _textOffsetX, _textOffsetY + _positionY); } _labelControl.TextColor = dwTextColor; _labelControl.TextAlignment = _textAlignment; _labelControl.Label = (string)_subItemList[SelectedItem]; _labelControl.Width = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX); _labelControl.Render(timePassed); } /* * // Select current item, if user doesn't * // move left or right for 1.5 sec. * long dwTicksSpan=DateTime.Now.Ticks-_ticks; * dwTicksSpan/=10000; * if ((float)(dwTicksSpan/1000)>0.8f) * { * // User hasn't moved disable selection mode... * _showSelect=false; * * // ...and send a thread message. * // (Sending a message with SendMessage * // can result in a GPF.) * GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED,WindowId,GetID, ParentID ,0,0,null); * GUIWindowManager.SendThreadMessage(message); * _updateNeeded=true; * } */ } // if (_showSelect) else { // No, render a normal button if (!IsVisible) { base.Render(timePassed); return; } if (Focus) { /* * int dwAlphaCounter = _frameCounter+2; * int dwAlphaChannel; * if ((dwAlphaCounter%128)>=64) * dwAlphaChannel = dwAlphaCounter%64; * else * dwAlphaChannel = 63-(dwAlphaCounter%64); * * dwAlphaChannel += 192; * SetAlpha(dwAlphaChannel ); * _imageFocused.IsVisible=true; * _imageNonFocused.IsVisible=false; * _frameCounter++;*/ _imageFocused.Render(timePassed); } else { //SetAlpha(0xff); _imageNonFocused.Render(timePassed); } if (_label != null && _label.Length > 0 && _font != null) { _labelControl.FontName = _font.FontName; if (_textAlignment == Alignment.ALIGN_RIGHT) { _labelControl.SetPosition(_positionX + _width - _textOffsetX2, _textOffsetY2 + _positionY); } else { _labelControl.SetPosition(_textOffsetX2 + _positionX, _textOffsetY2 + _positionY); } if (Disabled || _subItemList.Count == 0) { _labelControl.TextColor = _disabledColor; } else { _labelControl.TextColor = Focus ? _textColor : _textColorNoFocus; } _labelControl.TextAlignment = _textAlignment; _labelControl.Label = _label; _labelControl.Render(timePassed); } } base.Render(timePassed); }