Thread Tools Display Modes
12-28-20, 06:00 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
AceConfig-3.0 Options: How to pass imageCoords?

In AceConfig-3.0 Options you can set an image to be displayed instead of an execute button.

But I don't understand how you are supposed to pass the imageCoords, as it says in the manual:
  • image (string|function) - path to image texture, if this is a function it can optionally return the width and height of the image as the 2nd and 3rd value, these will be used instead of imageWidth and imageHeight.
    • imageCoords (table|methodname|function) - arguments to pass to SetTexCoord, e.g. {0.1,0.9,0.1,0.9}.
    • imageWidth (number) - Width of the displayed image
    • imageHeight (number) - Height of the displayed image

The 1st return value is the image string, the 2nd and 3rd is are width and height. But what about the imageCoords table??

Lua Code:
  1. image = function()
  2.     -- What do I do with this?
  3.     local myCoords = {0.4, 0.6, 0.4, 0.6}
  4.                                  
  5.     return "Interface\\Transmogrify\\Transmogrify", "20", "20"
  6.   end,
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
12-28-20, 07:36 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Lua Code:
  1. myOptions = {
  2.      type = "group",
  3.      args = {
  4.           myButton = {
  5.                name = "My Button",
  6.                type = "execute",
  7.                desc = "Click me to do stuff!",
  8.                func = function()
  9.                               --do something here
  10.                          end,
  11.                image = "Interface\\Transmogrify\\Transmogrify",
  12.                imageCoords = {0.4, 0.6, 0.4, 0.6},
  13.                imageWidth = 20,
  14.                imageHeight = 20,
  15.           },
  16.      },
  17. }
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-28-20, 07:55 PM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Brilliant!! Thanks a lot. Kind of stupid that I did not think of this, but this "2nd and 3rd value" thing got me thinking that this is the only way. It works now.
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
12-28-20, 08:23 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Yes, if you wanted to do it that way, then it'd look like this.
Lua Code:
  1. myOptions = {
  2.      type = "group",
  3.      args = {
  4.           myButton = {
  5.                name = "My Button",
  6.                type = "execute",
  7.                desc = "Click me to do stuff!",
  8.                func = function()
  9.                               --do something here
  10.                          end,
  11.                image = function()
  12.                               return "Interface\\Transmogrify\\Transmogrify", 20, 20
  13.                          end,
  14.                imageCoords = {0.4, 0.6, 0.4, 0.6},
  15.           },
  16.      },
  17. }

But if your image is static, then don't create an extra function.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceConfig-3.0 Options: How to pass imageCoords?

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