<Ui>

	<Frame name="TellMeWhen_CLEUOptions" inherits="TellMeWhen_OptionsModuleContainer" virtual="true">
		<Size y="250"/>
		<Frames>
		
			<Frame name="$parentCLEUEvents" inherits="TMW_DropDownMenuTemplate" parentKey="CLEUEvents">
				<Anchors>
					<Anchor point="TOPLEFT" x="5" y="-3"/>
					<Anchor point="RIGHT" x="-5" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							title = TMW.L["CLEU_EVENTS"],
							tooltip = TMW.L["CLEU_EVENTS_DESC"],
							func = TMW.Types.cleu.CONFIG.EventMenu,
						})

						self.Button:HookScript("OnClick", function(self)
							TMW.IE:SaveSettings()
						end)
					</OnLoad>
				</Scripts>
			</Frame>
			
			<EditBox name="$parentCLEUDur" parentKey="CLEUDur" inherits="TellMeWhen_TimeEditBoxTemplate">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentCLEUEvents" relativePoint="BOTTOMLEFT" y="3"/>
				</Anchors>
				<Layers>
					<Layer level="ARTWORK">
						<FontString parentKey="text2" wordwrap="true" justifyH="LEFT" inherits="GameFontHighlightSmall">
							<Anchors>
								<Anchor point="LEFT" relativePoint="RIGHT" x="5"/>
								<Anchor point="RIGHT" relativeto="TellMeWhen_CLEUOptions" x="-5"/>
							</Anchors>
						</FontString>
					</Layer>
				</Layers>
				<Scripts>
					<OnLoad>
						self.text2:SetText(TMW.L["CLEU_TIMER"])
						self.text2:SetWidth(self:GetParent().CLEUEvents:GetWidth() - self:GetWidth() - 35)
						self.setting = "CLEUDur"
						
						TMW:CInit(self, {
							setting = "CLEUDur",
							title = TMW.L["CLEU_TIMER"],
							tooltip = TMW.L["CLEU_TIMER_DESC"],
							ModifySettingValue = function(self, value)
								return tonumber(value) or 0
							end,
						})
					</OnLoad>
				</Scripts>
			</EditBox>

			<CheckButton name="$parentCLEUNoRefresh" inherits="TellMeWhen_CheckTemplate" parentKey="CLEUNoRefresh">
				<Anchors>
					<Anchor point="LEFT" relativeTo="$parentCLEUDur" relativePoint="RIGHT" x="2" y="-1"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						self:SetFrameLevel(self:GetFrameLevel() + 2) -- sometimes it ends up under the type dropdown which makes half of the checkbox unclickable
					
						TMW:CInit(self, {
							setting = "CLEUNoRefresh",
							title = TMW.L["ICONMENU_CLEU_NOREFRESH"],
							tooltip = TMW.L["ICONMENU_CLEU_NOREFRESH_DESC"],
						})
					</OnLoad>
				</Scripts>
			</CheckButton>
			
			<EditBox name="$parentSourceUnit" inherits="TellMeWhen_UnitEditBox" parentKey="SourceUnit">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentCLEUDur" relativePoint="BOTTOMLEFT" x="0" y="-10"/>
					<Anchor point="RIGHT" x="-125"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW.SUG:EnableEditBox(self, "units")
						
						self:RegisterEvent("MODIFIER_STATE_CHANGED")
						self.label = TMW.L["CLEU_SOURCEUNITS"]
						self.BackgroundText:SetWidth(self:GetWidth())
						
						TMW:CInit(self, {
							setting = "SourceUnit",
							title = TMW.L["CLEU_SOURCEUNITS"],
							tooltip = function()
								if IsModifierKeyDown() then
									return TMW.UNITS:GetUnitInputDetailedTooltip(self)
								else
									return TMW.L["CLEU_SOURCEUNITS_DESC"]
								end
							end,
							OnTextChanged = function(self)
								self:GetParent():AdjustHeight()
							end,
							doCleanString = true,
						})
					</OnLoad>
				</Scripts>
			</EditBox>
			<Frame name="$parentSourceFlags" inherits="TMW_DropDownMenuTemplate" parentKey="SourceFlags">
				<Anchors>
					<Anchor point="BOTTOMLEFT" relativeTo="$parentSourceUnit" relativePoint="BOTTOMRIGHT" x="2" y="-11"/>
					<Anchor point="RIGHT" x="-5" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							title = TMW.L["CLEU_FLAGS_SOURCE"],
							tooltip = TMW.L["CLEU_FLAGS_DESC"],
							func = TMW.Types.cleu.CONFIG.FlagsMenu,
						})

						self.flagSet = "SourceFlags" -- the setting name, basically
						self.Button:HookScript("OnClick", function(self)
							TMW.IE:SaveSettings()
						end)
					</OnLoad>
				</Scripts>
			</Frame>

			<EditBox name="$parentDestUnit" inherits="TellMeWhen_UnitEditBox" parentKey="DestUnit">
				<Anchors>
					<Anchor point="TOP" relativeTo="$parentSourceUnit" relativePoint="BOTTOM" y="-10"/>
					<Anchor point="LEFT" relativeTo="$parentSourceUnit"/>
					<Anchor point="RIGHT" relativeTo="$parentSourceUnit"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW.SUG:EnableEditBox(self, "units")
						
						self:RegisterEvent("MODIFIER_STATE_CHANGED")
						self.label = TMW.L["CLEU_DESTUNITS"]
						self.BackgroundText:SetWidth(self:GetWidth())
						
						TMW:CInit(self, {
							setting = "DestUnit",
							title = TMW.L["CLEU_DESTUNITS"],
							tooltip = function()
								if IsModifierKeyDown() then
									return TMW.UNITS:GetUnitInputDetailedTooltip(self)
								else
									return TMW.L["CLEU_DESTUNITS_DESC"]
								end
							end,
							OnTextChanged = function(self)
								self:GetParent():AdjustHeight()
							end,
							doCleanString = true,
						})
					</OnLoad>
				</Scripts>
			</EditBox>
			<Frame name="$parentDestFlags" inherits="TMW_DropDownMenuTemplate" parentKey="DestFlags">
				<Anchors>
					<Anchor point="BOTTOMLEFT" relativeTo="$parentDestUnit" relativePoint="BOTTOMRIGHT" x="2" y="-11"/>
					<Anchor point="RIGHT" x="-5" />
				</Anchors>
				<Scripts>
					<OnLoad>
						TMW:CInit(self, {
							title = TMW.L["CLEU_FLAGS_DEST"],
							tooltip = TMW.L["CLEU_FLAGS_DESC"],
							func = TMW.Types.cleu.CONFIG.FlagsMenu,
						})

						self.flagSet = "DestFlags" -- the setting name, basically
						self.Button:HookScript("OnClick", function(self)
							TMW.IE:SaveSettings()
						end)
					</OnLoad>
				</Scripts>
			</Frame>

		</Frames>
		<Scripts>
			<OnLoad>
				self.Header:SetText(TMW.L["CONFIGPANEL_CLEU_HEADER"])
				
				TMW.IE:DistributeFrameAnchorsLaterally(self, 2, self.CLEUDur, self.CLEUNoRefresh)
				self.CLEUDur:SetPoint("LEFT", 8, 0)
				
				self.CLEUNoRefresh:ConstrainLabel(self, "RIGHT")

				self.CLEUDur.text2:SetPoint("RIGHT", self.CLEUNoRefresh, "LEFT")
				self.CLEUDur.text2:SetHeight(30)
				
				function self:AdjustHeight()
					--self:SetHeight(75 + self.SourceUnit:GetHeight() + self.DestUnit:GetHeight())
					TMW:AnimateHeightChange(self, 75 + self.SourceUnit:GetHeight() + self.DestUnit:GetHeight(), 0.1)
				end
			</OnLoad>
		</Scripts>
	</Frame>
	
</Ui>