public override void Paint (Cairo.Context gr, Rectangle rect, string subPart = "")
{
- float widthRatio = (float)rect.Width / Dimensions.Width;
- float heightRatio = (float)rect.Height / Dimensions.Height;
+ float widthRatio = 1f;
+ float heightRatio = 1f;
+
+ if (Scale){
+ widthRatio = (float)rect.Width / Dimensions.Width;
+ heightRatio = (float)rect.Height / Dimensions.Height;
+ }
+
float ratio = Math.Min (widthRatio, heightRatio);
// if (KeepProportions)
Size _minimumSize;\r
\r
Picture _backgroundImage;\r
+ string _backgroundImagePath;\r
string _template;\r
#endregion\r
\r
false : \r
true; } }\r
[XmlAttributeAttribute()][DefaultValue(null)]\r
+ public virtual string BackgroundImagePath {\r
+ get { return _backgroundImagePath; }\r
+ set { \r
+ _backgroundImagePath = value;\r
+ if (string.IsNullOrEmpty(_backgroundImagePath)) \r
+ return;\r
+\r
+ if (_backgroundImagePath.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) \r
+ _backgroundImage = new SvgPicture ();\r
+ else \r
+ _backgroundImage = new BmpPicture ();\r
+\r
+ _backgroundImage.LoadImage (_backgroundImagePath);\r
+ //_backgroundImage.Scale = false;\r
+ registerForGraphicUpdate ();\r
+ }\r
+ }\r
+ [XmlAttributeAttribute()]\r
public virtual Picture BackgroundImage {\r
get { return _backgroundImage; }\r
set { \r
}\r
internal virtual void checkHoverWidget(MouseMoveEventArgs e)\r
{\r
- if (TopContainer.hoverWidget != this) {\r
- TopContainer.hoverWidget = this;\r
+ IGOLibHost glh = TopContainer;\r
+ if (glh.hoverWidget != this) {\r
+ glh.hoverWidget = this;\r
onMouseEnter (this, e);\r
}\r
\r
protected override void onDraw (Context gr)\r
{\r
Rectangle rBack = new Rectangle (Slot.Size);\r
+ if (BackgroundImage != null) \r
+ BackgroundImage.Paint (gr, rBack, BackImgSub);\r
gr.Color = Background;\r
CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);\r
gr.Fill ();\r
public override Orientation Orientation\r
{\r
get { return Orientation.Horizontal; }\r
- //set { }\r
}\r
-\r
-\r
-\r
}\r
}\r
{\r
base.onMouseMove (sender, e);\r
\r
- if ((sender as OpenTKGameWindow).activeWidget != this)\r
+ IGOLibHost glh = TopContainer;\r
+ if (glh.activeWidget != this)\r
return;\r
-\r
if (!Selectable)\r
return;\r
\r
if (data == null)
return;
- #if DEBUG
- Stopwatch loadingTime = new Stopwatch ();
- loadingTime.Start ();
- #endif
+// #if DEBUG
+// Stopwatch loadingTime = new Stopwatch ();
+// loadingTime.Start ();
+// #endif
MemoryStream ms = new MemoryStream ();
using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
ms.Dispose ();
- #if DEBUG
- loadingTime.Stop ();
- Debug.WriteLine("Listbox Loading: {0} ticks \t, {1} ms",
- loadingTime.ElapsedTicks,
- loadingTime.ElapsedMilliseconds);
- #endif
+// #if DEBUG
+// loadingTime.Stop ();
+// Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+// loadingTime.ElapsedTicks,
+// loadingTime.ElapsedMilliseconds, this.ToString());
+// #endif
}
}
#region GraphicObject overrides
public override void ClearBinding ()
{
- if (Content != null)
+ if (Content != null) {
+ //fix datasource = null to clear bindings, but it's illogic
+ Content.DataSource = this.DataSource;
Content.ClearBinding ();
+ }
base.ClearBinding ();
}
string _title;
string _icon;
+ bool _resizable;
Container _contentContainer;
Direction currentDirection = Direction.None;
NotifyValueChanged ("Icon", _icon);
}
}
-
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public bool Resizable {
+ get {
+ return _resizable;
+ }
+ set {
+ _resizable = value;
+ NotifyValueChanged ("Resizable", _resizable);
+ }
+ }
+
+
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
if (otkgw.activeWidget == null) {
- Direction lastDir = currentDirection;
-
- if (Math.Abs (e.Position.Y - this.Slot.Y) < Interface.BorderThreshold) {
- if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
- currentDirection = Direction.NW;
- else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
- currentDirection = Direction.NE;
- else
- currentDirection = Direction.N;
- } else if (Math.Abs (e.Position.Y - this.Slot.Bottom) < Interface.BorderThreshold) {
- if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
- currentDirection = Direction.SW;
+ if (Resizable) {
+ Direction lastDir = currentDirection;
+
+ if (Math.Abs (e.Position.Y - this.Slot.Y) < Interface.BorderThreshold) {
+ if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ currentDirection = Direction.NW;
+ else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
+ currentDirection = Direction.NE;
+ else
+ currentDirection = Direction.N;
+ } else if (Math.Abs (e.Position.Y - this.Slot.Bottom) < Interface.BorderThreshold) {
+ if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ currentDirection = Direction.SW;
+ else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
+ currentDirection = Direction.SE;
+ else
+ currentDirection = Direction.S;
+ } else if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
+ currentDirection = Direction.W;
else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
- currentDirection = Direction.SE;
+ currentDirection = Direction.E;
else
- currentDirection = Direction.S;
- } else if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold)
- currentDirection = Direction.W;
- else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold)
- currentDirection = Direction.E;
- else
- currentDirection = Direction.None;
-
- if (currentDirection != lastDir) {
- switch (currentDirection) {
- case Direction.None:
- otkgw.Cursor = XCursor.Default;
- break;
- case Direction.N:
- otkgw.Cursor = XCursor.V;
- break;
- case Direction.S:
- otkgw.Cursor = XCursor.V;
- break;
- case Direction.E:
- otkgw.Cursor = XCursor.H;
- break;
- case Direction.W:
- otkgw.Cursor = XCursor.H;
- break;
- case Direction.NW:
- otkgw.Cursor = XCursor.NW;
- break;
- case Direction.NE:
- otkgw.Cursor = XCursor.NE;
- break;
- case Direction.SW:
- otkgw.Cursor = XCursor.SW;
- break;
- case Direction.SE:
- otkgw.Cursor = XCursor.SE;
- break;
- }
- }
+ currentDirection = Direction.None;
+
+ if (currentDirection != lastDir) {
+ switch (currentDirection) {
+ case Direction.None:
+ otkgw.Cursor = XCursor.Default;
+ break;
+ case Direction.N:
+ otkgw.Cursor = XCursor.V;
+ break;
+ case Direction.S:
+ otkgw.Cursor = XCursor.V;
+ break;
+ case Direction.E:
+ otkgw.Cursor = XCursor.H;
+ break;
+ case Direction.W:
+ otkgw.Cursor = XCursor.H;
+ break;
+ case Direction.NW:
+ otkgw.Cursor = XCursor.NW;
+ break;
+ case Direction.NE:
+ otkgw.Cursor = XCursor.NE;
+ break;
+ case Direction.SW:
+ otkgw.Cursor = XCursor.SW;
+ break;
+ case Direction.SE:
+ otkgw.Cursor = XCursor.SE;
+ break;
+ }
+ }
+ }
return;
}
this.TopContainer.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
+ int currentLeft = this.Left;
+ int currentTop = this.Top;
+
+ if (currentLeft == 0)
+ currentLeft = this.Slot.Left;
+ if (currentTop == 0)
+ currentTop = this.Slot.Top;
+
switch (currentDirection) {
case Direction.None:
- this.Left += e.XDelta;
- this.Top += e.YDelta;
+ this.Left = currentLeft + e.XDelta;
+ this.Top = currentTop + e.YDelta;
break;
case Direction.N:
- this.Top += e.YDelta;
+ this.Top = currentTop + e.YDelta;
this.Height -= e.YDelta;
break;
case Direction.S:
this.Height += e.YDelta;
break;
case Direction.W:
- this.Left += e.XDelta;
+ this.Left = currentLeft + e.XDelta;
this.Width -= e.XDelta;
break;
case Direction.E:
this.Width += e.XDelta;
break;
case Direction.NW:
- this.Left += e.XDelta;
- this.Top += e.YDelta;
+ this.Left = currentLeft + e.XDelta;
+ this.Top = currentTop + e.YDelta;
this.Width -= e.XDelta;
this.Height -= e.YDelta;
break;
case Direction.NE:
this.Width += e.XDelta;
- this.Top += e.YDelta;
+ this.Top = currentTop + e.YDelta;
this.Height -= e.YDelta;
break;
case Direction.SW:
- this.Left += e.XDelta;
+ this.Left = currentLeft + e.XDelta;
this.Width -= e.XDelta;
this.Height += e.YDelta;
break;
// DisplayDevice.Default,\r
// 3,0,OpenTK.Graphics.GraphicsContextFlags.Default)\r
public OpenTKGameWindow(int _width, int _height, string _title="golib")\r
- : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), \r
+ : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 1), \r
_title,GameWindowFlags.Default,DisplayDevice.GetDisplay(DisplayIndex.Second),\r
3,2,OpenTK.Graphics.GraphicsContextFlags.Debug|OpenTK.Graphics.GraphicsContextFlags.ForwardCompatible)\r
// public OpenTKGameWindow(int _width, int _height, string _title="golib")\r
byte[] bmp;\r
int texID;\r
\r
- QuadVAO uiQuad;\r
+ public QuadVAO uiQuad, uiQuad2;\r
go.GLBackend.Shader shader;\r
Matrix4 projectionMatrix, \r
modelviewMatrix;\r
if (uiQuad != null)\r
uiQuad.Dispose ();\r
uiQuad = new QuadVAO (0, 0, ClientRectangle.Width, ClientRectangle.Height, 0, 1, 1, -1);\r
+ uiQuad2 = new QuadVAO (0, 0, ClientRectangle.Width, ClientRectangle.Height, 0, 0, 1, 1);\r
projectionMatrix = Matrix4.CreateOrthographicOffCenter \r
(0, ClientRectangle.Width, ClientRectangle.Height, 0, 0, 1);\r
modelviewMatrix = Matrix4.Identity;\r
shader.Disable ();\r
GL.Viewport (viewport [0], viewport [1], viewport [2], viewport [3]);\r
}\r
+ public void RenderCustomTextureOnUIQuad(int _customTex)\r
+ {\r
+ GL.GetInteger (GetPName.Viewport, viewport);\r
+ GL.Viewport (0, 0, ClientRectangle.Width, ClientRectangle.Height);\r
+ shader.Enable ();\r
+ shader.ProjectionMatrix = projectionMatrix;\r
+ shader.ModelViewMatrix = modelviewMatrix;\r
+ shader.Color = new Vector4(1f,1f,1f,1f);\r
+ GL.ActiveTexture (TextureUnit.Texture0);\r
+ GL.BindTexture (TextureTarget.Texture2D, _customTex);\r
+ GL.Disable (EnableCap.DepthTest);\r
+ uiQuad2.Render (PrimitiveType.TriangleStrip);\r
+ GL.Enable (EnableCap.DepthTest);\r
+ GL.BindTexture(TextureTarget.Texture2D, 0);\r
+ shader.Disable ();\r
+ GL.Viewport (viewport [0], viewport [1], viewport [2], viewport [3]); \r
+ }\r
\r
#endregion\r
\r
// Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms",\r
// updateTime.ElapsedTicks,\r
// updateTime.ElapsedMilliseconds);\r
- //update Mouse cursor\r
- if (_hoverWidget is Window) {\r
- \r
- }\r
} \r
#endregion\r
\r
public string Path;
public Size Dimensions;
public bool KeepProportions = false;
+ public bool Scale = true;
public Picture ()
{