Navigation menu

WoW:UI coordinates: Difference between revisions

Jump to navigation Jump to search
demoted headings
m (Updated GetWidth/GetHeight details.)
(demoted headings)
Line 5: Line 5:




= Origin and Axes =
== Origin and Axes ==
The origin is generally the BOTTOM LEFT corner of the screen. X coordinates always increase to the RIGHT (and decrease LEFT), and Y coordinates always increase UP (and decrease DOWN).
The origin is generally the BOTTOM LEFT corner of the screen. X coordinates always increase to the RIGHT (and decrease LEFT), and Y coordinates always increase UP (and decrease DOWN).




= Coordinate Systems =
== Coordinate Systems ==


== Real Screen Coordinates ==
=== Real Screen Coordinates ===
The actual SIZE of the user's screen isn't readily available from the game, though you can query the current video settings for users that are not playing in windowed mode, to find out. Windowed mode presents somewhat of a challenge, because there the video settings determine the shape of the window, but the user can resize it on screen to whatever height or width they wish. It's best to just forget all about the real screen size anyway, and concentrate instead on the UI Root Coordinates:
The actual SIZE of the user's screen isn't readily available from the game, though you can query the current video settings for users that are not playing in windowed mode, to find out. Windowed mode presents somewhat of a challenge, because there the video settings determine the shape of the window, but the user can resize it on screen to whatever height or width they wish. It's best to just forget all about the real screen size anyway, and concentrate instead on the UI Root Coordinates:


== UI Root Coordinates ==
=== UI Root Coordinates ===
WoW normalizes all screen resolutions to be 768 pixels high, and then an aspect-appropriate width. Thus any 4:3 screen resolution appears as 1024x768, any 5:4 as 960x768, and 16:10 as 1228.8x768. The virtual "root" frame, which all non-parented frames are children of, then has this normalized size.
WoW normalizes all screen resolutions to be 768 pixels high, and then an aspect-appropriate width. Thus any 4:3 screen resolution appears as 1024x768, any 5:4 as 960x768, and 16:10 as 1228.8x768. The virtual "root" frame, which all non-parented frames are children of, then has this normalized size.


Line 21: Line 21:
(Prior to WoW 2.0, for frames with anchor-defined sizes (not forced sizes), [[API LayoutFrame GetWidth|w = layoutFrame:GetWidth()]] and [[API LayoutFrame GetHeight|h = layoutFrame:GetHeight()]] return values in the UI Root Coordinate system.)
(Prior to WoW 2.0, for frames with anchor-defined sizes (not forced sizes), [[API LayoutFrame GetWidth|w = layoutFrame:GetWidth()]] and [[API LayoutFrame GetHeight|h = layoutFrame:GetHeight()]] return values in the UI Root Coordinate system.)


== Frame Scaled Coordinates ==
=== Frame Scaled Coordinates ===
Most frame-specific coordinate functions operate in a coordinate system that is adjusted by the Frame's effective scale (As returned by [[API Frame GetEffectiveScale|effScale = frame:GetEffectiveScale()]]. Each unit in the frame scaled coordinate system corresponds to effScale units in the UI Root coordinate system.  The origin, however, is still the BOTTOM LEFT corner of the screen.
Most frame-specific coordinate functions operate in a coordinate system that is adjusted by the Frame's effective scale (As returned by [[API Frame GetEffectiveScale|effScale = frame:GetEffectiveScale()]]. Each unit in the frame scaled coordinate system corresponds to effScale units in the UI Root coordinate system.  The origin, however, is still the BOTTOM LEFT corner of the screen.


Line 31: Line 31:




= Useful Code Snippets =
== Useful Code Snippets ==


== Cursor Over Frame ==
=== Cursor Over Frame ===


  function MouseIsOver(frame)
  function MouseIsOver(frame)
Line 43: Line 43:
  end
  end


== Frame Overlap ==
=== Frame Overlap ===


  function FramesOverlap(frameA, frameB)
  function FramesOverlap(frameA, frameB)
Anonymous user