@ -3,6 +3,7 @@ local config = require "core.config"
local style = require " core.style "
local common = require " core.common "
local Object = require " core.object "
local keymap = require " core.keymap "
local View = Object : extend ( )
@ -44,6 +45,7 @@ function View:get_name()
end
-- TODO: implement this
function View : get_scrollable_size ( )
return math.huge
end
@ -96,9 +98,14 @@ function View:on_text_input(text)
end
function View : on_mouse_wheel ( y )
function View : on_mouse_wheel ( y , x )
if self.scrollable then
self.scroll . to.y = self.scroll . to.y + y * - config.mouse_wheel_scroll
if keymap.modkeys [ ' alt ' ] then
self.scroll . to.x = self.scroll . to.x + y * - config.mouse_wheel_scroll_x
else
self.scroll . to.y = self.scroll . to.y + y * - config.mouse_wheel_scroll_y
self.scroll . to.x = self.scroll . to.x + x * - config.mouse_wheel_scroll_x
end
end
end
@ -118,8 +125,10 @@ end
function View : clamp_scroll_position ( )
local max = self : get_scrollable_size ( ) - self.size . y
self.scroll . to.y = common.clamp ( self.scroll . to.y , 0 , max )
local max_y = self : get_scrollable_size ( ) - self.size . y
local max_x = self : get_scrollable_size ( ) - self.size . x
self.scroll . to.y = common.clamp ( self.scroll . to.y , 0 , max_y )
self.scroll . to.x = common.clamp ( self.scroll . to.x , 0 , max_x )
end