class_margincontainer.rst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the MarginContainer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_MarginContainer:
  6. MarginContainer
  7. ===============
  8. **Inherits:** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Simple margin container.
  10. Description
  11. -----------
  12. Adds a top, left, bottom, and right margin to all :ref:`Control<class_Control>` nodes that are direct children of the container. To control the ``MarginContainer``'s margin, use the ``margin_*`` theme properties listed below.
  13. \ **Note:** Be careful, :ref:`Control<class_Control>` margin values are different from the constant margin values. If you want to change the custom margin values of the ``MarginContainer`` by code, you should use the following examples:
  14. .. tabs::
  15. .. code-tab:: gdscript
  16. # This code sample assumes the current script is extending MarginContainer.
  17. var margin_value = 100
  18. add_theme_constant_override("margin_top", margin_value)
  19. add_theme_constant_override("margin_left", margin_value)
  20. add_theme_constant_override("margin_bottom", margin_value)
  21. add_theme_constant_override("margin_right", margin_value)
  22. .. code-tab:: csharp
  23. // This code sample assumes the current script is extending MarginContainer.
  24. int marginValue = 100;
  25. AddThemeConstantOverride("margin_top", marginValue);
  26. AddThemeConstantOverride("margin_left", marginValue);
  27. AddThemeConstantOverride("margin_bottom", marginValue);
  28. AddThemeConstantOverride("margin_right", marginValue);
  29. Theme Properties
  30. ----------------
  31. +-----------------------+--------------------------------------------------------------------------+-------+
  32. | :ref:`int<class_int>` | :ref:`margin_bottom<class_MarginContainer_theme_constant_margin_bottom>` | ``0`` |
  33. +-----------------------+--------------------------------------------------------------------------+-------+
  34. | :ref:`int<class_int>` | :ref:`margin_left<class_MarginContainer_theme_constant_margin_left>` | ``0`` |
  35. +-----------------------+--------------------------------------------------------------------------+-------+
  36. | :ref:`int<class_int>` | :ref:`margin_right<class_MarginContainer_theme_constant_margin_right>` | ``0`` |
  37. +-----------------------+--------------------------------------------------------------------------+-------+
  38. | :ref:`int<class_int>` | :ref:`margin_top<class_MarginContainer_theme_constant_margin_top>` | ``0`` |
  39. +-----------------------+--------------------------------------------------------------------------+-------+
  40. Theme Property Descriptions
  41. ---------------------------
  42. .. _class_MarginContainer_theme_constant_margin_bottom:
  43. - :ref:`int<class_int>` **margin_bottom**
  44. +-----------+-------+
  45. | *Default* | ``0`` |
  46. +-----------+-------+
  47. All direct children of ``MarginContainer`` will have a bottom margin of ``margin_bottom`` pixels.
  48. ----
  49. .. _class_MarginContainer_theme_constant_margin_left:
  50. - :ref:`int<class_int>` **margin_left**
  51. +-----------+-------+
  52. | *Default* | ``0`` |
  53. +-----------+-------+
  54. All direct children of ``MarginContainer`` will have a left margin of ``margin_left`` pixels.
  55. ----
  56. .. _class_MarginContainer_theme_constant_margin_right:
  57. - :ref:`int<class_int>` **margin_right**
  58. +-----------+-------+
  59. | *Default* | ``0`` |
  60. +-----------+-------+
  61. All direct children of ``MarginContainer`` will have a right margin of ``margin_right`` pixels.
  62. ----
  63. .. _class_MarginContainer_theme_constant_margin_top:
  64. - :ref:`int<class_int>` **margin_top**
  65. +-----------+-------+
  66. | *Default* | ``0`` |
  67. +-----------+-------+
  68. All direct children of ``MarginContainer`` will have a top margin of ``margin_top`` pixels.
  69. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  70. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  71. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  72. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  73. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  74. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`