<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/..\FrameXML\UI.xsd">
	
	<Script file="scripts.lua"/>
	
	<EditBox name="BongosOptionsEditBox" autoFocus="false" virtual="true">
		<Size x="298" y="30"/>
		
		<Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border">
			<BackgroundInsets>
				<AbsInset left="2" right="2" top="2" bottom="2"/>
			</BackgroundInsets>
			<EdgeSize>
				<AbsValue val="16"/>
			</EdgeSize>
			<BorderColor r="0.6" g="0.6" b="0.6"/>
		</Backdrop>
		
		<Layers>
			<Layer level ="BACKGROUND">
				<Texture file="Interface\ChatFrame\ChatFrameBackground">
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="4" y="-4"/>
						</Anchor>
						<Anchor point="BOTTOMRIGHT">
							<Offset x="-4" y="4"/>
						</Anchor>
					</Anchors>
					<Gradient orientation="VERTICAL">
						<MinColor r="0" g="0" b="0" a="0.9"/>
						<MaxColor r="0.2" g="0.2" b="0.2" a="0.9"/>
					</Gradient>
				</Texture>
			</Layer>
		</Layers>
		
		<Scripts>
			<OnEscapePressed>
				this:ClearFocus();
			</OnEscapePressed>
		</Scripts>
		
		<FontString font="GameFontHighlight"/>
	</EditBox>
	
	<Button name="BongosOptionsDropDownButton" virtual="true">
		<Size x="24" y="24"/>
		
		<ButtonText>
			<Anchors>
				<Anchor point="LEFT" relativeTo="$parent" relativePoint="RIGHT">
					<Offset x="2" y="2"/>
				</Anchor>
			</Anchors>
		</ButtonText>
		
		<NormalFont font="GameFontNormal" justifyH="RIGHT"/>
		<NormalTexture file="Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up" setAllPoints="true"/>
		<PushedTexture file="Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down" setAllPoints="true"/>
		<HighlightTexture file="Interface\Buttons\UI-Common-MouseHilight" setAllPoints="true" alphaMode="ADD"/>
	</Button>
	
	<CheckButton name="BongosOptionsDropDownItem" virtual="true">
		<Size x="140" y="24"/>

		<ButtonText>
			<Anchors>
				<Anchor point="LEFT">
					<Offset x="24" y="0"/>
				</Anchor>
			</Anchors>
		</ButtonText>

		<NormalFont font= "GameFontNormal" justifyH="LEFT"/>
		<HighlightFont font="GameFontHighlight" justifyH="LEFT"/>

		<CheckedTexture file="Interface\Buttons\UI-CheckBox-Check">
			<Anchors>
				<Anchor point="TOPLEFT"/>
				<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMLEFT">
					<Offset x="24" y="0"/>
				</Anchor>
			</Anchors>
		</CheckedTexture>
	</CheckButton>
	
	<!-- the dropdown list of character names that we have data about -->
	<Frame name="BongosOptionsDropdownList" enableMouse="true" toplevel="true" hidden="true" virtual="true">
		<Size x="160" y="0"/>
		
		<Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border">
			<BackgroundInsets>
				<AbsInset left="2" right="2" top="2" bottom="2"/>
			</BackgroundInsets>
			<EdgeSize>
				<AbsValue val="16"/>
			</EdgeSize>
			<BorderColor r="0.6" g="0.6" b="0.6"/>
		</Backdrop>
				
		<Layers>
			<Layer level ="BACKGROUND">
				<Texture file="Interface\ChatFrame\ChatFrameBackground">
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="4" y="-4"/>
						</Anchor>
						<Anchor point="BOTTOMRIGHT">
							<Offset x="-4" y="4"/>
						</Anchor>
					</Anchors>
					<Gradient orientation="VERTICAL">
						<MinColor r="0" g="0" b="0" a="0.9"/>
						<MaxColor r="0.2" g="0.2" b="0.2" a="0.9"/>
					</Gradient>
				</Texture>
			</Layer>
		</Layers>
	</Frame>
	

	<Frame name="BongosOptionsScripts" inherits="BongosOptionsPanel" virtual="true">
		<Frames>
			<Button name="$parentBarDropDown" inherits="BongosOptionsDropDownButton">
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="7" y="1"/>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						BOptionsScript_ShowBarList(getglobal(this:GetParent():GetName() .. "BarList"));
					</OnClick>
				</Scripts>
			</Button>
			
			<EditBox name="$parentBarNameBox" inherits="BongosOptionsEditbox">
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="4" y="4"/>
					</Anchor>
				</Anchors>
				
				<Layers>
					<Layer level="ARTWORK">
						<FontString name="$parentName" font="GameFontNormal" text="Bar:">
							<Anchors>
								<Anchor point="LEFT">
									<Offset x="26" y="0"/>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
				</Layers>

				<Scripts>
					<OnLoad>
						this:SetTextInsets(56, 4, 0, 0)
					</OnLoad>
				</Scripts>
			</EditBox>
			
			<Frame name="$parentBarList" inherits="BongosOptionsDropdownList">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentBarNameBox" relativePoint="BOTTOMLEFT">
						<Offset x="0" y="6"/>
					</Anchor>
				</Anchors>
			</Frame>
			
			<Button name="$parentEventDropDown" inherits="BongosOptionsDropDownButton">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentBarDropDown" relativePoint="BOTTOMLEFT">
						<Offset x="0" y="-6"/>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						BOptionsScript_ShowEventList(getglobal(this:GetParent():GetName() .. "EventList"));
					</OnClick>
				</Scripts>
			</Button>
			
			<EditBox name="$parentEventBox" inherits="BongosOptionsEditBox" autoFocus="false">
				<Layers>
					<Layer level="ARTWORK">
						<FontString name="$parentName" font="GameFontNormal" text="Event:">
							<Anchors>
								<Anchor point="LEFT">
									<Offset x="26" y="0"/>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
				</Layers>

				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentBarNameBox" relativePoint="BOTTOMLEFT">
						<Offset x="0" y="0"/>
					</Anchor>
				</Anchors>

				<Scripts>
					<OnLoad>
						this:SetTextInsets(72, 6, 0, 0)
					</OnLoad>
				</Scripts>
			</EditBox>
			
			<Frame name="$parentEventList" inherits="BongosOptionsDropdownList">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentEventBox" relativePoint="BOTTOMLEFT">
						<Offset x="0" y="6"/>
					</Anchor>
				</Anchors>
			</Frame>
			
			<EditBox name="$parentActionBox" inherits="BongosOptionsEditbox" multiLine="true">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentEventBox" relativePoint="BOTTOMLEFT">
						<Offset x="0" y="-2"/>
					</Anchor>
					<Anchor point="BOTTOMRIGHT">
						<Offset x="-6" y="26"/>
					</Anchor>
				</Anchors>
				
				<Layers>
					<Layer level="ARTWORK">
						<FontString name="$parentName" font="GameFontNormal" text="Action:">
							<Anchors>
								<Anchor point="TOPLEFT">
									<Offset x="8" y="-6"/>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
				</Layers>
				
				<Scripts>
					<OnLoad>
						this:SetTextInsets(6, 6, 24, 6)
					</OnLoad>
				</Scripts>
			</EditBox>
			
			<Button name="$parentDelete" inherits="UIPanelButtonTemplate" text="Delete">
				<Size x="50" y="22"/>

				<Anchors>
					<Anchor point="BOTTOMRIGHT">
						<Offset x="-8" y="4"/>
					</Anchor>
				</Anchors>

				<Scripts>
					<OnClick>
						local barID = getglobal(this:GetParent():GetName() .. "BarNameBox"):GetText();
						if tonumber(barID) then
							barID = tonumber(barID);
						end
						local event = getglobal(this:GetParent():GetName() .. "EventBox"):GetText();
						
						BCustomScript.Delete(barID, event);
						
						getglobal(this:GetParent():GetName() .. "BarNameBox"):SetText("");
						getglobal(this:GetParent():GetName() .. "EventBox"):SetText("");	
						getglobal(this:GetParent():GetName() .. "ActionBox"):SetText("");
					</OnClick>
				</Scripts>
			</Button>
			
			<Button name="$parentSave" inherits="UIPanelButtonTemplate" text="Save">
				<Size x="42" y="22"/>

				<Anchors>
					<Anchor point="RIGHT" relativeTo="$parentDelete" relativePoint="LEFT">
						<Offset x="-2" y="0"/>
					</Anchor>
				</Anchors>

				<Scripts>
					<OnClick>
						local barID = getglobal(this:GetParent():GetName() .. "BarNameBox"):GetText();
						if tonumber(barID) then
							barID = tonumber(barID);
						end
						local event = getglobal(this:GetParent():GetName() .. "EventBox"):GetText();
						local action = getglobal(this:GetParent():GetName() .. "ActionBox"):GetText();
						local runNow = getglobal(this:GetParent():GetName() .. "RunNow"):GetChecked();
						BCustomScript.Save(barID, event, action, runNow);
					</OnClick>
				</Scripts>
			</Button>
			
			<CheckButton name="$parentRunNow" inherits="BongosCheckButtonTemplate" text="Run at Load">
				<Anchors>
					<Anchor point="BOTTOMLEFT">
						<Offset x="2" y="-2"/>
					</Anchor>
				</Anchors>
			</CheckButton>
		</Frames>
		
		<Scripts>
			<OnShow>
				local frame = this:GetParent():GetParent();
				frame:SetWidth(frame:GetWidth() + 80);
				frame:SetHeight(frame:GetHeight() + 140);
			</OnShow>
			<OnHide>
				local frame = this:GetParent():GetParent();
				frame:SetWidth(frame:GetWidth() - 80);
				frame:SetHeight(frame:GetHeight() - 140);
				getglobal(this:GetName() .. "BarList"):Hide();
				getglobal(this:GetName() .. "EventList"):Hide();
			</OnHide>
		</Scripts>
	</Frame>
</Ui>