DecoratorTiledBoxInstancer.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "precompiled.h"
  29. #include "DecoratorTiledBoxInstancer.h"
  30. #include "DecoratorTiledBox.h"
  31. namespace Rml {
  32. namespace Core {
  33. DecoratorTiledBoxInstancer::DecoratorTiledBoxInstancer()
  34. {
  35. RegisterTileProperty("top-left-image", false);
  36. RegisterTileProperty("top-right-image", false);
  37. RegisterTileProperty("bottom-left-image", false);
  38. RegisterTileProperty("bottom-right-image", false);
  39. RegisterTileProperty("left-image", true);
  40. RegisterTileProperty("right-image", true);
  41. RegisterTileProperty("top-image", true);
  42. RegisterTileProperty("bottom-image", true);
  43. RegisterTileProperty("center-image", true);
  44. }
  45. DecoratorTiledBoxInstancer::~DecoratorTiledBoxInstancer()
  46. {
  47. }
  48. // Instances a box decorator.
  49. Decorator* DecoratorTiledBoxInstancer::InstanceDecorator(const String& RMLUI_UNUSED_PARAMETER(name), const PropertyDictionary& properties)
  50. {
  51. RMLUI_UNUSED(name);
  52. DecoratorTiled::Tile tiles[9];
  53. String texture_names[9];
  54. String rcss_paths[9];
  55. GetTileProperties(tiles[0], texture_names[0], rcss_paths[0], properties, "top-left-image");
  56. GetTileProperties(tiles[1], texture_names[1], rcss_paths[1], properties, "top-right-image");
  57. GetTileProperties(tiles[2], texture_names[2], rcss_paths[2], properties, "bottom-left-image");
  58. GetTileProperties(tiles[3], texture_names[3], rcss_paths[3], properties, "bottom-right-image");
  59. GetTileProperties(tiles[4], texture_names[4], rcss_paths[4], properties, "left-image");
  60. GetTileProperties(tiles[5], texture_names[5], rcss_paths[5], properties, "right-image");
  61. GetTileProperties(tiles[6], texture_names[6], rcss_paths[6], properties, "top-image");
  62. GetTileProperties(tiles[7], texture_names[7], rcss_paths[7], properties, "bottom-image");
  63. GetTileProperties(tiles[8], texture_names[8], rcss_paths[8], properties, "center-image");
  64. DecoratorTiledBox* decorator = new DecoratorTiledBox();
  65. if (decorator->Initialise(tiles, texture_names, rcss_paths))
  66. return decorator;
  67. decorator->RemoveReference();
  68. ReleaseDecorator(decorator);
  69. return NULL;
  70. }
  71. // Releases the given decorator.
  72. void DecoratorTiledBoxInstancer::ReleaseDecorator(Decorator* decorator)
  73. {
  74. delete decorator;
  75. }
  76. // Releases the instancer.
  77. void DecoratorTiledBoxInstancer::Release()
  78. {
  79. delete this;
  80. }
  81. }
  82. }