Re: Please don't drop support for Curve



Ignoring the tone of your email and trying to make a point of that creating your own widget is relatively easy, I created an example showing a skeleton of a Gamma curve widget in Python and GooCanvas for your convenience. The example shows the power of using GooCanvas for doing the widget definition and how easy it is to create signals that notify that user of the widget of application changes. Note, that I have not added resize support. To get that you need to listen for the "configure" event.

"""
An example gtk widget using the goo canvas.
Dov Grobgeld <dov grobgeld gmail com>
Sunday 2011-05-08 00:20
This file is in the public domain
"""
import gobject
import gtk
import goocanvas
import math
class GooGammaCurve(goocanvas.Canvas):
    __gsignals__ = {
        "gamma-changed": (gobject.SIGNAL_RUN_LAST,
                          gobject.TYPE_NONE,          # Return type
                          (gobject.TYPE_FLOAT, ))     # Signature of signal
        }

    def __init__(self):
        """Build the goocanvas widget and internal members"""
        goocanvas.Canvas.__init__(self)
        self.height,self.width = 100,100
        self.set_size_request(self.width,self.height)
        root = self.get_root_item()
        self.margin=10
        m,w,h = self.margin, self.width, self.height
        self.axis = goocanvas.Group(parent=root)
        self.axis_x = goocanvas.Polyline(parent=self.axis,
                                         points = goocanvas.Points([(m,h-m),
                                                                    (w-m,h-m)]),
                                         end_arrow=True)
        self.axis_y = goocanvas.Polyline(parent=self.axis,
                                         points = goocanvas.Points([(m,h-m),
                                                                    (m,m)]),
                                         end_arrow=True)
        graph = [(0.01*i,
                  0.01*i) for i in range(100)]
        points = [self.curve_point_to_canvas(p) for p in graph]
        curve = goocanvas.Points(points)
        self.curve = goocanvas.Polyline(parent=root,
                                        points=curve,
                                        stroke_color="red")
        
        wx,wy = self.curve_point_to_canvas((0.5,0.5))
        s=7
        s2=s/2
        self.handle = goocanvas.Rect(parent=root,
                                     x=wx-s2,
                                     y=wy-s2,
                                     width=s,
                                     height=s,
                                     stroke_color='black',
                                     fill_color='pink')
        self.dragging=False
        self.setup_item_signals(self.handle)

    def rect_center(self, item):
        """Get the center coordinate of a rectangle"""
        bbox = item.get_bounds()
        return (0.5*(bbox.x1+bbox.x2),
                0.5*(bbox.y1+bbox.y2))

    def setup_item_signals (self, item):
        item.connect ("motion_notify_event", self.on_motion_notify)
        item.connect ("button_press_event", self.on_button_press)
        item.connect ("button_release_event", self.on_button_release)

    def on_motion_notify (self, item, target, event):
        if (self.dragging == True) and (event.state & gtk.gdk.BUTTON1_MASK):
            new_x = event.x
            new_y = event.y
            # only move in y direction
            item.translate (0, new_y - self.drag_y)
            # Recalc and notify about gamma
            wx,wy = self.canvas_to_curve_point(self.rect_center(item))
            gamma = math.log(wy)/math.log(0.5)
            self.set_gamma(gamma)
        return True
    
    def on_button_press (self, item, target, event):
        if event.button == 1:
            self.drag_x = event.x
            self.drag_y = event.y
            fleur = gtk.gdk.Cursor (gtk.gdk.FLEUR)
            canvas = item.get_canvas ()
            canvas.pointer_grab (item,
                                 gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_RELEASE_MASK,
                                 fleur,
                                 event.time)
            self.dragging = True
            return True
        return False

    def on_button_release (self, item, target, event):
        canvas = item.get_canvas ()
        canvas.pointer_ungrab (item, event.time)
        self.dragging = False

    def curve_point_to_canvas(self,
                              p):
        """Translate coordinates in world coordinates to canvas
        coordinates"""
        m = self.margin
        w = self.width
        h = self.height
        return (m+p[0]*(w-3*m),
                h-m-p[1]*(h-3*m))

    def canvas_to_curve_point(self,
                              c):
        """Translate canvas  coordinates to world coordinates"""
        m = self.margin
        w = self.width
        h = self.height
        return ((c[0]-m)/(w-3*m),
                -(c[1]-h+m)/(h-3*m))

    def set_gamma(self,gamma):
        """Change the gamma curve and emit a signal that gamma
        has been changed"""
        self.gamma = gamma
        graph = [(0.01*i,
                  (0.01*i)**gamma) for i in range(100)]
        points = [self.curve_point_to_canvas(p) for p in graph]
        curve = goocanvas.Points(points)
        self.curve.set_properties(points=curve)
        self.emit('gamma-changed', gamma)
           
class TestGammaCurve(gtk.Window):
    def on_gamma_changed(self,widget,gamma):
        self.label.set_properties(label="gamma=%.2f"%gamma)
        
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.connect("delete_event", gtk.main_quit)
        vbox = gtk.VBox()
        self.add(vbox)
        self.goo_curve = GooGammaCurve()
        self.goo_curve.connect("gamma-changed",
                               self.on_gamma_changed)
        vbox.pack_start(self.goo_curve, True, True, 0)
        self.label = gtk.Label('gamma')
        vbox.pack_start(self.label, True, True, 0)
        self.show_all()

test = TestGammaCurve()
gtk.main()


On Wed, May 4, 2011 at 21:15, Charlie De <charliecoeli yahoo com> wrote:
Don't be funny, Dov. As you know, GTK+ is tied through pyGTK to Python, and Python is not used by pro coders only, it also gets used by non-programmers as well. People like me. People who appreciate relatively easy solutions. And it was difficult enough getting to grips with Python, Glade and pyGTK, but it was doable. And that is the limit of what can be expected of a user like me. I looked at the link you provided, and it's anything but "very easy".

Anyhow, my last post. As I said in my reply to David, I think you're a bunch of bums. You might be good at coding, but you have no appreciation of how to serve a broad user base. To think that you'd so casually remove a unique widget that can't be replaced by any other, on such flimsy justification, and then simply say "learn to do it yourself" - it beggars belief. If this were a commercial project, you'd be out of your job by next week, I could guarantee you that.

Take it easy, campers, and thanks for nothing.

Charlie


From: Dov Grobgeld <dov grobgeld gmail com>
To: Charlie De <charliecoeli yahoo com>
Cc: gtk-devel-list gnome org
Sent: Wed, May 4, 2011 4:37:55 PM
Subject: Re: Please don't drop support for Curve

I suggest that you learn how to create your own widget. A widget like GtkCurve is very easy to develop by subclassing one of the canvas widgets, e.g. GooCanvas. Or do it directly through Cairo on a GtkDrawingArea. This is described here:

http://live.gnome.org/Vala/CustomWidgetSamples

Regards,
Dov

On Wed, May 4, 2011 at 13:22, Charlie De <charliecoeli yahoo com> wrote:
Hello all,


I've joined up with this list for one single reason: to ask the developers to
re-consider and reverse their decision to deprecate and eventually remove the
Curve widget from GTK+.

Recently, I learnt to create Python scripts, and with the help of Glade, created
a GUI to ImageMagick routines, for my own "proprietary photo editor". The Curve
widget was absolutely central to this endeavour. The only downside is that it is
basic and not very well developed.

To me, the reasons given for this widget being deprecated, that it isn't very
useful and only appeals to a minority of users, sounds disingenuous and hurtful
to the easy usefulness of GTK+. What do you expect users to do in its absence?
Do you really expect users to go breaking their knuckles to try and create a
curve dialog with a drawing area? How could you see such "progress" as anything
but a step backwards?

So please, hear a busy user who has taken the trouble of registering here to
offer feedback: do not drop this essensial component of GTK+, and instead of
deprecating it, continue its development. You can drop Gamma Curve if you like,
which is too idiosyncratic to be of much use. What is needed instead is the
Curve offering point data - the points on the curve that the user creates -
being able to be read and manipulated by other widgets, such as the numerical
scroll boxes. (Rather like the Curves dialog in Photoshop.) And I'm sure there
are other improvements that could be made.

If on the other hand you insist on dropping the Curve, then when the time comes
I guess I'll have to switch to another widget toolset, whichever will still be
offering a Curve interface element. I can't even begin to image how long it
would take me to create the widget manually - it frankly strikes me as an insane
and pointless effort.

Thank you for your attention and best wishes with your continuing good work.
What you have created in GTK+ (and pyGTK) is greatly appreciated and wonderfully
useful.

All the best,

Charlie
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]