constants.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. * @license
  3. * Visual Blocks Editor
  4. *
  5. * Copyright 2016 Google Inc.
  6. * https://developers.google.com/blockly/
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Blockly constants.
  22. * @author fenichel@google.com (Rachel Fenichel)
  23. */
  24. 'use strict';
  25. goog.provide('Blockly.constants');
  26. /**
  27. * Number of pixels the mouse must move before a drag starts.
  28. */
  29. Blockly.DRAG_RADIUS = 5;
  30. /**
  31. * Maximum misalignment between connections for them to snap together.
  32. */
  33. Blockly.SNAP_RADIUS = 20;
  34. /**
  35. * Delay in ms between trigger and bumping unconnected block out of alignment.
  36. */
  37. Blockly.BUMP_DELAY = 250;
  38. /**
  39. * Number of characters to truncate a collapsed block to.
  40. */
  41. Blockly.COLLAPSE_CHARS = 30;
  42. /**
  43. * Length in ms for a touch to become a long press.
  44. */
  45. Blockly.LONGPRESS = 750;
  46. /**
  47. * Prevent a sound from playing if another sound preceded it within this many
  48. * miliseconds.
  49. */
  50. Blockly.SOUND_LIMIT = 100;
  51. /**
  52. * The richness of block colours, regardless of the hue.
  53. * Must be in the range of 0 (inclusive) to 1 (exclusive).
  54. */
  55. Blockly.HSV_SATURATION = 0.45;
  56. /**
  57. * The intensity of block colours, regardless of the hue.
  58. * Must be in the range of 0 (inclusive) to 1 (exclusive).
  59. */
  60. Blockly.HSV_VALUE = 0.65;
  61. /**
  62. * Sprited icons and images.
  63. */
  64. Blockly.SPRITE = {
  65. width: 96,
  66. height: 124,
  67. url: 'sprites.png'
  68. };
  69. // Constants below this point are not intended to be changed.
  70. /**
  71. * Required name space for SVG elements.
  72. * @const
  73. */
  74. Blockly.SVG_NS = 'http://www.w3.org/2000/svg';
  75. /**
  76. * Required name space for HTML elements.
  77. * @const
  78. */
  79. Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml';
  80. /**
  81. * ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
  82. * @const
  83. */
  84. Blockly.INPUT_VALUE = 1;
  85. /**
  86. * ENUM for a left-facing value output. E.g. 'random fraction'.
  87. * @const
  88. */
  89. Blockly.OUTPUT_VALUE = 2;
  90. /**
  91. * ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
  92. * @const
  93. */
  94. Blockly.NEXT_STATEMENT = 3;
  95. /**
  96. * ENUM for an up-facing block stack. E.g. 'break out of loop'.
  97. * @const
  98. */
  99. Blockly.PREVIOUS_STATEMENT = 4;
  100. /**
  101. * ENUM for an dummy input. Used to add field(s) with no input.
  102. * @const
  103. */
  104. Blockly.DUMMY_INPUT = 5;
  105. /**
  106. * ENUM for left alignment.
  107. * @const
  108. */
  109. Blockly.ALIGN_LEFT = -1;
  110. /**
  111. * ENUM for centre alignment.
  112. * @const
  113. */
  114. Blockly.ALIGN_CENTRE = 0;
  115. /**
  116. * ENUM for right alignment.
  117. * @const
  118. */
  119. Blockly.ALIGN_RIGHT = 1;
  120. /**
  121. * ENUM for no drag operation.
  122. * @const
  123. */
  124. Blockly.DRAG_NONE = 0;
  125. /**
  126. * ENUM for inside the sticky DRAG_RADIUS.
  127. * @const
  128. */
  129. Blockly.DRAG_STICKY = 1;
  130. /**
  131. * ENUM for inside the non-sticky DRAG_RADIUS, for differentiating between
  132. * clicks and drags.
  133. * @const
  134. */
  135. Blockly.DRAG_BEGIN = 1;
  136. /**
  137. * ENUM for freely draggable (outside the DRAG_RADIUS, if one applies).
  138. * @const
  139. */
  140. Blockly.DRAG_FREE = 2;
  141. /**
  142. * Lookup table for determining the opposite type of a connection.
  143. * @const
  144. */
  145. Blockly.OPPOSITE_TYPE = [];
  146. Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE] = Blockly.OUTPUT_VALUE;
  147. Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE] = Blockly.INPUT_VALUE;
  148. Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT] = Blockly.PREVIOUS_STATEMENT;
  149. Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT] = Blockly.NEXT_STATEMENT;
  150. /**
  151. * ENUM for toolbox and flyout at top of screen.
  152. * @const
  153. */
  154. Blockly.TOOLBOX_AT_TOP = 0;
  155. /**
  156. * ENUM for toolbox and flyout at bottom of screen.
  157. * @const
  158. */
  159. Blockly.TOOLBOX_AT_BOTTOM = 1;
  160. /**
  161. * ENUM for toolbox and flyout at left of screen.
  162. * @const
  163. */
  164. Blockly.TOOLBOX_AT_LEFT = 2;
  165. /**
  166. * ENUM for toolbox and flyout at right of screen.
  167. * @const
  168. */
  169. Blockly.TOOLBOX_AT_RIGHT = 3;