Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5366 - developers/werner/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-08-02 07:36:21 +0200 (Sun, 02 Aug 2009)
New Revision: 5366

Modified:
   developers/werner/fped/TODO
   developers/werner/fped/gui_inst.c
   developers/werner/fped/gui_inst.h
   developers/werner/fped/inst.c
Log:
- the stem of a vector can now also be selected, but at low priority
- active elements are drawn above inactive ones
- the selected element is always drawn on top



Modified: developers/werner/fped/TODO
===================================================================
--- developers/werner/fped/TODO 2009-08-02 05:17:39 UTC (rev 5365)
+++ developers/werner/fped/TODO 2009-08-02 05:36:21 UTC (rev 5366)
@@ -17,8 +17,6 @@
 - eliminate duplicate instances
 
 Style:
-- stack elements (2a): all inactive below all active
-- stack elements (2b): unselected below selected
 - make column of entry field greedily consume all unallocated space
 
 Code cleanup:

Modified: developers/werner/fped/gui_inst.c
===================================================================
--- developers/werner/fped/gui_inst.c   2009-08-02 05:17:39 UTC (rev 5365)
+++ developers/werner/fped/gui_inst.c   2009-08-02 05:36:21 UTC (rev 5366)
@@ -143,6 +143,22 @@
 }
 
 
+/*
+ * The circles at a vector's tip enjoy the highest selection priority. However,
+ * users will probably also expected a click on a nicely exposed stem to work.
+ * So we give it second look after having exhausted all other options.
+ */
+
+unit_type gui_dist_vec_fallback(struct inst *self, struct coord pos,
+    unit_type scale)
+{
+       unit_type d;
+
+       d = dist_line(pos, self->base, self->u.end)/scale;
+       return d > SELECT_R ? -1 : d;
+}
+
+
 void gui_draw_vec(struct inst *self, struct draw_ctx *ctx)
 {
        struct coord from = translate(ctx, self->base);

Modified: developers/werner/fped/gui_inst.h
===================================================================
--- developers/werner/fped/gui_inst.h   2009-08-02 05:17:39 UTC (rev 5365)
+++ developers/werner/fped/gui_inst.h   2009-08-02 05:36:21 UTC (rev 5366)
@@ -31,6 +31,8 @@
 struct coord canvas_to_coord(const struct draw_ctx *ctx, int x, int y);
 
 unit_type gui_dist_vec(struct inst *self, struct coord pos, unit_type scale);
+unit_type gui_dist_vec_fallback(struct inst *self, struct coord pos,
+    unit_type scale);
 unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_pad(struct inst *self, struct coord pos, unit_type scale);

Modified: developers/werner/fped/inst.c
===================================================================
--- developers/werner/fped/inst.c       2009-08-02 05:17:39 UTC (rev 5365)
+++ developers/werner/fped/inst.c       2009-08-02 05:36:21 UTC (rev 5366)
@@ -129,8 +129,8 @@
 
        deselect_outside();
        edit_nothing();
+       selected_inst = NULL;
        FOR_INST_PRIOS_DOWN(prio) {
-               selected_inst = NULL;
                for (inst = insts[prio]; inst; inst = inst->next) {
                        if (!inst->active || !inst->ops->distance)
                                continue;
@@ -140,14 +140,30 @@
                                best_dist = dist;
                        }
                }
-               if (selected_inst) {
-                       set_path(1);
-                       if (selected_inst->ops->select)
-                               selected_inst->ops->select(selected_inst);
-                       return 1;
+               if (selected_inst)
+                       goto selected;
+       }
+
+       /* give vectors a second chance */
+
+       for (inst = insts[ip_vec]; inst; inst = inst->next) {
+               if (!inst->active)
+                       continue;
+               dist = gui_dist_vec_fallback(inst, pos, ctx->scale);
+               if (dist >= 0 && (!selected_inst || best_dist > dist)) {
+                       selected_inst = inst;
+                       best_dist = dist;
                }
        }
-       return 0;
+       
+       if (!selected_inst)
+               return 0;
+
+selected:
+       set_path(1);
+       if (selected_inst->ops->select)
+               selected_inst->ops->select(selected_inst);
+       return 1;
 }
 
 
@@ -615,8 +631,13 @@
        struct inst *inst;
 
        FOR_INSTS_UP(prio, inst)
-               if (inst->ops->draw)
+               if (!inst->active && inst->ops->draw)
                        inst->ops->draw(inst, ctx);
+       FOR_INSTS_UP(prio, inst)
+               if (inst->active && inst != selected_inst && inst->ops->draw)
+                       inst->ops->draw(inst, ctx);
+       if (selected_inst && selected_inst->ops->draw)
+               selected_inst->ops->draw(selected_inst, ctx);
 }
 
 




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to