Reorganize codebase into modular structure

This commit is contained in:
2025-05-09 21:37:15 -05:00
parent f4c83e31c0
commit cf1c90856f
24 changed files with 2008 additions and 817 deletions
+77
View File
@@ -0,0 +1,77 @@
// UI view components
use iced::{
widget::{button, text, Column, Row, container, image as iced_image},
Element, Length,
};
use crate::app::{CursorRush, Message};
// View function to render the UI
pub fn view_app(state: &CursorRush) -> Element<Message> {
let mut content = Column::new()
.spacing(16)
.push(text("Cursor Rush").size(24));
// Add a button for each cursor
if !state.cursors.is_empty() {
let current_cursor = &state.cursors[state.current_index];
content = content.push(text(format!("Current cursor: {}", current_cursor.name)));
// Display the current cursor image as a preview
let img_handle = iced_image::Handle::from_path(&current_cursor.path);
let cursor_image = iced_image::Image::new(img_handle)
.width(Length::Fixed(64.0))
.height(Length::Fixed(64.0));
content = content.push(cursor_image);
// Create a row of cursor buttons
let mut cursor_row = Row::new().spacing(10);
for (i, cursor) in state.cursors.iter().enumerate() {
// Create a small preview image for each cursor
let preview_handle = iced_image::Handle::from_path(&cursor.path);
let preview_image = iced_image::Image::new(preview_handle)
.width(Length::Fixed(32.0))
.height(Length::Fixed(32.0));
let btn = button(
Row::new()
.spacing(5)
.push(preview_image)
.push(text(&cursor.name).size(16))
)
.on_press(Message::SelectCursor(i));
cursor_row = cursor_row.push(btn);
}
content = content
.push(cursor_row)
.push(button("Next cursor").on_press(Message::NextCursor))
.push(button("Quit").on_press(Message::Quit));
// Add instructions for the hotkey and close button behavior
content = content.push(
container(
Column::new()
.spacing(5)
.push(text("Press Ctrl+Shift+F12 to exit the application").size(16))
.push(text("Close button (X) minimizes to system tray").size(16))
)
.padding(10)
);
} else {
content = content.push(text("No cursors found in assets directory"));
}
// Create the main container
container(content)
.width(Length::Fill)
.height(Length::Fill)
.center_x(Length::Fill)
.center_y(Length::Fill)
.padding(20)
.into()
}