Files
Momentum-Firmware/applications/main/archive/views/archive_browser_view.h
Alexander Bays b9c0289847 Archive: Add dynamic paths to browser tab (#322)
* feat(Archive): Adds dynamic paths to browser tab

I thought it would be cool to be able to see when I was in say the
`apps_data/flipchess` folder, or some other nested folder, and have
"flipchess" be shown rather than the just "Browser" all the time. It's
not a huge or really crucial change, just a personal modification that
some people may also find useful.

* fix(Archive): Clean up, built-ins, safer

Cleaned up `archive_update_formatted_path` function using switch case,
and also using the built in furi functions where possible. Also removed
the arbitrary and unnecessary `path_buf[256]`, making formatting the
path in the Brief section more memory safe.

* Rename setting and use setting_enum()

* Remove prev_path

* Enum names

* Single text draw call

* Rename to statusbar title

* Revert "Rename to statusbar title"

This reverts commit 243f2a754f.

* Revert "Single text draw call"

This reverts commit 3bbe30449b.

* Simpler fix

* Shorter setting label

* Update changelog

---------

Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
2025-01-17 01:44:11 +00:00

136 lines
3.2 KiB
C

#pragma once
#include "../helpers/archive_files.h"
#include "../helpers/archive_favorites.h"
#include "archive/archive.h"
#include <gui/gui_i.h>
#include <gui/view.h>
#include <gui/canvas.h>
#include <gui/elements.h>
#include <gui/modules/file_browser_worker.h>
#include <storage/storage.h>
#include "../helpers/archive_files.h"
#include "../helpers/archive_menu.h"
#include "../helpers/archive_favorites.h"
#include "gui/modules/file_browser_worker.h"
#define MAX_LEN_PX 110
#define MAX_NAME_LEN 254
#define FRAME_HEIGHT 12
#define MENU_ITEMS 5u
#define MOVE_OFFSET 5u
typedef enum {
ArchiveTabFavorites,
ArchiveTabSubGhz,
ArchiveTabLFRFID,
ArchiveTabNFC,
ArchiveTabInfrared,
ArchiveTabIButton,
ArchiveTabBadKb,
ArchiveTabU2f,
ArchiveTabApplications,
ArchiveTabSearch,
ArchiveTabDiskImage,
ArchiveTabInternal,
ArchiveTabBrowser,
ArchiveTabTotal,
} ArchiveTabEnum;
typedef enum {
ArchiveBrowserEventFileMenuNone,
ArchiveBrowserEventFileMenuOpen,
ArchiveBrowserEventManageMenuOpen,
ArchiveBrowserEventFileMenuRun,
ArchiveBrowserEventFileMenuFavorite,
ArchiveBrowserEventFileMenuInfo,
ArchiveBrowserEventFileMenuShow,
ArchiveBrowserEventFileMenuPaste,
ArchiveBrowserEventFileMenuCut,
ArchiveBrowserEventFileMenuCopy,
ArchiveBrowserEventFileMenuNewDir,
ArchiveBrowserEventFileMenuRename,
ArchiveBrowserEventFileMenuDelete,
ArchiveBrowserEventFileMenuClose,
ArchiveBrowserEventEnterDir,
ArchiveBrowserEventSearch,
ArchiveBrowserEventFavMoveUp,
ArchiveBrowserEventFavMoveDown,
ArchiveBrowserEventEnterFavMove,
ArchiveBrowserEventExitFavMove,
ArchiveBrowserEventSaveFavMove,
ArchiveBrowserEventLoadPrevItems,
ArchiveBrowserEventLoadNextItems,
ArchiveBrowserEventListRefresh,
ArchiveBrowserEventExit,
} ArchiveBrowserEvent;
typedef struct ArchiveBrowserView ArchiveBrowserView;
typedef void (*ArchiveBrowserViewCallback)(ArchiveBrowserEvent event, void* context);
typedef enum {
BrowserActionBrowse,
BrowserActionItemMenu,
BrowserActionTotal,
} BrowserActionEnum;
struct ArchiveBrowserView {
View* view;
BrowserWorker* worker;
bool worker_running;
ArchiveBrowserViewCallback callback;
void* context;
FuriString* path;
FuriString* formatted_path;
bool path_changed;
InputKey last_tab_switch_dir;
bool is_root;
FuriTimer* scroll_timer;
File* disk_image;
};
typedef struct {
ArchiveApp* archive;
ArchiveTabEnum tab_idx;
files_array_t files;
uint8_t menu_idx;
bool menu;
bool menu_manage;
bool menu_can_switch;
char* clipboard;
bool clipboard_copy;
menu_array_t context_menu;
bool is_app_tab;
bool move_fav;
bool list_loading;
bool folder_loading;
uint32_t item_cnt;
int32_t item_idx;
int32_t array_offset;
int32_t list_offset;
size_t scroll_counter;
int32_t button_held_for_ticks;
} ArchiveBrowserViewModel;
void archive_browser_set_callback(
ArchiveBrowserView* browser,
ArchiveBrowserViewCallback callback,
void* context);
View* archive_browser_get_view(ArchiveBrowserView* browser);
ArchiveBrowserView* browser_alloc(void);
void browser_free(ArchiveBrowserView* browser);