View Single Post
06-25-19, 01:12 AM   #3
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
I fixed this with help. Its a solution that appears to work from my testing. And implemented it in my latest release found here https://wow.curseforge.com/projects/...unitbars/files

What it looks like
https://i.imgur.com/XaW7t1W.jpg


The fix is below

Code:
-- Setup pullout
local function SetupPullout(Widget)
  local Dropdown = Widget.dropdown
  local Pullout = Widget.pullout
  local Slider = Pullout.slider
  local ScrollFrame = Pullout.scrollFrame
  local ItemFrame = Pullout.itemFrame

  -- Store original values in userdata
  local UserData = WidgetUserData[Widget]
  if UserData == nil then
    UserData = {}
    WidgetUserData[Widget] = UserData
  end
  local SliderPoints = {}

  -- Save all points
  UserData.SliderPoints = SliderPoints
  for PointIndex = 1, Slider:GetNumPoints() do
    SliderPoints[PointIndex] = { Slider:GetPoint(PointIndex) }
  end

  -- Setup the pullout width and height
  UserData.MaxHeight = Pullout.maxHeight
  Pullout:SetMaxHeight(188)
  Widget:SetPulloutWidth(280)

  -- Move slider a few pixels to the left and make it easier to click
  Slider:SetHitRectInsets(-5, 0, -10, 0)

  UserData.SliderWidth = Slider:GetWidth()
  Slider:SetWidth(12)

  Slider:ClearAllPoints()
  Slider:SetPoint('TOPLEFT', ScrollFrame, 'TOPRIGHT', -20, 0)
  Slider:SetPoint('BOTTOMLEFT', ScrollFrame, 'BOTTOMRIGHT', -20, 0)

  -- Lower the strata of the itemframe so the slider is easier to click
  -- Slider frame strata was set to 'TOOLTIP'
  UserData.ItemFrameStrata = ItemFrame:GetFrameStrata()
  ItemFrame:SetFrameStrata('FULLSCREEN_DIALOG')
end

-- Restore pullout
local function RestorePullout(Widget)
  local UserData = WidgetUserData[Widget]
  local SliderPoints = UserData.SliderPoints
  local Pullout = Widget.pullout
  local Slider = Pullout.slider

  Slider:SetWidth(UserData.SliderWidth)
  Slider:SetHitRectInsets(0, 0, -10, 0)
  Slider:ClearAllPoints()
  for PointIndex = 1, #SliderPoints do
    Slider:SetPoint(unpack(SliderPoints[PointIndex]))
  end
  Pullout:SetMaxHeight(UserData.MaxHeight)
  Pullout.itemFrame:SetFrameStrata(UserData.ItemFrameStrata)

  WidgetUserData[Widget] = nil
end

-------------------------------------------------------------------------------
-- DropdownSelectConstructor
--
-- This uses an existing widget, then changes it into a custom
-- This make a menu have a scroll bar
-------------------------------------------------------------------------------
local function DropdownSelectConstructor()
  local Widget = AceGUI:Create('Dropdown')
  Widget.type = DropdownSelectWidgetType

  -- methods
  local OldOnRelease = Widget.OnRelease
  local OldOnAcquire = Widget.OnAcquire

  Widget.OnRelease = function(self, ...)
    RestorePullout(self)
    OldOnRelease(self, ...)
  end
  Widget.OnAcquire = function(self, ...)
    -- Only call OnAcquire if there is no pullout created
    -- This prevents two calls. Once during Create and
    -- again when this custom control is created
    if Widget.pullout == nil then
      OldOnAcquire(self, ...)
    end

    SetupPullout(self)
  end

  return AceGUI:RegisterAsWidget(Widget)
end

AceGUI:RegisterWidgetType(DropdownSelectWidgetType, DropdownSelectConstructor, DropdownSelectWidgetVersion)
  Reply With Quote