Quantcast Drawing a texture on top of fontstring - WoWInterface
Thread Tools Display Modes
06-26-17, 06:55 AM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Drawing a texture on top of fontstring

Hi all,

Both texture and fontstring are drawn on same frame (frame.Health), but each are created via two separate functions, ComposeNameText() and ComposeReadyCheckIndicator() where ReadyCheckIndicator is created after NameText.

Lua Code:
  1. function ComposeNameText()
  2.     local nameText = frame.Health:CreateFontString(frame:GetName() .. "NameText", "OVERLAY");
  3. end

Lua Code:
  1. function ComposeReadyCheckIndicator()
  2.     local readyCheckIndicator = frame.Health:CreateTexture(frame:GetName() .. "ReadyCheckIndicator", "OVERLAY");
  3. end

Here's what it looks like at the moment.



I tried to use 'sublevel' argument, but unlike texture, fontstring doesn't seem to have a sublevel argument

At this stage, I've changed fontstring's draw layer to "ARTWORK" as a temporary solution.

My question is would modifying draw layer be the only solution to solve this problem?

Last edited by Layback_ : 06-26-17 at 07:01 AM.
  Reply With Quote
06-26-17, 07:25 AM   #2
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Layback_ View Post
Hi all,

Both texture and fontstring are drawn on same frame (frame.Health), but each are created via two separate functions, ComposeNameText() and ComposeReadyCheckIndicator() where ReadyCheckIndicator is created after NameText.

Lua Code:
  1. function ComposeNameText()
  2.     local nameText = frame.Health:CreateFontString(frame:GetName() .. "NameText", "OVERLAY");
  3. end

Lua Code:
  1. function ComposeReadyCheckIndicator()
  2.     local readyCheckIndicator = frame.Health:CreateTexture(frame:GetName() .. "ReadyCheckIndicator", "OVERLAY");
  3. end

Here's what it looks like at the moment.



I tried to use 'sublevel' argument, but unlike texture, fontstring doesn't seem to have a sublevel argument

At this stage, I've changed fontstring's draw layer to "ARTWORK" as a temporary solution.

My question is would modifying draw layer be the only solution to solve this problem?
Just create a invisible frame, then attach the text or icon which ever you want to be highest frame level.
  Reply With Quote
06-26-17, 10:05 AM   #3
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 925
Originally Posted by Layback_ View Post
At this stage, I've changed fontstring's draw layer to "ARTWORK" as a temporary solution.

My question is would modifying draw layer be the only solution to solve this problem?
You can use SetDrawLayer, which has an optional parameter for subLevel. It works with both fonts and textures.
__________________
Knowledge = Power; Be OP

  Reply With Quote
06-26-17, 10:09 AM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 426
Regions should have a sublevel argument; the fourth parameter on creation:
Lua Code:
  1. texture = frame:CreateTexture(["name" [, "layer" [, "inherits" [, sublevel]]]])

All regions also have the :SetDrawLayer method.
Lua Code:
  1. region:SetDrawLayer("layer", sublayer)
__________________
  Reply With Quote
06-26-17, 06:04 PM   #5
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Hi

@Game92, thank you for your idea, but I don't want to waste a resource only to draw one region on top of another

@Gethe & MunkDev, After I've posted this, I tried SetDrawLayer, but no luck

It still has a same result as it's shown below.



Lua Code:
  1. local text = UIParent:CreateFontString();
  2. text:SetDrawLayer("ARTWORK", -8);
  3. text:SetFont(LSM:Fetch("font", "koverwatch"), 24, "OUTLINE");
  4. text:SetPoint("CENTER");
  5. text:SetText("Text");
  6.  
  7. local texture = UIParent:CreateTexture();
  8. texture:SetDrawLayer("ARTWORK", 7);
  9. texture:SetTexture(READY_CHECK_READY_TEXTURE);
  10. texture:SetPoint("CENTER");
  11. texture:SetSize(36, 36);

AFAIK, sublevel argument should change the rendering order of regions in same layer where 7 is the highest order while -8 is the lowest order, but the texture is still drawn at the back

I also tested with different layers, but still didn't work out..

*EDIT: Creating fontstring after texture did not solve this problem as well.

Last edited by Layback_ : 06-26-17 at 06:06 PM.
  Reply With Quote
06-26-17, 06:39 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,184
Have you tried setting the BlendMode?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-26-17, 09:28 PM   #7
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 328
The "problem" is that FontStrings ALWAYS use the highest sublevel of the layer, it doesn't matter what your set.

So to address your issue, I'd either put your text on a lower layer: ARTWORK, or move your texture to a higher layer: HIGHLIGHT.

Lua Code:
  1. local text = UIParent:CreateFontString()
  2. text:SetDrawLayer("ARTWORK")
  3. text:SetFont(LSM:Fetch("font", "koverwatch"), 24, "OUTLINE")
  4. text:SetPoint("CENTER")
  5. text:SetText("Text")
  6.  
  7. local texture = UIParent:CreateTexture()
  8. texture:SetDrawLayer("OVERLAY")
  9. texture:SetTexture(READY_CHECK_READY_TEXTURE)
  10. texture:SetPoint("CENTER")
  11. texture:SetSize(36, 36)

Creating additional frames and using them as parents for your FontStrings and Textures is a solution too, it's viable if you have really complex unit frames w/ multiple layers of textures and/or texts, otherwise it's an overkill.
__________________

Last edited by lightspark : 06-27-17 at 05:43 AM.
  Reply With Quote
06-27-17, 12:15 AM   #8
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Hi

@Fizzlemizz, No, I haven't tried that one, but would that do a trick in this case?

@lightspark, Ah..... that's why....... I didn't know that fontstring takes the highest place of sublevel

In my case, I should put texture on "OVERLAY" and text on "ARTWORK", right?
(Since I am expecting texture to be on top of text)

Last edited by Layback_ : 06-27-17 at 12:42 AM.
  Reply With Quote
06-27-17, 02:05 AM   #9
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 328
Originally Posted by Layback_ View Post
@lightspark, Ah..... that's why....... I didn't know that fontstring takes the highest place of sublevel

In my case, I should put texture on "OVERLAY" and text on "ARTWORK", right?
(Since I am expecting texture to be on top of text)
Please, take a look at the code block I posted. I used your code, but fixed layers.

Also, you can assign layers and sublevels by passing them to CreateTexture and CreateFontString. I dunno why you're using SetDrawLayer.
__________________
  Reply With Quote
06-27-17, 04:29 AM   #10
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Originally Posted by lightspark View Post
Please, take a look at the code block I posted. I used your code, but fixed layers.
My bad haha...

I only read your comment, not code

Originally Posted by lightspark View Post
I'd either put your texture on a lower layer: ARTWORK, or move your text to an higher layer: HIGHLIGHT

Originally Posted by lightspark View Post
Also, you can assign layers and sublevels by passing them to CreateTexture and CreateFontString. I dunno why you're using SetDrawLayer.
When I checked an API on wowprogramming and wowpedia, CreateFontString didn't seem to have a sublevel argument

So I chose to use SetDrawLayer instead of setting layer and sublevel argument on Creation.

But, since I know that fontstrings are always set to have highest sublevel, I don't need to use SetDrawLayer like you said

Thanks for clarification.

Last edited by Layback_ : 06-27-17 at 04:32 AM.
  Reply With Quote
06-27-17, 05:42 AM   #11
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 328
Originally Posted by Layback_ View Post
My bad haha...

I only read your comment, not code
K, I fixed higher/lower typo
__________________
  Reply With Quote
06-27-17, 08:51 AM   #12
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Originally Posted by lightspark View Post
K, I fixed higher/lower typo
! ! ! !
  Reply With Quote
06-27-17, 04:43 PM   #13
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,890
Originally Posted by lightspark View Post
I'd either put your text on a lower layer: ARTWORK, or move your texture to a higher layer: HIGHLIGHT.
HIGHLIGHT is a special layer that only shows on mouseover. Don't use it unless you need this behavior.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Drawing a texture on top of fontstring

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