示例#1
0
void KankerApp::onMouseMove(double x, double y) {

  if (NULL != gui) {
    gui->onMouseMove(x, y);
  }

  switch (state) {
    case KSTATE_CHAR_INPUT_DRAWING: {
      if (is_mouse_pressed) {
        if (x < (painter.width() - gui_width)) {
          kanker_glyph->addPoint(x, y, 0.0f);
        }
      }
      break;
    }
    case KSTATE_CHAR_EDIT: {
      if (kanker_glyph) {
        
        if (is_mouse_inside_char && is_mouse_pressed) {
          char_offset_x = x - mouse_down_x;
          char_offset_y = y - mouse_down_y;
          return;
        }

        if (IS_INSIDE(x, y, kanker_glyph->min_x, kanker_glyph->min_y, kanker_glyph->width, kanker_glyph->height)) {
          is_mouse_inside_char = true;
        }
        else { 
          is_mouse_inside_char = false;
        }

        if (is_mouse_inside_advance && is_mouse_pressed) {
          advance_x = x;
        }
        
        if (IS_INSIDE(x, y, gui_width, 0, (advance_x - gui_width), 50)) {
          is_mouse_inside_advance = true;
        }
        else {
          is_mouse_inside_advance = false;
        }
      }
      break;
    }
    default: { 
      break;
    }
  }
}
示例#2
0
void KankerApp::onMousePress(double x, double y, int bt, int mods) {

  is_mouse_pressed = true;

  if (NULL != gui) {
    gui->onMousePress(x, y, bt, mods);
  }

  switch (state) {
    case KSTATE_CHAR_INPUT_DRAWING: {
      if (x < (painter.width() - gui_width)) {
        kanker_glyph->onStartLine();
        kanker_glyph->addPoint(x, y, 0.0f);
      }
      break;
    }
    case KSTATE_CHAR_EDIT: { 
      if (IS_INSIDE(x, y, kanker_glyph->min_x, kanker_glyph->min_y, kanker_glyph->width, kanker_glyph->height)) {
        is_mouse_inside_char = true;
        mouse_down_x = x;
        mouse_down_y = y;
      } 
      else {
        is_mouse_inside_char = false;
      }

      break;
    }
    default: { 
      break;
    }
  }
}
示例#3
0
文件: event.c 项目: Shoes3/shoes3
/*
 * Yes it does seem to be expensive but events happen at user speed (slow)
 * Recursive when it finds a new slot (canvas) 
 * Beware all these non-widgets are canvas based! Return Qnil if no non-natives
 * match the x,y. Return the matching non-native (not it's containing canvas/slot)
*/
VALUE shoes_event_find_psuedo (VALUE self, int x, int y, VALUE *hitobj) {
    long i;
    int ox = x, oy = y;
    VALUE v = Qnil;  //  v is t/f, Qtrue/Qnil
    shoes_canvas *self_t;
    Data_Get_Struct(self, shoes_canvas, self_t);

    if (ORIGIN(self_t->place)) {
        oy = y + self_t->slot->scrolly;
        ox = x - self_t->place.ix + self_t->place.dx;
        oy = oy - (self_t->place.iy + self_t->place.dy);
        if (oy < self_t->slot->scrolly || ox < 0 || oy > self_t->slot->scrolly + self_t->place.ih || ox > self_t->place.iw)
            return Qnil;
    }
    if (ATTR(self_t->attr, hidden) != Qtrue) {
        if (self_t->app->canvas == self) // when we are the app's slot
            y -= self_t->slot->scrolly;

        if (IS_INSIDE(self_t, x, y)) {
            // TODO:  something
            VALUE click = ATTR(self_t->attr, click);
            if (!NIL_P(click)) {
                if (ORIGIN(self_t->place))
                    y += self_t->slot->scrolly;
                //hoes_safe_block(self, click, rb_ary_new3(4, INT2NUM(button), INT2NUM(x), INT2NUM(y), mods));
            }
        }

        for (i = RARRAY_LEN(self_t->contents) - 1; i >= 0; i--) {
            VALUE ele = rb_ary_entry(self_t->contents, i);
            if (rb_obj_is_kind_of(ele, cCanvas)) {
                v = shoes_event_find_psuedo(ele, ox, oy, hitobj);
            } else if (rb_obj_is_kind_of(ele, cTextBlock)) {
                v = shoes_textblock_event_is_here(ele, ox, oy);
                *hitobj = ele;
            } else if (rb_obj_is_kind_of(ele, cImage)) {
                v = shoes_image_event_is_here(ele, ox, oy);
                *hitobj = ele;
            } else if (rb_obj_is_kind_of(ele, cSvg)) {
                v = shoes_svg_event_is_here(ele, ox, oy);
                *hitobj  = ele;
            
            } else if (rb_obj_is_kind_of(ele, cPlot)) {
                v = shoes_plot_event_is_here(ele, ox, oy);
                *hitobj = ele;
            
            } else if (rb_obj_is_kind_of(ele, cShape)) {
                v = shoes_shape_event_is_here(ele, ox, oy);
                *hitobj = ele;
            }

            if (!NIL_P(v))
                return v;
        }
    }

    return Qnil;
}