Back to Home

ESO Lua File v100036

libraries/zo_templates/treetemplates.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
function ZO_LabelHeader_Setup(control, open)
    control:SetSelected(open)
end
    if not control.text:IsSelected() and control.enabled then
        if control.allowIconScaling then
            control.icon.animation:PlayForward()
        end
        control.iconHighlight:SetHidden(false)
    end
    if(control.text:WasTruncated()) then
        InitializeTooltip(InformationTooltip, control, RIGHT, -10)
        SetTooltipText(InformationTooltip, control.text:GetText())
    end
end
ZO_TREE_ENTRY_ICON_HEADER_ICON_MAX_DIMENSIONS = 48
ZO_TREE_ENTRY_ICON_HEADER_TEXT_OFFSET_X = 55
ZO_TREE_ENTRY_ICON_HEADER_TEXT_PADDING_Y = 9
    if not control.text:IsSelected() and control.allowIconScaling then
        control.icon.animation:PlayBackward()
    end
    control.iconHighlight:SetHidden(true)
    ClearTooltip(InformationTooltip)
end
function ZO_IconHeader_OnMouseUp(control, upInside)
    if control.enabled then
        ZO_TreeHeader_OnMouseUp(control, upInside)
    end
end
function ZO_IconHeader_Setup(control, open, enabled, disableScaling, updateSizeFunction)
    enabled = enabled == nil or enabled
    control.enabled = enabled
    if control.node then
        control.node.enabled = enabled
    end
    control.allowIconScaling = not disableScaling
    if not control.icon.animation and control.allowIconScaling then
        control.icon.animation = ANIMATION_MANAGER:CreateTimelineFromVirtual(control.animationTemplate, control.icon)
    end
    if enabled and (open or WINDOW_MANAGER:GetMouseOverControl() == control) then
        if control.allowIconScaling then
            control.icon.animation:PlayForward()
        end
        control.iconHighlight:SetHidden(WINDOW_MANAGER:GetMouseOverControl() ~= control)
    else
        if control.allowIconScaling then
            control.icon.animation:PlayBackward()
        end
        control.iconHighlight:SetHidden(true)
    end
    control.text:SetSelected(open)
    if updateSizeFunction then
        updateSizeFunction(control)
    else
    end
end
    local textWidth, textHeight = control.text:GetTextDimensions()
    local height = textHeight + ZO_TREE_ENTRY_ICON_HEADER_TEXT_PADDING_Y * 2
    height = zo_max(height, ZO_TREE_ENTRY_ICON_HEADER_ICON_MAX_DIMENSIONS)
    local width = textWidth + ZO_TREE_ENTRY_ICON_HEADER_TEXT_OFFSET_X
    control:SetDimensions(width, height)
end
    self.icon = self:GetNamedChild("Icon")
    self.iconHighlight = self.icon:GetNamedChild("Highlight")
    self.text = self:GetNamedChild("Text")
    self.animationTemplate = "IconHeaderAnimation"
end
function ZO_IconHeader_SetAnimation(self, animationTemplate)
    self.animationTemplate = animationTemplate
end
function ZO_IconHeader_SetMaxLines(self, maxLines)
    self.text:SetHeight(self.text:GetFontHeight() * maxLines + 1)
end
-- Simple Arrow Icon Header
do
    local function OnMouseEnter(control)
        control.iconHighlight:SetHidden(false)
    end
    local function OnMouseExit(control)
        control.iconHighlight:SetHidden(true)
    end
    local function OnMouseUp(control, upInside)
        ZO_TreeHeader_OnMouseUp(control, upInside)
    end
    
    local OPEN_TEXTURE = "EsoUI/Art/Buttons/tree_open_up.dds"
    local CLOSED_TEXTURE = "EsoUI/Art/Buttons/tree_closed_up.dds"
    local OPEN_OVER_TEXTURE = "EsoUI/Art/Buttons/tree_open_over.dds"
    local CLOSED_OVER_TEXTURE = "EsoUI/Art/Buttons/tree_closed_over.dds"
    local function SimpleArrowSetup(control, name, open)
        control.text:SetText(name)
        control.icon:SetTexture(open and OPEN_TEXTURE or CLOSED_TEXTURE)
        control.iconHighlight:SetTexture(open and OPEN_OVER_TEXTURE or CLOSED_OVER_TEXTURE)
        control.text:SetSelected(open)
    end
        self.icon = self:GetNamedChild("Icon")
        self.iconHighlight = self.icon:GetNamedChild("Highlight")
        self.text = self:GetNamedChild("Text")
        self.OnMouseEnter = OnMouseEnter
        self.OnMouseExit = OnMouseExit
        self.OnMouseUp = OnMouseUp
    end
end