|
From: <Pi...@us...> - 2011-01-14 02:22:23
|
Revision: 1644
http://cs-sdl.svn.sourceforge.net/cs-sdl/?rev=1644&view=rev
Author: Pikablu
Date: 2011-01-14 02:22:17 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
Modified Paths:
--------------
branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs
branches/experimental/src/Widgets/ContainerWidget.cs
branches/experimental/src/Widgets/Widget.cs
branches/experimental/src/Widgets/Window.cs
Modified: branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs
===================================================================
--- branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs 2011-01-14 00:38:13 UTC (rev 1643)
+++ branches/experimental/examples/SdlDotNetExamples/SmallDemos/GuiExample.cs 2011-01-14 02:22:17 UTC (rev 1644)
@@ -55,7 +55,7 @@
}
Video.WindowIcon();
Video.WindowCaption = "SDL.NET - Gui Example";
- Video.UseResolutionScaling = true;
+ Video.UseResolutionScaling = false;
Resolution.SetStandardResolution(640, 480);
Resolution.SetResolution(1024, 768);
Modified: branches/experimental/src/Widgets/ContainerWidget.cs
===================================================================
--- branches/experimental/src/Widgets/ContainerWidget.cs 2011-01-14 00:38:13 UTC (rev 1643)
+++ branches/experimental/src/Widgets/ContainerWidget.cs 2011-01-14 02:22:17 UTC (rev 1644)
@@ -160,7 +160,7 @@
public void CheckWidgets() {
for (int i = 0; i < childWidgets.Count; i++) {
if (childWidgets[i].RedrawRequested) {
- ClearRegion(childWidgets[i].Bounds, childWidgets[i]);
+ ClearRegion(childWidgets[i].ScaledBounds, childWidgets[i]);
UpdateWidget(childWidgets[i]);
}
if (childWidgets[i] is ContainerWidget) {
@@ -199,9 +199,9 @@
for (int i = 0; i < childWidgets.Count; i++) {
if (childWidgets[i].Visible && (widgetToSkip != null && childWidgets[i] != widgetToSkip)) {
- if (childWidgets[i].Bounds.IntersectsWith(bounds)) {
- Rectangle region = CalculateRegion(bounds, childWidgets[i].Bounds);//new Rectangle(widgetToSkip.X - childWidgets[i].X, widgetToSkip.Y - childWidgets[i].Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widgetToSkip.X, widgetToSkip.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widgetToSkip.Y, widgetToSkip.Height));
- childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].X + region.X, childWidgets[i].Y + region.Y));
+ if (childWidgets[i].ScaledBounds.IntersectsWith(bounds)) {
+ Rectangle region = CalculateRegion(bounds, childWidgets[i].ScaledBounds);//new Rectangle(widgetToSkip.X - childWidgets[i].X, widgetToSkip.Y - childWidgets[i].Y, System.Math.Min((childWidgets[i].Width + childWidgets[i].X) - widgetToSkip.X, widgetToSkip.Width), System.Math.Min((childWidgets[i].Height + childWidgets[i].Y) - widgetToSkip.Y, widgetToSkip.Height));
+ childWidgets[i].BlitToScreen(base.Buffer, region, new Point(childWidgets[i].ScaledX + region.X, childWidgets[i].ScaledY + region.Y));
}
}
}
Modified: branches/experimental/src/Widgets/Widget.cs
===================================================================
--- branches/experimental/src/Widgets/Widget.cs 2011-01-14 00:38:13 UTC (rev 1643)
+++ branches/experimental/src/Widgets/Widget.cs 2011-01-14 02:22:17 UTC (rev 1644)
@@ -49,7 +49,7 @@
Color borderColor;
BorderStyle borderStyle;
int borderWidth;
- Rectangle bounds;
+ //Rectangle bounds;
SdlDotNet.Graphics.Surface buffer;
Rectangle clipRectangle;
Color foreColor;
@@ -71,6 +71,7 @@
bool updating;
bool visible;
Rectangle cachedBounds = Rectangle.Empty;
+ Rectangle cachedOriginalBounds = Rectangle.Empty;
bool resizeRequested;
bool relocateRequested;
Rectangle unscaledBounds = Rectangle.Empty;
@@ -407,10 +408,18 @@
//}
}
set {
- if (bounds.Height != value) {
+ if (unscaledBounds.Height != value) {
+ cachedOriginalBounds.Height = this.ScaledSize.Height;
+
+ unscaledBounds.Height = value;
+
+ if (Video.UseResolutionScaling) {
+ value = Core.Resolution.ConvertHeight(value);
+ }
+
cachedBounds.Height = value;
- if (cachedBounds.Width == 0) {
- cachedBounds.Width = bounds.Width;
+ if (cachedBounds.Height == 0) {
+ cachedBounds.Height = unscaledBounds.Height;
}
resizeRequested = true;
RequestRedraw();
@@ -458,7 +467,7 @@
public Point ScaledLocation {
get {
if (cachedBounds.Location == Point.Empty) {
- return bounds.Location;
+ return unscaledBounds.Location;
} else {
return cachedBounds.Location;
}
@@ -479,18 +488,22 @@
//}
}
set {
- unscaledBounds.Location = value;
+ SetLocation(value, true);
+ }
+ }
- if (SdlDotNet.Graphics.Video.UseResolutionScaling) {
- value = Core.Resolution.ConvertPoint(value.X, value.Y);
+ private void SetLocation(Point location, bool scale) {
+ if (unscaledBounds.Location != location) {
+ cachedOriginalBounds.Location = this.ScaledLocation;
+
+ unscaledBounds.Location = location;
+
+ if (scale) {
+ if (SdlDotNet.Graphics.Video.UseResolutionScaling) {
+ location = Core.Resolution.ConvertPoint(location.X, location.Y);
+ }
}
- SetLocation(value);
- }
- }
-
- private void SetLocation(Point location) {
- if (bounds.Location != location) {
cachedBounds.Location = location;
relocateRequested = true;
//ClearWidget();
@@ -506,9 +519,9 @@
}
public void SetLocationUnscaled(Point location) {
- unscaledBounds.Location = location;
+ //unscaledBounds.Location = location;
- SetLocation(location);
+ SetLocation(location, false);
}
/// <summary>
@@ -580,7 +593,7 @@
/// <value>The absolute location of the widget.</value>
public Point ScreenLocation {
get {
- Point totalLoc = GetTotalAddLocation(bounds.Location, this);
+ Point totalLoc = GetTotalAddLocation(unscaledBounds.Location, this);
return totalLoc;
}
}
@@ -588,7 +601,7 @@
public Size ScaledSize {
get {
if (cachedBounds.Size == Size.Empty) {
- return bounds.Size;
+ return unscaledBounds.Size;
} else {
return cachedBounds.Size;
}
@@ -609,14 +622,16 @@
//}
}
set {
- unscaledBounds.Width = value.Width;
- unscaledBounds.Height = value.Height;
+ if (unscaledBounds.Size != value) {
+ cachedOriginalBounds.Size = this.ScaledSize;
- if (SdlDotNet.Graphics.Video.UseResolutionScaling) {
- value = Core.Resolution.ConvertSize(value.Width, value.Height);
- }
+ unscaledBounds.Width = value.Width;
+ unscaledBounds.Height = value.Height;
- if (bounds.Size != value) {
+ if (SdlDotNet.Graphics.Video.UseResolutionScaling) {
+ value = Core.Resolution.ConvertSize(value.Width, value.Height);
+ }
+
cachedBounds.Size = value;
resizeRequested = true;
//ClearWidget();
@@ -722,16 +737,18 @@
//}
}
set {
- unscaledBounds.Width = value;
+ if (unscaledBounds.Width != value) {
+ cachedOriginalBounds.Width = this.ScaledSize.Width;
- if (Video.UseResolutionScaling) {
- value = Core.Resolution.ConvertWidth(value);
- }
+ unscaledBounds.Width = value;
- if (bounds.Width != value) {
+ if (Video.UseResolutionScaling) {
+ value = Core.Resolution.ConvertWidth(value);
+ }
+
cachedBounds.Width = value;
if (cachedBounds.Height == 0) {
- cachedBounds.Height = bounds.Height;
+ cachedBounds.Height = unscaledBounds.Height;
}
resizeRequested = true;
//ClearWidget();
@@ -745,7 +762,7 @@
public int ScaledX {
get {
if (cachedBounds.Location == Point.Empty) {
- return bounds.X;
+ return unscaledBounds.X;
} else {
return cachedBounds.X;
}
@@ -766,8 +783,8 @@
//}
}
set {
- if (this.bounds.X != value) {
- this.Location = new Point(value, bounds.Y);
+ if (this.unscaledBounds.X != value) {
+ this.Location = new Point(value, unscaledBounds.Y);
}
//ClearWidget();
//bounds.X = value;
@@ -779,7 +796,7 @@
public int ScaledY {
get {
if (cachedBounds.Location == Point.Empty) {
- return bounds.Y;
+ return unscaledBounds.Y;
} else {
return cachedBounds.Y;
}
@@ -800,8 +817,8 @@
//}
}
set {
- if (this.bounds.Y != value) {
- this.Location = new Point(bounds.X, value);
+ if (this.unscaledBounds.Y != value) {
+ this.Location = new Point(unscaledBounds.X, value);
}
//ClearWidget();
//bounds.Y = value;
@@ -860,9 +877,9 @@
if (relocateRequested) {
relocateRequested = false;
if (parentContainer != null) {
- parentContainer.ClearRegion(bounds, this);
+ parentContainer.ClearRegion(cachedOriginalBounds, this);
}
- bounds.Location = cachedBounds.Location;
+ unscaledBounds.Location = cachedBounds.Location;
cachedBounds.Location = Point.Empty;
if (!topLevel && parentContainer != null) {
RequestRedraw();
@@ -871,7 +888,7 @@
if (resizeRequested) {
resizeRequested = false;
if (parentContainer != null) {
- parentContainer.ClearRegion(bounds, this);
+ parentContainer.ClearRegion(cachedOriginalBounds, this);
}
ResizeBuffer();
cachedBounds.Size = Size.Empty;
@@ -898,13 +915,13 @@
//if (!e.CancelBufferBlit) {
if (sourceRectangle == Rectangle.Empty) {
if (location == Point.Empty) {
- destinationSurface.Blit(buffer, this.Location);
+ destinationSurface.Blit(buffer, this.ScaledLocation);
} else {
destinationSurface.Blit(buffer, location);
}
} else {
if (location == Point.Empty) {
- destinationSurface.Blit(buffer, this.Location, sourceRectangle);
+ destinationSurface.Blit(buffer, this.ScaledLocation, sourceRectangle);
} else {
destinationSurface.Blit(buffer, location, sourceRectangle);
}
@@ -1269,7 +1286,7 @@
/// Initializes the default widget.
/// </summary>
protected void InitializeDefaultWidget() {
- bounds = new Rectangle(0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT);
+ unscaledBounds = new Rectangle(0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT);
backColor = Color.LightGray;
borderColor = Color.Black;
this.visible = true;
@@ -1304,8 +1321,8 @@
if (buffer != null) {
buffer.Close();
}
- bounds.Size = size;
- buffer = new SdlDotNet.Graphics.Surface(unscaledBounds.Size);
+ unscaledBounds.Size = size;
+ buffer = new SdlDotNet.Graphics.Surface(ScaledBounds.Size);
if (backColor.A == 0) {
buffer.TransparentColor = Color.Transparent;
buffer.Transparent = true;
@@ -1363,7 +1380,7 @@
lock (lockObject) {
if (!topLevel && parentContainer != null) {
if (!autoHide) {
- parentContainer.ClearRegion(this.Bounds, this);
+ parentContainer.ClearRegion(this.ScaledBounds, this);
} else {
parentContainer.ClearRegion(this.clipRectangle, this);
}
Modified: branches/experimental/src/Widgets/Window.cs
===================================================================
--- branches/experimental/src/Widgets/Window.cs 2011-01-14 00:38:13 UTC (rev 1643)
+++ branches/experimental/src/Widgets/Window.cs 2011-01-14 02:22:17 UTC (rev 1644)
@@ -342,10 +342,10 @@
lock (lockObject) {
if (windowed) {
this.Location = new Point(base.Location.X, base.Location.Y - titleBar.UnscaledSize.Height);
- Size size = this.ScaledSize;
+ Size size = this.Size;
fullBounds.Width = size.Width;
fullBounds.Height = size.Height;
- Point location = this.ScaledLocation;
+ Point location = this.Location;
fullBounds.X = location.X;
fullBounds.Y = location.Y;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|