<Ui>



	<Button name="TellMeWhen_BarDisplay_ColorButton" virtual="true">
		<Size x="20" y="20"/>

		<Attributes>
			<Attribute name="tmw-class" type="string" value="Config_ColorButton"/>
		</Attributes>

		<Layers>
			<Layer level="BACKGROUND">
				<Texture parentKey="background">
					<Size x="17.5" y="17.5"/>
					<Anchors>
						<Anchor point="CENTER"/>
					</Anchors>
					<Color r="1.0" g="1.0" b="1.0"/>
				</Texture>
				<FontString name="$parenttext" parentKey="text" justifyH="LEFT" inherits="GameFontHighlightSmall">
					<Anchors>
						<Anchor point="LEFT" relativePoint="RIGHT" x="2"/>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<NormalTexture name="$parentNormalTexture" file="Interface\ChatFrame\ChatFrameColorSwatch"/>
	</Button>

	<Frame name="TellMeWhen_BarDisplayBarOptions" inherits="TellMeWhen_OptionsModuleContainer" virtual="true">
		<Size y="85"/>
		<Frames>
			<CheckButton name="$parentInvert" inherits="TellMeWhen_CheckTemplate" parentKey="Invert">
				<Anchors>
					<!-- Left anchor is handled by DistributeFrameAnchorsLaterally in parent's OnLoad -->
					<Anchor point="TOP" y="-1"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_Invert",
							title = TMW.L["ICONMENU_INVERTBARS"],
							tooltip = TMW.L["ICONMENU_INVERTBARDISPLAYBAR_DESC"],
						})
					</OnLoad>
				</Scripts>
			</CheckButton>
			
			<CheckButton name="$parentBarGCD" inherits="TellMeWhen_CheckTemplate" parentKey="BarGCD">
				<!-- Anchoring is handled by DistributeFrameAnchorsLaterally in parent's OnLoad -->
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_BarGCD",
							title = TMW.L["ICONMENU_ALLOWGCD"],
							tooltip = TMW.L["ICONMENU_ALLOWGCD_DESC"],
							hidden = function(self)
								return TMW.CI.icon.typeData.hasNoGCD
							end,
						})
					</OnLoad>
				</Scripts>
			</CheckButton>
			
			<CheckButton name="$parentEnableColors" inherits="TellMeWhen_CheckTemplate" parentKey="EnableColors">
				<Anchors>
					<!-- Left anchor is handled by DistributeFrameAnchorsLaterally in parent's OnLoad -->
					<Anchor point="TOP" relativeTo="$parentInvert" relativePoint="BOTTOM" y="3"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_EnableColors",
							title = TMW.L["ICONMENU_ENABLECOLORS"],
							tooltip = TMW.L["ICONMENU_ENABLECOLORS_DESC"],
							OnState = function(self)
								if self:GetChecked() then
									TMW.HELP:Show{
										code = "COLOR_COPY_DRAG",
										icon = nil,
										relativeTo = self,
										x = 0,
										y = 0,
										text = format(TMW.L["ICONMENU_ENABLECOLORS_HELP"])
									}
								end
							end,
						})
					</OnLoad>
				</Scripts>
			</CheckButton>
			
			<EditBox name="$parentFakeMax" inherits="TellMeWhen_TimeEditBoxTemplate" parentKey="FakeMax" autoFocus="false">
				<Size x="45" y="15"/>
				<Anchors>
					<Anchor point="TOP" relativeTo="$parentBarGCD" relativePoint="BOTTOM" y="-2"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						self.text:SetText(TMW.L["ICONMENU_FAKEMAX"])
						--self.text:SetWidth(50)
						self.text:ClearAllPoints()
						self.text:SetPoint("LEFT", self, "RIGHT", 2, 0)
						self.text:SetPoint("RIGHT", self:GetParent(), "RIGHT", -5, 0)
						
						self:SetPoint("LEFT", self:GetParent().BarGCD, "LEFT", 8, 0)
						
						TMW:CInit(self, {
							setting = "BarDisplay_FakeMax",
							title = TMW.L["ICONMENU_FAKEMAX"],
							tooltip = TMW.L["ICONMENU_FAKEMAX_DESC"],
							disabled = function(self)
								return TMW.CI.ics.BarDisplay_Invert
							end,
							ModifySettingValue = function(self, value)
								return tonumber(value) or 0
							end,
						})
					</OnLoad>
				</Scripts>
			</EditBox>

			<Button name="$parentColorStart" parentKey="ColorStart" inherits="TellMeWhen_BarDisplay_ColorButton">
				<Anchors>
					<Anchor point="TOP" relativeTo="$parentFakeMax" relativePoint="BOTTOM" y="-10" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_StartColor",
							title = TMW.L["ICONMENU_BAR_COLOR_START"],
							tooltip = TMW.L["ICONMENU_BAR_COLOR_START_DESC"],
							disabled = function(self)
								return not TMW.CI.ics.BarDisplay_EnableColors
							end,
						})
					</OnLoad>
				</Scripts>
			</Button>

			<Button name="$parentColorMiddle" parentKey="ColorMiddle" inherits="TellMeWhen_BarDisplay_ColorButton">
				<Anchors>
					<Anchor point="TOP" relativeTo="$parentColorStart" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_MiddleColor",
							title = TMW.L["ICONMENU_BAR_COLOR_MIDDLE"],
							tooltip = TMW.L["ICONMENU_BAR_COLOR_MIDDLE_DESC"],
							disabled = function(self)
								return not TMW.CI.ics.BarDisplay_EnableColors
							end,
						})
					</OnLoad>
				</Scripts>
			</Button>

			<Button name="$parentColorComplete" parentKey="ColorComplete" inherits="TellMeWhen_BarDisplay_ColorButton">
				<Anchors>
					<Anchor point="TOP" relativeTo="$parentColorStart" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							setting = "BarDisplay_CompleteColor",
							title = TMW.L["ICONMENU_BAR_COLOR_COMPLETE"],
							tooltip = TMW.L["ICONMENU_BAR_COLOR_COMPLETE_DESC"],
							disabled = function(self)
								return not TMW.CI.ics.BarDisplay_EnableColors
							end,
						})
					</OnLoad>
				</Scripts>
			</Button>

		</Frames>
		<Scripts>
			<OnLoad>
				self.Header:SetText(TMW.L["CONFIGPANEL_TIMERBAR_BARDISPLAY_HEADER"])
				
				self.Invert:ConstrainLabel(self.BarGCD)
				self.BarGCD:ConstrainLabel(self, "RIGHT", -1, 0)

				self.EnableColors:ConstrainLabel(self.FakeMax)
				self.FakeMax:ConstrainLabel(self, "RIGHT", -1, 0)

				self.ColorStart:ConstrainLabel(self.ColorMiddle)
				self.ColorMiddle:ConstrainLabel(self.ColorComplete)
				self.ColorComplete:ConstrainLabel(self, "RIGHT", -1, 0)
				
				TMW.IE:DistributeFrameAnchorsLaterally(self, 2, self.Invert, self.BarGCD)
				TMW.IE:DistributeFrameAnchorsLaterally(self, 2, self.EnableColors)
				TMW.IE:DistributeFrameAnchorsLaterally(self, 3, self.ColorStart, self.ColorMiddle, self.ColorComplete)
			</OnLoad>
		</Scripts>
	</Frame>
 
</Ui>