aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-01 23:31:22 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-01 23:31:22 +0100
commit47fe040bb568b4eff544bb9f287481343216373e (patch)
tree497c57cb3028d54f01d4d5748743dd0af69a77ab /src/GraphicObjects
parent9fa17cdc9487e3ba92ef467c0c6d5d9941530de1 (diff)
debug and improvments
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/Border.cs12
-rw-r--r--src/GraphicObjects/Button.cs110
-rw-r--r--src/GraphicObjects/ComboBox.cs4
-rw-r--r--src/GraphicObjects/GenericStack.cs3
-rw-r--r--src/GraphicObjects/GraphicObject.cs169
-rw-r--r--src/GraphicObjects/Group.cs4
-rw-r--r--src/GraphicObjects/ILayoutable.cs2
-rw-r--r--src/GraphicObjects/Image.cs51
-rw-r--r--src/GraphicObjects/Label.cs366
-rw-r--r--src/GraphicObjects/NumericControl.cs4
-rw-r--r--src/GraphicObjects/Popper.cs4
-rw-r--r--src/GraphicObjects/Scroller.cs2
-rw-r--r--src/GraphicObjects/Slider.cs8
-rw-r--r--src/GraphicObjects/TextBox.cs11
-rw-r--r--src/GraphicObjects/Window.cs225
15 files changed, 548 insertions, 427 deletions
diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs
index f412268c..d9791050 100644
--- a/src/GraphicObjects/Border.cs
+++ b/src/GraphicObjects/Border.cs
@@ -12,7 +12,6 @@ namespace Crow
#endregion
#region private fields
- Color _borderColor;
int _borderWidth;
#endregion
@@ -26,12 +25,9 @@ namespace Crow
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
- public virtual Color BorderColor {
- get { return _borderColor; }
- set {
- _borderColor = value;
- registerForGraphicUpdate ();
- }
+ public override Color Foreground {
+ get { return base.Foreground;}
+ set {base.Foreground = value;}
}
#endregion
@@ -62,7 +58,7 @@ namespace Crow
if (BorderWidth > 0) {
gr.LineWidth = BorderWidth;
- gr.Color = BorderColor;
+ gr.Color = Foreground;
CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Stroke ();
}
diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs
index 5d3e81ca..17fbe328 100644
--- a/src/GraphicObjects/Button.cs
+++ b/src/GraphicObjects/Button.cs
@@ -13,71 +13,93 @@ using System.ComponentModel;
namespace Crow
{
- public class Button : Container, IXmlSerializable
+ [DefaultTemplate("#Crow.Templates.Button.crow")]
+ public class Button : TemplatedContainer
{
#region CTOR
public Button() : base()
{
//MouseEnter += delegate { Background = Color.RedDevil;};
//MouseLeave += delegate { Background = Color.Transparent;};
- MouseButtonDown += delegate { BackImgSub = "pressed"; registerForGraphicUpdate();};
- MouseButtonUp += delegate { BackImgSub = "normal";registerForGraphicUpdate();};
+// MouseButtonDown += delegate { BackImgSub = "pressed"; registerForGraphicUpdate();};
+// MouseButtonUp += delegate { BackImgSub = "normal";registerForGraphicUpdate();};
}
#endregion
- #region GraphicObject Overrides
- [XmlAttributeAttribute()][DefaultValue(50)]
- public override int Width {
- get { return base.Width; }
- set { base.Width = value; }
- }
- [XmlAttributeAttribute()][DefaultValue(20)]
- public override int Height {
- get { return base.Height; }
- set { base.Height = value; }
+ string caption;
+ string image;
+ Container _contentContainer;
+
+ public override GraphicObject Content {
+ get {
+ return _contentContainer == null ? null : _contentContainer.Child;
+ }
+ set {
+ if (_contentContainer != null)
+ _contentContainer.SetChild(value);
+ }
}
- [XmlAttributeAttribute()][DefaultValue("Transparent")]
- public override Color Background {
- get { return base.Background; }
- set { base.Background = value; }
+ protected override void loadTemplate(GraphicObject template = null)
+ {
+ base.loadTemplate (template);
+
+ _contentContainer = this.child.FindByName ("Content") as Container;
}
+
+ #region GraphicObject Overrides
+// [XmlAttributeAttribute()][DefaultValue(50)]
+// public override int Width {
+// get { return base.Width; }
+// set { base.Width = value; }
+// }
+// [XmlAttributeAttribute()][DefaultValue(20)]
+// public override int Height {
+// get { return base.Height; }
+// set { base.Height = value; }
+// }
[XmlAttributeAttribute()][DefaultValue(true)]
public override bool Focusable
{
get { return base.Focusable; }
set { base.Focusable = value; }
}
- [XmlAttributeAttribute()][DefaultValue("#Crow.Images.button.svg")]
- public override Picture BackgroundImage {
- get {
- return base.BackgroundImage;
- }
- set {
- base.BackgroundImage = value;
- BackImgSub = "normal";
- }
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Content != null)
+ Content.ResolveBindings ();
+ }
+ public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ {
+ base.onMouseDown (sender, e);
+ NotifyValueChanged ("State", "pressed");
+ }
+ public override void onMouseUp (object sender, MouseButtonEventArgs e)
+ {
+ base.onMouseUp (sender, e);
+ NotifyValueChanged ("State", "normal");
}
#endregion
- [XmlAttributeAttribute][DefaultValue("Button")]
- public string Text
- {
- get {
- Label l = Child as Label;
- return l == null ? "" : l.Text;
+ [XmlAttributeAttribute()][DefaultValue("Button")]
+ public string Caption {
+ get { return caption; }
+ set {
+ if (caption == value)
+ return;
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
- set
- {
- Label l = Child as Label;
- if (l == null)
- this.SetChild(new Label (value)
- {
- TextAlignment = Alignment.Center,
- Foreground = Color.Black
- });
- else
- l.Text = value;
+ }
+ [XmlAttributeAttribute()][DefaultValue("#Crow.Images.button.svg")]
+ public string Image {
+ get { return image; }
+ set {
+ if (image == value)
+ return;
+ image = value;
+ NotifyValueChanged ("Image", image);
}
- }
+ }
}
}
diff --git a/src/GraphicObjects/ComboBox.cs b/src/GraphicObjects/ComboBox.cs
index 5d9c8e97..b958a81b 100644
--- a/src/GraphicObjects/ComboBox.cs
+++ b/src/GraphicObjects/ComboBox.cs
@@ -316,7 +316,7 @@ namespace Crow
public virtual void onPop(object sender, EventArgs e)
{
- IGOLibHost tc = TopContainer;
+ IGOLibHost tc = HostContainer;
if (tc == null)
return;
if (Overlay != null) {
@@ -329,7 +329,7 @@ namespace Crow
}
public virtual void onUnpop(object sender, EventArgs e)
{
- IGOLibHost tc = TopContainer;
+ IGOLibHost tc = HostContainer;
if (tc == null)
return;
Overlay.Visible = false;
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 968c76ac..1624c530 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -88,6 +88,9 @@ namespace Crow
}
public virtual void ComputeChildrenPositions()
{
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine("ComputeChildrenPosition: " + this.ToString());
+ #endif
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index ff94392c..69f19ca2 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -73,6 +73,7 @@ namespace Crow
int _margin = 0;
bool _focusable = false;
bool _hasFocus = false;
+ bool _mouseRepeat;
protected bool _isVisible = true;
VerticalAlignment _verticalAlignment = VerticalAlignment.Center;
HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
@@ -93,6 +94,8 @@ namespace Crow
#endregion
#region ILayoutable
+ //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject
+ // or we could add to the interface the mouse events
[XmlIgnore]public ILayoutable Parent {
get { return _parent; }
set {
@@ -116,8 +119,8 @@ namespace Crow
return cb;
}
}
- [XmlIgnore]public virtual IGOLibHost TopContainer {
- get { return Parent == null ? null : Parent.TopContainer; }
+ [XmlIgnore]public virtual IGOLibHost HostContainer {
+ get { return Parent == null ? null : Parent.HostContainer; }
}
public virtual Rectangle ContextCoordinates(Rectangle r){
return
@@ -141,8 +144,8 @@ namespace Crow
#region EVENT HANDLERS
public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
- public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
- public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
+ public event EventHandler<MouseButtonEventArgs> MouseUp;
+ public event EventHandler<MouseButtonEventArgs> MouseDown;
public event EventHandler<MouseButtonEventArgs> MouseClick;
public event EventHandler<MouseMoveEventArgs> MouseMove;
public event EventHandler<MouseMoveEventArgs> MouseEnter;
@@ -247,35 +250,75 @@ namespace Crow
}
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool Focusable {
- get { return _focusable | Interface.DesignerMode; }
- set { _focusable = value; }
- }
+ get { return _focusable; }
+ set {
+ if (_focusable == value)
+ return;
+ _focusable = value;
+ NotifyValueChanged ("Focusable", _focusable);
+ }
+ }
+ [XmlIgnore]public virtual bool HasFocus {
+ get { return _hasFocus; }
+ set {
+ if (value == _hasFocus)
+ return;
+
+ _hasFocus = value;
+ NotifyValueChanged ("HasFocus", _hasFocus);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public virtual bool MouseRepeat {
+ get { return _mouseRepeat; }
+ set {
+ if (_mouseRepeat == value)
+ return;
+ _mouseRepeat = value;
+ NotifyValueChanged ("MouseRepeat", _mouseRepeat);
+ }
+ }
[XmlAttributeAttribute()][DefaultValue("Transparent")]
public virtual Color Background {
get { return _background; }
set {
- _background = value;
+ if (_background == value)
+ return;
+ _background = value;
+ NotifyValueChanged ("Background", _background);
registerForGraphicUpdate ();
}
- }
+ }
[XmlAttributeAttribute()][DefaultValue("White")]
public virtual Color Foreground {
get { return _foreground; }
set {
- _foreground = value;
+ if (_foreground == value)
+ return;
+ _foreground = value;
+ NotifyValueChanged ("Foreground", _foreground);
registerForGraphicUpdate ();
}
- }
+ }
[XmlAttributeAttribute()][DefaultValue("droid,10")]
public virtual Font Font {
get { return _font; }
- set { _font = value; }
+ set {
+ if (value == _font)
+ return;
+ _font = value;
+ NotifyValueChanged ("Font", _font);
+ registerForGraphicUpdate ();
+ }
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
public virtual double CornerRadius {
get { return _cornerRadius; }
set {
- _cornerRadius = value;
+ if (value == _cornerRadius)
+ return;
+ _cornerRadius = value;
+ NotifyValueChanged ("CornerRadius", _cornerRadius);
registerForGraphicUpdate ();
}
}
@@ -283,7 +326,10 @@ namespace Crow
public virtual int Margin {
get { return _margin; }
set {
- _margin = value;
+ if (value == _margin)
+ return;
+ _margin = value;
+ NotifyValueChanged ("Margin", _margin);
registerForGraphicUpdate ();
}
}
@@ -296,25 +342,20 @@ namespace Crow
_isVisible = value;
- if (TopContainer == null)
+ if (HostContainer == null)
return;
//add slot to clipping to redraw
- TopContainer.gobjsToRedraw.Add (this);
+ HostContainer.gobjsToRedraw.Add (this);
//ensure main win doesn't keep hidden childrens ref
- if (this.Contains (TopContainer.hoverWidget))
- TopContainer.hoverWidget = null;
+ if (this.Contains (HostContainer.hoverWidget))
+ HostContainer.hoverWidget = null;
if (Parent is GenericStack)
Parent.RegisterForLayouting ((int)LayoutingType.Sizing | (int)LayoutingType.PositionChildren);
-// Parent.InvalidateLayout ();
- //else
- // registerForRedraw();
+
+ NotifyValueChanged ("Visible", _isVisible);
}
}
- [XmlIgnore]public virtual bool HasFocus {
- get { return _hasFocus; }
- set { _hasFocus = value; }
- }
//TODO: only used in group, should be removed from base go object
[XmlIgnore]public virtual bool DrawingIsValid
{ get { return bmp == null ?
@@ -450,16 +491,16 @@ namespace Crow
public virtual void registerForGraphicUpdate ()
{
bmp = null;
- if (TopContainer != null)
- TopContainer.gobjsToRedraw.Add (this);
+ if (HostContainer != null)
+ HostContainer.gobjsToRedraw.Add (this);
}
/// <summary>
/// Add clipping region in redraw list of interface, dont update cached object content
/// </summary>
public virtual void RegisterForRedraw ()
{
- if (TopContainer != null)
- TopContainer.gobjsToRedraw.Add (this);
+ if (HostContainer != null)
+ HostContainer.gobjsToRedraw.Add (this);
}
/// <summary>
@@ -477,10 +518,10 @@ namespace Crow
public virtual void registerClipRect()
{
- TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
+ HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
//this clipping should take only last painted slots in ancestor tree which
//is not the case for now.
- TopContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot));
+ HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot));
}
/// <summary> return size of content + margins </summary>
protected virtual Size measureRawSize ()
@@ -782,7 +823,7 @@ namespace Crow
}
public virtual void checkHoverWidget(MouseMoveEventArgs e)
{
- IGOLibHost glh = TopContainer;
+ IGOLibHost glh = HostContainer;
if (glh.hoverWidget != this) {
glh.hoverWidget = this;
onMouseEnter (this, e);
@@ -799,19 +840,37 @@ namespace Crow
MouseMove.Raise (sender, e);
}
- public virtual void onMouseButtonUp(object sender, MouseButtonEventArgs e){
- if (MouseIsIn (e.Position))
- onMouseClick (sender, e);
-
- MouseButtonUp.Raise (this, e);
+ public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
+ IGOLibHost hc = HostContainer;
+ if (hc.activeWidget == null)
+ hc.activeWidget = this;
+ if (this.Focusable && !Interface.FocusOnHover) {
+ BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
+ if (be.Focused == null) {
+ be.Focused = this;
+ hc.FocusedWidget = this;
+ }
+ }
+ //bubble event to the top
+ GraphicObject p = Parent as GraphicObject;
+ if (p != null)
+ p.onMouseDown(sender,e);
+
+ MouseDown.Raise (this, e);
}
- public virtual void onMouseButtonDown(object sender, MouseButtonEventArgs e){
- TopContainer.FocusedWidget = this;
+ public virtual void onMouseUp(object sender, MouseButtonEventArgs e){
+ //bubble event to the top
+ GraphicObject p = Parent as GraphicObject;
+ if (p != null)
+ p.onMouseUp(sender,e);
- MouseButtonDown.Raise (this, e);
+ MouseUp.Raise (this, e);
+
+ if (MouseIsIn (e.Position)&&HasFocus)
+ onMouseClick(sender,e);
}
- public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
- MouseClick.Raise (this,e);
+ public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
+ MouseClick.Raise (this, e);
}
public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
GraphicObject p = Parent as GraphicObject;
@@ -1080,24 +1139,28 @@ namespace Crow
GraphicObject lopObj = this; //default left operand base object is
//the first arg (object sender) of the event handler
+ il.Emit(OpCodes.Ldarg_0); //load sender ref onto the stack
+
string[] lopParts = lop.Split (new char[] { '.' });
- if (lopParts.Length == 2) {//should search also for member of es.Source
- lopObj = this.FindByName (lopParts [0]);
- if (lopObj==null)
- throw new Exception (string.Format("GOML:Unknown name: {0}", lopParts[0]));
- //TODO: should create private member holding ref of lopObj, and emit
- //a call to FindByName(lopObjName) during #ctor or in a onLoad func or evt handler
- throw new Exception (string.Format("GOML:obj tree ref not yet implemented", lopParts[0]));
- }else
- il.Emit(OpCodes.Ldarg_0); //load sender ref onto the stack
+ if (lopParts.Length > 1) {//should search also for member of es.Source
+ MethodInfo FindByNameMi = typeof(GraphicObject).GetMethod("FindByName");
+ for (int j = 0; j < lopParts.Length - 1; j++) {
+ il.Emit (OpCodes.Ldstr, lopParts[j]);
+ il.Emit(OpCodes.Callvirt, FindByNameMi);
+ }
+ }
int i = lopParts.Length -1;
- MemberInfo lopMbi = lopObj.GetType().GetMember (lopParts[i])[0];
+ MemberInfo[] lopMbis = lopObj.GetType().GetMember (lopParts[i]);
+
+ if (lopMbis.Length<1)
+ throw new Exception (string.Format("CROW BINDING: Member not found '{0}'", lop));
+
OpCode lopSetOC;
dynamic lopSetMbi;
Type lopT = null;
- switch (lopMbi.MemberType) {
+ switch (lopMbis[0].MemberType) {
case MemberTypes.Property:
PropertyInfo lopPi = sourceType.GetProperty (lopParts[i]);
MethodInfo dstMi = lopPi.GetSetMethod ();
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 7f2ce060..77cb6d64 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -255,8 +255,8 @@ namespace Crow
#region Mouse handling
public override void checkHoverWidget (OpenTK.Input.MouseMoveEventArgs e)
{
- if (TopContainer.hoverWidget != this) {
- TopContainer.hoverWidget = this;
+ if (HostContainer.hoverWidget != this) {
+ HostContainer.hoverWidget = this;
onMouseEnter (this, e);
}
foreach (GraphicObject g in Children)
diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs
index 0d4201d9..000d377b 100644
--- a/src/GraphicObjects/ILayoutable.cs
+++ b/src/GraphicObjects/ILayoutable.cs
@@ -10,7 +10,7 @@ namespace Crow
Rectangle getSlot();
Rectangle getBounds();
- IGOLibHost TopContainer { get; }
+ IGOLibHost HostContainer { get; }
void RegisterForLayouting(int layoutType);
void UpdateLayout(LayoutingType layoutType);
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index 0aa48ac7..e7f75fe8 100644
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -15,7 +15,36 @@ namespace Crow
{
Picture _pic;
string _svgSub;
-
+ bool scaled;
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public virtual bool Scaled {
+ get { return scaled; }
+ set {
+ if (scaled == value)
+ return;
+ scaled = value;
+ NotifyValueChanged ("Scaled", scaled);
+ if (_pic == null)
+ return;
+ _pic.Scaled = scaled;
+ registerForGraphicUpdate ();
+ }
+ }
+ bool keepProps;
+ [XmlAttributeAttribute()][DefaultValue(true)]
+ public virtual bool KeepProportions {
+ get { return keepProps; }
+ set {
+ if (keepProps == value)
+ return;
+ keepProps = value;
+ NotifyValueChanged ("KeepProportions", keepProps);
+ if (_pic == null)
+ return;
+ _pic.KeepProportions = keepProps;
+ registerForGraphicUpdate ();
+ }
+ }
[XmlAttributeAttribute("Path")]
public string Path {
get { return _pic == null ? null : _pic.Path; }
@@ -26,7 +55,8 @@ namespace Crow
return;
}
LoadImage (value);
- _pic.KeepProportions = true;
+ _pic.Scaled = scaled;
+ _pic.KeepProportions = keepProps;
} catch (Exception ex) {
Debug.WriteLine (ex.Message);
_pic = null;
@@ -47,23 +77,6 @@ namespace Crow
public Image () : base()
{
}
- public Image (string _imgPath, Rectangle _bounds)
- : base(_bounds)
- {
- LoadImage(_imgPath);
- }
- public Image (string _imgPath)
- : base()
- {
- LoadImage(_imgPath);
- }
-// public Image (System.Drawing.Bitmap _bitmap)
-// : base()
-// {
-// _pic = new BmpPicture ();
-//
-// LoadImage (_bitmap);
-// }
#endregion
#region Image Loading
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index 5ad5474a..460dcbdc 100644
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -35,10 +35,11 @@ namespace Crow
bool _multiline = false;
Color selColor;
Color selFontColor;
- bool _selectable;
- Point mouseLocalPos; //mouse coord in widget space, filled only when clicked
+ Point mouseLocalPos = -1;//mouse coord in widget space, filled only when clicked
int _currentCol; //0 based cursor position in string
int _currentLine;
+ Point _selBegin = -1; //selection start (row,column)
+ Point _selRelease = -1; //selection end (row,column)
double textCursorPos; //cursor position in cairo units in widget client coord.
double SelStartCursorPos = -1;
double SelEndCursorPos = -1;
@@ -55,24 +56,24 @@ namespace Crow
public virtual Color SelectionBackground {
get { return selColor; }
set {
+ if (value == selColor)
+ return;
selColor = value;
+ NotifyValueChanged ("SelectionBackground", selColor);
registerForGraphicUpdate ();
}
}
- [XmlAttributeAttribute()][DefaultValue("Black")]
+ [XmlAttributeAttribute()][DefaultValue("DarkGray")]
public virtual Color SelectionForeground {
get { return selFontColor; }
set {
+ if (value == selFontColor)
+ return;
selFontColor = value;
+ NotifyValueChanged ("SelectionForeground", selFontColor);
registerForGraphicUpdate ();
}
}
- [XmlAttributeAttribute()][DefaultValue(false)]
- public virtual bool Selectable {
- get { return _selectable; }
- set { _selectable = value; }
- }
-
[XmlAttributeAttribute()][DefaultValue(Alignment.LeftCenter)]
public Alignment TextAlignment
{
@@ -90,24 +91,19 @@ namespace Crow
{
if (_text == value)
return;
-
- registerForGraphicUpdate();
- this.RegisterForLayouting ((int)LayoutingType.Sizing);
-
-
+
_text = value;
if (string.IsNullOrEmpty(_text))
_text = "";
lines = getLines;
+
+ //registerForGraphicUpdate();
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);
+ NotifyValueChanged ("Text", Text);
}
}
- [XmlAttributeAttribute()][DefaultValue("droid,10")]
- public Font Font {
- get { return _font; }
- set { _font = value; }
- }
[XmlAttributeAttribute()][DefaultValue(false)]
public bool Multiline
{
@@ -126,7 +122,7 @@ namespace Crow
else if (value > lines [_currentLine].Count ())
_currentCol = lines [_currentLine].Count ();
else
- _currentCol = value;
+ _currentCol = value;
}
}
[XmlIgnore]public int currentLine{
@@ -140,40 +136,71 @@ namespace Crow
_currentLine = value;
}
}
- [XmlIgnore]protected Point selBegin;
- [XmlIgnore]protected Point selRelease;
+
+ [XmlIgnore]public Point SelBegin {
+ get {
+ return _selBegin;
+ }
+ set {
+ if (value == _selBegin)
+ return;
+ _selBegin = value;
+ NotifyValueChanged ("SelectedText", SelectedText);
+ }
+ }
+ [XmlIgnore]public Point SelRelease {
+ get {
+ return _selRelease;
+ }
+ set {
+ if (value == _selRelease)
+ return;
+ _selRelease = value;
+ NotifyValueChanged ("SelectedText", SelectedText);
+ }
+ }
+
[XmlIgnore]protected Point selectionStart //ordered selection start and end positions
{
get {
- return selRelease < 0 || selBegin.Y < selRelease.Y ? selBegin :
- selBegin.Y > selRelease.Y ? selRelease :
- selBegin.X < selRelease.X ? selBegin : selRelease;
+ return SelRelease < 0 || SelBegin.Y < SelRelease.Y ? SelBegin :
+ SelBegin.Y > SelRelease.Y ? SelRelease :
+ SelBegin.X < SelRelease.X ? SelBegin : SelRelease;
}
}
[XmlIgnore]public Point selectionEnd
{
get {
- return selRelease < 0 || selBegin.Y > selRelease.Y ? selBegin :
- selBegin.Y < selRelease.Y ? selRelease :
- selBegin.X > selRelease.X ? selBegin : selRelease;
+ return SelRelease < 0 || SelBegin.Y > SelRelease.Y ? SelBegin :
+ SelBegin.Y < SelRelease.Y ? SelRelease :
+ SelBegin.X > SelRelease.X ? SelBegin : SelRelease;
}
}
- [XmlIgnore]public string selectedText
+ [XmlIgnore]public string SelectedText
{
- get {
- return null;
- //selectionEnd < 0 ? null :
- //Text.Substring(selectionStart, selectionEnd - selectionStart);
+ get {
+
+ if (SelRelease < 0 || SelBegin < 0)
+ return "";
+ if (selectionStart.Y == selectionEnd.Y)
+ return lines [selectionStart.Y].Substring (selectionStart.X, selectionEnd.X - selectionStart.X);
+ string tmp = "";
+ tmp = lines [selectionStart.Y].Substring (selectionStart.X);
+ for (int l = selectionStart.Y + 1; l < selectionEnd.Y; l++) {
+ tmp += Interface.LineBreak + lines [l];
+ }
+ tmp += Interface.LineBreak + lines [selectionEnd.Y].Substring (0, selectionEnd.X);
+ return tmp;
}
}
[XmlIgnore]public bool selectionIsEmpty
- { get { return selRelease < 0; } }
+ { get { return SelRelease < 0; } }
List<string> lines;
List<string> getLines {
get {
return _multiline ?
- Regex.Split (_text, "\r\n|\r|\n").ToList() :
+ Regex.Split (_text, "\r\n|\r|\n|" + @"\\n").ToList() :
new List<string>(new string[] { _text });
}
}
@@ -208,8 +235,8 @@ namespace Crow
} else
lines [l] = lines [l].Remove (selectionStart.X, selectionEnd.X - selectionStart.X);
currentCol = selectionStart.X;
- selBegin = -1;
- selRelease = -1;
+ SelBegin = -1;
+ SelRelease = -1;
}
}
/// <summary>
@@ -389,77 +416,94 @@ namespace Crow
break;
}
}
+ OpenTKGameWindow.currentWindow.CursorVisible = true;
#region draw text cursor
- if (mouseLocalPos > 0)
+ if (mouseLocalPos >= 0)
{
computeTextCursor(gr);
if (SelectionInProgress)
{
- selRelease = new Point(currentCol, currentLine);
- SelEndCursorPos = textCursorPos;
+ if (SelBegin < 0){
+ SelBegin = new Point(currentCol, currentLine);
+ SelStartCursorPos = textCursorPos;
+ SelRelease = -1;
+ }else{
+ SelRelease = new Point(currentCol, currentLine);
+ if (SelRelease == SelBegin)
+ SelRelease = -1;
+ else
+ SelEndCursorPos = textCursorPos;
+ }
}
- else if (selBegin < 0)
- {
- selBegin = new Point(currentCol, currentLine);
- SelStartCursorPos = textCursorPos;
- selRelease = -1;
- }
- else
- computeTextCursorPosition(gr);
- }
- else
+ }else
computeTextCursorPosition(gr);
- if (HasFocus && Selectable)
+
+ #endregion
+
+ //*******************
+ //debug selection
+ if (SelRelease >= 0) {
+ gr.Color = Color.Green;
+ Rectangle R = new Rectangle (
+ rText.X + (int)SelEndCursorPos - 2,
+ rText.Y + (int)(SelRelease.Y * fe.Height),
+ 4,
+ (int)fe.Height);
+ gr.Rectangle (R);
+ gr.Fill ();
+ }
+ if (SelBegin >= 0) {
+ gr.Color = Color.UnmellowYellow;
+ Rectangle R = new Rectangle (
+ rText.X + (int)SelStartCursorPos - 2,
+ rText.Y + (int)(SelBegin.Y * fe.Height),
+ 4,
+ (int)fe.Height);
+ gr.Rectangle (R);
+ gr.Fill ();
+ }
+ //*******************
+ if (HasFocus )
{
//TODO:
- gr.Color = Foreground;
+ gr.SetSourceColor(Foreground);
gr.LineWidth = 1.5;
gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + currentLine * fe.Height));
gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (currentLine + 1) * fe.Height));
gr.Stroke();
}
- #endregion
-
- //*******************
- //debug selection
-// gr.Color = Color.Green;
-// Rectangle R = new Rectangle(
-// rText.X + (int)SelEndCursorPos-10,
-// rText.Y + (int)(selRelease.Y * fe.Height),
-// 20,
-// (int)fe.Height);
-// gr.Rectangle(R);
-// gr.Fill();
-// gr.Color = Color.UnmellowYellow;
-// R = new Rectangle(
-// rText.X + (int)SelStartCursorPos-10,
-// rText.Y + (int)(selBegin.Y * fe.Height),
-// 20,
-// (int)fe.Height);
-// gr.Rectangle(R);
-// gr.Fill();
- //*******************
-
gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
-
+ OpenTKGameWindow.currentWindow.CursorVisible = true;
for (int i = 0; i < lines.Count; i++) {
string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
- if (selRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
- gr.Color = selColor;
- int lineLength = (int)gr.TextExtents (l).XAdvance;
- Rectangle selRect = new Rectangle (
- rText.X,
- rText.Y + (int)(i * fe.Height),
- lineLength,
- (int)fe.Height);
+ int lineLength = (int)gr.TextExtents (l).XAdvance;
+ Rectangle lineRect = new Rectangle (
+ rText.X,
+ rText.Y + (int)(i * fe.Height),
+ lineLength,
+ (int)fe.Height);
+
+// if (TextAlignment == Alignment.Center ||
+// TextAlignment == Alignment.TopCenter ||
+// TextAlignment == Alignment.BottomCenter)
+// lineRect.X += (rText.Width - lineLength) / 2;
+// else if (TextAlignment == Alignment.RightCenter ||
+// TextAlignment == Alignment.TopRight ||
+// TextAlignment == Alignment.BottomRight)
+// lineRect.X += (rText.Width - lineLength);
+
+ if (SelRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
+ gr.SetSourceColor(selColor);
+
+ Rectangle selRect = lineRect ;
int cpStart = (int)SelStartCursorPos,
cpEnd = (int)SelEndCursorPos;
- if (selBegin.Y > selRelease.Y) {
+ if (SelBegin.Y > SelRelease.Y) {
cpStart = cpEnd;
cpEnd = (int)SelStartCursorPos;
}
@@ -477,27 +521,9 @@ namespace Crow
if (string.IsNullOrWhiteSpace (l))
continue;
-
-// double t = rText.Y;
-// gr.LineWidth = 1;
-// gr.Color = Color.Green;
-// gr.MoveTo (rText.X, t);
-// gr.LineTo (rText.X + rText.Width, t);
-// gr.Stroke ();
-// gr.MoveTo (rText.X, t + rText.Height);
-// gr.LineTo (rText.X + rText.Width, t + rText.Height);
-// gr.Stroke ();
-// gr.Rectangle (rText);
-// gr.Fill ();
-//
-// t += fe.Ascent;
-// gr.Color = Color.Red;
-// gr.MoveTo (rText.X, t);
-// gr.LineTo (rText.X + rText.Width, t);
-// gr.Stroke ();
- gr.Color = Foreground;
- gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * i);
+ gr.SetSourceColor(Foreground);
+ gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
#if _WIN32 || _WIN64
gr.ShowText(l.ToUtf8());
@@ -505,65 +531,81 @@ namespace Crow
gr.ShowText (l);
#endif
gr.Fill ();
-
- }
+ }
}
#endregion
#region Mouse handling
- public override void onMouseEnter (object sender, MouseMoveEventArgs e)
+ void updatemouseLocalPos(Point mpos){
+ mouseLocalPos = mpos - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
+ if (mouseLocalPos.X < 0)
+ mouseLocalPos.X = 0;
+ if (mouseLocalPos.Y < 0)
+ mouseLocalPos.Y = 0;
+ }
+ public override void onFocused (object sender, EventArgs e)
{
- // SelectionInProgress = true;
- // mouseLocalPos = e.Position - ScreenCoordBounds.TopLeft - rText.TopLeft;
- // registerForGraphicUpdate();
+ base.onFocused (sender, e);
- base.onMouseEnter (sender, e);
+ SelBegin = new Point(0,0);
+ SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1);
+ OpenTKGameWindow.currentWindow.CursorVisible = true;
+ registerForGraphicUpdate ();
+ Debug.WriteLine("focused:", this.ToString());
}
- public override void onMouseLeave (object sender, MouseMoveEventArgs e)
+ public override void onUnfocused (object sender, EventArgs e)
{
- base.onMouseLeave (sender, e);
+ base.onUnfocused (sender, e);
+
+ SelBegin = -1;
+ SelRelease = -1;
+
+ registerForGraphicUpdate ();
+ Debug.WriteLine("unfocused:", this.ToString());
}
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
- IGOLibHost glh = TopContainer;
- if (glh.activeWidget != this)
- return;
- if (!Selectable)
+ if (!(SelectionInProgress && HasFocus))
return;
-
- SelectionInProgress = true;
- mouseLocalPos = e.Position - ScreenCoordinates(ClientRectangle).TopLeft;
+
+ updatemouseLocalPos (e.Position);
+
registerForGraphicUpdate();
}
- public override void onMouseButtonDown (object sender, MouseButtonEventArgs e)
- {
- if (this.HasFocus && Selectable){
- mouseLocalPos = e.Position - ScreenCoordinates(ClientRectangle).TopLeft;
- selBegin = -1;
- selRelease = -1;
- }else{
-// selBeginPos = 0;
-// selReleasePos = new Point(lines[lines.Count].Length-1, lines.Count-1);
- }
+ public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ {
+ if (this.HasFocus){
+ updatemouseLocalPos (e.Position);
+ SelBegin = -1;
+ SelRelease = -1;
+ SelectionInProgress = true;
+ }
//done at the end to set 'hasFocus' value after testing it
- base.onMouseButtonDown (sender, e);
+ base.onMouseDown (sender, e);
registerForGraphicUpdate();
}
- public override void onMouseButtonUp (object sender, MouseButtonEventArgs e)
+ public override void onMouseUp (object sender, MouseButtonEventArgs e)
{
- base.onMouseButtonUp (sender, e);
+ base.onMouseUp (sender, e);
+
+ if (!SelectionInProgress)
+ return;
+
+ updatemouseLocalPos (e.Position);
SelectionInProgress = false;
+ registerForGraphicUpdate ();
}
#endregion
-
-
+ /// <summary>
+ /// Update Current Column, line and TextCursorPos
+ /// from mouseLocalPos
+ /// </summary>
void computeTextCursor(Context gr)
- {
- //FontExtents fe = gr.FontExtents;
+ {
TextExtents te;
double cPos = 0f;
@@ -604,41 +646,25 @@ namespace Crow
//reset mouseLocalPos
mouseLocalPos = -1;
}
+ /// <summary> Computes offsets in cairo units </summary>
void computeTextCursorPosition(Context gr)
{
- TextExtents te;
-
- double cPos = 0f;
-
- int limit = currentCol;
-
- if (selectionEnd > 0)
- limit = Math.Max(currentCol, selectionEnd.X);
-
- for (int i = 0; i <= limit; i++)
- {
- if (i == currentCol)
- textCursorPos = cPos;
- if (i == selectionStart.X)
- SelStartCursorPos = cPos;
- if (i == selectionEnd.X)
- SelEndCursorPos = cPos;
-
- if (i < lines[currentLine].Length)
- {
- string c = lines [currentLine].Substring (i, 1);
- if (c == "\t")
- c = new string (' ', Interface.TabSize);
- #if _WIN32 || _WIN64
- byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1));
- te = gr.TextExtents(c);
- #elif __linux__
- te = gr.TextExtents(c);
- #endif
- cPos += te.XAdvance;
- }
+ if (SelBegin >= 0)
+ SelStartCursorPos = GetXFromTextPointer (gr, SelBegin);
+ if (SelRelease >= 0)
+ SelEndCursorPos = GetXFromTextPointer (gr, SelRelease);
+ textCursorPos = GetXFromTextPointer (gr, new Point(currentCol, currentLine));
+ }
+ /// <summary> Compute x offset in cairo unit from text position </summary>
+ double GetXFromTextPointer(Context gr, Point pos)
+ {
+ try {
+ string l = lines [pos.Y].Substring (0, pos.X).
+ Replace ("\t", new String (' ', Interface.TabSize));
+ return gr.TextExtents (l).XAdvance;
+ } catch (Exception ex) {
+ return -1;
}
-
- }
+ }
}
}
diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs
index e323ef3e..3e35f102 100644
--- a/src/GraphicObjects/NumericControl.cs
+++ b/src/GraphicObjects/NumericControl.cs
@@ -13,10 +13,6 @@ namespace Crow
public NumericControl(double minimum, double maximum, double step)
: base()
{
- minValue = minimum;
- maxValue = maximum;
- smallStep = step;
- bigStep = step * 5;
}
#endregion
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index 15a209ce..2ed1c06f 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -158,7 +158,7 @@ namespace Crow
public virtual void onPop(object sender, EventArgs e)
{
- IGOLibHost tc = TopContainer;
+ IGOLibHost tc = HostContainer;
if (tc == null)
return;
if (Content != null) {
@@ -172,7 +172,7 @@ namespace Crow
}
public virtual void onUnpop(object sender, EventArgs e)
{
- IGOLibHost tc = TopContainer;
+ IGOLibHost tc = HostContainer;
if (tc == null)
return;
Content.Visible = false;
diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs
index ec0def4d..a4eb2a57 100644
--- a/src/GraphicObjects/Scroller.cs
+++ b/src/GraphicObjects/Scroller.cs
@@ -202,7 +202,7 @@ namespace Crow
public override void registerClipRect ()
{
- TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
+ HostContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
}
public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs
index 7b44a93e..2351669c 100644
--- a/src/GraphicObjects/Slider.cs
+++ b/src/GraphicObjects/Slider.cs
@@ -158,9 +158,9 @@ namespace Crow
}
#region mouse handling
- public override void onMouseButtonDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+ public override void onMouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
{
- base.onMouseButtonDown (sender, e);
+ base.onMouseDown (sender, e);
Rectangle cursInScreenCoord = ScreenCoordinates (cursor + Slot.Position);
if (cursInScreenCoord.ContainsOrIsEqual (e.Position))
@@ -177,9 +177,9 @@ namespace Crow
Value += LargeIncrement;
}
}
- public override void onMouseButtonUp (object sender, OpenTK.Input.MouseButtonEventArgs e)
+ public override void onMouseUp (object sender, OpenTK.Input.MouseButtonEventArgs e)
{
- base.onMouseButtonUp (sender, e);
+ base.onMouseUp (sender, e);
holdCursor = false;
}
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs
index 9fca2fea..f2fdace6 100644
--- a/src/GraphicObjects/TextBox.cs
+++ b/src/GraphicObjects/TextBox.cs
@@ -44,11 +44,6 @@ namespace Crow
get { return base.Focusable; }
set { base.Focusable = value; }
}
- [XmlAttributeAttribute()][DefaultValue(true)]
- public override bool Selectable {
- get { return base.Selectable; }
- set { base.Selectable = value; }
- }
[XmlAttributeAttribute()][DefaultValue("White")]
public override Color Background {
get { return base.Background; }
@@ -107,7 +102,7 @@ namespace Crow
case Key.Escape:
Text = "";
currentCol = 0;
- selRelease = -1;
+ SelRelease = -1;
break;
case Key.Home:
//TODO
@@ -195,8 +190,8 @@ namespace Crow
this.Insert (k);
- selRelease = -1;
- selBegin.X = currentCol;
+ SelRelease = -1;
+ SelBegin = new Point(currentCol, SelBegin.Y);
break;
}
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs
index 50176d6f..d98d296c 100644
--- a/src/GraphicObjects/Window.cs
+++ b/src/GraphicObjects/Window.cs
@@ -83,127 +83,134 @@ namespace Crow
{
base.onMouseMove (sender, e);
- OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
+ OpenTKGameWindow otkgw = HostContainer as OpenTKGameWindow;
- if (otkgw.activeWidget == null) {
- if (Resizable) {
- Direction lastDir = currentDirection;
+ if (e.Mouse.IsButtonDown (MouseButton.Left)) {
+ if (!HasFocus)
+ return;
+
+ otkgw.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
- 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.E;
- else
- currentDirection = Direction.None;
+ int currentLeft = this.Left;
+ int currentTop = this.Top;
+
+ if (currentLeft == 0)
+ currentLeft = this.Slot.Left;
+ if (currentTop == 0)
+ currentTop = this.Slot.Top;
- 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;
- }
- }
+ switch (currentDirection) {
+ case Direction.None:
+ this.Left = currentLeft + e.XDelta;
+ this.Top = currentTop + e.YDelta;
+ break;
+ case Direction.N:
+ this.Top = currentTop + e.YDelta;
+ this.Height -= e.YDelta;
+ break;
+ case Direction.S:
+ this.Height += e.YDelta;
+ break;
+ case Direction.W:
+ this.Left = currentLeft + e.XDelta;
+ this.Width -= e.XDelta;
+ break;
+ case Direction.E:
+ this.Width += e.XDelta;
+ break;
+ case Direction.NW:
+ 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 = currentTop + e.YDelta;
+ this.Height -= e.YDelta;
+ break;
+ case Direction.SW:
+ this.Left = currentLeft + e.XDelta;
+ this.Width -= e.XDelta;
+ this.Height += e.YDelta;
+ break;
+ case Direction.SE:
+ this.Width += e.XDelta;
+ this.Height += e.YDelta;
+ break;
}
return;
}
+ GraphicObject firstFocusableAncestor = otkgw.hoverWidget;
+ while (firstFocusableAncestor != this) {
+ if (firstFocusableAncestor == null)
+ return;
+ if (firstFocusableAncestor.Focusable)
+ return;
+ firstFocusableAncestor = firstFocusableAncestor.Parent as GraphicObject;
+ }
+ if (Resizable) {
+ Direction lastDir = currentDirection;
- if (TopContainer.activeWidget != this)
- 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;
+ 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.E;
+ else
+ currentDirection = Direction.None;
- switch (currentDirection) {
- case Direction.None:
- this.Left = currentLeft + e.XDelta;
- this.Top = currentTop + e.YDelta;
- break;
- case Direction.N:
- this.Top = currentTop + e.YDelta;
- this.Height -= e.YDelta;
- break;
- case Direction.S:
- this.Height += e.YDelta;
- break;
- case Direction.W:
- this.Left = currentLeft + e.XDelta;
- this.Width -= e.XDelta;
- break;
- case Direction.E:
- this.Width += e.XDelta;
- break;
- case Direction.NW:
- 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 = currentTop + e.YDelta;
- this.Height -= e.YDelta;
- break;
- case Direction.SW:
- this.Left = currentLeft + e.XDelta;
- this.Width -= e.XDelta;
- this.Height += e.YDelta;
- break;
- case Direction.SE:
- this.Width += e.XDelta;
- this.Height += e.YDelta;
- break;
- }
+ 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;
+ }
+ }
+ }
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
currentDirection = Direction.None;
- OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
+ OpenTKGameWindow otkgw = HostContainer as OpenTKGameWindow;
otkgw.Cursor = XCursor.Default;
}
@@ -218,7 +225,7 @@ namespace Crow
ILayoutable parent = (sender as GraphicObject).Parent;
while(!(parent is Window))
parent = parent.Parent;
- TopContainer.DeleteWidget (parent as GraphicObject);
+ HostContainer.DeleteWidget (parent as GraphicObject);
}
public override void ResolveBindings ()