def pick_context_cb(self, action):
        if not self.tdw.has_pointer:
            for follower in self.followers:
                if follower.tdw.has_pointer:
                    print "passing %s action to %s" % (action.get_name(), follower)
                    follower.pick_context_cb(action)
                    return
            return
        x, y = self.tdw.get_cursor_in_model_coordinates()
        for idx, layer in reversed(list(enumerate(self.model.layers))):
            if layer.locked:
                continue
            if not layer.visible:
                continue
            alpha = layer.get_alpha (x, y, 5) * layer.effective_opacity
            if alpha > 0.1:
                old_layer = self.model.layer
                self.model.select_layer(idx)
                if self.model.layer != old_layer:
                    self.layerblink_state.activate()

                # find the most recent (last) stroke that touches our picking point
                si = self.model.layer.get_stroke_info_at(x, y)
                if si:
                    self.restore_brush_from_stroke_info(si)
                    self.si = si # FIXME: should be a method parameter?
                    self.strokeblink_state.activate(action)
                return
 def pick_layer_cb(self, action):
     x, y = self.tdw.get_cursor_in_model_coordinates()
     for idx, layer in reversed(list(enumerate(self.model.layers))):
         if layer.locked:
             continue
         if not layer.visible:
             continue
         alpha = layer.get_alpha (x, y, 5) * layer.effective_opacity
         if alpha > 0.1:
             self.model.select_layer(idx)
             self.layerblink_state.activate(action)
             return
     self.model.select_layer(0)
     self.layerblink_state.activate(action)