/// <summary> /// Composes the element based on the context. /// </summary> /// <param name="ctx">The context of the element.</param> /// <param name="surface">The surface of the image. (Not used)</param> public override void ComposeElements(Context ctx, ImageSurface surface) { Bounds.CalcWorldBounds(); ctx.SetSourceRGBA(0, 0, 0, 0.2); RoundRectangle(ctx, Bounds.drawX, Bounds.drawY, Bounds.InnerWidth, Bounds.InnerHeight, 3); ctx.Fill(); EmbossRoundRectangleElement(ctx, Bounds, true, 1, 1); listMenu.ComposeDynamicElements(); ComposeDynamicElements(); }
public override void ComposeTextElements(Context ctx, ImageSurface surface) { if (!didInit) { SetUpMovableState(null); didInit = true; } RoundRectangle(ctx, Bounds.bgDrawX, Bounds.bgDrawY, Bounds.OuterWidth, Bounds.OuterHeight, GuiStyle.DialogBGRadius); //ctx.SetSourceRGBA(GuiStyle.DialogDefaultBgColor[0], GuiStyle.DialogDefaultBgColor[1], GuiStyle.DialogDefaultBgColor[2], 1); //ctx.FillPreserve(); LinearGradient gradient = new LinearGradient(0, 0, Bounds.InnerWidth, 0); gradient.AddColorStop(0, new Color(GuiStyle.DialogDefaultBgColor[0] * 1.4, GuiStyle.DialogDefaultBgColor[1] * 1.4, GuiStyle.DialogDefaultBgColor[2] * 1.4, 1)); gradient.AddColorStop(0.5, new Color(GuiStyle.DialogDefaultBgColor[0] * 1.1, GuiStyle.DialogDefaultBgColor[1] * 1.1, GuiStyle.DialogDefaultBgColor[2] * 1.1, 1)); gradient.AddColorStop(1, new Color(GuiStyle.DialogDefaultBgColor[0] * 1.4, GuiStyle.DialogDefaultBgColor[1] * 1.4, GuiStyle.DialogDefaultBgColor[2] * 1.4, 1)); ctx.SetSource(gradient); ctx.FillPreserve(); gradient.Dispose(); Bounds.CalcWorldBounds(); double radius = GuiStyle.DialogBGRadius; ctx.NewPath(); ctx.MoveTo(Bounds.drawX, Bounds.drawY + Bounds.InnerHeight); ctx.LineTo(Bounds.drawX, Bounds.drawY + radius); ctx.Arc(Bounds.drawX + radius, Bounds.drawY + radius, radius, 180 * GameMath.DEG2RAD, 270 * GameMath.DEG2RAD); ctx.Arc(Bounds.drawX + Bounds.OuterWidth - radius, Bounds.drawY + radius, radius, -90 * GameMath.DEG2RAD, 0 * GameMath.DEG2RAD); ctx.LineTo(Bounds.drawX + Bounds.OuterWidth, Bounds.drawY + Bounds.InnerHeight); ctx.SetSourceRGBA(GuiStyle.TitleBarColor); ctx.FillPreserve(); ctx.SetSourceRGBA(new double[] { 45 / 255.0, 35 / 255.0, 33 / 255.0, 1 }); ctx.LineWidth = 6; ctx.Stroke(); Font.SetupContext(ctx); DrawTextLineAt(ctx, text, scaled(GuiStyle.ElementToDialogPadding), (Bounds.InnerHeight - Font.GetFontExtents().Height) / 2 + scaled(2)); double crossSize = scaled(unscaledCloseIconSize); double menuSize = scaled(unscaledCloseIconSize + 2); double crossX = Bounds.drawX + Bounds.OuterWidth - crossSize - scaled(12); double iconY = Bounds.drawY + scaled(7); double crossWidth = scaled(2); double menuX = Bounds.drawX + Bounds.OuterWidth - crossSize - menuSize - scaled(20); menuIconRect = new Rectangled(Bounds.OuterWidth - crossSize - menuSize - scaled(20), scaled(6), crossSize, crossSize); closeIconRect = new Rectangled(Bounds.OuterWidth - crossSize - scaled(12), scaled(5), menuSize, menuSize); ctx.Operator = Operator.Over; ctx.SetSourceRGBA(0, 0, 0, 0.3); api.Gui.Icons.DrawCross(ctx, crossX + 2, iconY + 2, crossWidth, crossSize); ctx.Operator = Operator.Source; ctx.SetSourceRGBA(GuiStyle.DialogDefaultTextColor); api.Gui.Icons.DrawCross(ctx, crossX, iconY, crossWidth, crossSize); ctx.Operator = Operator.Over; api.Gui.Icons.Drawmenuicon_svg(ctx, (int)menuX + 2, (int)iconY + 2, (int)menuSize, (int)menuSize, new double[] { 0, 0, 0, 0.3 }); ctx.Operator = Operator.Source; api.Gui.Icons.Drawmenuicon_svg(ctx, (int)menuX, (int)iconY + 1, (int)menuSize, (int)menuSize, GuiStyle.DialogDefaultTextColor); ctx.Operator = Operator.Over; ComposeHoverIcons(); listMenu.Bounds.fixedX = (Bounds.absX + menuIconRect.X - Bounds.absX) / RuntimeEnv.GUIScale; listMenu.ComposeDynamicElements(); }