/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { base.Layout(skin); m_ScrollButton[0].Width = Height; m_ScrollButton[0].Dock = Pos.Left; m_ScrollButton[1].Width = Height; m_ScrollButton[1].Dock = Pos.Right; m_Bar.Height = ButtonSize; m_Bar.Padding = new Padding(ButtonSize, 0, ButtonSize, 0); float barWidth = (m_ViewableContentSize / m_ContentSize) * (Width - (ButtonSize * 2)); if (barWidth < ButtonSize * 0.5f) barWidth = (int)(ButtonSize * 0.5f); m_Bar.Width = (int)(barWidth); m_Bar.IsHidden = Width - (ButtonSize * 2) <= barWidth; //Based on our last scroll amount, produce a position for the bar if (!m_Bar.IsHeld) { SetScrollAmount(ScrollAmount, true); } }
/// <summary> /// Renders the focus overlay. /// </summary> /// <param name="skin">Skin to use.</param> protected override void RenderFocus(SkinBase skin) { if (InputHandler.KeyboardFocus != this) return; if (!IsTabable) return; skin.DrawKeyboardHighlight(this, RenderBounds, 0); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { base.Layout(skin); m_ScrollButton[0].Height = Width; m_ScrollButton[0].Dock = Pos.Top; m_ScrollButton[1].Height = Width; m_ScrollButton[1].Dock = Pos.Bottom; m_Bar.Width = ButtonSize; m_Bar.Padding = new Padding(0, ButtonSize, 0, ButtonSize); float barHeight = 0.0f; if (m_ContentSize > 0.0f) barHeight = (m_ViewableContentSize/m_ContentSize)*(Height - (ButtonSize*2)); if (barHeight < ButtonSize*0.5f) barHeight = (int) (ButtonSize*0.5f); m_Bar.Height = (int) (barHeight); m_Bar.IsHidden = Height - (ButtonSize*2) <= barHeight; //Based on our last scroll amount, produce a position for the bar if (!m_Bar.IsHeld) { SetScrollAmount(ScrollAmount, true); } }
/// <summary> /// Setup OpenGL and load resources here. /// </summary> /// <param name="e">Not used.</param> protected override void OnLoad(EventArgs e) { GL.ClearColor(System.Drawing.Color.MidnightBlue); Platform.Platform.Init(new Platform.Windows()); //m_Renderer = new Gwen.Renderer.OpenTK.OpenTKGL10(); //m_Renderer = new Gwen.Renderer.OpenTK.OpenTKGL20(); m_Renderer = new Gwen.Renderer.OpenTK.OpenTKGL40(); m_Skin = new Gwen.Skin.TexturedBase(m_Renderer, "DefaultSkin2.png"); m_Skin.DefaultFont = new Font(m_Renderer, "Arial", 11); m_Canvas = new Canvas(m_Skin); m_Input = new Gwen.Renderer.OpenTK.Input.OpenTK(this); m_Input.Initialize(m_Canvas); m_Canvas.SetSize(Width, Height); m_Canvas.ShouldDrawBackground = true; m_Canvas.BackgroundColor = m_Skin.Colors.ModalBackground; if (Configuration.RunningOnMacOS) { m_Canvas.Scale = 1.5f; } m_UnitTest = new Gwen.UnitTest.UnitTest(m_Canvas); m_Stopwatch.Restart(); m_LastTime = 0; }
/// <summary> /// Function invoked after layout. /// </summary> /// <param name="skin">Skin to use.</param> protected override void PostLayout(SkinBase skin) { foreach (ControlBase child in Children) // ok? { child.Position(m_Pos); } }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { base.Layout(skin); if (AutoSizeToContents) { DoSizeToContents(); } }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { if (null == Parent) return; //Move to our current position to force clamping - is this a hack? MoveTo(X, Y); }
/// <summary> /// Initializes a new instance of the <see cref="SkinBase"/> class. /// </summary> /// <param name="renderer">Renderer to use.</param> protected SkinBase(Renderer.RendererBase renderer) { if (DefaultSkin == null) { DefaultSkin = this; } m_DefaultFont = new Font(renderer); m_Renderer = renderer; }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { base.Layout(skin); Align.PlaceDownLeft(m_Button, m_Label, 10); Align.CenterHorizontally(m_Button); m_InnerPanel.SizeToChildren(); m_InnerPanel.Height += 10; SizeToChildren(); }
/// <summary> /// Initializes a new instance of the <see cref="Canvas"/> class. /// </summary> /// <param name="skin">Skin to use.</param> public Canvas(SkinBase skin) { SetBounds(0, 0, 10000, 10000); SetSkin(skin); Scale = 1.0f; BackgroundColor = Color.White; ShouldDrawBackground = false; m_DisposeQueue = new List<IDisposable>(); }
/// <summary> /// Function invoked after layout. /// </summary> /// <param name="skin">Skin to use.</param> protected override void PostLayout(SkinBase skin) { m_SplitterBar.Height = 0; if (SizeToChildren(false, true)) { InvalidateParent(); } m_SplitterBar.SetSize(3, Height); }
protected override void Layout(SkinBase skin) { // ugly stuff because we don't have anchoring without docking (docking resizes children) if (m_Label.Height > m_RadioButton.Height) // usually radio is smaller than label so it gets repositioned to avoid clipping with negative Y { m_RadioButton.Y = (m_Label.Height - m_RadioButton.Height)/2; } Align.PlaceRightBottom(m_Label, m_RadioButton); SizeToChildren(); base.Layout(skin); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { int childrenHeight = Children.Sum(child => child != null ? child.Height : 0); if (Y + childrenHeight > GetCanvas().Height) childrenHeight = GetCanvas().Height - Y; SetSize(Width, childrenHeight); base.Layout(skin); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { /* SORRY */ if (IsEditing != m_LastEditing) { OnEditingChanged(); m_LastEditing = IsEditing; } if (IsHovered != m_LastHover) { OnHoverChanged(); m_LastHover = IsHovered; } /* SORRY */ skin.DrawPropertyRow(this, m_Label.Right, IsEditing, IsHovered | m_Property.IsHovered); }
public override void Dispose() { if (m_Canvas != null) { m_Canvas.Dispose(); m_Canvas = null; } if (m_Skin != null) { m_Skin.Dispose(); m_Skin = null; } if (m_Renderer != null) { m_Renderer.Dispose(); m_Renderer = null; } base.Dispose(); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { //Is there any way to move this into skin? Not for now, no idea how we'll "actually" render these if (m_Texture == null) { byte[] pixelData = new byte[Width * Height * 4]; for (int y = 0; y < Height; y++) { Color c = GetColorAtHeight(y); for (int x = 0; x < Width; x++) { pixelData[4 * (x + y * Width)] = c.R; pixelData[4 * (x + y * Width) + 1] = c.G; pixelData[4 * (x + y * Width) + 2] = c.B; pixelData[4 * (x + y * Width) + 3] = c.A; } } m_Texture = new Texture(skin.Renderer); m_Texture.Width = Width; m_Texture.Height = Height; m_Texture.LoadRaw(Width, Height, pixelData); } skin.Renderer.DrawColor = Color.White; skin.Renderer.DrawTexturedRect(m_Texture, new Rectangle(5, 0, Width-10, Height)); int drawHeight = m_SelectedDist - 3; //Draw our selectors skin.Renderer.DrawColor = Color.Black; skin.Renderer.DrawFilledRect(new Rectangle(0, drawHeight + 2, Width, 1)); skin.Renderer.DrawFilledRect(new Rectangle(0, drawHeight, 5, 5)); skin.Renderer.DrawFilledRect(new Rectangle(Width - 5, drawHeight, 5, 5)); skin.Renderer.DrawColor = Color.White; skin.Renderer.DrawFilledRect(new Rectangle(1, drawHeight + 1, 3, 3)); skin.Renderer.DrawFilledRect(new Rectangle(Width - 4, drawHeight + 1, 3, 3)); base.Render(skin); }
/// <summary> /// Renders the currently visible tooltip. /// </summary> /// <param name="skin"></param> public static void RenderToolTip(SkinBase skin) { if (null == g_ToolTip) return; RendererBase render = skin.Renderer; Point oldRenderOffset = render.RenderOffset; Point mousePos = Input.InputHandler.MousePosition; Rectangle bounds = g_ToolTip.ToolTip.Bounds; Rectangle offset = Util.FloatRect(mousePos.X - bounds.Width*0.5f, mousePos.Y - bounds.Height - 10, bounds.Width, bounds.Height); offset = Util.ClampRectToRect(offset, g_ToolTip.GetCanvas().Bounds); //Calculate offset on screen bounds render.AddRenderOffset(offset); render.EndClip(); skin.DrawToolTip(g_ToolTip.ToolTip); g_ToolTip.ToolTip.DoRender(skin); render.RenderOffset = oldRenderOffset; }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { if (m_Alt) { if (IsDepressed || ToggleState) Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button_Selected; else if (IsHovered) Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button_Hover; else Skin.Renderer.DrawColor = skin.Colors.Category.LineAlt.Button; } else { if (IsDepressed || ToggleState) Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button_Selected; else if (IsHovered) Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button_Hover; else Skin.Renderer.DrawColor = skin.Colors.Category.Line.Button; } skin.Renderer.DrawFilledRect(RenderBounds); }
protected virtual void LayoutVertical(SkinBase skin) { int w = Width; int h = Height; if (m_Panel[0] != null) { Margin m = m_Panel[0].Margin; if (m_Scale[0]) m_Panel[0].SetBounds(m.Left, m.Top, w - m.Left - m.Right, (h*0.5f) - m.Top - m.Bottom); else m_Panel[0].Position(Pos.Center, 0, (int) (h*-0.25f)); } if (m_Panel[1] != null) { Margin m = m_Panel[1].Margin; if (m_Scale[1]) m_Panel[1].SetBounds(m.Left, m.Top + (h*0.5f), w - m.Left - m.Right, (h*0.5f) - m.Top - m.Bottom); else m_Panel[1].Position(Pos.Center, 0, (int) (h*0.25f)); } }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { #if false // Debug render - this shouldn't render ANYTHING REALLY - it should be up to the parent! Gwen::Rect rect = GetRenderBounds(); Gwen::Renderer::Base* render = skin->GetRender(); render->SetDrawColor( Gwen::Color( 255, 255, 0, 100 ) ); render->DrawFilledRect( rect ); render->SetDrawColor( Gwen::Color( 255, 0, 0, 100 ) ); render->DrawFilledRect( m_InnerPanel->GetBounds() ); render->RenderText( skin->GetDefaultFont(), Gwen::Point( 0, 0 ), Utility::Format( L"Offset: %i %i", m_InnerPanel->X(), m_InnerPanel->Y() ) ); #endif }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawListBox(this); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawWindowCloseButton(this, IsDepressed && IsHovered, IsHovered && ShouldDrawHover, !m_Window.IsOnTop); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawCategoryHolder(this); base.Render(skin); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawMenuDivider(this); }
/// <summary> /// Renders over the actual control (overlays). /// </summary> /// <param name="skin">Skin to use.</param> protected override void RenderOver(SkinBase skin) { if (!m_DrawHover) return; RendererBase render = skin.Renderer; render.DrawColor = Color.FromArgb(20, 255, 200, 255); render.DrawFilledRect(RenderBounds); if (m_HoverRect.Width == 0) return; render.DrawColor = Color.FromArgb(100, 255, 200, 255); render.DrawFilledRect(m_HoverRect); render.DrawColor = Color.FromArgb(200, 255, 200, 255); render.DrawLinedRect(m_HoverRect); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawComboBox(this, IsDepressed, IsOpen); }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { base.Render(skin); if (ShouldDrawBackground) skin.DrawTextBox(this); if (!HasFocus) return; // Draw selection.. if selected.. if (m_CursorPos != m_CursorEnd) { skin.Renderer.DrawColor = Color.FromArgb(200, 50, 170, 255); skin.Renderer.DrawFilledRect(m_SelectionBounds); } // Draw caret float time = Platform.Neutral.GetTimeInSeconds() - m_LastInputTime; if ((time % 1.0f) <= 0.5f) { skin.Renderer.DrawColor = Color.Black; skin.Renderer.DrawFilledRect(m_CaretBounds); } }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { skin.DrawTreeButton(this, ToggleState); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { UpdateScrollBars(); base.Layout(skin); }
/// <summary> /// Renders the focus overlay. /// </summary> /// <param name="skin">Skin to use.</param> protected override void RenderFocus(SkinBase skin) { }
/// <summary> /// Renders the control using specified skin. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Render(SkinBase skin) { base.Render(skin); skin.DrawCheckBox(this, m_Checked, IsDepressed); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { base.Layout(skin); RefreshCursorBounds(); }
/// <summary> /// Lays out the control's interior according to alignment, padding, dock etc. /// </summary> /// <param name="skin">Skin to use.</param> protected override void Layout(SkinBase skin) { m_Button.Position(Pos.Right|Pos.CenterV, 4, 0); base.Layout(skin); }