PitBull Unit Frames 4.0

API / UnitFrameLayout

UnitFrame:UpdateLayout(should_update_texts)

Reposition all controls on the Unit Frame

Parameters

should_update_texts
whether :Update should be called for the frame on text modules

Usage

frame:UpdateLayout()


calculate_width_height_points(layout, center_bars, left_bars, right_bars)

Calculate the sizing points for the various bars given.

Parameters

layout
the name of the layout
center_bars
a list of bar-like elements where side = 'center'
left_bars
a list of bar-like elements where side = 'left'
right_bars
a list of bar-like elements where side = 'right'

Return values

  1. the number of total width points make up the layout (except for the square indicators on the sides) with the given bars
  2. the number of total height points make up the layout with the given bars
  3. the number of square indicators are on the left side
  4. the number of square indicators are on the right side

Usage

bar_width_points, bar_height_points, left_exempt_width, right_exempt_width = calculate_width_height_points("Normal", {"HealthBar", "PowerBar"}, {"Portrait"}, {})


filter_elements_for_side(element_ids, layout, side)

Return a list of element ids that are on a given side for a given layout.

Parameters

element_ids
a list of element ids
layout
name of the layout
side
the side to filter on, one of "left", "center", or "right"

Return value

a list of element ids

Usage

element_ids = filter_elements_for_side({ "HealthBar", "PowerBar" }, "Normal", "center")


get_all_bars(frame)

Return lists of all element ids that represent bar-like objects.
The resultant lists will be sorted by position.

Parameters

frame
a unit frame

Return values

  1. a list of all element ids
  2. a list of element ids where side = 'center'
  3. a list of element ids where side = 'left'
  4. a list of element ids where side = 'right'

Usage

bars, center_bars, left_bars, right_bars = get_all_bars(frame)


get_all_indicators_and_texts(frame)

Return lists of all element ids that represent non-bar-like indicators and texts.
The resultant list will be sorted by position.

Parameters

frame
a unit frame

Return value

a list of all element ids

Usage

elements = get_all_indicators_and_texts(frame)


get_element_db(id, layout)

Return the element-specific layout db for the given id and layout.

Parameters

id
either a module id or a module id, semicolon, and element id.
layout
the name of the layout

Return value

the element db or nil

Usage

db = get_element_db("CombatText", "Normal")
db = get_element_db("DogTagTexts;Name", "Normal")


get_half_width(frame, indicators_and_texts)

Return an estimated half-width of elements in a given location on a frame.

Parameters

frame
a unit frame
indicators_and_texts
a list of element ids to estimate the width of.

Return value

the estimated number of pixels that make up half the width.

Usage

local width = get_half_width(frame, { "CombatText", "HappinessIcon" })


ipairs_with_del(list)

Iterate over a list until nil is hit.

Parameters

list
a list

Return value

an iterator which returns index, value

Usage

for i, v in ipairs_with_del({"a", "b", "c"}) do
	    print(i, v)
	end
for i, v in ipairs_with_del({"a", "b", "c", nil, "e"}) do
	    -- same as above, since it stops at i == 4
	    print(i, v)
	end


position_indicator_or_text(frame, indicator_id, attach_frame, last_indicator_id, location, indicators_and_texts)

Position an indicator on the unit frame based on the given arguments.

Parameters

frame
a unit frame
indicator_id
the id of the indicator to position on the unit frame
attach_frame
what frame we're currently attaching to. This can be the unit frame or a separate bar.
last_indicator_id
the id of the last indicator we placed down, or nil if we haven't placed one down yet.
location
the location we're placing the indicator in relation to attach_frame.
indicators_and_texts
a list of element ids in the same location.

Usage

position_indicator_or_text(frame, "PvPIcon", frame, nil, "edge_top_left", { "PvPIcon", "CombatIcon" })


position_overlapping_texts(frame, attach_frame, location_to_indicators_and_texts)

Position texts on a given attach frame to not overlap one another.

Parameters

frame
a unit frame
attach_frame
the frame the texts attach to, or frame for the unit frame itself
location_to_indicators_and_texts
a dictionary of location to indicators and texts

Usage

position_overlapping_texts(frame, frame.HealthBar, { left = {"DogTagTexts;Name"}, right = {"DogTagTexts;Health"}})


position_overlapping_textshelper(frame, attach_frame, left, center, right, inside_width, spacing)

Position texts to one another so that they don't overlap.
Priority-wise, it goes center, then right, then left for what takes precedence.

Parameters

frame
the unit frame
attach_frame
the attach frame that the texts reside on
left
the element ids of all indicators and texts on the left side
center
the element ids of all indicators and texts in the center
right
the element ids of all indicators and texts in the right side
inside_width
how far inside a left text would be attaching to attach_frame's right side
spacing
the spacing between texts

Usage

position_overlapping_texts__helper(frame, frame.HealthBar, { "DogTagTexts;Name" }, {}, { "DogTagTexts;Health" }, 3, 2)


reverse_ipairs(list)

Iterate backwards over a list.

Parameters

list
a list

Return value

an iterator which returns index, value

Usage

for i, v in reverse_ipairs({"a", "b", "c"}) do
	    -- 3, "c" -- 2, "b", -- 1, "a"
	end


sort_elements_by_position(element_ids, layout)

Sort a list of elements by position for the given layout.

Parameters

element_ids
a list of element ids
layout
name of the layout

Usage

element_ids = { "HealthBar", "PowerBar" }
	sort_elements_by_position(element_ids)


update_bar_layout(frame)

Position all bar-like objects on the given frame.

Parameters

frame
a unit frame

Usage

update_bar_layout(frame)


update_indicator_and_text_layout(frame)

Position all non-bar-like indicators and texts on the given frame.

Parameters

frame
a unit frame

Usage

update_indicator_and_text_layout(frame)


You must login to post a comment. Don't have an account? Register to get one!