internal override void Draw(SpriteBatch spriteBatch, Point offset) { int thumbOffset = (Position.Height - 3 * TextHeight) * scrollPosition / ScrollSize; Vector2 rotateOrigin = new Vector2(0, 16); // Top button spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y, TextHeight, TextHeight), new Rectangle(0, 0, 16, 16), Color.White, (float)Math.PI / 2, rotateOrigin, SpriteEffects.None, 0); // Top gutter spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y + TextHeight, thumbOffset, TextHeight), new Rectangle(2 * 16, 0, 16, 16), Color.White, (float)Math.PI / 2, rotateOrigin, SpriteEffects.None, 0); // Thumb spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y + TextHeight + thumbOffset, TextHeight, TextHeight), new Rectangle(ScrollSize > 0 ? 16 : 2 * 16, 0, 16, 16), Color.White, (float)Math.PI / 2, rotateOrigin, SpriteEffects.None, 0); // Bottom gutter spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y + 2 * TextHeight + thumbOffset, Position.Height - 3 * TextHeight - thumbOffset, TextHeight), new Rectangle(2 * 16, 0, 16, 16), Color.White, (float)Math.PI / 2, rotateOrigin, SpriteEffects.None, 0); // Bottom button spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y + Position.Height - TextHeight, TextHeight, TextHeight), new Rectangle(3 * 16, 0, 16, 16), Color.White, (float)Math.PI / 2, rotateOrigin, SpriteEffects.None, 0); // Draw contents inside a scissor rectangle (so they're clipped to the client area). WindowManager.Flush(spriteBatch); Rectangle oldScissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(offset.X + Position.X, offset.Y + Position.Y, Position.Width - TextHeight, Position.Height); spriteBatch.GraphicsDevice.RasterizerState = ScissorTestEnable; base.Draw(spriteBatch, offset); WindowManager.Flush(spriteBatch); spriteBatch.GraphicsDevice.ScissorRectangle = oldScissorRectangle; spriteBatch.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; }
internal override void Draw(SpriteBatch spriteBatch, Point offset) { var thumbOffset = (int)((float)(Position.Width - 3 * TextHeight) * (float)ScrollPosition / (float)ScrollSize); // Left button spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X, offset.Y + Position.Y + Position.Height - TextHeight, TextHeight, TextHeight), new Rectangle(0, 0, 16, 16), Color.White); // Left gutter spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + TextHeight, offset.Y + Position.Y + Position.Height - TextHeight, thumbOffset, TextHeight), new Rectangle(2 * 16, 0, 16, 16), Color.White); // Thumb spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + TextHeight + thumbOffset, offset.Y + Position.Y + Position.Height - TextHeight, TextHeight, TextHeight), new Rectangle(ScrollSize > 0 ? 16 : 2 * 16, 0, 16, 16), Color.White); // Right gutter spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + 2 * TextHeight + thumbOffset, offset.Y + Position.Y + Position.Height - TextHeight, Position.Width - 3 * TextHeight - thumbOffset, TextHeight), new Rectangle(2 * 16, 0, 16, 16), Color.White); // Right button spriteBatch.Draw(WindowManager.ScrollbarTexture, new Rectangle(offset.X + Position.X + Position.Width - TextHeight, offset.Y + Position.Y + Position.Height - TextHeight, TextHeight, TextHeight), new Rectangle(3 * 16, 0, 16, 16), Color.White); // Draw contents inside a scissor rectangle (so they're clipped to the client area). WindowManager.Flush(spriteBatch); var oldScissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(offset.X + Position.X, offset.Y + Position.Y, Position.Width, Position.Height - TextHeight); spriteBatch.GraphicsDevice.RasterizerState = ScissorTestEnable; base.Draw(spriteBatch, offset); WindowManager.Flush(spriteBatch); spriteBatch.GraphicsDevice.ScissorRectangle = oldScissorRectangle; spriteBatch.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; }