Permalink
Browse files

Don't extend PickHelper instances. Fixes #24

  • Loading branch information...
thomthom committed Feb 11, 2019
1 parent a485699 commit 0c07fd546806af665ed4d6fbb68e5a4e336bafb1
Showing with 14 additions and 5 deletions.
  1. +13 −2 src/tt_truebend/dpi/pick_helper.rb
  2. +1 −3 src/tt_truebend/dpi/view.rb
@@ -1,3 +1,5 @@
require 'delegate.rb'

require 'tt_truebend/dpi/view'
require 'tt_truebend/dpi'

@@ -6,7 +8,16 @@ module TT::Plugins::TrueBend
#
# The users of this class work with logical units and they are automatically
# converted to device pixels for the API to consume where appropriate.
module HighDpiPickHelper
class HighDpiPickHelper < SimpleDelegator

# @param [Sketchup::PickHelper] pick_helper
def initialize(pick_helper)
unless pick_helper.is_a?(Sketchup::PickHelper)
raise TypeError, "Expected Sketchup::PickHelper, got #{pick_helper.class.name}"
end

super(pick_helper)
end

# @param [Integer] x
# @param [Integer] y
@@ -75,5 +86,5 @@ def view
HighDpiView.new(super)
end

end # module
end # class
end # module
@@ -123,9 +123,7 @@ def line_width=(width)
def pick_helper(*args)
args[0] *= DPI.scale_factor if args.size >= 1 # x
args[1] *= DPI.scale_factor if args.size >= 2 # y
ph = @view.pick_helper(*args)
ph.extend(HighDpiPickHelper)
ph
HighDpiPickHelper.new(@view.pick_helper(*args))
end

# @param [Integer] x

0 comments on commit 0c07fd5

Please sign in to comment.