UIVBox.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /****************************************************************************
  2. Copyright (c) 2011-2012 cocos2d-x.org
  3. Copyright (c) 2013-2014 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. /**
  22. * The vertical box of Cocos UI. Its layout type is ccui.Layout.LINEAR_VERTICAL.
  23. * @class
  24. * @extends ccui.Layout
  25. */
  26. ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{
  27. /**
  28. * The constructor of ccui.VBox
  29. * @function
  30. * @param {cc.Size} size
  31. */
  32. ctor: function(size){
  33. if(size)
  34. this.initWithSize(size);
  35. else
  36. this.init();
  37. },
  38. /**
  39. * Initializes a VBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
  40. * @override
  41. * @returns {boolean}
  42. */
  43. init: function(){
  44. if(ccui.Layout.prototype.init.call(this)){
  45. this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);
  46. return true;
  47. }
  48. return false;
  49. },
  50. /**
  51. * Initializes a VBox with size.
  52. * @param {cc.Size} size
  53. * @returns {boolean}
  54. */
  55. initWithSize: function(size){
  56. if(this.init()){
  57. this.setContentSize(size);
  58. return true;
  59. }
  60. return false;
  61. }
  62. });
  63. /**
  64. * Creates a VBox
  65. * @param {cc.Size} size
  66. * @returns {ccui.VBox}
  67. */
  68. ccui.VBox.create = function(size){
  69. return new ccui.VBox(size);
  70. };