Skip to content

Commit

Permalink
Merge pull request #13 from leedave/feature/xremote_edit
Browse files Browse the repository at this point in the history
Started on Edit Menu for Remote Items
  • Loading branch information
leedave authored May 5, 2023
2 parents 835a1c7 + 48d23ac commit ec32310
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tools/xremote/scenes/xremote_scene_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ADD_SCENE(xremote, infoscreen, Infoscreen)
ADD_SCENE(xremote, menu, Menu)
ADD_SCENE(xremote, create, Create)
ADD_SCENE(xremote, create_add, CreateAdd)
ADD_SCENE(xremote, edit_item, EditItem)
ADD_SCENE(xremote, settings, Settings)
ADD_SCENE(xremote, wip, Wip)
ADD_SCENE(xremote, ir_list, IrList)
Expand Down
3 changes: 3 additions & 0 deletions Tools/xremote/scenes/xremote_scene_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ bool xremote_scene_create_on_event(void* context, SceneManagerEvent event) {
} else if(button_index == ButtonIndexSave) {
scene_manager_next_scene(app->scene_manager, XRemoteSceneSaveRemote);
}
} else if(custom_type == XRemoteCustomEventMenuSelected) {
app->edit_item = button_index;
scene_manager_next_scene(app->scene_manager, XRemoteSceneEditItem);
}
/*switch(event.event) {
case XRemoteCustomEventCreateLeft:
Expand Down
34 changes: 34 additions & 0 deletions Tools/xremote/scenes/xremote_scene_edit_item.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "../xremote.h"

enum SubmenuIndexEdit {
SubmenuIndexRename = 10,
SubmenuIndexDelete,
};

void xremote_scene_edit_item_submenu_callback(void* context, uint32_t index) {
XRemote* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}

void xremote_scene_edit_item_on_enter(void* context)
{
XRemote* app = context;
submenu_add_item(app->editmenu, "Rename", SubmenuIndexRename, xremote_scene_edit_item_submenu_callback, app);
submenu_add_item(app->editmenu, "Delete", SubmenuIndexDelete, xremote_scene_edit_item_submenu_callback, app);

submenu_set_selected_item(app->editmenu, scene_manager_get_scene_state(app->scene_manager, XRemoteSceneMenu));

view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdEditItem);
}

bool xremote_scene_edit_item_on_event(void* context, SceneManagerEvent event)
{
UNUSED(context);
UNUSED(event);
return 0;
}

void xremote_scene_edit_item_on_exit(void* context)
{
UNUSED(context);
}
2 changes: 2 additions & 0 deletions Tools/xremote/xremote.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ XRemote* xremote_app_alloc() {
view_dispatcher_set_tick_event_callback(app->view_dispatcher, xremote_tick_event_callback, 100);
view_dispatcher_set_custom_event_callback(app->view_dispatcher, xremote_custom_event_callback);
app->submenu = submenu_alloc();
app->editmenu = submenu_alloc();

// Set defaults, in case no config loaded
app->haptic = 1;
Expand All @@ -63,6 +64,7 @@ XRemote* xremote_app_alloc() {
view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdTextInput, text_input_get_view(app->text_input));

view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdMenu, submenu_get_view(app->submenu));
view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdEditItem, submenu_get_view(app->editmenu));
app->xremote_infoscreen = xremote_infoscreen_alloc();
view_dispatcher_add_view(app->view_dispatcher, XRemoteViewIdInfoscreen, xremote_infoscreen_get_view(app->xremote_infoscreen));
app->xremote_transmit = xremote_transmit_alloc();
Expand Down
3 changes: 3 additions & 0 deletions Tools/xremote/xremote.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct {
NotificationApp* notification;
ViewDispatcher* view_dispatcher;
Submenu* submenu;
Submenu* editmenu;
ButtonMenu* button_menu_create;
ButtonMenu* button_menu_create_add;
ButtonMenu* button_menu_ir;
Expand All @@ -36,13 +37,15 @@ typedef struct {
uint32_t speaker;
uint32_t led;
uint32_t save_settings;
uint32_t edit_item;
bool transmitting;
char text_store[XREMOTE_TEXT_STORE_NUM][XREMOTE_TEXT_STORE_SIZE + 1];
} XRemote;

typedef enum {
XRemoteViewIdInfoscreen,
XRemoteViewIdMenu,
XRemoteViewIdEditItem,
XRemoteViewIdCreate,
XRemoteViewIdCreateAdd,
XRemoteViewIdSettings,
Expand Down

0 comments on commit ec32310

Please sign in to comment.