added horizontal scroll

added the ability to scroll gorizontally, in two ways:
	- with a touchpad
	- holding "alt" and scrolling
also made the scroll senitivity configurable for both directions
master
Alessandro Mauri 3 years ago
parent a7df717cf0
commit a5e90420e8
  1. 4
      TODO
  2. 3
      data/core/config.lua
  3. 4
      data/core/rootview.lua
  4. 17
      data/core/view.lua
  5. 3
      src/api/system.c

@ -16,7 +16,7 @@
[ ] that command can be what is selected
[ ] console: accept input
[ ] doc: detect file changes with hash
[ ] add horizontal scroll
[x] add horizontal scroll
[ ] add a cross to close tab
[ ] add context menu to various things
[ ] document and selection context menu
@ -55,3 +55,5 @@
[ ] show hidden files config and binding
[ ] syntax: highlight FIXME TODO BUG FIX and IMPROVEMENT keywords
[ ] do not open doc in new tab if current tab has an unchanged document
[ ] doc: add auto close brackets and quotes
[ ] view: implement get_scrollable_size()

@ -4,7 +4,8 @@ config.project_scan_rate = 5
config.fps = 60
config.max_log_items = 80
config.message_timeout = 3
config.mouse_wheel_scroll = 50 * SCALE
config.mouse_wheel_scroll_y = 50 * SCALE
config.mouse_wheel_scroll_x = 30 * SCALE
config.file_size_limit = 10
config.ignore_files = "^%."
config.symbol_pattern = "[%a_][%w_]*"

@ -473,10 +473,10 @@ function RootView:on_mouse_moved(x, y, dx, dy)
end
function RootView:on_mouse_wheel(...)
function RootView:on_mouse_wheel(dy, dx)
local x, y = self.mouse.x, self.mouse.y
local node = self.root_node:get_child_overlapping_point(x, y)
node.active_view:on_mouse_wheel(...)
node.active_view:on_mouse_wheel(dy, dx)
end

@ -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

@ -123,7 +123,8 @@ top:
case SDL_MOUSEWHEEL:
lua_pushstring(L, "mousewheel");
lua_pushnumber(L, e.wheel.y);
return 2;
lua_pushnumber(L, e.wheel.x);
return 3;
default:
goto top;

Loading…
Cancel
Save