Thread Tools Display Modes
11/08/16, 05:46 PM   #1
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Define texture size in xml

Hey guys,

there is a little problem that currently drives me into desperation. Lets take the following example:

Code:
-- results in a button control of 24x24 with a smaller texture in it
<Button name="$(parent)_CloseButton" clickSound="Click">
  <Dimensions x="24" y="24" />
  <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="0" offsetY="0" />
  <Textures normal="EsoUI/Art/Buttons/closebutton_up.dds" pressed="EsoUI/Art/Buttons/closebutton_down.dds" mouseOver="EsoUI/Art/Buttons/closebutton_mouseover.dds" disabled="EsoUI/Art/Buttons/closebutton_disabled.dds" />
</Button>
Although the button has a size of 24x24 the texture is not stretched to match its size. If I use lua to initialize the control OR to modify it after its xml has been loaded, it works as intended and the texture is stretched to match the buttons actual size:

Code:
-- will result in a texture of 24x24
local button = WM:GetControlByName("someButtonControl")

button:SetNormalTexture("/esoui/art/buttons/decline_up.dds");
button:SetMouseOverTexture("/esoui/art/buttons/decline_over.dds");
button:SetPressedTexture("/esoui/art/buttons/decline_down.dds");
Some enlightenment would be much appreciated, because I'd like to use XML for setting up the UI.
  Reply With Quote
11/08/16, 06:16 PM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Could you post an example of your problem and what expected ? I don't see the issue.

Here is an example of things which works well for me.
The button is 120x120 px when you mouse over its dimensions becomes 140x140 and texture is changed aswell.

Lua Code:
  1. <Button name="$(parent)Execute" inherits="ZO_ButtonBehaviorClickSound">
  2.     <Dimensions x="120" y="120" />
  3.     <OnMouseEnter>
  4.         self:SetDimensions(140, 140)
  5.     </OnMouseEnter>
  6.     <OnMouseExit>
  7.         self:SetDimensions(120, 120)
  8.     </OnMouseExit>
  9.     <OnClicked>
  10.         BankManagerRevived_executeRule()
  11.     </OnClicked>
  12.     <OnMouseWheel>
  13.         BankManagerRevived_nextRule(_, delta)
  14.     </OnMouseWheel>
  15.     <Textures
  16.         normal="BankManagerRevived/img/gold-normal.dds"
  17.         pressed="BankManagerRevived/img/gold-pressed.dds"
  18.     />
  19.     <Anchor point="CENTER" relativePoint="CENTER" relativeTo="$(parent)" />
  20. </Button>
  Reply With Quote
11/09/16, 03:28 AM   #3
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Hi Ayantir, what I meant is:

The way I understand how to setup a button with a texture in lua or xml is, that

Code:
<Textures normal="EsoUI/Art/Buttons/closebutton_up.dds" pressed="EsoUI/Art/Buttons/closebutton_down.dds" mouseOver="EsoUI/Art/Buttons/closebutton_mouseover.dds" disabled="EsoUI/Art/Buttons/closebutton_disabled.dds" />
and
Code:
:SetNormalTexture("/esoui/art/buttons/decline_up.dds");
:SetMouseOverTexture("/esoui/art/buttons/decline_over.dds");
:SetPressedTexture("/esoui/art/buttons/decline_down.dds");
should do exactly the same thing. But they don't, because the XML variant does not scale the texture to the size of it's parent element (<Button>), where SetxyzTexture does.

This is the difference (I used Circonians Control outline to show the actual dimensions of the button element):

... using SetXyzTexture() working as intended


... using XML not working as intended


Cheers, Letho
  Reply With Quote
11/09/16, 05:30 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,962
Try the tag <AnchorFill/> below the Textures in the xml.
I'm not sure if this works for the Textures tag but it does inside a button, if you are using different Texture controls inside this button (setting each one fir one except using textures to set all in one line).

Check this thread here, maybe it helps too
http://www.esoui.com/forums/showthre...ght=Anchorfill

Last edited by Baertram : 11/09/16 at 05:33 AM.
  Reply With Quote
11/09/16, 11:11 AM   #5
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Hey,
tried <AnchorFill /> already, also setting up dimensions, etc. - that does not work.
<TextureCoords> do sth. different, they define to only use a section of a texture, like an imagemap in html.


@Ayantir:
Copied your mouseHandlers to my example. If defined in lua the texture will grow with the button. If defined in xml the texture will grow too, but only in relation to it's former size (probably its original size).

This behavior is really strange.

Last edited by Letho : 11/09/16 at 11:31 AM.
  Reply With Quote
11/09/16, 12:17 PM   #6
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
@Letho Could it be that you're confusing different textures? In the XML example you use *closebutton*.dds, while in the Lua example you use *decline*.dds.

I can't find the *closebutton*.dds files to check, but looking at the ZO template that uses them, they actually do have padding that's cropped out with TextureCoords:
xml Code:
  1. <Button name="ZO_CloseButton" inherits="ZO_ButtonBehaviorClickSound" mouseOverBlendMode="ADD" virtual="true">
  2.     <Dimensions x="20" y="20" />
  3.     <Anchor point="TOPRIGHT" offsetX="-5" offsetY="6" />
  4.  
  5.     <TextureCoords left="0" top="0" right="0.625" bottom="0.625" />
  6.  
  7.     <Textures
  8.        normal="EsoUI/Art/Buttons/closeButton_up.dds"
  9.        pressed="EsoUI/Art/Buttons/closeButton_down.dds"
  10.        mouseOver="EsoUI/Art/Buttons/closeButton_mouseOver.dds"
  11.        disabled="EsoUI/Art/Buttons/closeButton_disabled.dds"
  12.     />
  13. </Button>
  Reply With Quote
11/09/16, 06:43 PM   #7
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Originally Posted by merlight View Post
@Letho Could it be that you're confusing different textures? In the XML example you use *closebutton*.dds, while in the Lua example you use *decline*.dds.

I can't find the *closebutton*.dds files to check, but looking at the ZO template that uses them, they actually do have padding that's cropped out with TextureCoords:
xml Code:
  1. <Button name="ZO_CloseButton" inherits="ZO_ButtonBehaviorClickSound" mouseOverBlendMode="ADD" virtual="true">
  2.     <Dimensions x="20" y="20" />
  3.     <Anchor point="TOPRIGHT" offsetX="-5" offsetY="6" />
  4.  
  5.     <TextureCoords left="0" top="0" right="0.625" bottom="0.625" />
  6.  
  7.     <Textures
  8.        normal="EsoUI/Art/Buttons/closeButton_up.dds"
  9.        pressed="EsoUI/Art/Buttons/closeButton_down.dds"
  10.        mouseOver="EsoUI/Art/Buttons/closeButton_mouseOver.dds"
  11.        disabled="EsoUI/Art/Buttons/closeButton_disabled.dds"
  12.     />
  13. </Button>
Oh man, that's it! Unbelievable how stupid I am... Thx for your hint
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Define texture size in xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off