Changeset 5366


Ignore:
Timestamp:
08/02/09 07:36:21 (4 years ago)
Author:
werner
Message:
  • 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
Location:
developers/werner/fped
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/fped/TODO

    r5365 r5366  
    1818 
    1919Style: 
    20 - stack elements (2a): all inactive below all active 
    21 - stack elements (2b): unselected below selected 
    2220- make column of entry field greedily consume all unallocated space 
    2321 
  • developers/werner/fped/gui_inst.c

    r5365 r5366  
    141141        d = dist_point(pos, self->u.end)/scale; 
    142142        return d > VEC_EYE_R ? -1 : d; 
     143} 
     144 
     145 
     146/* 
     147 * The circles at a vector's tip enjoy the highest selection priority. However, 
     148 * users will probably also expected a click on a nicely exposed stem to work. 
     149 * So we give it second look after having exhausted all other options. 
     150 */ 
     151 
     152unit_type gui_dist_vec_fallback(struct inst *self, struct coord pos, 
     153    unit_type scale) 
     154{ 
     155        unit_type d; 
     156 
     157        d = dist_line(pos, self->base, self->u.end)/scale; 
     158        return d > SELECT_R ? -1 : d; 
    143159} 
    144160 
  • developers/werner/fped/gui_inst.h

    r5364 r5366  
    3232 
    3333unit_type gui_dist_vec(struct inst *self, struct coord pos, unit_type scale); 
     34unit_type gui_dist_vec_fallback(struct inst *self, struct coord pos, 
     35    unit_type scale); 
    3436unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale); 
    3537unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale); 
  • developers/werner/fped/inst.c

    r5365 r5366  
    130130        deselect_outside(); 
    131131        edit_nothing(); 
     132        selected_inst = NULL; 
    132133        FOR_INST_PRIOS_DOWN(prio) { 
    133                 selected_inst = NULL; 
    134134                for (inst = insts[prio]; inst; inst = inst->next) { 
    135135                        if (!inst->active || !inst->ops->distance) 
     
    141141                        } 
    142142                } 
    143                 if (selected_inst) { 
    144                         set_path(1); 
    145                         if (selected_inst->ops->select) 
    146                                 selected_inst->ops->select(selected_inst); 
    147                         return 1; 
     143                if (selected_inst) 
     144                        goto selected; 
     145        } 
     146 
     147        /* give vectors a second chance */ 
     148 
     149        for (inst = insts[ip_vec]; inst; inst = inst->next) { 
     150                if (!inst->active) 
     151                        continue; 
     152                dist = gui_dist_vec_fallback(inst, pos, ctx->scale); 
     153                if (dist >= 0 && (!selected_inst || best_dist > dist)) { 
     154                        selected_inst = inst; 
     155                        best_dist = dist; 
    148156                } 
    149157        } 
    150         return 0; 
     158         
     159        if (!selected_inst) 
     160                return 0; 
     161 
     162selected: 
     163        set_path(1); 
     164        if (selected_inst->ops->select) 
     165                selected_inst->ops->select(selected_inst); 
     166        return 1; 
    151167} 
    152168 
     
    616632 
    617633        FOR_INSTS_UP(prio, inst) 
    618                 if (inst->ops->draw) 
     634                if (!inst->active && inst->ops->draw) 
    619635                        inst->ops->draw(inst, ctx); 
     636        FOR_INSTS_UP(prio, inst) 
     637                if (inst->active && inst != selected_inst && inst->ops->draw) 
     638                        inst->ops->draw(inst, ctx); 
     639        if (selected_inst && selected_inst->ops->draw) 
     640                selected_inst->ops->draw(selected_inst, ctx); 
    620641} 
    621642 
Note: See TracChangeset for help on using the changeset viewer.