Class: YogaLayout::Config

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/yoga_layout/config.rb

Overview

Config changes the way the Yoga layout system works.

Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the #set_experimental_feature_enabled method. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.

Examples:

Use web defaults by default

YogaLayout::Config.default.set_use_web_defaults(true)

Create a node tree with a custom config

config = YogaLayout::Config.new
node = YogaLayout::Node.new_with_config(config)
node.insert_child(config.new_node, 0)

Instance Attribute Summary

Attributes inherited from Wrapper

#pointer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Wrapper

#==, auto_ptr, #initialize, #inspect, map_method

Constructor Details

This class inherits a constructor from YogaLayout::Wrapper

Class Method Details

.defaultObject

Use this to adjust the default settings.



33
34
35
36
# File 'lib/yoga_layout/config.rb', line 33

def self.default
  # Not using auto_ptr, because you can't deallocate the default config
  @default ||= new(YogaLayout::Bindings.YGConfigGetDefault)
end

.unsafe_free_pointer(pointer) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/yoga_layout/config.rb', line 28

def self.unsafe_free_pointer(pointer)
  YogaLayout::Bindings.YGConfigFree(pointer)
end

.unsafe_new_pointerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/yoga_layout/config.rb', line 22

def self.unsafe_new_pointer
  YogaLayout::Bindings.YGConfigNew
end

Instance Method Details

#new_nodeYogaLayout::Node

Convinience method to create new nodes with this config.

Returns:



41
42
43
# File 'lib/yoga_layout/config.rb', line 41

def new_node
  YogaLayout::Node.new_with_config(self)
end