Scale fonts context menu (#246)
* Retrieve scale plugin from lite-plugins * New implementation of scale plugin and font C API Introduce two new C API functions, renderer.font.get_size and set_size respectively to get the font size and to set the size to a new value. Using these functions we don't need to know the name of the font but we can just change their size. Adapt the scale plugin to use the new C API function with minor adaptations in the logic. Use smaller step to scale fonts. Rename font_desc_free function, previous name was misleading as only the cached resources are freed. * Add contextmenu plugin from takase From https://github.com/takase1121/lite-contextmenu Adapted to show font scaling commands and find/replace commands. i# testing.lua * Fix the cursor flickering with contextmenu To avoid flickering of the cursor when using the context menu we add a new function `core.request_cursor` that just take note of the cursor requested. The cursor will be actually changed only in root_view:draw() method only when all the drawing operations are done. This means the cursor will be changed only once per frame and only the most recent cursor change request will take effect. * Remove unneeded scale plugin return functions
This commit is contained in:
@@ -1073,6 +1073,11 @@ function core.blink_reset()
|
||||
end
|
||||
|
||||
|
||||
function core.request_cursor(value)
|
||||
core.cursor_change_req = value
|
||||
end
|
||||
|
||||
|
||||
function core.on_error(err)
|
||||
-- write error to file
|
||||
local fp = io.open(USERDIR .. "/error.txt", "wb")
|
||||
|
||||
@@ -783,7 +783,7 @@ end
|
||||
|
||||
function RootView:on_mouse_moved(x, y, dx, dy)
|
||||
if core.active_view == core.nag_view then
|
||||
system.set_cursor("arrow")
|
||||
core.request_cursor("arrow")
|
||||
core.active_view:on_mouse_moved(x, y, dx, dy)
|
||||
return
|
||||
end
|
||||
@@ -808,14 +808,14 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
||||
local div = self.root_node:get_divider_overlapping_point(x, y)
|
||||
local tab_index = node and node:get_tab_overlapping_point(x, y)
|
||||
if node and node:get_scroll_button_index(x, y) then
|
||||
system.set_cursor("arrow")
|
||||
core.request_cursor("arrow")
|
||||
elseif div then
|
||||
local axis = (div.type == "hsplit" and "x" or "y")
|
||||
if div.a:is_resizable(axis) and div.b:is_resizable(axis) then
|
||||
system.set_cursor(div.type == "hsplit" and "sizeh" or "sizev")
|
||||
core.request_cursor(div.type == "hsplit" and "sizeh" or "sizev")
|
||||
end
|
||||
elseif tab_index then
|
||||
system.set_cursor("arrow")
|
||||
core.request_cursor("arrow")
|
||||
if self.dragged_node and self.dragged_node ~= tab_index then
|
||||
local tab = node.views[self.dragged_node]
|
||||
table.remove(node.views, self.dragged_node)
|
||||
@@ -823,7 +823,7 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
||||
self.dragged_node = tab_index
|
||||
end
|
||||
else
|
||||
system.set_cursor(node.active_view.cursor)
|
||||
core.request_cursor(node.active_view.cursor)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -858,6 +858,10 @@ function RootView:draw()
|
||||
local t = table.remove(self.deferred_draws)
|
||||
t.fn(table.unpack(t))
|
||||
end
|
||||
if core.cursor_change_req then
|
||||
system.set_cursor(core.cursor_change_req)
|
||||
core.cursor_change_req = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user