texture_progress.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*************************************************************************/
  2. /* texture_progress.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "texture_progress.h"
  31. #include "core/engine.h"
  32. void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
  33. under = p_texture;
  34. update();
  35. minimum_size_changed();
  36. }
  37. Ref<Texture> TextureProgress::get_under_texture() const {
  38. return under;
  39. }
  40. void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) {
  41. over = p_texture;
  42. update();
  43. if (under.is_null()) {
  44. minimum_size_changed();
  45. }
  46. }
  47. Ref<Texture> TextureProgress::get_over_texture() const {
  48. return over;
  49. }
  50. void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
  51. ERR_FAIL_INDEX(p_margin, 4);
  52. stretch_margin[p_margin] = p_size;
  53. update();
  54. minimum_size_changed();
  55. }
  56. int TextureProgress::get_stretch_margin(Margin p_margin) const {
  57. ERR_FAIL_INDEX_V(p_margin, 4, 0);
  58. return stretch_margin[p_margin];
  59. }
  60. void TextureProgress::set_nine_patch_stretch(bool p_stretch) {
  61. nine_patch_stretch = p_stretch;
  62. update();
  63. minimum_size_changed();
  64. }
  65. bool TextureProgress::get_nine_patch_stretch() const {
  66. return nine_patch_stretch;
  67. }
  68. Size2 TextureProgress::get_minimum_size() const {
  69. if (nine_patch_stretch)
  70. return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]);
  71. else if (under.is_valid())
  72. return under->get_size();
  73. else if (over.is_valid())
  74. return over->get_size();
  75. else if (progress.is_valid())
  76. return progress->get_size();
  77. return Size2(1, 1);
  78. }
  79. void TextureProgress::set_progress_texture(const Ref<Texture> &p_texture) {
  80. progress = p_texture;
  81. update();
  82. minimum_size_changed();
  83. }
  84. Ref<Texture> TextureProgress::get_progress_texture() const {
  85. return progress;
  86. }
  87. void TextureProgress::set_tint_under(const Color &p_tint) {
  88. tint_under = p_tint;
  89. update();
  90. }
  91. Color TextureProgress::get_tint_under() const {
  92. return tint_under;
  93. }
  94. void TextureProgress::set_tint_progress(const Color &p_tint) {
  95. tint_progress = p_tint;
  96. update();
  97. }
  98. Color TextureProgress::get_tint_progress() const {
  99. return tint_progress;
  100. }
  101. void TextureProgress::set_tint_over(const Color &p_tint) {
  102. tint_over = p_tint;
  103. update();
  104. }
  105. Color TextureProgress::get_tint_over() const {
  106. return tint_over;
  107. }
  108. Point2 TextureProgress::unit_val_to_uv(float val) {
  109. if (progress.is_null())
  110. return Point2();
  111. if (val < 0)
  112. val += 1;
  113. if (val > 1)
  114. val -= 1;
  115. Point2 p = get_relative_center();
  116. // Minimal version of Liang-Barsky clipping algorithm
  117. float angle = (val * Math_TAU) - Math_PI * 0.5;
  118. Point2 dir = Vector2(Math::cos(angle), Math::sin(angle));
  119. float t1 = 1.0;
  120. float cp;
  121. float cq;
  122. float cr;
  123. float edgeLeft = 0.0;
  124. float edgeRight = 1.0;
  125. float edgeBottom = 0.0;
  126. float edgeTop = 1.0;
  127. for (int edge = 0; edge < 4; edge++) {
  128. if (edge == 0) {
  129. if (dir.x > 0)
  130. continue;
  131. cp = -dir.x;
  132. cq = -(edgeLeft - p.x);
  133. } else if (edge == 1) {
  134. if (dir.x < 0)
  135. continue;
  136. cp = dir.x;
  137. cq = (edgeRight - p.x);
  138. } else if (edge == 2) {
  139. if (dir.y > 0)
  140. continue;
  141. cp = -dir.y;
  142. cq = -(edgeBottom - p.y);
  143. } else if (edge == 3) {
  144. if (dir.y < 0)
  145. continue;
  146. cp = dir.y;
  147. cq = (edgeTop - p.y);
  148. }
  149. cr = cq / cp;
  150. if (cr >= 0 && cr < t1)
  151. t1 = cr;
  152. }
  153. return (p + t1 * dir);
  154. }
  155. Point2 TextureProgress::get_relative_center() {
  156. if (progress.is_null())
  157. return Point2();
  158. Point2 p = progress->get_size() / 2;
  159. p += rad_center_off;
  160. p.x /= progress->get_width();
  161. p.y /= progress->get_height();
  162. p.x = CLAMP(p.x, 0, 1);
  163. p.y = CLAMP(p.y, 0, 1);
  164. return p;
  165. }
  166. void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) {
  167. Vector2 texture_size = p_texture->get_size();
  168. Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]);
  169. Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]);
  170. Rect2 src_rect = Rect2(Point2(), texture_size);
  171. Rect2 dst_rect = Rect2(Point2(), get_size());
  172. if (p_ratio < 1.0) {
  173. // Drawing a partially-filled 9-patch is a little tricky -
  174. // texture is divided by 3 sections toward fill direction,
  175. // then middle section is stretching while the other two aren't.
  176. double width_total = 0.0;
  177. double width_texture = 0.0;
  178. double first_section_size = 0.0;
  179. double last_section_size = 0.0;
  180. switch (mode) {
  181. case FILL_LEFT_TO_RIGHT:
  182. case FILL_RIGHT_TO_LEFT: {
  183. width_total = dst_rect.size.x;
  184. width_texture = texture_size.x;
  185. first_section_size = topleft.x;
  186. last_section_size = bottomright.x;
  187. } break;
  188. case FILL_TOP_TO_BOTTOM:
  189. case FILL_BOTTOM_TO_TOP: {
  190. width_total = dst_rect.size.y;
  191. width_texture = texture_size.y;
  192. first_section_size = topleft.y;
  193. last_section_size = bottomright.y;
  194. } break;
  195. case FILL_BILINEAR_LEFT_AND_RIGHT: {
  196. // TODO: Implement
  197. } break;
  198. case FILL_BILINEAR_TOP_AND_BOTTOM: {
  199. // TODO: Implement
  200. } break;
  201. case FILL_CLOCKWISE:
  202. case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
  203. case FILL_COUNTER_CLOCKWISE: {
  204. // Those modes are circular, not relevant for nine patch
  205. } break;
  206. }
  207. double width_filled = width_total * p_ratio;
  208. double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size);
  209. middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
  210. last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
  211. width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
  212. switch (mode) {
  213. case FILL_LEFT_TO_RIGHT: {
  214. src_rect.size.x = width_texture;
  215. dst_rect.size.x = width_filled;
  216. bottomright.x = last_section_size;
  217. } break;
  218. case FILL_RIGHT_TO_LEFT: {
  219. src_rect.position.x += src_rect.size.x - width_texture;
  220. src_rect.size.x = width_texture;
  221. dst_rect.position.x += width_total - width_filled;
  222. dst_rect.size.x = width_filled;
  223. topleft.x = last_section_size;
  224. } break;
  225. case FILL_TOP_TO_BOTTOM: {
  226. src_rect.size.y = width_texture;
  227. dst_rect.size.y = width_filled;
  228. bottomright.y = last_section_size;
  229. } break;
  230. case FILL_BOTTOM_TO_TOP: {
  231. src_rect.position.y += src_rect.size.y - width_texture;
  232. src_rect.size.y = width_texture;
  233. dst_rect.position.y += width_total - width_filled;
  234. dst_rect.size.y = width_filled;
  235. topleft.y = last_section_size;
  236. } break;
  237. case FILL_BILINEAR_LEFT_AND_RIGHT: {
  238. // TODO: Implement
  239. } break;
  240. case FILL_BILINEAR_TOP_AND_BOTTOM: {
  241. // TODO: Implement
  242. } break;
  243. case FILL_CLOCKWISE:
  244. case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
  245. case FILL_COUNTER_CLOCKWISE: {
  246. // Those modes are circular, not relevant for nine patch
  247. } break;
  248. }
  249. }
  250. p_texture->get_rect_region(dst_rect, src_rect, dst_rect, src_rect);
  251. RID ci = get_canvas_item();
  252. VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, true, p_modulate);
  253. }
  254. void TextureProgress::_notification(int p_what) {
  255. const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
  256. switch (p_what) {
  257. case NOTIFICATION_DRAW: {
  258. if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) {
  259. if (under.is_valid()) {
  260. draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0, tint_under);
  261. }
  262. if (progress.is_valid()) {
  263. draw_nine_patch_stretched(progress, mode, get_as_ratio(), tint_progress);
  264. }
  265. if (over.is_valid()) {
  266. draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0, tint_over);
  267. }
  268. } else {
  269. if (under.is_valid())
  270. draw_texture(under, Point2(), tint_under);
  271. if (progress.is_valid()) {
  272. Size2 s = progress->get_size();
  273. switch (mode) {
  274. case FILL_LEFT_TO_RIGHT: {
  275. Rect2 region = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y));
  276. draw_texture_rect_region(progress, region, region, tint_progress);
  277. } break;
  278. case FILL_RIGHT_TO_LEFT: {
  279. Rect2 region = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
  280. draw_texture_rect_region(progress, region, region, tint_progress);
  281. } break;
  282. case FILL_TOP_TO_BOTTOM: {
  283. Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio()));
  284. draw_texture_rect_region(progress, region, region, tint_progress);
  285. } break;
  286. case FILL_BOTTOM_TO_TOP: {
  287. Rect2 region = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio()));
  288. draw_texture_rect_region(progress, region, region, tint_progress);
  289. } break;
  290. case FILL_CLOCKWISE:
  291. case FILL_COUNTER_CLOCKWISE:
  292. case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
  293. float val = get_as_ratio() * rad_max_degrees / 360;
  294. if (val == 1) {
  295. Rect2 region = Rect2(Point2(), s);
  296. draw_texture_rect_region(progress, region, region, tint_progress);
  297. } else if (val != 0) {
  298. Array pts;
  299. float direction = mode == FILL_COUNTER_CLOCKWISE ? -1 : 1;
  300. float start;
  301. if (mode == FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE) {
  302. start = rad_init_angle / 360 - val / 2;
  303. } else {
  304. start = rad_init_angle / 360;
  305. }
  306. float end = start + direction * val;
  307. pts.append(start);
  308. pts.append(end);
  309. float from = MIN(start, end);
  310. float to = MAX(start, end);
  311. for (int i = 0; i < 12; i++)
  312. if (corners[i] > from && corners[i] < to)
  313. pts.append(corners[i]);
  314. pts.sort();
  315. Vector<Point2> uvs;
  316. Vector<Point2> points;
  317. uvs.push_back(get_relative_center());
  318. points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
  319. for (int i = 0; i < pts.size(); i++) {
  320. Point2 uv = unit_val_to_uv(pts[i]);
  321. if (uvs.find(uv) >= 0)
  322. continue;
  323. uvs.push_back(uv);
  324. points.push_back(Point2(uv.x * s.x, uv.y * s.y));
  325. }
  326. Vector<Color> colors;
  327. colors.push_back(tint_progress);
  328. draw_polygon(points, colors, uvs, progress);
  329. }
  330. if (Engine::get_singleton()->is_editor_hint()) {
  331. Point2 p = progress->get_size();
  332. p.x *= get_relative_center().x;
  333. p.y *= get_relative_center().y;
  334. p = p.floor();
  335. draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
  336. draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
  337. }
  338. } break;
  339. case FILL_BILINEAR_LEFT_AND_RIGHT: {
  340. Rect2 region = Rect2(Point2(s.x / 2 - s.x * get_as_ratio() / 2, 0), Size2(s.x * get_as_ratio(), s.y));
  341. draw_texture_rect_region(progress, region, region, tint_progress);
  342. } break;
  343. case FILL_BILINEAR_TOP_AND_BOTTOM: {
  344. Rect2 region = Rect2(Point2(0, s.y / 2 - s.y * get_as_ratio() / 2), Size2(s.x, s.y * get_as_ratio()));
  345. draw_texture_rect_region(progress, region, region, tint_progress);
  346. } break;
  347. default:
  348. draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), tint_progress);
  349. }
  350. }
  351. if (over.is_valid())
  352. draw_texture(over, Point2(), tint_over);
  353. }
  354. } break;
  355. }
  356. }
  357. void TextureProgress::set_fill_mode(int p_fill) {
  358. ERR_FAIL_INDEX(p_fill, 9);
  359. mode = (FillMode)p_fill;
  360. update();
  361. }
  362. int TextureProgress::get_fill_mode() {
  363. return mode;
  364. }
  365. void TextureProgress::set_radial_initial_angle(float p_angle) {
  366. while (p_angle > 360)
  367. p_angle -= 360;
  368. while (p_angle < 0)
  369. p_angle += 360;
  370. rad_init_angle = p_angle;
  371. update();
  372. }
  373. float TextureProgress::get_radial_initial_angle() {
  374. return rad_init_angle;
  375. }
  376. void TextureProgress::set_fill_degrees(float p_angle) {
  377. rad_max_degrees = CLAMP(p_angle, 0, 360);
  378. update();
  379. }
  380. float TextureProgress::get_fill_degrees() {
  381. return rad_max_degrees;
  382. }
  383. void TextureProgress::set_radial_center_offset(const Point2 &p_off) {
  384. rad_center_off = p_off;
  385. update();
  386. }
  387. Point2 TextureProgress::get_radial_center_offset() {
  388. return rad_center_off;
  389. }
  390. void TextureProgress::_bind_methods() {
  391. ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgress::set_under_texture);
  392. ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgress::get_under_texture);
  393. ClassDB::bind_method(D_METHOD("set_progress_texture", "tex"), &TextureProgress::set_progress_texture);
  394. ClassDB::bind_method(D_METHOD("get_progress_texture"), &TextureProgress::get_progress_texture);
  395. ClassDB::bind_method(D_METHOD("set_over_texture", "tex"), &TextureProgress::set_over_texture);
  396. ClassDB::bind_method(D_METHOD("get_over_texture"), &TextureProgress::get_over_texture);
  397. ClassDB::bind_method(D_METHOD("set_fill_mode", "mode"), &TextureProgress::set_fill_mode);
  398. ClassDB::bind_method(D_METHOD("get_fill_mode"), &TextureProgress::get_fill_mode);
  399. ClassDB::bind_method(D_METHOD("set_tint_under", "tint"), &TextureProgress::set_tint_under);
  400. ClassDB::bind_method(D_METHOD("get_tint_under"), &TextureProgress::get_tint_under);
  401. ClassDB::bind_method(D_METHOD("set_tint_progress", "tint"), &TextureProgress::set_tint_progress);
  402. ClassDB::bind_method(D_METHOD("get_tint_progress"), &TextureProgress::get_tint_progress);
  403. ClassDB::bind_method(D_METHOD("set_tint_over", "tint"), &TextureProgress::set_tint_over);
  404. ClassDB::bind_method(D_METHOD("get_tint_over"), &TextureProgress::get_tint_over);
  405. ClassDB::bind_method(D_METHOD("set_radial_initial_angle", "mode"), &TextureProgress::set_radial_initial_angle);
  406. ClassDB::bind_method(D_METHOD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
  407. ClassDB::bind_method(D_METHOD("set_radial_center_offset", "mode"), &TextureProgress::set_radial_center_offset);
  408. ClassDB::bind_method(D_METHOD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
  409. ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgress::set_fill_degrees);
  410. ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
  411. ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgress::set_stretch_margin);
  412. ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgress::get_stretch_margin);
  413. ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgress::set_nine_patch_stretch);
  414. ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch);
  415. ADD_GROUP("Textures", "texture_");
  416. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_under_texture", "get_under_texture");
  417. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_over_texture", "get_over_texture");
  418. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_progress_texture", "get_progress_texture");
  419. ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom), Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode");
  420. ADD_GROUP("Tint", "tint_");
  421. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under");
  422. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_over"), "set_tint_over", "get_tint_over");
  423. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_progress"), "set_tint_progress", "get_tint_progress");
  424. ADD_GROUP("Radial Fill", "radial_");
  425. ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_radial_initial_angle", "get_radial_initial_angle");
  426. ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_fill_degrees", "get_fill_degrees");
  427. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "radial_center_offset"), "set_radial_center_offset", "get_radial_center_offset");
  428. ADD_GROUP("Stretch", "stretch_");
  429. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "nine_patch_stretch"), "set_nine_patch_stretch", "get_nine_patch_stretch");
  430. ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_LEFT);
  431. ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_TOP);
  432. ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_RIGHT);
  433. ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_BOTTOM);
  434. BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT);
  435. BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT);
  436. BIND_ENUM_CONSTANT(FILL_TOP_TO_BOTTOM);
  437. BIND_ENUM_CONSTANT(FILL_BOTTOM_TO_TOP);
  438. BIND_ENUM_CONSTANT(FILL_CLOCKWISE);
  439. BIND_ENUM_CONSTANT(FILL_COUNTER_CLOCKWISE);
  440. BIND_ENUM_CONSTANT(FILL_BILINEAR_LEFT_AND_RIGHT);
  441. BIND_ENUM_CONSTANT(FILL_BILINEAR_TOP_AND_BOTTOM);
  442. BIND_ENUM_CONSTANT(FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE);
  443. }
  444. TextureProgress::TextureProgress() {
  445. mode = FILL_LEFT_TO_RIGHT;
  446. rad_init_angle = 0;
  447. rad_center_off = Point2();
  448. rad_max_degrees = 360;
  449. set_mouse_filter(MOUSE_FILTER_PASS);
  450. nine_patch_stretch = false;
  451. stretch_margin[MARGIN_LEFT] = 0;
  452. stretch_margin[MARGIN_RIGHT] = 0;
  453. stretch_margin[MARGIN_BOTTOM] = 0;
  454. stretch_margin[MARGIN_TOP] = 0;
  455. tint_under = tint_progress = tint_over = Color(1, 1, 1);
  456. }