gui_over.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * gui_over.h - GUI, canvas overlays
  3. *
  4. * Written 2009 by Werner Almesberger
  5. * Copyright 2009 by Werner Almesberger
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef GUI_OVER_H
  13. #define GUI_OVER_H
  14. /*
  15. * Dynamic changes around the pointer are affected by the following events:
  16. *
  17. * - enter: enter a circle where we're hovering
  18. * - leave: leave a circle where we've been hovering
  19. * - begin: begin dragging
  20. * - move: move with or without dragging
  21. * - end: end dragging
  22. * - reset: we got a redraw, just drop everything
  23. *
  24. * We have the following states:
  25. *
  26. * - NOTHING: neither hovering nor dragging
  27. * - HOVER: we're hovering but not dragging
  28. * - DRAG: we're dragging but not hovering, e.g., when searching for a place to
  29. * end the drag
  30. * - BOTH: we're dragging and hovering
  31. *
  32. * Both drag and hover save the area being changed and restore it after a
  33. * change. We have to make sure the save/draw/restore operations are properly
  34. * sequenced. We call the hover area H, the drag area D. This is the state
  35. * machine that does the sequencing:
  36. *
  37. * NOTHING (saved: -)
  38. * enter -> save H, draw H, HOVER
  39. * begin -> save D, draw D, DRAG
  40. * move -> NOTHING
  41. * reset -> NOTHING
  42. *
  43. * HOVER: (saved: H)
  44. * leave -> restore H, NOTHING
  45. * begin -> save D, draw D, BOTH
  46. * move -> HOVER
  47. * reset -> drop H, NOTHING
  48. *
  49. * DRAG: (saved: D)
  50. * end -> restore D, NOTHING
  51. * enter -> restore D, save H, draw H, save D, draw D, BOTH
  52. * move -> restore D, update, save D, draw D, DRAG
  53. * reset -> drop D, NOTHING
  54. *
  55. * BOTH: (saved: D on top of H)
  56. * end -> restore D, HOVER
  57. * leave -> restore D, restore H, save D, draw D, DRAG
  58. * move -> restore D, update, save D, draw D, BOTH
  59. * reset -> drop D, drop H, NOTHING
  60. */
  61. #include "coord.h"
  62. #include "inst.h"
  63. void over_enter(struct pix_buf *(*save_and_draw)(void *user), void *user);
  64. void over_leave(void);
  65. void over_begin(struct pix_buf *(*save_and_draw)(void *user, struct coord pos),
  66. void *user, struct coord pos);
  67. void over_move(struct coord pos);
  68. void over_end(void);
  69. void over_reset(void);
  70. #endif /* !GUI_OVER_H */