aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-01-20 06:35:36 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-01-20 06:35:36 +0100
commit33d043a799a4dc1e57eabd8999bddbf0543f0fbc (patch)
tree144a98401c858cf12e1d5ad6cf9165bcda88c360 /src
parent4a7050f54b5da5bbf813ea1fd5329f567930d65c (diff)
debug ColorPicker
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/ColorSelector.cs30
-rw-r--r--src/GraphicObjects/HueSelector.cs12
-rw-r--r--src/GraphicObjects/SaturationValueSelector.cs15
3 files changed, 16 insertions, 41 deletions
diff --git a/src/GraphicObjects/ColorSelector.cs b/src/GraphicObjects/ColorSelector.cs
index 13a588ce..672eea73 100644
--- a/src/GraphicObjects/ColorSelector.cs
+++ b/src/GraphicObjects/ColorSelector.cs
@@ -54,36 +54,10 @@ namespace Crow
mousePos = mPos - r.Position;
mousePos.X = Math.Max(cb.X, mousePos.X);
- mousePos.X = Math.Min(cb.Right-1, mousePos.X);
+ mousePos.X = Math.Min(cb.Right, mousePos.X);
mousePos.Y = Math.Max(cb.Y, mousePos.Y);
- mousePos.Y = Math.Min(cb.Bottom-1, mousePos.Y);
+ mousePos.Y = Math.Min(cb.Bottom, mousePos.Y);
}
-// virtual protected void updateColorFromPicking(bool redraw = true){
-// SelectedColor = new SolidColor(getPixelAt(mousePos.X, mousePos.Y));
-//
-// updateHSV ();
-//
-// NotifyValueChanged ("R", R);
-// NotifyValueChanged ("G", G);
-// NotifyValueChanged ("B", B);
-// NotifyValueChanged ("A", A);
-//
-// if (redraw)
-// RegisterForRedraw ();
-// }
-//
-// protected Color getPixelAt(int x, int y){
-// if (bmp == null)
-// return Color.Transparent;
-//
-// int ptr = y * Slot.Width * 4 + x * 4;
-//
-// return new Color(
-// (double)bmp[ptr + 2] * colDiv,
-// (double)bmp[ptr + 1] * colDiv,
-// (double)bmp[ptr] * colDiv,
-// (double)bmp[ptr + 3] * colDiv);
-// }
}
}
diff --git a/src/GraphicObjects/HueSelector.cs b/src/GraphicObjects/HueSelector.cs
index ec0a6f2c..ba1d856b 100644
--- a/src/GraphicObjects/HueSelector.cs
+++ b/src/GraphicObjects/HueSelector.cs
@@ -53,9 +53,9 @@ namespace Crow
if (hue == value)
return;
hue = value;
-
notifyHueChanged ();
updateMousePosFromHue ();
+ RegisterForRedraw ();
}
}
protected override void onDraw (Cairo.Context gr)
@@ -95,11 +95,11 @@ namespace Crow
ctx.SetSourceColor (Color.White);
Rectangle r = ClientRectangle;
if (Orientation == Orientation.Horizontal) {
- r.Width = 5;
- r.X = mousePos.X;
+ r.Width = 4;
+ r.X = mousePos.X - 2;
} else {
- r.Height = 5;
- r.Y = mousePos.Y;
+ r.Height = 4;
+ r.Y = mousePos.Y - 2;
}
CairoHelpers.CairoRectangle (ctx, r, 2);
@@ -126,13 +126,13 @@ namespace Crow
else
hue = (double)mousePos.Y / (double)ClientRectangle.Height;
notifyHueChanged ();
+ RegisterForRedraw ();
}
void updateMousePosFromHue(){
if (Orientation == Orientation.Horizontal)
mousePos.X = (int)Math.Floor(hue * (double)ClientRectangle.Width);
else
mousePos.Y = (int)Math.Floor(hue * (double)ClientRectangle.Height);
- CurrentInterface.EnqueueForRepaint (this);
}
void notifyHueChanged(){
NotifyValueChanged ("Hue", hue);
diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs
index b71fa7ef..a1ddc5b4 100644
--- a/src/GraphicObjects/SaturationValueSelector.cs
+++ b/src/GraphicObjects/SaturationValueSelector.cs
@@ -42,7 +42,7 @@ namespace Crow
NotifyValueChanged ("V", v);
mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
- CurrentInterface.EnqueueForRepaint (this);
+ RegisterForRedraw ();
}
}
[XmlAttributeAttribute()]
@@ -54,7 +54,8 @@ namespace Crow
s = value;
NotifyValueChanged ("S", s);
mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
- CurrentInterface.EnqueueForRepaint (this);
+
+ RegisterForRedraw ();
}
}
protected override void onDraw (Cairo.Context gr)
@@ -62,8 +63,6 @@ namespace Crow
base.onDraw (gr);
Rectangle r = ClientRectangle;
- Rectangle rGrad = r;
- rGrad.Inflate (-1);
if (Foreground != null) {//TODO:test if null should be removed
Foreground.SetAsSource (gr, r);
@@ -74,13 +73,13 @@ namespace Crow
Crow.Gradient grad = new Gradient (Gradient.Type.Horizontal);
grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 1, 1, 1)));
grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 1, 1, 0)));
- grad.SetAsSource (gr, rGrad);
+ grad.SetAsSource (gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill();
grad = new Gradient (Gradient.Type.Vertical);
grad.Stops.Add (new Gradient.ColorStop (0, new Color (0, 0, 0, 0)));
grad.Stops.Add (new Gradient.ColorStop (1, new Color (0, 0, 0, 1)));
- grad.SetAsSource (gr, rGrad);
+ grad.SetAsSource (gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill();
}
@@ -95,7 +94,7 @@ namespace Crow
ctx.Translate (rb.X, rb.Y);
ctx.SetSourceColor (Color.White);
- ctx.Arc (mousePos.X, mousePos.Y, 3.0, 0, Math.PI * 2.0);
+ ctx.Arc (mousePos.X, mousePos.Y, 3.5, 0, Math.PI * 2.0);
ctx.LineWidth = 1.0;
ctx.Stroke ();
@@ -111,6 +110,8 @@ namespace Crow
v = 1.0 - (double)mousePos.Y / (double)cb.Height;
NotifyValueChanged ("S", s);
NotifyValueChanged ("V", v);
+
+ RegisterForRedraw ();
}
public override void OnLayoutChanges (LayoutingType layoutType)
{