Skip to content

Blockgroup browser#154

Merged
bobvh merged 17 commits intomainfrom
bvh-viewer-tweaks
Mar 3, 2025
Merged

Blockgroup browser#154
bobvh merged 17 commits intomainfrom
bvh-viewer-tweaks

Conversation

@bobvh
Copy link
Contributor

@bobvh bobvh commented Feb 25, 2025

No description provided.

// 1) Set up an in-memory database
let conn = Connection::open_in_memory().unwrap();

// Minimal schema for the required tables, adapted from migrations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the test harness for an in memory db?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to test_helpers.rs? I'm not familiar really with how to chain those together, but if get_connection() is sufficient to make Collection::create etc work robustly then I'll swap it in here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, we need to condense it, but put this at the top:

setup_gen_dir();
        let conn = &mut get_connection(None);
        let db_uuid = get_db_uuid(conn);
        let operation_conn = &get_operation_connection(None);
        setup_db(operation_conn, &db_uuid);

let mut focus_zone = "canvas";

// Create explorer and its state that persists across frames
let mut explorer = CollectionExplorer::new(conn, collection_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain more why we need this other thing for state management?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider the Explorer sidebar as its own widget that lives independently from the Viewer. That way, I don't force it on the operations UI, for example. I also need to keep the state on the listview third-party widget, so I refer to that state from inside of the explorer state.

KeyCode::Esc => {
show_panel = false;
if key.modifiers == KeyModifiers::SHIFT {
// Shift+Tab - cycle backwards
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need some better focus thing to handle these. mine is also a bit of a mess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I saw the index based focus cycler you had in operations but it didn't fit well here. I actually made the sidebar permanent because of the focus cycling. Fyi: I didn't use ctrl+arrows because the window manager on macOS uses that.

let sibling_candidates = Collection::query(
conn,
"SELECT * FROM collections
WHERE name GLOB ?1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this over like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're emulating file paths, so it seemed appropriate. (not a strong opinion though)

state.list_state.selected = self.find_prev_selectable(state, current_idx);
}

pub fn handle_input(&self, state: &mut CollectionExplorerState, key: KeyEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this using the stateful widget vs. the custom state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be able to skip the headers when scrolling down the sidebar, that's not a part of tui-widget-list currently.

@bobvh bobvh merged commit 7a98c0c into main Mar 3, 2025
1 check passed
@bobvh bobvh deleted the bvh-viewer-tweaks branch March 3, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants