public override void Draw(Gdk.Rectangle cliprect) { if (!cliprect.IntersectsWith(new Gdk.Rectangle((int)X, (int)Y, (int)Width, (int)Height))) { return; } float left = X; float right = X + Width; float top = Y; float bottom = Y + Height; float[] current_color = new float[4]; gl.GetFloatv(gl.CURRENT_COLOR, current_color); //get current color, might be transparent gl.Color4f(Color.Red, Color.Green, Color.Blue, current_color[3] * Color.Alpha); gl.Disable(gl.TEXTURE_2D); gl.Begin(gl.QUADS); gl.Vertex2f(left, top); gl.Vertex2f(right, top); gl.Vertex2f(right, bottom); gl.Vertex2f(left, bottom); gl.End(); gl.Enable(gl.TEXTURE_2D); gl.Color4fv(current_color); }
public virtual void Draw(Gdk.Rectangle cliprect) { if (Sprite == null) { return; } if (cliprect.IntersectsWith((Gdk.Rectangle)Area)) { Sprite.Draw(new Vector(X, Y)); } }
public void Draw(Gdk.Rectangle cliprect) { if (surface == null) { return; } Surface sm = surface; Surface st = (surfaceTop != null)?(surfaceTop):(surface); Surface sb = (surfaceBottom != null)?(surfaceBottom):(surface); // TODO only draw tiles inside level and do draw all inside level for (int tileX = -10; tileX <= 10; tileX++) { for (int tileY = -10; tileY <= 0; tileY++) { if (cliprect.IntersectsWith(new Gdk.Rectangle((int)(X + st.Width * tileX), (int)(Y - st.Height + st.Height * tileY), (int)st.Width, (int)st.Height))) { st.Draw(new Vector(X + st.Width * tileX, Y - st.Height + st.Height * tileY)); } } if (cliprect.IntersectsWith(new Gdk.Rectangle((int)(X + sm.Width * tileX), (int)(Y), (int)sm.Width, (int)sm.Height))) { sm.Draw(new Vector(X + sm.Width * tileX, Y)); } for (int tileY = 0; tileY <= 10; tileY++) { if (cliprect.IntersectsWith(new Gdk.Rectangle((int)(X + sb.Width * tileX), (int)(Y + surface.Height + sb.Height * tileY), (int)sb.Width, (int)sb.Height))) { sb.Draw(new Vector(X + sb.Width * tileX, Y + surface.Height + sb.Height * tileY)); } } } }
public override void Draw(Gdk.Rectangle cliprect) { if (Sprite == null) { return; } if (cliprect.IntersectsWith((Gdk.Rectangle)Area)) { Sprite.Draw(new Vector(X, Y)); Sprite.Draw(new Vector(X + Sprite.Width, Y)); } }
public override void Draw(Gdk.Rectangle cliprect) { if (Sprite == null) { return; } if (cliprect.IntersectsWith((Gdk.Rectangle)Area)) { Sprite.Draw(new Vector(X - 128 - Sprite.Width / 2, Y - Sprite.Height / 2)); Sprite.Draw(new Vector(X + 128 - Sprite.Width / 2, Y - Sprite.Height / 2)); } }
//HERZUM END SPRINT 2: TLAB-156 //HERZUM SPRINT 2.0 TLAB-135 protected void OverlayScope (ApplicationContext applicationContext) { ScopeNodeControl sncBrother; ScopeNodeBase scopeNodeBrother; Gdk.Rectangle areaBrother = new Gdk.Rectangle(); Gdk.Rectangle areaTarget = new Gdk.Rectangle(); BasicNodeControl componentControl; ScopeNodeBase scopeNodeTarget = ExperimentNode as ScopeNodeBase; GetSizeAreaWidget (out areaTarget.X, out areaTarget.Y, out areaTarget.Width, out areaTarget.Height); foreach (ExperimentNode node in ExperimentNode.Owner.Vertices) { if (!node.Equals(ExperimentNode)) { scopeNodeBrother= node as ScopeNodeBase; if (scopeNodeBrother != null) { if (m_applicationContext.NodeControlFactory.TryGetNodeControl (node, out componentControl)) { sncBrother = componentControl as ScopeNodeControl; sncBrother.GetSizeAreaWidget(out areaBrother.X, out areaBrother.Y, out areaBrother.Width, out areaBrother.Height); if (areaTarget.IntersectsWith(areaBrother) && sncBrother.stateWidget!="iconized") { sncBrother.IconizeScope(); sncBrother.IconisationForced = true; } else if (!areaTarget.IntersectsWith(areaBrother) && sncBrother.IconisationForced) { sncBrother.NormalizeScope(); sncBrother.IconisationForced = false; } } } } } }
public override void Draw(Gdk.Rectangle cliprect) { if (!cliprect.IntersectsWith((Gdk.Rectangle)Area)) { return; } if (Sprite == null) { return; } Sprite.Draw(new Vector(X * 32 + 16, Y * 32 + 16)); }
public override void Draw(Gdk.Rectangle cliprect) { if (!cliprect.IntersectsWith((Gdk.Rectangle)Area)) { return; } // Draw sprite if (Sprite == null) { return; } Sprite.Draw(new Vector(X, Y)); // Draw a color rectangle DrawColor(lightcolor); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Cairo.Context cr = Gdk.CairoHelper.Create(e.Window); Gdk.Rectangle area = e.Area; if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage)) { Pango.Layout messageLayout = new Pango.Layout(this.PangoContext); messageLayout.Alignment = Pango.Alignment.Center; messageLayout.Width = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale); if (!string.IsNullOrEmpty(CustomMessage)) { messageLayout.SetText(CustomMessage); } else { messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document.")); } cr.MoveTo(Allocation.Width * 1 / 6, 12); cr.SetSourceColor(Style.Text(StateType.Normal).ToCairoColor()); Pango.CairoHelper.ShowLayout(cr, messageLayout); messageLayout.Dispose(); ((IDisposable)cr).Dispose(); return(true); } var backColor = Style.Base(StateType.Normal).ToCairoColor(); cr.SetSourceColor(backColor); cr.Rectangle(area.X, area.Y, area.Width, area.Height); cr.Fill(); int xpos = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0); int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0); int ypos = -vadjustment; ToolboxWidgetCategory lastCategory = null; int lastCategoryYpos = 0; cr.LineWidth = 1; Iterate(ref xpos, ref ypos, (category, itemDimension) => { ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension))) { return(true); } cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); cr.SetSourceColor(Ide.Gui.Styles.PadCategoryBackgroundColor.ToCairoColor()); cr.Fill(); if (lastCategory == null || lastCategory.IsExpanded || lastCategory.AnimatingExpand) { cr.MoveTo(xpos, ypos + 0.5); cr.LineTo(itemDimension.Width, ypos + 0.5); } cr.MoveTo(0, ypos + itemDimension.Height - 0.5); cr.LineTo(xpos + Allocation.Width, ypos + itemDimension.Height - 0.5); cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor()); cr.Stroke(); headerLayout.SetMarkup(category.Text); int width, height; cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryLabelColor.ToCairoColor()); headerLayout.GetPixelSize(out width, out height); cr.MoveTo(xpos + CategoryLeftPadding, ypos + (double)(Math.Round((double)(itemDimension.Height - height) / 2))); Pango.CairoHelper.ShowLayout(cr, headerLayout); var img = category.IsExpanded ? discloseUp : discloseDown; cr.DrawImage(this, img, Allocation.Width - img.Width - CategoryRightPadding, ypos + Math.Round((itemDimension.Height - img.Height) / 2)); lastCategory = category; lastCategoryYpos = ypos + itemDimension.Height; return(true); }, (curCategory, item, itemDimension) => { if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension))) { return(true); } var icon = item.Icon; if (!icon.HasFixedSize) { var maxIconSize = Math.Min(itemDimension.Width, itemDimension.Height); var fittingIconSize = maxIconSize > 32 ? Xwt.IconSize.Large : maxIconSize > 16 ? Xwt.IconSize.Medium : Xwt.IconSize.Small; icon = item.Icon.WithSize(fittingIconSize); } if (item == SelectedItem) { icon = icon.WithStyles("sel"); cr.SetSourceColor(Style.Base(StateType.Selected).ToCairoColor()); cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height); cr.Fill(); } if (listMode || !curCategory.CanIconizeItems) { cr.DrawImage(this, icon, xpos + ItemLeftPadding, ypos + Math.Round((itemDimension.Height - icon.Height) / 2)); layout.SetMarkup(item.Text); layout.Width = (int)((itemDimension.Width - ItemIconTextItemSpacing - iconSize.Width - ItemLeftPadding * 2) * Pango.Scale.PangoScale); layout.GetPixelSize(out var width, out var height); cr.SetSourceColor(Style.Text(item != SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor()); cr.MoveTo(xpos + ItemLeftPadding + iconSize.Width + ItemIconTextItemSpacing, ypos + Math.Round((double)(itemDimension.Height - height) / 2)); Pango.CairoHelper.ShowLayout(cr, layout); } else { cr.DrawImage(this, icon, xpos + Math.Round((itemDimension.Width - icon.Width) / 2), ypos + Math.Round((itemDimension.Height - icon.Height) / 2)); } if (item == mouseOverItem) { cr.SetSourceColor(Style.Dark(StateType.Prelight).ToCairoColor()); cr.Rectangle(xpos + 0.5, ypos + 0.5, itemDimension.Width - 1, itemDimension.Height - 1); cr.Stroke(); } return(true); }); ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos); if (lastCategory != null && lastCategory.AnimatingExpand) { // Closing line when animating the last group of the toolbox cr.MoveTo(area.X, ypos + 0.5); cr.RelLineTo(area.Width, 0); cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor()); cr.Stroke(); } ((IDisposable)cr).Dispose(); return(true); }
internal static void UpdateWindow (ICompletionWidget widget) { // Updates the parameter information window from the information // of the current method overload if (window == null && methods.Count > 0) { window = new ParameterInformationWindow (); wasAbove = false; } if (methods.Count == 0) { if (window != null) { window.Hide (); wasAbove = false; } return; } var ctx = widget.CurrentCodeCompletionContext; MethodData md = methods[methods.Count - 1]; int cparam = md.MethodProvider.GetCurrentParameterIndex (widget, md.CompletionContext); Gtk.Requisition reqSize = window.ShowParameterInfo (md.MethodProvider, md.CurrentOverload, cparam - 1); X = md.CompletionContext.TriggerXCoord; if (CompletionWindowManager.IsVisible) { // place above Y = ctx.TriggerYCoord - ctx.TriggerTextHeight - reqSize.Height - 10; } else { // place below Y = ctx.TriggerYCoord; } Gdk.Rectangle geometry = DesktopService.GetUsableMonitorGeometry (window.Screen, window.Screen.GetMonitorAtPoint (X + reqSize.Width, Y)); if (X + reqSize.Width > geometry.Right) X = geometry.Right - reqSize.Width; if (Y < geometry.Top) Y = ctx.TriggerYCoord; if (wasAbove || Y + reqSize.Height > geometry.Bottom) { Y = Y - ctx.TriggerTextHeight - reqSize.Height - 4; wasAbove = true; } if (CompletionWindowManager.IsVisible) { Rectangle completionWindow = new Rectangle (CompletionWindowManager.X, CompletionWindowManager.Y, CompletionWindowManager.Wnd.Allocation.Width, CompletionWindowManager.Wnd.Allocation.Height); if (completionWindow.IntersectsWith (new Rectangle (X, Y, reqSize.Width, reqSize.Height))) { X = completionWindow.X; Y = completionWindow.Y - reqSize.Height - 6; if (Y < 0) Y = completionWindow.Bottom + 6; } } window.Move (X, Y); window.Show (); }
static async void PositionParameterInfoWindow (Rectangle allocation) { lastW = allocation.Width; lastH = allocation.Height; wasVisi = CompletionWindowManager.IsVisible; var ctx = window.Widget.CurrentCodeCompletionContext; int cparam = window.Ext != null ? await window.Ext.GetCurrentParameterIndex (currentMethodGroup.MethodProvider.StartOffset) : 0; X = currentMethodGroup.CompletionContext.TriggerXCoord; if (CompletionWindowManager.IsVisible) { // place above Y = ctx.TriggerYCoord - ctx.TriggerTextHeight - allocation.Height - 10; } else { // place below Y = ctx.TriggerYCoord; } var geometry = DesktopService.GetUsableMonitorGeometry (window.Screen.Number, window.Screen.GetMonitorAtPoint (X, Y)); window.ShowParameterInfo (currentMethodGroup.MethodProvider, currentMethodGroup.CurrentOverload, cparam - 1, (int)geometry.Width); if (X + allocation.Width > geometry.Right) X = (int)geometry.Right - allocation.Width; if (Y < geometry.Top) Y = ctx.TriggerYCoord; if (wasAbove || Y + allocation.Height > geometry.Bottom) { Y = Y - ctx.TriggerTextHeight - allocation.Height - 4; wasAbove = true; } if (CompletionWindowManager.IsVisible) { var completionWindow = new Rectangle (CompletionWindowManager.X, CompletionWindowManager.Y, CompletionWindowManager.Wnd.Allocation.Width, CompletionWindowManager.Wnd.Allocation.Height); if (completionWindow.IntersectsWith (new Rectangle (X, Y, allocation.Width, allocation.Height))) { X = completionWindow.X; Y = completionWindow.Y - allocation.Height - 6; if (Y < 0) Y = completionWindow.Bottom + 6; } } window.Move (X, Y); }
/// <summary> /// This method is used to render a sprite viewport onto a /// drawable object, such as Gdk.Pixmap. This handles the /// translation of widget space into sprite space and also the /// appropriate clipping. /// </summary> public void Render( Drawable drawable, Rectangle region) { // Create the GC GC gc = new GC(drawable); // Figure out what parts of the rectangle we care about Rectangle ourselves = new Rectangle(x, y, width, height); if (!ourselves.IntersectsWith(region)) { // No overlap, don't bother return; } // Get the intersection of ourselves and the update // region. This helps with keeping to a specific focus. ourselves.Intersect(region); // Clear everything gc.RgbFgColor = BackgroundColor; drawable.DrawRectangle(gc, true, ourselves); // Go through the sprites foreach (ISprite sprite in SpriteList) { sprite.Render(drawable, gc); } }