multi_converter_mode_select.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <input/input.h>
  4. #include <gui/gui.h>
  5. #include "multi_converter_definitions.h"
  6. #include "multi_converter_units.h"
  7. //
  8. // aux draw function for units offsets and draw stuff
  9. //
  10. void multi_converter_mode_select_draw_destination_offset(
  11. uint8_t x,
  12. uint8_t y,
  13. int8_t d,
  14. Canvas* const canvas,
  15. const MultiConverterState* multi_converter_state);
  16. void multi_converter_mode_select_draw_selected_unit(
  17. uint8_t x,
  18. uint8_t y,
  19. MultiConverterUnitType unit_type,
  20. Canvas* const canvas);
  21. //
  22. // draw the main SELECT view with the current multi_converter_state values
  23. //
  24. void multi_converter_mode_select_draw(
  25. Canvas* const canvas,
  26. const MultiConverterState* multi_converter_state);
  27. //
  28. // reset the SELECT mode view, showing as "pre-selected" the current working units
  29. //
  30. void multi_converter_mode_select_reset(MultiConverterState* const multi_converter_state);
  31. //
  32. // exit from SELECT mode and go back to display view, if save_changes == 1 use the current SELECT view info
  33. // to modify the current selected units and reset the views properly (usually if the ORIGIN unit has been
  34. // changed, reset everything; otherwise just trigger the convert function with a new DESTINATION)
  35. //
  36. // currently this function DON'T CHECK invalid unit relations (the navigation and display functions will
  37. // prevent weird behaviours, so for now we're trusting the selected_unit_orig/dest_type values)
  38. //
  39. // returns an enum code MultiConverterDisplayTrigger based on doing nothing (cancel), triggering the display
  40. // convert method or reseting the whole display mode (when fully changing the units)
  41. //
  42. // notice the MODE CHANGE itself is not done here but in the main loop (outside the call) via the ModeTrigger enum element
  43. //
  44. MultiConverterModeTrigger multi_converter_mode_select_exit(
  45. uint8_t save_changes,
  46. MultiConverterState* const multi_converter_state);
  47. //
  48. // switch between selecting the ORIGIN or the DESTINATION unit on DISPLAY mode (since there're only
  49. // two options, both left/right arrow keys acts as toggles, no "direction" required)
  50. //
  51. void multi_converter_mode_select_switch(MultiConverterState* const multi_converter_state);
  52. //
  53. // change the selected unit on SELECTED mode, using the select_orig flag to check if we're switching the
  54. // ORIGIN or the DESTINATION unit; the DIRECTION (up or down to travel the array) is set as a param
  55. //
  56. // when switching the ORIGIN one, reset the DESTINATION to the first valid unit (if the current one is not
  57. // valid anymore); when switching the DESTINATION one, an allowed_function() check is performed in order to
  58. // properly set a valid destination unit.
  59. //
  60. // (notice the draw step also perform which units are valid to display, so no worries about that here)
  61. //
  62. void multi_converter_mode_select_change_unit(
  63. int8_t direction,
  64. MultiConverterState* const multi_converter_state);