mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#255 fixed rectangle element not offsetting mouse events
This commit is contained in:
parent
8c87cb3e26
commit
5d6dda5619
@ -20,7 +20,7 @@ local sounder = require("coordinator.sounder")
|
||||
|
||||
local apisessions = require("coordinator.session.apisessions")
|
||||
|
||||
local COORDINATOR_VERSION = "v0.16.0"
|
||||
local COORDINATOR_VERSION = "v0.16.1"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
@ -60,7 +60,9 @@ local element = {}
|
||||
-- a base graphics element, should not be created on its own
|
||||
---@nodiscard
|
||||
---@param args graphics_args arguments
|
||||
function element.new(args)
|
||||
---@param child_offset_x? integer mouse event offset x
|
||||
---@param child_offset_y? integer mouse event offset y
|
||||
function element.new(args, child_offset_x, child_offset_y)
|
||||
local self = {
|
||||
id = nil, ---@type element_id|nil
|
||||
elem_type = debug.getinfo(2).name,
|
||||
@ -101,8 +103,10 @@ function element.new(args)
|
||||
-------------------------
|
||||
|
||||
-- prepare the template
|
||||
---@param offset_x integer x offset for mouse events
|
||||
---@param offset_y integer y offset for mouse events
|
||||
---@param next_y integer next line if no y was provided
|
||||
function protected.prepare_template(next_y)
|
||||
function protected.prepare_template(offset_x, offset_y, next_y)
|
||||
-- get frame coordinates/size
|
||||
if args.gframe ~= nil then
|
||||
protected.frame.x = args.gframe.x
|
||||
@ -150,7 +154,11 @@ function element.new(args)
|
||||
-- record position
|
||||
self.position.x, self.position.y = protected.window.getPosition()
|
||||
|
||||
-- calculate bounds
|
||||
-- shift per parent child offset
|
||||
self.position.x = self.position.x + offset_x
|
||||
self.position.y = self.position.y + offset_y
|
||||
|
||||
-- calculate mouse event bounds
|
||||
self.bounds.x1 = self.position.x
|
||||
self.bounds.x2 = self.position.x + f.w - 1
|
||||
self.bounds.y1 = self.position.y
|
||||
@ -283,7 +291,7 @@ function element.new(args)
|
||||
-- prepare the template
|
||||
if args.parent == nil then
|
||||
self.id = args.id or "__ROOT__"
|
||||
protected.prepare_template(1)
|
||||
protected.prepare_template(0, 0, 1)
|
||||
else
|
||||
self.id = args.parent.__add_child(args.id, protected)
|
||||
end
|
||||
@ -337,7 +345,7 @@ function element.new(args)
|
||||
---@param child graphics_base
|
||||
---@return integer|string key
|
||||
function public.__add_child(key, child)
|
||||
child.prepare_template(self.next_y)
|
||||
child.prepare_template(child_offset_x or 0, child_offset_y or 0, self.next_y)
|
||||
|
||||
self.next_y = child.frame.y + child.frame.h
|
||||
|
||||
|
@ -45,7 +45,7 @@ local function rectangle(args)
|
||||
end
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
local e = element.new(args, offset_x, offset_y)
|
||||
|
||||
-- create content window for child elements
|
||||
e.content_window = window.create(e.window, 1 + offset_x, 1 + offset_y, e.frame.w - (2 * offset_x), e.frame.h - (2 * offset_y))
|
||||
|
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@ local coreio = require("pocket.coreio")
|
||||
local pocket = require("pocket.pocket")
|
||||
local renderer = require("pocket.renderer")
|
||||
|
||||
local POCKET_VERSION = "alpha-v0.4.4"
|
||||
local POCKET_VERSION = "alpha-v0.4.5"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
||||
local renderer = require("reactor-plc.renderer")
|
||||
local threads = require("reactor-plc.threads")
|
||||
|
||||
local R_PLC_VERSION = "v1.4.5"
|
||||
local R_PLC_VERSION = "v1.4.6"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
@ -28,7 +28,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||
|
||||
local RTU_VERSION = "v1.3.5"
|
||||
local RTU_VERSION = "v1.3.6"
|
||||
|
||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||
|
@ -20,7 +20,7 @@ local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local svsessions = require("supervisor.session.svsessions")
|
||||
|
||||
local SUPERVISOR_VERSION = "v0.17.5"
|
||||
local SUPERVISOR_VERSION = "v0.17.6"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
Loading…
Reference in New Issue
Block a user