Thread Tools Display Modes
01-22-09, 12:10 PM   #1
Cuthwine
A Kobold Labourer
Join Date: Jan 2009
Posts: 1
Arrow Making a button for turning visibility on bars on and off

Okay, lately I've been working a lot on my UI, and when Im running around or flying or whatever that does need my attention on my bars id like it when they are gone.

Still, when Im doing a quest or what ever I would like them to be visible.
I figured "hide out of combat" seemed like nice alternative since it does mostly what I need, but it disappears to early, Id like them to be stuck for until Im done with my quest. Using bartender4 btw.

So I started wondering, is there some way to make a button turning the visibility on and off on my spellbars, but since I have no clue making it, I thought Id ask some where.
  Reply With Quote
01-22-09, 12:42 PM   #2
tinyu
A Molten Giant
 
tinyu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 837
have you tried pressing alt-Z?
__________________
"There's no such thing as too many addons."
Lothaer
Titan Dev Team Member.
  Reply With Quote
01-22-09, 04:44 PM   #3
Auren
An Aku'mai Servant
 
Auren's Avatar
Join Date: Sep 2006
Posts: 37
This is a quick put together, I didn't write the code, just edited for my use.
Thanks goes to PortalBox Author (who's minimap button code i "borrowed").

Either click the minimap button or use macro:
Code:
/script HideFrame_toggle();
HideFrame.lua
Code:
function HideFrame_MinimapButton_Reposition()
	HideFrame_MinimapButton:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-(80*cos(MinimapPos)),(80*sin(MinimapPos))-52)
end

function HideFrame_OnLoad()
	this:RegisterEvent("VARIABLES_LOADED");
	out("• HideFrame Loaded •");
end

function HideFrame_OnEvent()
	if ( event == "VARIABLES_LOADED" ) then
		if (MinimapPos == NIL) then
			MinimapPos = 1
		end
    	HideFrame_MinimapButton_Reposition();
	end
end

function HideFrame_MinimapButton_DraggingFrame_OnUpdate()

	local xpos,ypos = GetCursorPosition()
	local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()

	xpos = xmin-xpos/UIParent:GetScale()+70 -- get coordinates as differences from the center of the minimap
	ypos = ypos/UIParent:GetScale()-ymin-70

	MinimapPos = math.deg(math.atan2(ypos,xpos)) -- save the degrees we are relative to the minimap center
	HideFrame_MinimapButton_Reposition() -- move the button
end

function HideFrame_MinimapButton_OnClick()
	HideFrame_toggle(msg);
end

function out(text)
	DEFAULT_CHAT_FRAME:AddMessage(text)
end

function HideFrame_toggle()
	if (BT4Bar1:IsVisible()) then
		BT4Bar1:Hide();
		BT4Bar2:Hide();
	else
		BT4Bar1:Show();
		BT4Bar2:Show();
	end
end
HideFrame.xml
Code:
<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/">
	
<Script file="HideFrame.lua"/>
<Frame name="HFFrame">
	<Scripts>
		<OnLoad>
			HideFrame_OnLoad();
		</OnLoad>
		<OnEvent>
			HideFrame_OnEvent();
		</OnEvent>
	</Scripts>
</Frame>
	<Button name="HideFrame_MinimapButton" parent="Minimap" frameStrata="HIGH" enableMouse="true" movable="true" hidden="false">
		<Size>
			<AbsDimension x="33" y="33"/>
		</Size>
		<Anchors>
			<Anchor point="TOPLEFT"/>
		</Anchors>
		<Layers>
			<Layer level="HIGH">
				<Texture name="HideFrame_MinimapButton_Icon" file="Interface\Icons\Spell_Arcane_PortalIronforge">
					<Size>
						<AbsDimension x="21" y="21"/>
					</Size>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset>
								<AbsDimension x="7" y="-6"/>
							</Offset>
						</Anchor>
					</Anchors>
				</Texture>
			</Layer>
			<Layer level="OVERLAY">
				<Texture file="Interface\Minimap\MiniMap-TrackingBorder">
					<Size>
						<AbsDimension x="56" y="56"/>
					</Size>
					<Anchors>
						<Anchor point="TOPLEFT"/>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Frames>
			<Frame name="HideFrame_MinimapButton_DraggingFrame" hidden="true">
				<Scripts>
					<OnUpdate>
						HideFrame_MinimapButton_DraggingFrame_OnUpdate()
					</OnUpdate>
				</Scripts>
			</Frame>
		</Frames>
		<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
		<Scripts>
			<OnLoad>
				this:RegisterForClicks("LeftButtonUp","RightButtonUp")
				this:RegisterForDrag("LeftButton","RightButton")
			</OnLoad>
			<OnEnter>
				GameTooltip:SetOwner(this, ANCHOR_TOPLEFT);
				GameTooltip:AddLine("HideFrame")
				GameTooltip:Show()
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide()
			</OnLeave>
			<OnDragStart>
				this:LockHighlight()
				HideFrame_MinimapButton_DraggingFrame:Show()
			</OnDragStart>
			<OnDragStop>
				this:UnlockHighlight()
				HideFrame_MinimapButton_DraggingFrame:Hide()
			</OnDragStop>
			<OnClick>
				HideFrame_MinimapButton_OnClick() -- do your thing in here, arg1 is mouse button clicked
			</OnClick>
		</Scripts>
	</Button>

</Ui>

HideFrame.toc
Code:
## Interface: 30000
## Title: HideFrame
## Notes: 
## SavedVariables: MinimapPos
HideFrame.lua
HideFrame.xml
This only hides bar1 and 2, to add more, find the bar names.
Usually BT4Bar2, BT4Bar3 etc, and add it to the bottom of the lua file.
Feel free to edit, just thank the original author of PortalBox.

Do NOT blame me for any damage this causes, any limbs lost, pc's fried etc.
It worked fine on my pc.
Hope this helped.
__________________
Rogue [Combat] - 80
Paladin [Protection] - 80
Death Knight [Blood] - 77
Shaman [Elemental] - 77
Mage [Frost] - 76
Priest [Shadow] - 75
Hunter [Beast] - 72
  Reply With Quote
01-22-09, 04:49 PM   #4
Sepioth
A Molten Giant
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 894
I agree with Tinyu ... Press Alt+Z to make your UI disappear and re-appear .. no need for an addon to do this when it is built into the game.
  Reply With Quote
01-22-09, 07:00 PM   #5
Auren
An Aku'mai Servant
 
Auren's Avatar
Join Date: Sep 2006
Posts: 37
Alt+z removes everything.. minimaps. chat windows, health frames etc.
If thats what he wants then yes, but if he wants to keep those (I believe he does as he asked for bars.)
__________________
Rogue [Combat] - 80
Paladin [Protection] - 80
Death Knight [Blood] - 77
Shaman [Elemental] - 77
Mage [Frost] - 76
Priest [Shadow] - 75
Hunter [Beast] - 72
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Making a button for turning visibility on bars on and off


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