WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   TitleRegion - Movable Frame on TitleFrame only (https://www.wowinterface.com/forums/showthread.php?t=57135)

urakkaamyx 05-09-19 11:32 PM

TitleRegion - Movable Frame on TitleFrame only
 
Issue: Cant seem to get TitleRegion to work. Making Frame movable via Title Frame only
Method: XML: Using Template Frames. lua on the event of OnMouseDown/OnMouseUp.

I can get the whole frame to drag around by doing the OnMouseDown/OnMouseUp events if i place it in my root <Frame />, Which is fine except i dont want it to drag the frame unless im clicking on the title frame

Im wandering, can i set the OnMouseDown/OnMouseUp events in the TitleFrame template in order to accomplish what im after? or does that not work?.

code:
Main Frame (Called Via CreateFrame())
iTrackerFrameTemplate.xml
Code:


<Ui>
    <Script file="iTrackerFrameTemplate.lua" />
    <Frame name="iTrackerFrameTemplate" virtual="true">
        <Size x="200" y="292" />
        <Anchors>
            <Anchor point="CENTER" relativeTo="UIParent" relativePoint="CENTER" />
        </Anchors>
        <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="" tile="true">
            <BackgroundInsets>
                <AbsInset left="11" right="12" top="12" bottom="11" />
            </BackgroundInsets>
            <TileSize val="32" />
            <EdgeSize val="32" />
        </Backdrop>
        <Frames>
            <Frame name="$parent_TitleFrame" parentKey="titleFrame" inherits="iTrackerFrame_TitleFrameTemplate">
                <Scripts>
                    <OnLoad>
                        iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(self)
                    </OnLoad>
                </Scripts>
            </Frame>
        </Frames>
    </Frame>
</Ui>

iTrackerFrame_TitleFrameTemplate.xml
Code:

<Ui>
    <Script file="iTrackerFrame_TitleFrameTemplate.lua" />
    <Frame name="iTrackerFrame_TitleFrameTemplate" parentKey="titleFrame" virtual="true" movable="true">
        <Size x="80" y="50" />
        <Anchors>
            <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT" y="20" />
        </Anchors>
        <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="" tile="true">
            <BackgroundInsets>
                <AbsInset left="11" right="12" top="12" bottom="11" />
            </BackgroundInsets>
            <TileSize val="32" />
            <EdgeSize val="32" />
        </Backdrop>
        <Layers>
            <Layer level="OVERLAY">
                <FontString name="title" parentKey="title" inherits="GameFontNormal" text="&lt;title&gt;">
                    <Size x="80" y="20" />
                    <Anchors>
                        <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT" />
                        <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" />
                    </Anchors>
                </FontString>
            </Layer>
        </Layers>
    </Frame>
</Ui>

The only Script in that file atm.
iTrackerFrameTemplate.lua

Code:

function iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(Frame)
    -- Set Width Based on title length
    local title = Frame.title
    title:SetText(iTracker:GetInfo('AppName'))
    Frame:SetWidth(title:GetWidth())
end

-- iTracker:GetInfo() just gets a data from a simple table when the Addon is loaded (Based on some settings I have a dev-local, and dev-game, and game (local loads up the project for external debugging. game uses the ingame/addon debugging .. and game is live and a few other various ease of information access.))

you can just set that to "TITLE OF FRAME" if you want.

Fizzlemizz 05-10-19 12:19 AM

More like:
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
  2.     <Script file="Some.lua" />
  3.  
  4.     <Frame name="iTrackerBodyFrameTemplate" virtual="true">
  5.         <Anchors>
  6.             <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT"/>
  7.             <Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT"/>
  8.         </Anchors>
  9.         <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="" tile="true">
  10.             <BackgroundInsets>
  11.                 <AbsInset left="0" right="0" top="0" bottom="0" />
  12.             </BackgroundInsets>
  13.             <TileSize val="32" />
  14.             <EdgeSize val="32" />
  15.         </Backdrop>
  16.         <Scripts>
  17.             <OnLoad>
  18.                 iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(self)
  19.             </OnLoad>
  20.         </Scripts>
  21.     </Frame>
  22.  
  23.     <Frame name="iTrackerFrame_TitleFrameTemplate" virtual="true" movable="true">
  24.         <Size x="200" y="20" />
  25.         <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="" tile="true">
  26.             <BackgroundInsets>
  27.                 <AbsInset left="0" right="0" top="0" bottom="0" />
  28.             </BackgroundInsets>
  29.             <TileSize val="32" />
  30.             <EdgeSize val="32" />
  31.         </Backdrop>
  32.         <Layers>
  33.             <Layer level="OVERLAY">
  34.                 <FontString name="title" parentKey="title" inherits="GameFontNormal" text="&lt;title&gt;">
  35.                     <Anchors>
  36.                         <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT" />
  37.                         <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" />
  38.                     </Anchors>
  39.                 </FontString>
  40.             </Layer>
  41.         </Layers>
  42.         <Frames>
  43.             <Frame name="$parent_BodyFrame" parentKey="body" inherits="iTrackerBodyFrameTemplate" />
  44.         </Frames>
  45.         <Scripts>
  46.             <OnLoad>
  47.                 self:EnableMouse(true)
  48.                 self:RegisterForDrag("LeftButton")
  49.             </OnLoad>
  50.             <OnDragStart>
  51.                 self:StartMoving()
  52.             </OnDragStart>
  53.             <OnDragStop>
  54.                 self:StopMovingOrSizing()
  55.             </OnDragStop>
  56.         </Scripts>
  57.     </Frame>
  58.  
  59.     <Frame name="FizzTrack" parent="UIParent"  inherits="iTrackerFrame_TitleFrameTemplate">
  60.         <Anchors>
  61.             <Anchor point="CENTER" relativeTo="UIParent" relativePoint="CENTER" />
  62.         </Anchors>
  63.     </Frame>
  64. </Ui>

Lua Code:
  1. function iTrackerFrame_TitleFrameTemplate_OnLoad_SetWidth(Frame)
  2.     -- Set desired height
  3.     title:SetText("Some Name")
  4.     Frame:SetHeight(300)
  5. end

The width of the body will size with the header and its height can be set independently so the function name is now a bit misleading, more like
TrackerFrame_BodyFrameTemplate_OnLoad_SetHeight.

Edited: so the background insets and anchors don't overlay and darken the text.

urakkaamyx 05-10-19 05:53 AM

Thanks :)
 
First off, Thanks for replying :)

THANK you so much. I was a little confused as to the whole width height thing, but once i pasted your code in and gave it a test i figured out what was going on.. Thank you again. ^_^


All times are GMT -6. The time now is 03:23 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI