Refactor transparency logic and improve button interaction in PatchVisualizer

- Simplified transparency handling in the SelectionOption component to enhance hover effects for parent-only and normal nodes.
- Updated the DomLabel component to ensure the button is active for input events, improving user interaction.
- Cleaned up comments for clarity and maintainability.
This commit is contained in:
Joe 2026-02-01 10:42:02 -06:00
parent b2ce199a37
commit df70dc1ff4
4 changed files with 38 additions and 21 deletions

View file

@ -80,9 +80,7 @@ function SelectionOption:render()
-- Use wider button for "Studio" text (6 chars vs 4 for others) -- Use wider button for "Studio" text (6 chars vs 4 for others)
local buttonWidth = if props.text == "Studio" then 44 else 36 local buttonWidth = if props.text == "Studio" then 44 else 36
-- Transparency logic: -- Transparency logic with hover effect
-- - Parent-only nodes: more transparent when not hovered, less so when hovering button
-- - Normal nodes: standard transparency based on selection
local bgTransparency, txtTransparency local bgTransparency, txtTransparency
if isParentOnly then if isParentOnly then
-- Parent-only: partially transparent, less so when hovering the button -- Parent-only: partially transparent, less so when hovering the button
@ -93,8 +91,13 @@ function SelectionOption:render()
return if isHovered then 0 + t else 0.3 + (0.7 * t) return if isHovered then 0 + t else 0.3 + (0.7 * t)
end) end)
else else
-- Normal buttons: show hover effect by reducing transparency
bgTransparency = props.transparency:map(function(t) bgTransparency = props.transparency:map(function(t)
return if isSelected then 0.1 + (0.9 * t) else 0.7 + (0.3 * t) if isSelected then
return if isHovered then 0 + (1 * t) else 0.1 + (0.9 * t)
else
return if isHovered then 0.5 + (0.5 * t) else 0.7 + (0.3 * t)
end
end) end)
txtTransparency = props.transparency txtTransparency = props.transparency
end end
@ -373,6 +376,7 @@ function DomLabel:render()
PaddingRight = UDim.new(0, 10), PaddingRight = UDim.new(0, 10),
}), }),
Button = e("Frame", { Button = e("Frame", {
Active = true, -- Required for InputBegan to work on Frames
BackgroundTransparency = 1, BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 1, 0), Size = UDim2.new(1, 0, 1, 0),
[Roact.Event.MouseEnter] = function() [Roact.Event.MouseEnter] = function()

View file

@ -385,33 +385,47 @@ pub fn syncback_loop_with_stats(
if !incremental && !existing_paths.is_empty() { if !incremental && !existing_paths.is_empty() {
log::debug!("Clean mode: checking for orphaned files to remove"); log::debug!("Clean mode: checking for orphaned files to remove");
// Helper to normalize a path by stripping UNC prefix on Windows // Helper to strip UNC prefix on Windows
// This is needed because paths may have different prefixes (\\?\ vs regular) fn strip_unc_prefix(p: PathBuf) -> PathBuf {
fn normalize_path(p: &Path) -> PathBuf {
// Strip Windows UNC prefix if present
let path_str = p.to_string_lossy(); let path_str = p.to_string_lossy();
if path_str.starts_with(r"\\?\") || path_str.starts_with("//?/") { if path_str.starts_with(r"\\?\") || path_str.starts_with("//?/") {
PathBuf::from(&path_str[4..]) PathBuf::from(&path_str[4..])
} else { } else {
p.to_path_buf() p
} }
} }
// Convert added_paths to absolute paths by joining with project base path. // Helper to normalize a path by:
// 1. Canonicalizing to resolve symlinks (important on macOS where /var -> /private/var)
// 2. Stripping UNC prefix on Windows
fn normalize_existing_path(p: &Path) -> PathBuf {
// First try to canonicalize to resolve symlinks
// This is important on macOS where /var is a symlink to /private/var
let canonicalized = std::fs::canonicalize(p).unwrap_or_else(|_| p.to_path_buf());
strip_unc_prefix(canonicalized)
}
// Canonicalize the project path base to resolve symlinks consistently
// This is important on macOS where /var -> /private/var
let canonical_project_path =
std::fs::canonicalize(project_path).unwrap_or_else(|_| project_path.to_path_buf());
let canonical_project_path = strip_unc_prefix(canonical_project_path);
// Convert added_paths to absolute paths by joining with canonicalized project base path.
// fs_snapshot paths are relative to the project folder. // fs_snapshot paths are relative to the project folder.
let added_paths: HashSet<PathBuf> = fs_snapshot let added_paths: HashSet<PathBuf> = fs_snapshot
.added_paths() .added_paths()
.into_iter() .into_iter()
.map(|p| normalize_path(&project_path.join(p))) .map(|p| canonical_project_path.join(p))
.collect(); .collect();
// Get the project file path to exclude it from removal // Get the project file path to exclude it from removal
let project_file = normalize_path(&project.file_location); let project_file = normalize_existing_path(&project.file_location);
// First pass: collect normalized paths to remove (deduplicated) // First pass: collect normalized paths to remove (deduplicated)
let mut paths_to_remove: HashSet<PathBuf> = HashSet::new(); let mut paths_to_remove: HashSet<PathBuf> = HashSet::new();
for old_path in &existing_paths { for old_path in &existing_paths {
let old_path_norm = normalize_path(old_path); let old_path_norm = normalize_existing_path(old_path);
// Never remove the project file itself // Never remove the project file itself
if old_path_norm == project_file { if old_path_norm == project_file {
@ -454,7 +468,6 @@ pub fn syncback_loop_with_stats(
// Skip any path that is inside another path we're removing, // Skip any path that is inside another path we're removing,
// since remove_dir_all will handle the contents. // since remove_dir_all will handle the contents.
let paths_vec: Vec<_> = paths_to_remove.iter().collect(); let paths_vec: Vec<_> = paths_to_remove.iter().collect();
let normalized_project_path = normalize_path(project_path);
for old_path in &paths_vec { for old_path in &paths_vec {
// Check if this path is inside another path we're removing // Check if this path is inside another path we're removing
let is_nested = paths_vec let is_nested = paths_vec
@ -468,7 +481,7 @@ pub fn syncback_loop_with_stats(
// Convert absolute path to relative path for FsSnapshot. // Convert absolute path to relative path for FsSnapshot.
// FsSnapshot expects relative paths and joins them with base_path in write_to_vfs. // FsSnapshot expects relative paths and joins them with base_path in write_to_vfs.
let relative_path = old_path let relative_path = old_path
.strip_prefix(&normalized_project_path) .strip_prefix(&canonical_project_path)
.unwrap_or(old_path); .unwrap_or(old_path);
log::debug!("Removing orphaned path: {}", relative_path.display()); log::debug!("Removing orphaned path: {}", relative_path.display());