コード例 #1
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(Skin.Base skin)
        {
            base.Layout(skin);

            Pos align = m_Align;

            if (m_AutoSizeToContents)
            {
                SizeToContents();
            }

            int x = m_TextPadding.Left + Padding.Left;
            int y = m_TextPadding.Top + Padding.Top;

            if (0 != (align & Pos.Right))
            {
                x = Width - m_Text.Width - m_TextPadding.Right - Padding.Right;
            }
            if (0 != (align & Pos.CenterH))
            {
                x = (int)((m_TextPadding.Left + Padding.Left) + ((Width - m_Text.Width - m_TextPadding.Left - Padding.Left - m_TextPadding.Right - Padding.Right) * 0.5f));
            }

            if (0 != (align & Pos.CenterV))
            {
                y = (int)((m_TextPadding.Top + Padding.Top) + ((Height - m_Text.Height) * 0.5f) - m_TextPadding.Bottom - Padding.Bottom);
            }
            if (0 != (align & Pos.Bottom))
            {
                y = Height - m_Text.Height - m_TextPadding.Bottom - Padding.Bottom;
            }

            m_Text.SetPosition(x, y);
        }
コード例 #2
0
        public static void RenderOverlay(Canvas canvas, Skin.Base skin)
        {
            if (CurrentPackage == null)
            {
                return;
            }

            if (CurrentPackage.DrawControl == null)
            {
                return;
            }

            var old = skin.Renderer.RenderOffset;

            skin.Renderer.AddRenderOffset(
                new Rectangle(
                    sMouseX - SourceControl.X - CurrentPackage.HoldOffset.X,
                    sMouseY - SourceControl.Y - CurrentPackage.HoldOffset.Y, 0, 0
                    )
                );

            CurrentPackage.DrawControl.DoRender(skin);

            skin.Renderer.RenderOffset = old;
        }
コード例 #3
0
        /// <summary>
        /// Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base 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);
        }
コード例 #4
0
        /// <summary>
        ///     Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base skin)
        {
            skin.Renderer.DrawColor = Color.White;
            skin.Renderer.DrawTexturedRect(skin.Renderer.GetWhiteTexture(), RenderBounds, Color.White);

            skin.Renderer.DrawColor = Color.Black;
            skin.Renderer.DrawLinedRect(RenderBounds);

            var selected = SelectedColor;

            if ((selected.R + selected.G + selected.B) / 3 < 170)
            {
                skin.Renderer.DrawColor = Color.White;
            }
            else
            {
                skin.Renderer.DrawColor = Color.Black;
            }

            var testRect = new Rectangle(mCursorPos.X - 3, mCursorPos.Y - 3, 6, 6);

            skin.Renderer.DrawShavedCornerRect(testRect);

            base.Render(skin);
        }
コード例 #5
0
 /// <summary>
 ///     Renders the control using specified skin.
 /// </summary>
 /// <param name="skin">Skin to use.</param>
 protected override void Render(Skin.Base skin)
 {
     if (ShouldDrawBackground)
     {
         skin.DrawButton(this, true, false, IsDisabled);
     }
 }
コード例 #6
0
        /// <summary>
        /// Function invoked after layout.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void PostLayout(Skin.Base skin)
        {
            if (IsCollapsed)
            {
                Height = m_HeaderButton.Height;
            }
            else
            {
                SizeToChildren(false, true);
            }

            // alternate row coloring
            bool b = true;

            foreach (Base child in Children)
            {
                CategoryButton button = child as CategoryButton;
                if (button == null)
                {
                    continue;
                }

                button.m_Alt = b;
                button.UpdateColors();
                b = !b;
            }
        }
コード例 #7
0
 /// <summary>
 /// Function invoked after layout.
 /// </summary>
 /// <param name="skin">Skin to use.</param>
 protected override void PostLayout(Skin.Base skin)
 {
     if (SizeToChildren(false, true))
     {
         InvalidateParent();
     }
 }
コード例 #8
0
        /// <summary>
        /// Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base 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);
            }
        }
コード例 #9
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(Skin.Base 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);
            }
        }
コード例 #10
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(Skin.Base skin)
        {
            for (int i = 0; i < m_HSplitter.Count; i++)
            {
                m_HSplitter[i].SetSize(m_BarSize, Height);
                UpdateHSplitter(m_HSplitter[i]);
            }
            if (m_ZoomedSection == -1)
            {
                if (m_Sections != null)
                {
                    m_Sections [0].SetBounds(0, 0, m_HSplitter[0].X, Height);

                    if (m_Sections.Count > 1)
                    {
                        for (int i = 1; i < m_Sections.Count; i++)
                        {
                            if (m_Sections [i] != null)
                            {
                                m_Sections [i].SetBounds(m_HSplitter [i - 1].X + m_BarSize, 0, (i == m_Sections.Count - 1) ? Width - (m_HSplitter [i - 1].X + m_BarSize):m_HSplitter [i].X - m_HSplitter [i - 1].X - m_BarSize, Height);
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        protected virtual void LayoutVertical(Skin.Base 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));
                }
            }
        }
コード例 #12
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(Skin.Base skin)
        {
            if (m_ToggleButton != null)
            {
                if (m_Title != null)
                {
                    m_ToggleButton.SetPosition(0, (m_Title.Height - m_ToggleButton.Height) * 0.5f);
                }

                if (m_InnerPanel.Children.Count == 0 && !ForceShowToggle)
                {
                    m_ToggleButton.Hide();
                    m_ToggleButton.ToggleState = false;
                    m_InnerPanel.Hide();
                }
                else
                {
                    m_ToggleButton.Show();
                    if (m_InnerPanel.IsVisible)
                    {
                        m_InnerPanel.SizeToChildren(false, true);
                    }
                }
            }

            base.Layout(skin);
        }
コード例 #13
0
 /// <summary>
 /// Renders the control using specified skin.
 /// </summary>
 /// <param name="skin">Skin to use.</param>
 protected override void Render(Skin.Base skin)
 {
     if (ShouldDrawBackground)
     {
         skin.DrawTreeControl(this);
     }
 }
コード例 #14
0
ファイル: MenuItem.cs プロジェクト: esdrubal/guieditor
 /// <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(Skin.Base skin)
 {
     if (m_SubmenuArrow != null)
     {
         m_SubmenuArrow.Position(Pos.Right | Pos.CenterV, 4, 0);
     }
     base.Layout(skin);
 }
コード例 #15
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(Skin.Base skin)
 {
     base.Layout(skin);
     if (AutoSizeToContents)
     {
         DoSizeToContents();
     }
 }
コード例 #16
0
 protected override void PostLayout(Skin.Base skin)
 {
     base.PostLayout(skin);
     if (m_SizeToContents)
     {
         DoSizeToContents();
         m_SizeToContents = false;
     }
 }
コード例 #17
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(Skin.Base skin)
        {
            base.Layout(skin);

            Align.PlaceDownLeft(m_Button, m_Label, 10);
            Align.CenterHorizontally(m_Button);
            m_InnerPanel.SizeToChildren();
            m_InnerPanel.Height += 10;
            SizeToChildren();
        }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Canvas"/> class.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        public Canvas(Skin.Base skin)
        {
            SetBounds(0, 0, 10000, 10000);
            SetSkin(skin);
            Scale                = 1.0f;
            BackgroundColor      = Color.White;
            ShouldDrawBackground = false;

            m_DisposeQueue = new List <IDisposable>();
        }
コード例 #19
0
ファイル: ScrollBarBar.cs プロジェクト: gl-obsoleted/utouch
        /// <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(Skin.Base skin)
        {
            if (null == Parent)
            {
                return;
            }

            //Move to our current position to force clamping - is this a hack?
            MoveTo(X, Y);
        }
コード例 #20
0
 protected override void Layout(Skin.Base 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);
 }
コード例 #21
0
ファイル: Properties.cs プロジェクト: gered/gwen-dotnet
        /// <summary>
        /// Function invoked after layout.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void PostLayout(Skin.Base skin)
        {
            m_SplitterBar.Height = 0;

            if (SizeToChildren(false, true))
            {
                InvalidateParent();
            }

            m_SplitterBar.SetSize(3, Height);
        }
コード例 #22
0
        /// <summary>
        /// Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base skin)
        {
            int bottom = 0;

            if (m_InnerPanel.Children.Count > 0)
            {
                bottom = m_InnerPanel.Children.Last().Y + m_InnerPanel.Y;
            }

            skin.DrawTreeNode(this, m_InnerPanel.IsVisible, IsSelected, m_Title.Height, m_Title.TextRight,
                              (int)(m_ToggleButton.Y + m_ToggleButton.Height * 0.5f), bottom, m_TreeControl == Parent); // IsRoot
        }
コード例 #23
0
        /// <summary>
        /// Renders the focus overlay.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void RenderFocus(Skin.Base skin)
        {
            if (InputHandler.KeyboardFocus != this)
            {
                return;
            }
            if (!IsTabable)
            {
                return;
            }

            skin.DrawKeyboardHighlight(this, RenderBounds, 0);
        }
コード例 #24
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(Skin.Base skin)
        {
            base.Layout(skin);
            if (m_Image != null)
            {
                Align.CenterVertically(m_Image);

                if (m_CenterImage)
                {
                    Align.CenterHorizontally(m_Image);
                }
            }
        }
コード例 #25
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(Skin.Base 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);
        }
コード例 #26
0
        /// <summary>
        /// Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base skin)
        {
            if (m_Texture == null)
            {
                byte[] pixelData = new byte[Width * Height * 4];

                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        Color c = GetColorAt(x, y);
                        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)
                {
                    Width  = Width,
                    Height = Height
                };
                m_Texture.LoadRaw(Width, Height, pixelData);
            }

            skin.Renderer.DrawColor = Color.White;
            skin.Renderer.DrawTexturedRect(m_Texture, RenderBounds);


            skin.Renderer.DrawColor = Color.Black;
            skin.Renderer.DrawLinedRect(RenderBounds);

            Color selected = SelectedColor;

            if ((selected.R + selected.G + selected.B) / 3 < 170)
            {
                skin.Renderer.DrawColor = Color.White;
            }
            else
            {
                skin.Renderer.DrawColor = Color.Black;
            }

            Rectangle testRect = new Rectangle(m_CursorPos.X - 3, m_CursorPos.Y - 3, 6, 6);

            skin.Renderer.DrawShavedCornerRect(testRect);

            base.Render(skin);
        }
コード例 #27
0
        /// <summary>
        /// Renders the control using specified skin.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Render(Skin.Base skin)
        {
            bool hasFocus = IsOnTop;

            if (hasFocus)
            {
                m_Caption.TextColor = Skin.Colors.Window.TitleActive;
            }
            else
            {
                m_Caption.TextColor = Skin.Colors.Window.TitleInactive;
            }

            skin.DrawWindow(this, m_TitleBar.Bottom, hasFocus);
        }
コード例 #28
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(Skin.Base skin)
        {
            base.Layout(skin);

            bool even = false;

            foreach (TableRow row in Children)
            {
                row.EvenRow = even;
                even        = !even;
                for (int i = 0; i < m_ColumnCount; i++)
                {
                    row.SetColumnWidth(i, m_ColumnWidth[i]);
                }
            }
        }
コード例 #29
0
ファイル: ColorPicker.cs プロジェクト: gl-obsoleted/utouch
        /// <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(Skin.Base skin)
        {
            base.Layout(skin);

            SizeToChildren(false, true);
            SetSize(Width, Height + 5);

            GroupBox groupBox = FindChildByName("ResultGroupBox", true) as GroupBox;

            if (groupBox != null)
            {
                groupBox.SetPosition(groupBox.X, Height * 0.5f - groupBox.Height * 0.5f);
            }

            //UpdateControls(); // this spams events continuously every tick
        }
コード例 #30
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(Skin.Base skin)
        {
            Properties parent = Parent as Properties;

            if (null == parent)
            {
                return;
            }

            m_Label.Width = parent.SplitWidth;

            if (m_Property != null)
            {
                Height = m_Property.Height;
            }
        }
コード例 #31
0
ファイル: Base.cs プロジェクト: LawlietRyuuzaki/gwen-dotnet
        /// <summary>
        /// Sets the control's skin.
        /// </summary>
        /// <param name="skin">New skin.</param>
        /// <param name="doChildren">Deterines whether to change children skin.</param>
        public virtual void SetSkin(Skin.Base skin, bool doChildren = false)
        {
            if (m_Skin == skin)
                return;
            m_Skin = skin;
            Invalidate();
            Redraw();
            OnSkinChanged(skin);

            if (doChildren)
            {
                foreach (Base child in m_Children)
                {
                    child.SetSkin(skin, true);
                }
            }
        }