github.com/goki/ki@v1.1.11/ki/flags.go (about)

     1  // Copyright (c) 2018, The GoKi Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ki
     6  
     7  import "github.com/goki/ki/kit"
     8  
     9  // Flags are bit flags for efficient core state of nodes -- see bitflag
    10  // package for using these ordinal values to manipulate bit flag field.
    11  type Flags int32
    12  
    13  //go:generate stringer -type=Flags
    14  
    15  var KiT_Flags = kit.Enums.AddEnum(FlagsN, kit.BitFlag, nil)
    16  
    17  const (
    18  	// IsField indicates a node is a field in its parent node, not a child in children.
    19  	IsField Flags = iota
    20  
    21  	// HasKiFields indicates a node has Ki Node fields that will be processed in recursive descent.
    22  	// Use the HasFields() method to check as it will establish validity of flags on first call.
    23  	// If neither HasFields nor HasNoFields are set, then it knows to update flags.
    24  	HasKiFields
    25  
    26  	// HasNoKiFields indicates a node has NO Ki Node fields that will be processed in recursive descent.
    27  	// Use the HasFields() method to check as it will establish validity of flags on first call.
    28  	// If neither HasFields nor HasNoFields are set, then it knows to update flags.
    29  	HasNoKiFields
    30  
    31  	// Updating flag is set at UpdateStart and cleared if we were the first
    32  	// updater at UpdateEnd.
    33  	Updating
    34  
    35  	// OnlySelfUpdate means that the UpdateStart / End logic only applies to
    36  	// this node in isolation, not to its children -- useful for a parent node
    37  	// that has a different functional role than its children.
    38  	OnlySelfUpdate
    39  
    40  	// following flags record what happened to a given node since the last
    41  	// Update signal -- they are cleared at first UpdateStart and valid after
    42  	// UpdateEnd
    43  
    44  	// NodeDeleted means this node has been deleted.
    45  	NodeDeleted
    46  
    47  	// NodeDestroyed means this node has been destroyed -- do not trigger any
    48  	// more update signals on it.
    49  	NodeDestroyed
    50  
    51  	// ChildAdded means one or more new children were added to the node.
    52  	ChildAdded
    53  
    54  	// ChildDeleted means one or more children were deleted from the node.
    55  	ChildDeleted
    56  
    57  	// ChildrenDeleted means all children were deleted.
    58  	ChildrenDeleted
    59  
    60  	// ValUpdated means a value was updated (Field, Prop, any kind of value)
    61  	ValUpdated
    62  
    63  	// FlagsN is total number of flags used by base Ki Node -- can extend from
    64  	// here up to 64 bits.
    65  	FlagsN
    66  
    67  	// ChildUpdateFlagsMask is a mask for all child updates.
    68  	ChildUpdateFlagsMask = (1 << uint32(ChildAdded)) | (1 << uint32(ChildDeleted)) | (1 << uint32(ChildrenDeleted))
    69  
    70  	// StruUpdateFlagsMask is a mask for all structural changes update flags.
    71  	StruUpdateFlagsMask = ChildUpdateFlagsMask | (1 << uint32(NodeDeleted))
    72  
    73  	// ValUpdateFlagsMask is a mask for all non-structural, value-only changes update flags.
    74  	ValUpdateFlagsMask = (1 << uint32(ValUpdated))
    75  
    76  	// UpdateFlagsMask is a Mask for all the update flags -- destroyed is
    77  	// excluded b/c otherwise it would get cleared.
    78  	UpdateFlagsMask = StruUpdateFlagsMask | ValUpdateFlagsMask
    79  )