Re: RFC: Model-View-Controller



On Fri, 2011-11-11 at 15:55 +0100, Benjamin Otte wrote:
[Talking about GtkButton]
> And it'd have those "Controllers":
> (- Hover)
> - Click
> - Activate
> (- Focus)
> - KeyPress/Release

I just took a quick look at ClutterClickAction and ClutterDragAction.
They are certainly interesting.  I wonder how things would look once you
have widgets with complex behavior.

Let me reintroduce something I talked about during the Desktop Summit -
form languages and pattern languages.  The way I see things, you want to
encapsulate common actions as controllers, and common drawing idioms as
views, so we can compose them into final widgets.  I.e. you want to make
the form language finer-grained and richer, so it will allow us to
implement patterns more easily.

Think of an app that lets you select graphical objects and move them by
dragging.  How would you implement something that needs both clicks
(quick press/release with no movement) and drags (long
press-move-release)?  Do you need to somehow tie together a
ClickController and a DragController, or do you have a generic
PressMoveReleaseController, on top of which you implement the other two?

As you said, for GTK+ it probably makes sense to start by abstracting
out simple views and controllers.  Exercise: do that in a branch for
buttons and clicks, and refactor GtkButton and GtkScrollbar's arrow
"buttons" to use that.  See how the code looks.  Then you may want to
tackle GtkEntry's clickable icons in terms of the click controller as
well.

A much harder view/controller would be for selectable text.  GtkEntry
picks out the first PangoLayoutLine from the PangoLayout, and runs
pango_layout_line_x_to_index() on it.  However, GtkLabel does a direct
pango_layout_xy_to_index().  No idea why GtkEntry does it like that;
maybe it wants to explicitly ignore everything but the first "line" in
the text.  GtkEntry has scrolling offsets, but GtkLabel doesn't... etc.
No idea how a SelectableTextController would look :)

  Federico



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