From: Holger Schemel Date: Thu, 17 Dec 1998 01:18:43 +0000 (+0100) Subject: rnd-19981217-3 X-Git-Tag: 1.3.0^2~53 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5ed4de42ced8e7dce5b786ba3d5fd1a6f6a7d7f6;p=rocksndiamonds.git rnd-19981217-3 --- diff --git a/src/buttons.c b/src/buttons.c index 7ac61e36..75bcf616 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1761,16 +1761,13 @@ void HandleGadgets(int mx, int my, int button) static struct GadgetInfo *gi = NULL; static unsigned long pressed_delay = 0; -#if 0 - static boolean pressed = FALSE; -#endif - struct GadgetInfo *new_gi; boolean gadget_pressed; boolean gadget_pressed_repeated; - boolean gadget_moving_inside; - boolean gadget_moving_outside; + boolean gadget_moving; + boolean gadget_moving_off_borders; boolean gadget_released; + boolean gadget_released_off_borders; if (gadget_list_first_entry == NULL) return; @@ -1778,15 +1775,17 @@ void HandleGadgets(int mx, int my, int button) new_gi = getGadgetInfoFromMousePosition(mx,my); gadget_pressed = - (button != 0 && gi == NULL && new_gi != NULL); + (button != 0 && gi == NULL && new_gi != NULL && !motion_status); gadget_pressed_repeated = (button != 0 && gi != NULL && new_gi == gi); - gadget_moving_inside = + gadget_moving = (button != 0 && gi != NULL && new_gi == gi && motion_status); - gadget_moving_outside = + gadget_moving_off_borders = (button != 0 && gi != NULL && new_gi != gi && motion_status); gadget_released = (button == 0 && gi != NULL && new_gi == gi); + gadget_released_off_borders = + (button == 0 && gi != NULL && new_gi != gi); if (gadget_pressed) gi = new_gi; @@ -1827,7 +1826,7 @@ void HandleGadgets(int mx, int my, int button) gi->callback(gi); } - if (gadget_moving_inside) + if (gadget_moving) { if (gi->state == GD_BUTTON_UNPRESSED) DrawGadget(gi, TRUE, TRUE); @@ -1839,7 +1838,7 @@ void HandleGadgets(int mx, int my, int button) gi->callback(gi); } - if (gadget_moving_outside) + if (gadget_moving_off_borders) { if (gi->state == GD_BUTTON_PRESSED) DrawGadget(gi, FALSE, TRUE); @@ -1848,7 +1847,8 @@ void HandleGadgets(int mx, int my, int button) gi->event.type = GD_EVENT_MOVING; gi->event.off_borders = TRUE; - if (gi->event_mask & GD_EVENT_MOVING) + if (gi->event_mask & GD_EVENT_MOVING && + gi->event_mask & GD_EVENT_OFF_BORDERS) gi->callback(gi); } @@ -1863,111 +1863,15 @@ void HandleGadgets(int mx, int my, int button) gi->callback(gi); } - if (button == 0) - gi = NULL; - - - -#if 0 - if (button) + if (gadget_released_off_borders) { - if (!motion_status) /* mouse button just pressed */ - { - if (new_gi != NULL) - { - gi = new_gi; - gi->state = GD_BUTTON_PRESSED; - gi->event.type = GD_EVENT_PRESSED; - gi->event.button = button; - DrawGadget(gi, TRUE, TRUE); - - /* initialize delay counter */ - pressed_delay = 0; - DelayReached(&pressed_delay, GADGET_FRAME_DELAY); - - - printf("new gadget pressed\n"); - - - if (gi->event_mask & GD_EVENT_PRESSED) - gi->callback(gi); - - pressed = TRUE; - } - } - else /* mouse movement with pressed mouse button */ - { - if (new_gi != gi && gi != NULL) - { - if (pressed) - DrawGadget(gi, FALSE, TRUE); - gi->state = GD_BUTTON_UNPRESSED; - gi->event.type = GD_EVENT_MOVING; - - - printf("outside gadget\n"); - - - - - if (gi->event_mask & GD_EVENT_MOVING) - gi->callback(gi); - - pressed = FALSE; - } - else if (new_gi == gi && gi != NULL) - { - if (!pressed) - DrawGadget(gi, TRUE, TRUE); - gi->state = GD_BUTTON_PRESSED; - gi->event.type = GD_EVENT_MOVING; - - - printf("inside gadget\n"); - - - - - if (gi->event_mask & GD_EVENT_MOVING) - gi->callback(gi); - - pressed = TRUE; - } - } - - if (gi != NULL && - gi->event_mask & GD_EVENT_PRESSED_REPEATED && - gi->state == GD_BUTTON_PRESSED && - DelayReached(&pressed_delay, GADGET_FRAME_DELAY)) - { - printf("gadget pressed (repeated)\n"); - + gi->event.type = GD_EVENT_RELEASED; - gi->callback(gi); - } + if (gi->event_mask & GD_EVENT_RELEASED && + gi->event_mask & GD_EVENT_OFF_BORDERS) + gi->callback(gi); } - else /* mouse button just released */ - { - if (new_gi == gi && gi != NULL && pressed) - { - gi->state = GD_BUTTON_UNPRESSED; - gi->event.type = GD_EVENT_RELEASED; - DrawGadget(gi, FALSE, TRUE); - - - printf("gadget released\n"); - - - - if (gi->event_mask & GD_EVENT_RELEASED) - gi->callback(gi); - } + if (button == 0) gi = NULL; - pressed = FALSE; - } -#endif - - - } diff --git a/src/buttons.h b/src/buttons.h index 255c8243..bafbd2a2 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -287,6 +287,7 @@ int CheckCountButtons(int, int, int); #define GD_EVENT_RELEASED (1<<1) #define GD_EVENT_MOVING (1<<2) #define GD_EVENT_REPEATED (1<<3) +#define GD_EVENT_OFF_BORDERS (1<<4) /* gadget button states */ #define GD_BUTTON_UNPRESSED 0 diff --git a/src/editor.c b/src/editor.c index 88b7d7dc..bf3704bd 100644 --- a/src/editor.c +++ b/src/editor.c @@ -551,32 +551,6 @@ static void CreateControlButtons() } } - - -#if 0 - -static void test1(struct GadgetInfo *gi) -{ - int event_type = gi->event.type; - - printf("HandleControlButtons: (%d,%d) (%d,%d) [%d] ", - gi->x, gi->y, - gi->event.x, gi->event.y, gi->event.button); - - if (event_type == GD_EVENT_PRESSED) - printf("GD_EVENT_PRESSED\n"); - else if (event_type == GD_EVENT_RELEASED) - printf("GD_EVENT_RELEASED\n"); - else if (event_type == GD_EVENT_MOVING) - printf("GD_EVENT_MOVING\n"); - else - printf("?\n"); -} - -#endif - - - static void CreateCounterButtons(int counter_id) { int i; @@ -622,7 +596,9 @@ static void CreateDrawingAreas() struct GadgetInfo *gi; unsigned long event_mask; - event_mask = GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING; + event_mask = + GD_EVENT_PRESSED | GD_EVENT_RELEASED | GD_EVENT_MOVING | + GD_EVENT_OFF_BORDERS; gi = CreateGadget(GDI_CUSTOM_ID, ED_CTRL_ID_DRAWING_LEVEL, GDI_X, SX, @@ -1926,12 +1902,6 @@ static void CopyLevelToUndoBuffer() for(x=0; x lev_fieldx - 1 ? lev_fieldx - 1 : lx); + ly = (ly < 0 ? 0 : ly > lev_fieldy - 1 ? lev_fieldy - 1 : ly); + sx = lx - level_xpos; + sy = ly - level_ypos; + if (button_press_event) started_inside_drawing_area = inside_drawing_area; if (!started_inside_drawing_area) return; - printf("%d,%d, %d,%d, %d,%d.\n", - gi->event.x, gi->event.y, sx, sy, lx, ly); - if ((!button && !button_release_event) || sx > lev_fieldx || sy > lev_fieldy || (sx == 0 && level_xpos<0) || @@ -2119,127 +2091,6 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) } } - - -#if 0 - -static void HandlePressedControlButtons() -{ - static unsigned long button_delay = 0; - int i; - - /* buttons with action when held pressed */ - int gadget_id[] = - { - ED_CTRL_ID_WRAP_UP, - ED_CTRL_ID_WRAP_LEFT, - ED_CTRL_ID_WRAP_RIGHT, - ED_CTRL_ID_WRAP_DOWN, - ED_CTRL_ID_SCORE_DOWN, - ED_CTRL_ID_SCORE_UP, - -1 - }; - - if (!DelayReached(&button_delay, GADGET_FRAME_DELAY)) - return; - - for (i=0; gadget_id[i] != -1; i++) - { - int id = gadget_id[i]; - int state = level_editor_gadget[id]->state; - int button = level_editor_gadget[id]->event.button; - int step = (button == 1 ? 1 : button == 2 ? 5 : 10); - - if (state != GD_BUTTON_PRESSED) - continue; - - switch (id) - { - case ED_CTRL_ID_WRAP_LEFT: - if (level_xpos >= 0) - { - if (lev_fieldx < 2*SCR_FIELDX - 2) - break; - - level_xpos -= step; - if (level_xpos <- 1) - level_xpos = -1; - if (button == 1) - ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT); - else - DrawMiniLevel(level_xpos, level_ypos); - } - break; - - case ED_CTRL_ID_WRAP_RIGHT: - if (level_xpos <= lev_fieldx - 2*SCR_FIELDX) - { - if (lev_fieldx < 2*SCR_FIELDX - 2) - break; - - level_xpos += step; - if (level_xpos > lev_fieldx - 2*SCR_FIELDX + 1) - level_xpos = lev_fieldx - 2*SCR_FIELDX + 1; - if (button == 1) - ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT); - else - DrawMiniLevel(level_xpos, level_ypos); - } - break; - - case ED_CTRL_ID_WRAP_UP: - if (level_ypos >= 0) - { - if (lev_fieldy < 2*SCR_FIELDY - 2) - break; - - level_ypos -= step; - if (level_ypos < -1) - level_ypos = -1; - if (button == 1) - ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN); - else - DrawMiniLevel(level_xpos, level_ypos); - } - break; - - case ED_CTRL_ID_WRAP_DOWN: - if (level_ypos <= lev_fieldy - 2*SCR_FIELDY) - { - if (lev_fieldy < 2*SCR_FIELDY - 2) - break; - - level_ypos += step; - if (level_ypos > lev_fieldy - 2*SCR_FIELDY + 1) - level_ypos = lev_fieldy - 2*SCR_FIELDY + 1; - if (button == 1) - ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP); - else - DrawMiniLevel(level_xpos, level_ypos); - } - break; - - case ED_CTRL_ID_SCORE_DOWN: - case ED_CTRL_ID_SCORE_UP: - *gadget_score_value += (id == ED_CTRL_ID_SCORE_DOWN ? -step : step); - if (*gadget_score_value < 0) - *gadget_score_value = 0; - else if (*gadget_score_value > 255) - *gadget_score_value = 255; - - DrawCounterValueField(ED_COUNTER_SCORE, *gadget_score_value); - break; - - default: - break; - } - } -} - -#endif - - - static void HandleCounterButtons(struct GadgetInfo *gi) { int id = gi->custom_id;