mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 22:02:34 +00:00
WIP: Fix crash when deleting a group, implemented scroll_into_view- adding/editing an item it will be snapped into view.
This commit is contained in:
@@ -305,7 +305,7 @@ module TAC
|
|||||||
@variables_list.clear
|
@variables_list.clear
|
||||||
|
|
||||||
# Remove deleted action from list
|
# Remove deleted action from list
|
||||||
container = find_element_by_tag(@groups_list, action.name)
|
container = find_element_by_tag(@groups_list, group.name)
|
||||||
@groups_list.remove(container)
|
@groups_list.remove(container)
|
||||||
|
|
||||||
update_list_children(@groups_list)
|
update_list_children(@groups_list)
|
||||||
@@ -448,12 +448,23 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scroll_into_view(item)
|
def scroll_into_view(item)
|
||||||
|
list_container = nil
|
||||||
|
item_container = nil
|
||||||
|
|
||||||
if item.is_a?(TAC::Config::Group)
|
if item.is_a?(TAC::Config::Group)
|
||||||
|
list_container = @groups_list
|
||||||
elsif item.is_a?(TAC::Config::Action)
|
elsif item.is_a?(TAC::Config::Action)
|
||||||
|
list_container = @actions_list
|
||||||
elsif item.is_a?(TAC::Config::Variable)
|
elsif item.is_a?(TAC::Config::Variable)
|
||||||
|
list_container = @variables_list
|
||||||
else
|
else
|
||||||
raise "Unsupported item type: #{item.class}"
|
raise "Unsupported item type: #{item.class}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
item_container = find_element_by_tag(list_container, item.name)
|
||||||
|
|
||||||
|
@scroll_into_view_list_container = list_container
|
||||||
|
@scroll_into_view_item_container = item_container
|
||||||
end
|
end
|
||||||
|
|
||||||
def populate_groups_list
|
def populate_groups_list
|
||||||
@@ -586,6 +597,27 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
super
|
||||||
|
|
||||||
|
list_container = @scroll_into_view_list_container
|
||||||
|
item_container = @scroll_into_view_item_container
|
||||||
|
|
||||||
|
return unless list_container
|
||||||
|
return unless item_container
|
||||||
|
|
||||||
|
unless item_container.x.between?(list_container.x, list_container.x + list_container.width) &&
|
||||||
|
item_container.y.between?(list_container.y, list_container.y + list_container.height)
|
||||||
|
|
||||||
|
list_container.scroll_top = (item_container.y + item_container.height) - item_container.height
|
||||||
|
|
||||||
|
list_container.recalculate
|
||||||
|
end
|
||||||
|
|
||||||
|
@scroll_into_view_list_container = nil
|
||||||
|
@scroll_into_view_item_container = nil
|
||||||
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user