| @@ -1,7 +1,7 @@ | ||
| #ifndef INLINE_VIDEO_H | ||
| #define INLINE_VIDEO_H | ||
|
|
||
| #include "ui/panel.h" | ||
|
|
||
| #include <inttypes.h> | ||
| #include <stdbool.h> | ||
| @@ -0,0 +1,12 @@ | ||
| ## Hi, and thanks for helping with uTox. We're all glad for the support! | ||
|
|
||
| The structure for the layout/ directory is a bit different. All of | ||
| the #includes should be placed inline instead of the header; ideally right | ||
| before the first use. But thats a loose requirement. | ||
|
|
||
| Apart from that, the PRIMARY goal should be readability, a close second would | ||
| be easy of editing, meaning fewer files are probably better. But #include | ||
| exists for a reason. Make the code easy to read, then both my and your life | ||
| easy and everyone will be happy! | ||
|
|
||
| Thanks again!  |
| @@ -0,0 +1,123 @@ | ||
| #include "background.h" | ||
|
|
||
| #include "friend.h" | ||
| #include "group.h" | ||
| #include "notify.h" | ||
| #include "settings.h" | ||
| #include "sidebar.h" | ||
|
|
||
| #include "../macros.h" | ||
| #include "../theme.h" | ||
|
|
||
| #include "../ui.h" | ||
|
|
||
| #include "../ui/draw.h" | ||
| #include "../ui/panel.h" | ||
| #include "../ui/text.h" | ||
|
|
||
| static void draw_background(int UNUSED(x), int UNUSED(y), int width, int height) { | ||
| /* Default background */ | ||
| drawrect(0, 0, width, height, COLOR_BKGRND_MAIN); | ||
| /* Friend list (roster) background */ | ||
| drawrect(0, 0, SIDEBAR_WIDTH, height, COLOR_BKGRND_LIST); | ||
| /* Current user badge background */ | ||
| drawrect(0, 0, SIDEBAR_WIDTH, ROSTER_TOP, COLOR_BKGRND_MENU); | ||
|
|
||
| if (!panel_chat.disabled) { | ||
| /* Top frame for main chat panel */ | ||
| drawrect(MAIN_LEFT, 0, width, MAIN_TOP_FRAME_THICK, COLOR_BKGRND_ALT); | ||
| drawhline(MAIN_LEFT, MAIN_TOP_FRAME_THICK - 1, width, COLOR_EDGE_NORMAL); | ||
| /* Frame for the bottom chat text entry box */ | ||
| drawrect(MAIN_LEFT, height + CHAT_BOX_TOP, width, height, COLOR_BKGRND_ALT); | ||
| drawhline(MAIN_LEFT, height + CHAT_BOX_TOP, width, COLOR_EDGE_NORMAL); | ||
| } | ||
| // Chat and chat header separation | ||
| if (panel_settings_master.disabled) { | ||
| drawhline(MAIN_LEFT, MAIN_TOP_FRAME_THICK - 1, width, COLOR_EDGE_NORMAL); | ||
| } else { | ||
| drawhline(MAIN_LEFT, MAIN_TOP_FRAME_THIN - 1, width, COLOR_EDGE_NORMAL); | ||
| } | ||
| } | ||
|
|
||
| static void draw_splash_page(int x, int y, int w, int h) { | ||
| setcolor(COLOR_MAIN_TEXT); | ||
|
|
||
| x += SCALE(10); | ||
|
|
||
| /* Generic Splash */ | ||
| setfont(FONT_SELF_NAME); | ||
| int ny = utox_draw_text_multiline_within_box(x, y, w + x, y, y + h, font_small_lineheight, S(SPLASH_TITLE), | ||
| SLEN(SPLASH_TITLE), ~0, ~0, 0, 0, 1); | ||
| setfont(FONT_TEXT); | ||
| ny = utox_draw_text_multiline_within_box(x, ny, w + x, ny, ny + h, font_small_lineheight, S(SPLASH_TEXT), | ||
| SLEN(SPLASH_TEXT), ~0, ~0, 0, 0, 1); | ||
|
|
||
| ny += SCALE(30); | ||
| /* Change log */ | ||
| setfont(FONT_SELF_NAME); | ||
| ny = utox_draw_text_multiline_within_box(x, ny, w + x, y, ny + h, font_small_lineheight, S(CHANGE_LOG_TITLE), | ||
| SLEN(CHANGE_LOG_TITLE), ~0, ~0, 0, 0, 1); | ||
| setfont(FONT_TEXT); | ||
| ny = utox_draw_text_multiline_within_box(x, ny, w + x, ny, ny + h, font_small_lineheight, S(CHANGE_LOG_TEXT), | ||
| SLEN(CHANGE_LOG_TEXT), ~0, ~0, 0, 0, 1); | ||
| } | ||
|
|
||
|
|
||
| PANEL | ||
| panel_root = { | ||
| .type = PANEL_NONE, | ||
| .drawfunc = draw_background, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| &panel_side_bar, | ||
| &panel_main, | ||
| NULL | ||
| } | ||
| }, | ||
|
|
||
| /* Main panel, holds the overhead/settings, or the friend/group containers */ | ||
| panel_main = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| &panel_chat, | ||
| &panel_overhead, | ||
| NULL | ||
| } | ||
| }, | ||
|
|
||
| /* Chat panel, friend or group, depending on what's selected */ | ||
| panel_chat = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 1, | ||
| .child = (PANEL*[]) { | ||
| &panel_group, | ||
| &panel_friend, | ||
| &panel_friend_request, | ||
| NULL | ||
| } | ||
| }, | ||
|
|
||
| /* Settings master panel, holds the lower level settings */ | ||
| panel_overhead = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| &panel_splash_page, | ||
| &panel_profile_password, | ||
| &panel_add_friend, | ||
| &panel_settings_master, | ||
| // (PANEL*)&button_notify_create, // FIXME, left as a comment for later work on popup notifications | ||
| NULL | ||
| } | ||
| }, | ||
|
|
||
| panel_splash_page = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 1, | ||
| .drawfunc = draw_splash_page, | ||
| .content_scroll = &scrollbar_settings, | ||
| .child = (PANEL*[]) { | ||
| NULL, | ||
| } | ||
| }; |
| @@ -0,0 +1,11 @@ | ||
| #ifndef LAYOUT_BACKGROUND_H | ||
| #define LAYOUT_BACKGROUND_H | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL panel_root, | ||
| panel_main, | ||
| panel_chat, | ||
| panel_overhead, | ||
| panel_splash_page; | ||
|
|
||
| #endif // LAYOUT_BACKGROUND_H |
| @@ -0,0 +1,72 @@ | ||
| #ifndef LAYOUT_CREATE_H | ||
| #define LAYOUT_CREATE_H | ||
|
|
||
| /* Space keeping file for the macros I want to create to make changing/creating | ||
| * layouts easier and/of faster. */ | ||
|
|
||
| /* These macros are broken right now. | ||
| * TODO: Fix them. */ | ||
|
|
||
| /* | ||
| #define CREATE_BUTTON(n, a, b, w, h) button_##n = { \ | ||
| panel.type = PANEL_BUTTON, \ | ||
| panel.x = a, \ | ||
| panel.y = b, \ | ||
| panel.width = w, \ | ||
| panel.height = h, \ | ||
| }; | ||
| #define CREATE_EDIT(n, a, b, w, h) edit_##n = { \ | ||
| panel.type = PANEL_EDIT, \ | ||
| panel.x = a, \ | ||
| panel.y = b, \ | ||
| panel.width = w, \ | ||
| panel.height = h, \ | ||
| }; | ||
| #define CREATE_SWITCH(n, a, b, w, h) switch_##n = { \ | ||
| panel.type = PANEL_SWITCH, \ | ||
| panel.x = a, \ | ||
| panel.y = b, \ | ||
| panel.width = w, \ | ||
| panel.height = h, \ | ||
| }; | ||
| #define CREATE_DROPDOWN(n, a, b, h, w) dropdown_##n = { \ | ||
| panel.type = PANEL_DROPDOWN, \ | ||
| panel.x = a, \ | ||
| panel.y = b, \ | ||
| panel.height = h, \ | ||
| panel.width = w, \ | ||
| }; | ||
| */ | ||
|
|
||
| #define CREATE_BUTTON(n, a, b, w, h) \ | ||
| button_##n.panel.type = PANEL_BUTTON; \ | ||
| button_##n.panel.x = a; \ | ||
| button_##n.panel.y = b; \ | ||
| button_##n.panel.width = w; \ | ||
| button_##n.panel.height = h; | ||
|
|
||
| #define CREATE_EDIT(n, a, b, w, h) \ | ||
| edit_##n.panel.type = PANEL_EDIT; \ | ||
| edit_##n.panel.x = a; \ | ||
| edit_##n.panel.y = b; \ | ||
| edit_##n.panel.width = w; \ | ||
| edit_##n.panel.height = h; | ||
|
|
||
| #define CREATE_SWITCH(n, a, b, w, h) \ | ||
| switch_##n.panel.type = PANEL_SWITCH; \ | ||
| switch_##n.panel.x = a; \ | ||
| switch_##n.panel.y = b; \ | ||
| switch_##n.panel.width = w; \ | ||
| switch_##n.panel.height = h; | ||
|
|
||
| #define CREATE_DROPDOWN(n, a, b, h, w) \ | ||
| dropdown_##n.panel.type = PANEL_DROPDOWN; \ | ||
| dropdown_##n.panel.x = a; \ | ||
| dropdown_##n.panel.y = b; \ | ||
| dropdown_##n.panel.height = h; \ | ||
| dropdown_##n.panel.width = w; | ||
|
|
||
| #endif // LAYOUT_CREATE_H |
| @@ -0,0 +1,52 @@ | ||
| #ifndef LAYOUT_FRIEND_H | ||
| #define LAYOUT_FRIEND_H | ||
|
|
||
| typedef struct scrollable SCROLLABLE; | ||
| extern SCROLLABLE scrollbar_friend; | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL messages_friend; | ||
|
|
||
| extern PANEL panel_friend, | ||
| panel_add_friend, | ||
| panel_friend_chat, | ||
| panel_friend_video, | ||
| panel_friend_settings, | ||
| panel_friend_request, | ||
| panel_friend_confirm_deletion; | ||
|
|
||
|
|
||
| typedef struct button BUTTON; | ||
| // Top Bar | ||
| extern BUTTON button_call_decline, | ||
| button_call_audio, | ||
| button_call_video; | ||
| // Bottom Bar | ||
| extern BUTTON button_send_file, | ||
| button_send_screenshot, | ||
| button_chat_send_friend; | ||
|
|
||
| // Friend Requests | ||
| extern BUTTON button_send_friend_request, | ||
| button_accept_friend; | ||
|
|
||
| // Friend Settings | ||
| extern BUTTON button_export_chatlog; | ||
|
|
||
| // Friend Deletion model | ||
| extern BUTTON button_confirm_deletion, | ||
| button_deny_deletion; | ||
|
|
||
| typedef struct uiswitch UISWITCH; | ||
| extern UISWITCH switch_friend_autoaccept_ft; | ||
|
|
||
|
|
||
| typedef struct edit EDIT; | ||
| extern EDIT edit_add_new_friend_id, | ||
| edit_add_new_friend_msg, | ||
|
|
||
| edit_chat_msg_friend, | ||
| edit_friend_pubkey, | ||
| edit_friend_alias; | ||
|
|
||
| #endif // LAYOUT_FRIEND_H |
| @@ -0,0 +1,25 @@ | ||
| #ifndef LAYOUT_GROUP_H | ||
| #define LAYOUT_GROUP_H | ||
|
|
||
| typedef struct scrollable SCROLLABLE; | ||
| extern SCROLLABLE scrollbar_group; | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL panel_group, | ||
| panel_group_chat, | ||
| panel_group_video, | ||
| panel_group_settings, | ||
| messages_group; | ||
|
|
||
| typedef struct button BUTTON; | ||
| extern BUTTON button_group_audio, | ||
| button_chat_send_group; | ||
|
|
||
| typedef struct dropdown DROPDOWN; | ||
| extern DROPDOWN dropdown_notify_groupchats; | ||
|
|
||
| typedef struct edit EDIT; | ||
| extern EDIT edit_chat_msg_group, | ||
| edit_group_topic; | ||
|
|
||
| #endif // LAYOUT_GROUP_H |
| @@ -0,0 +1,123 @@ | ||
| #include "notify.h" | ||
|
|
||
| #include "userbadge.h" | ||
|
|
||
| #include "../ui.h" | ||
| #include "../self.h" | ||
| #include "../avatar.h" | ||
| #include "../debug.h" | ||
| #include "../theme.h" | ||
| #include "../notify.h" | ||
|
|
||
| #include "../ui/svg.h" | ||
| #include "../ui/draw.h" | ||
| #include "../ui/button.h" | ||
|
|
||
| #include "../main.h" // tox_thread_init | ||
|
|
||
| bool btn_move_window_down; | ||
|
|
||
| static void draw_notification(int x, int y, int w, int h) { | ||
| if (!tox_thread_init) { | ||
| return; | ||
| } | ||
|
|
||
| drawrect(x, y, w, h, COLOR_BKGRND_MAIN); | ||
|
|
||
| if (self_has_avatar()) { | ||
| draw_avatar_image(self.avatar->img, SIDEBAR_AVATAR_LEFT, SIDEBAR_AVATAR_TOP, self.avatar->width, | ||
| self.avatar->height, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH); | ||
| } else { | ||
| drawalpha(BM_CONTACT, SIDEBAR_AVATAR_LEFT, SIDEBAR_AVATAR_TOP, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, | ||
| COLOR_MENU_TEXT); | ||
| } | ||
|
|
||
| setcolor(!button_name.mouseover ? COLOR_MENU_TEXT : COLOR_MENU_TEXT_SUBTEXT); | ||
| setfont(FONT_SELF_NAME); | ||
| drawtext(SIDEBAR_NAME_LEFT, SIDEBAR_NAME_TOP, "This is a test of the new uTox popup", 36); | ||
| } | ||
|
|
||
| PANEL | ||
| panel_notify_generic = { | ||
| .type = PANEL_NONE, | ||
| .drawfunc = draw_notification, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| (PANEL*)&button_notify_one, | ||
| (PANEL*)&button_notify_two, | ||
| (PANEL*)&button_notify_three, | ||
|
|
||
| // (PANEL*)&button_move_notify, | ||
| NULL | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| static void btn_notify_one_mup(void) { | ||
| LOG_ERR("Layout Notify", "Button 1 pressed"); | ||
| } | ||
|
|
||
| BUTTON button_notify_one = { | ||
| // .bm = BM_SBUTTON, | ||
| .update = button_setcolors_success, | ||
| .on_mup = btn_notify_one_mup, | ||
| .nodraw = false, | ||
| }; | ||
|
|
||
| static void btn_notify_two_mup(void) { | ||
| LOG_ERR("Layout Notify", "Button 2 pressed"); | ||
| } | ||
|
|
||
| BUTTON button_notify_two = { | ||
| // .bm = BM_SBUTTON, | ||
| .update = button_setcolors_success, | ||
| .on_mup = btn_notify_two_mup, | ||
| .nodraw = false, | ||
| }; | ||
|
|
||
| static void btn_notify_three_mup(void) { | ||
| LOG_ERR("Layout Notify", "Button 3 pressed"); | ||
| } | ||
|
|
||
| BUTTON button_notify_three = { | ||
| // .bm = BM_SBUTTON, | ||
| .update = button_setcolors_success, | ||
| .on_mup = btn_notify_three_mup, | ||
| .nodraw = false, | ||
| }; | ||
|
|
||
| #if 0 | ||
| static void btn_move_window_mdn(void) { | ||
| LOG_NOTE(__FILE__, "button move down\n"); | ||
| btn_move_window_down = true; | ||
| } | ||
|
|
||
| static void btn_move_window_mup(void) { | ||
| LOG_NOTE(__FILE__, "button move up\n"); | ||
| btn_move_window_down = false; | ||
| } | ||
| #endif | ||
|
|
||
| static void btn_move_notify_mup(void) { | ||
| LOG_NOTE(__FILE__, "button tween\n"); | ||
| // window_tween(); | ||
| } | ||
|
|
||
| BUTTON button_move_notify = { | ||
| .nodraw = false, | ||
| .disabled = false, | ||
| .on_mup = btn_move_notify_mup, | ||
| }; | ||
|
|
||
|
|
||
| static void btn_notify_create_mup(void) { | ||
| notify_new(NOTIFY_TYPE_MSG); | ||
| } | ||
|
|
||
| BUTTON button_notify_create = { | ||
| .bm = BM_SBUTTON, | ||
| .update = button_setcolors_success, | ||
| .on_mup = btn_notify_create_mup, | ||
| .button_text = {.i18nal = STR_SHOW }, | ||
| .tooltip_text = {.i18nal = STR_SHOW }, | ||
| }; |
| @@ -0,0 +1,21 @@ | ||
| #ifndef LAYOUT_NOTIFY_H | ||
| #define LAYOUT_NOTIFY_H | ||
|
|
||
| #include <stdbool.h> | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL panel_notify_generic; | ||
|
|
||
| typedef struct button BUTTON; | ||
| extern BUTTON button_notify_one, | ||
| button_notify_two, | ||
| button_notify_three, | ||
| button_move_notify, | ||
| button_notify_create; | ||
|
|
||
|
|
||
| // TODO, no good capin' | ||
| extern bool btn_move_window_down; | ||
|
|
||
|
|
||
| #endif // LAYOUT_NOTIFY_H |
| @@ -0,0 +1,90 @@ | ||
| #ifndef LAYOUT_SETTINGS_H | ||
| #define LAYOUT_SETTINGS_H | ||
|
|
||
| typedef struct scrollable SCROLLABLE; | ||
| extern SCROLLABLE scrollbar_settings; | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL panel_settings_master, | ||
| panel_settings_subheader, | ||
| panel_settings_profile, | ||
| panel_profile_password_settings, | ||
| panel_settings_devices, | ||
| panel_settings_ui, | ||
| panel_settings_av, | ||
| panel_settings_notifications, | ||
| panel_settings_adv, | ||
| panel_nospam_settings; | ||
|
|
||
| extern PANEL panel_profile_password; | ||
|
|
||
| typedef struct button BUTTON; | ||
| extern BUTTON button_settings, | ||
| button_settings_sub_profile, | ||
| button_settings_sub_devices, | ||
| button_settings_sub_net, | ||
| button_settings_sub_ui, | ||
| button_settings_sub_av, | ||
| button_settings_sub_adv, | ||
| button_settings_sub_notifications; | ||
|
|
||
| extern BUTTON button_add_new_device_to_self; | ||
|
|
||
| extern BUTTON button_callpreview, | ||
| button_videopreview, | ||
| button_copyid, | ||
| button_lock_uTox, | ||
| button_show_password_settings, | ||
| button_change_nospam, | ||
| button_revert_nospam, | ||
| button_show_nospam; | ||
|
|
||
| typedef struct uiswitch UISWITCH; | ||
| extern UISWITCH /* User Interface Tab */ | ||
| switch_save_chat_history, | ||
| switch_close_to_tray, | ||
| switch_start_in_tray, | ||
| switch_auto_startup, | ||
| switch_mini_contacts, | ||
| /* AV Tab */ | ||
| switch_push_to_talk, | ||
| switch_audio_filtering, | ||
| /* Notifications Tab */ | ||
| switch_audible_notifications, | ||
| switch_status_notifications, | ||
| switch_typing_notes, | ||
| /* Advanced Tab */ | ||
| switch_ipv6, | ||
| switch_udp, | ||
| switch_proxy, | ||
| switch_proxy_force, | ||
| switch_auto_update, | ||
| switch_block_friend_requests; | ||
|
|
||
| typedef struct dropdown DROPDOWN; | ||
| extern DROPDOWN /* Profile */ | ||
| dropdown_language, | ||
| /* User interface */ | ||
| dropdown_theme, | ||
| dropdown_dpi, | ||
| /* AV */ | ||
| dropdown_audio_in, | ||
| dropdown_audio_out, | ||
| dropdown_video, | ||
| /* Notifications */ | ||
| dropdown_global_group_notifications; | ||
|
|
||
| typedef struct edit EDIT; | ||
| extern EDIT /* Profile */ | ||
| edit_name, | ||
| edit_status_msg, | ||
| edit_toxid, | ||
| /* Advanced */ | ||
| edit_proxy_ip, | ||
| edit_proxy_port, | ||
| edit_profile_password, | ||
| edit_nospam, | ||
| /* MDevice */ | ||
| edit_add_new_device_to_self; | ||
|
|
||
| #endif // LAYOUT_SETTINGS_H |
| @@ -0,0 +1,192 @@ | ||
| #include "sidebar.h" | ||
|
|
||
| #include "settings.h" | ||
| #include "friend.h" | ||
|
|
||
| #include "../avatar.h" | ||
| #include "../flist.h" | ||
| #include "../macros.h" | ||
| #include "../main_native.h" | ||
| #include "../self.h" | ||
| #include "../theme.h" | ||
|
|
||
| #include "../ui.h" | ||
| #include "../ui/draw.h" | ||
| #include "../ui/scrollable.h" | ||
| #include "../ui/edit.h" | ||
| #include "../ui/button.h" | ||
| #include "../ui/svg.h" | ||
|
|
||
| #include "../main.h" // tox_thread global | ||
|
|
||
| // Scrollbar or friend list | ||
| SCROLLABLE scrollbar_flist = { | ||
| .panel = { .type = PANEL_SCROLLABLE, }, | ||
| .color = C_SCROLL, | ||
| .x = 2, | ||
| .left = 1, | ||
| .small = 1, | ||
| }; | ||
|
|
||
| /* Top left self interface Avatar, name, statusmsg, status icon */ | ||
| static void draw_user_badge(int UNUSED(x), int UNUSED(y), int UNUSED(width), int UNUSED(height)) { | ||
| if (tox_thread_init == UTOX_TOX_THREAD_INIT_SUCCESS) { | ||
| /* Only draw the user badge if toxcore is running */ | ||
| /*draw avatar or default image */ | ||
| if (self_has_avatar()) { | ||
| draw_avatar_image(self.avatar->img, SIDEBAR_AVATAR_LEFT, SIDEBAR_AVATAR_TOP, self.avatar->width, | ||
| self.avatar->height, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH); | ||
| } else { | ||
| drawalpha(BM_CONTACT, SIDEBAR_AVATAR_LEFT, SIDEBAR_AVATAR_TOP, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, | ||
| COLOR_MENU_TEXT); | ||
| } | ||
| /* Draw name */ | ||
| setcolor(!button_name.mouseover ? COLOR_MENU_TEXT : COLOR_MENU_TEXT_SUBTEXT); | ||
| setfont(FONT_SELF_NAME); | ||
| drawtextrange(SIDEBAR_NAME_LEFT, SIDEBAR_NAME_WIDTH * 1.5, SIDEBAR_NAME_TOP, self.name, self.name_length); | ||
|
|
||
| /*&Draw current status message | ||
| @TODO: separate these colors if needed (COLOR_MAIN_TEXT_HINT) */ | ||
| setcolor(!button_status_msg.mouseover ? COLOR_MENU_TEXT_SUBTEXT : COLOR_MAIN_TEXT_HINT); | ||
| setfont(FONT_STATUS); | ||
| drawtextrange(SIDEBAR_STATUSMSG_LEFT, SIDEBAR_STATUSMSG_WIDTH * 1.5, SIDEBAR_STATUSMSG_TOP, self.statusmsg, | ||
| self.statusmsg_length); | ||
|
|
||
| /* Draw status button icon */ | ||
| drawalpha(BM_STATUSAREA, SELF_STATUS_ICON_LEFT, SELF_STATUS_ICON_TOP, BM_STATUSAREA_WIDTH, BM_STATUSAREA_HEIGHT, | ||
| button_usr_state.mouseover ? COLOR_BKGRND_LIST_HOVER : COLOR_BKGRND_LIST); | ||
| uint8_t status = tox_connected ? self.status : 3; | ||
| drawalpha(BM_ONLINE + status, SELF_STATUS_ICON_LEFT + BM_STATUSAREA_WIDTH / 2 - BM_STATUS_WIDTH / 2, | ||
| SELF_STATUS_ICON_TOP + BM_STATUSAREA_HEIGHT / 2 - BM_STATUS_WIDTH / 2, BM_STATUS_WIDTH, | ||
| BM_STATUS_WIDTH, status_color[status]); | ||
|
|
||
| /* Draw online/all friends filter text. */ | ||
| setcolor(!button_filter_friends.mouseover ? COLOR_MENU_TEXT_SUBTEXT : COLOR_MAIN_TEXT_HINT); | ||
| setfont(FONT_STATUS); | ||
| drawtextrange(SIDEBAR_FILTER_FRIENDS_LEFT, SIDEBAR_FILTER_FRIENDS_WIDTH, SIDEBAR_FILTER_FRIENDS_TOP, | ||
| flist_get_filter() ? S(FILTER_ONLINE) : S(FILTER_ALL), | ||
| flist_get_filter() ? SLEN(FILTER_ONLINE) : SLEN(FILTER_ALL)); | ||
| } else { | ||
| drawalpha(BM_CONTACT, SIDEBAR_AVATAR_LEFT, SIDEBAR_AVATAR_TOP, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, | ||
| COLOR_MENU_TEXT); | ||
|
|
||
| setcolor(!button_name.mouseover ? COLOR_MENU_TEXT : COLOR_MENU_TEXT_SUBTEXT); | ||
| setfont(FONT_SELF_NAME); | ||
| drawtextrange(SIDEBAR_NAME_LEFT, SIDEBAR_WIDTH - SIDEBAR_AVATAR_LEFT, SIDEBAR_NAME_TOP, S(NOT_CONNECTED), SLEN(NOT_CONNECTED)); | ||
|
|
||
| if (tox_thread_init == UTOX_TOX_THREAD_INIT_ERROR) { | ||
| setcolor(!button_status_msg.mouseover ? COLOR_MENU_TEXT_SUBTEXT : COLOR_MAIN_TEXT_HINT); | ||
| setfont(FONT_STATUS); | ||
| drawtextrange(SIDEBAR_STATUSMSG_LEFT, SIDEBAR_WIDTH, SIDEBAR_STATUSMSG_TOP, S(NOT_CONNECTED_SETTINGS), SLEN(NOT_CONNECTED_SETTINGS)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* Left side bar, holds the user, the roster, and the setting buttons */ | ||
| PANEL panel_side_bar = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| &panel_self, | ||
| &panel_quick_buttons, | ||
| &panel_flist, | ||
| NULL | ||
| } | ||
| }, | ||
| /* The user badge and buttons */ | ||
| panel_self = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .drawfunc = draw_user_badge, | ||
| .child = (PANEL*[]) { | ||
| (PANEL*)&button_avatar, (PANEL*)&button_name, (PANEL*)&button_usr_state, | ||
| (PANEL*)&button_status_msg, | ||
| NULL | ||
| } | ||
| }, | ||
| /* Left sided toggles */ | ||
| panel_quick_buttons = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| (PANEL*)&button_filter_friends, /* Top of roster */ | ||
| (PANEL*)&edit_search, /* Bottom of roster*/ | ||
| (PANEL*)&button_settings, | ||
| (PANEL*)&button_add_new_contact, | ||
| NULL | ||
| } | ||
| }, | ||
| /* The friends and group was called list */ | ||
| panel_flist = { | ||
| .type = PANEL_NONE, | ||
| .disabled = 0, | ||
| .child = (PANEL*[]) { | ||
| // TODO rename these | ||
| &panel_flist_list, | ||
| (PANEL*)&scrollbar_flist, | ||
| NULL | ||
| } | ||
| }, | ||
| panel_flist_list = { | ||
| .type = PANEL_LIST, | ||
| .content_scroll = &scrollbar_flist, | ||
| }; | ||
|
|
||
|
|
||
| #include "../friend.h" | ||
| static void e_search_onchange(EDIT *edit) { | ||
| char *data = edit->data; | ||
| uint16_t length = edit->length > sizeof search_data ? sizeof search_data - 1 : edit->length; | ||
|
|
||
| if (length) { | ||
| button_add_new_contact.panel.disabled = 0; | ||
| button_add_new_contact.nodraw = 0; | ||
| button_settings.panel.disabled = 1; | ||
| button_settings.nodraw = 1; | ||
| memcpy(search_data, data, length); | ||
| search_data[length] = 0; | ||
| flist_search((char *)search_data); | ||
| } else { | ||
| button_add_new_contact.panel.disabled = 1; | ||
| button_add_new_contact.nodraw = 1; | ||
| button_settings.panel.disabled = 0; | ||
| button_settings.nodraw = 0; | ||
| flist_search(NULL); | ||
| } | ||
|
|
||
| redraw(); | ||
| } | ||
|
|
||
| static void e_search_onenter(EDIT *edit) { | ||
| char * data = edit->data; | ||
| uint16_t length = edit->length; | ||
|
|
||
| if (length == 76) { // FIXME, this should be error checked! | ||
| // No, srsly... this is lucky, not right. | ||
| friend_add(data, length, (char *)"", 0); | ||
| edit_setstr(&edit_search, (char *)"", 0); | ||
| } else { | ||
| if (tox_thread_init == UTOX_TOX_THREAD_INIT_SUCCESS) { | ||
| /* Only change if we're logged in! */ | ||
| edit_setstr(&edit_add_new_friend_id, data, length); | ||
| edit_setstr(&edit_search, (char *)"", 0); | ||
| flist_selectaddfriend(); | ||
| edit_setfocus(&edit_add_new_friend_msg); | ||
| } | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| static char e_search_data[1024]; | ||
| EDIT edit_search = { | ||
| .data = e_search_data, | ||
| .maxlength = sizeof e_search_data - 1, | ||
| .onchange = e_search_onchange, | ||
| .onenter = e_search_onenter, | ||
| .style = AUXILIARY_STYLE, | ||
| .vcentered = true, | ||
| .empty_str = { .i18nal = STR_CONTACT_SEARCH_ADD_HINT }, | ||
| }; | ||
|
|
||
|
|
||
|
|
| @@ -0,0 +1,29 @@ | ||
| #ifndef LAYOUT_SIDEBAR_H | ||
| #define LAYOUT_SIDEBAR_H | ||
|
|
||
| typedef struct scrollable SCROLLABLE; | ||
| extern SCROLLABLE scrollbar_flist; | ||
|
|
||
| typedef struct panel PANEL; | ||
| extern PANEL panel_side_bar, | ||
| panel_self, | ||
|
|
||
| panel_flist, | ||
| panel_flist_list, | ||
|
|
||
| panel_quick_buttons, | ||
| panel_lower_buttons; | ||
|
|
||
| typedef struct button BUTTON; | ||
| extern BUTTON button_avatar, | ||
| button_name, | ||
| button_status_msg, | ||
| button_usr_state, | ||
|
|
||
| button_filter_friends, | ||
| button_add_new_contact; | ||
|
|
||
| typedef struct edit EDIT; | ||
| extern EDIT edit_search; | ||
|
|
||
| #endif //LAYOUT_SIDEBAR_H |
| @@ -0,0 +1,133 @@ | ||
| #include "userbadge.h" | ||
|
|
||
| #include "settings.h" | ||
|
|
||
| #include "../avatar.h" | ||
| #include "../flist.h" | ||
| #include "../macros.h" | ||
| #include "../main_native.h" | ||
| #include "../self.h" | ||
| #include "../tox.h" | ||
|
|
||
| #include "../ui/button.h" | ||
| #include "../ui/contextmenu.h" | ||
| #include "../ui/edit.h" | ||
|
|
||
| #include "../main.h" // tox_tread_init | ||
|
|
||
|
|
||
| /* On-press functions followed by the update functions when needed... */ | ||
| static void button_avatar_on_mup(void) { | ||
| if (tox_thread_init == UTOX_TOX_THREAD_INIT_SUCCESS) { | ||
| openfileavatar(); | ||
| } | ||
| } | ||
|
|
||
| static void button_name_on_mup(void) { | ||
| flist_selectsettings(); | ||
| if (tox_thread_init != UTOX_TOX_THREAD_INIT_SUCCESS) { | ||
| // jump to the network settings when unable to create tox instance | ||
| panel_settings_adv.disabled = false; | ||
| panel_settings_profile.disabled = true; | ||
| panel_settings_devices.disabled = true; | ||
| panel_settings_ui.disabled = true; | ||
| panel_settings_av.disabled = true; | ||
| panel_settings_notifications.disabled = true; | ||
| } else { | ||
| panel_settings_profile.disabled = false; | ||
| panel_settings_devices.disabled = true; | ||
| panel_settings_ui.disabled = true; | ||
| panel_settings_av.disabled = true; | ||
| panel_settings_adv.disabled = true; | ||
| panel_settings_notifications.disabled = true; | ||
| edit_setfocus(&edit_name); | ||
| } | ||
| } | ||
|
|
||
| static void button_statusmsg_on_mup(void) { | ||
| flist_selectsettings(); | ||
| if (tox_thread_init != UTOX_TOX_THREAD_INIT_SUCCESS) { | ||
| // jump to the network settings when unable to create tox instance | ||
| panel_settings_adv.disabled = false; | ||
|
|
||
| panel_settings_profile.disabled = true; | ||
| panel_settings_devices.disabled = true; | ||
| panel_settings_ui.disabled = true; | ||
| panel_settings_av.disabled = true; | ||
| panel_settings_notifications.disabled = true; | ||
| } else { | ||
| panel_settings_profile.disabled = false; | ||
|
|
||
| panel_settings_devices.disabled = true; | ||
| panel_settings_ui.disabled = true; | ||
| panel_settings_av.disabled = true; | ||
| panel_settings_adv.disabled = true; | ||
| panel_settings_notifications.disabled = true; | ||
| edit_setfocus(&edit_status_msg); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| #ifdef UNITY | ||
| #include "xlib/mmenu.h" | ||
| extern bool unity_running; | ||
| #endif | ||
| static void button_status_on_mup(void) { | ||
| self.status++; | ||
| if (self.status == 3) { // TODO typedef enum | ||
| self.status = 0; | ||
| } | ||
|
|
||
| #ifdef UNITY | ||
| if (unity_running) { | ||
| mm_set_status(self.status); | ||
| } | ||
| #endif | ||
|
|
||
| postmessage_toxcore(TOX_SELF_SET_STATE, self.status, 0, NULL); | ||
| } | ||
|
|
||
| static void contextmenu_avatar_onselect(uint8_t i) { | ||
| if (i == 0) { | ||
| avatar_unset_self(); | ||
| } | ||
| } | ||
|
|
||
| static void button_avatar_onright(void) { | ||
| if (self_has_avatar()) { | ||
| static UTOX_I18N_STR menu[] = { STR_REMOVE }; | ||
| contextmenu_new(COUNTOF(menu), menu, contextmenu_avatar_onselect); | ||
| } | ||
| } | ||
|
|
||
| BUTTON button_avatar = { | ||
| .nodraw = true, .on_mup = button_avatar_on_mup, .onright = button_avatar_onright, | ||
| }; | ||
|
|
||
| BUTTON button_name = { | ||
| .nodraw = true, .on_mup = button_name_on_mup, | ||
| }; | ||
|
|
||
| BUTTON button_status_msg = { | ||
| .nodraw = true, .on_mup = button_statusmsg_on_mup, | ||
| }; | ||
|
|
||
| BUTTON button_usr_state = { | ||
| .nodraw = true, | ||
| .on_mup = button_status_on_mup, | ||
| .tooltip_text = { | ||
| .i18nal = STR_STATUS | ||
| }, | ||
| }; | ||
|
|
||
| static void button_filter_friends_on_mup(void) { | ||
| // this only works because right now there are only 2 filters | ||
| // (none or online), basically a bool | ||
| flist_set_filter(!flist_get_filter()); | ||
| } | ||
| BUTTON button_filter_friends = { | ||
| .nodraw = true, | ||
| .on_mup = button_filter_friends_on_mup, | ||
| .tooltip_text = {.i18nal = STR_FILTER_CONTACT_TOGGLE }, | ||
| }; | ||
|
|
| @@ -0,0 +1,16 @@ | ||
| #ifndef LAYOUT_USERBADGE_H | ||
| #define LAYOUT_USERBADGE_H | ||
|
|
||
| typedef struct button BUTTON; | ||
| extern BUTTON button_avatar, | ||
| button_name, | ||
| button_status_msg, | ||
| button_usr_state, | ||
| button_filter_friends; | ||
|
|
||
| typedef struct edit EDIT; | ||
| extern EDIT edit_search, | ||
| edit_add_new_friend, | ||
| edit_add_new_friend_msg; | ||
|
|
||
| #endif // LAYOUT_USERBADGE_H |
| @@ -1,7 +1,22 @@ | ||
| #include "debug.h" | ||
|
|
||
| #include "settings.h" | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdarg.h> | ||
|
|
||
| int utox_verbosity() { | ||
| return settings.verbose; | ||
| } | ||
|
|
||
| void debug(const char *fmt, ...){ | ||
| va_list list; | ||
|
|
||
| va_start(list, fmt); | ||
| vfprintf(settings.debug_file, fmt, list); | ||
| va_end(list); | ||
|
|
||
| #ifdef __WIN32__ | ||
| fflush(settings.debug_file); | ||
| #endif | ||
| } |
| @@ -0,0 +1,45 @@ | ||
| #include "notify.h" | ||
|
|
||
| #include "main.h" | ||
| #include "debug.h" | ||
|
|
||
| #include "ui.h" | ||
| #include "window.h" | ||
|
|
||
| #include "layout/notify.h" | ||
|
|
||
| static uint16_t notification_number = 0; | ||
|
|
||
| UTOX_WINDOW *notify_new(NOTIFY_TYPE type) { | ||
| LOG_NOTE("Notifier", "Notify:\tCreating Notification #%u", notification_number); | ||
|
|
||
| const int notify_w = 400; | ||
| const int notify_h = 150; | ||
|
|
||
|
|
||
| const int x = 30; | ||
| const int y = 30 + (20 + notify_h) * notification_number; | ||
| ++notification_number; | ||
|
|
||
| PANEL *panel; | ||
| switch (type) { | ||
| case NOTIFY_TYPE_NONE: { | ||
| return NULL; | ||
| } | ||
| case NOTIFY_TYPE_MSG: { | ||
| panel = &panel_notify_generic; | ||
| break; | ||
| } | ||
| case NOTIFY_TYPE_CALL: | ||
| case NOTIFY_TYPE_CALL_VIDEO: { | ||
| panel = &panel_notify_generic; // TODO create a video call panel type | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| UTOX_WINDOW *w = window_create_notify(x, y, notify_w, notify_h, panel); | ||
|
|
||
| native_window_set_target(w); | ||
|
|
||
| return w; | ||
| } |
| @@ -0,0 +1,22 @@ | ||
| #ifndef NOTIFY_H | ||
| #define NOTIFY_H | ||
|
|
||
| #include "window.h" | ||
|
|
||
| typedef enum { | ||
| NOTIFY_TYPE_NONE, | ||
| NOTIFY_TYPE_MSG, | ||
| NOTIFY_TYPE_CALL, | ||
| NOTIFY_TYPE_CALL_VIDEO, | ||
| } NOTIFY_TYPE; | ||
|
|
||
| typedef enum { | ||
| TWEEN_NONE, | ||
| TWEEN_UP, | ||
| } NOTIFY_TWEEN; | ||
|
|
||
| UTOX_WINDOW *notify_new(NOTIFY_TYPE type); | ||
|
|
||
| void notify_tween(void); | ||
|
|
||
| #endif |
| @@ -0,0 +1,9 @@ | ||
| #include "screen_grab.h" | ||
|
|
||
| #include "main_native.h" | ||
|
|
||
|
|
||
|
|
||
| void utox_screen_grab_desktop(bool video) { | ||
| native_screen_grab_desktop(video); | ||
| } |
| @@ -0,0 +1,10 @@ | ||
| #ifndef SCREEN_GRAB_H | ||
| #define SCREEN_GRAB_H | ||
|
|
||
| #include <stdbool.h> | ||
|
|
||
| void native_screen_grab_desktop(bool video); | ||
|
|
||
| void utox_screen_grab_desktop(bool video); | ||
|
|
||
| #endif |
| @@ -1,28 +1,30 @@ | ||
| #include "self.h" | ||
|
|
||
| #include "avatar.h" | ||
| #include "debug.h" | ||
| #include "tox.h" | ||
|
|
||
| #include "ui/edit.h" | ||
| #include "layout/settings.h" | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| void init_self(Tox *tox) { | ||
| /* Set local info for self */ | ||
| edit_setstr(&edit_name, self.name, self.name_length); | ||
| edit_setstr(&edit_status_msg, self.statusmsg, self.statusmsg_length); | ||
|
|
||
| /* Get tox id, and gets the hex version for utox */ | ||
| tox_self_get_address(tox, self.id_binary); | ||
| id_to_string(self.id_str, self.id_binary); | ||
| self.id_str_length = TOX_ADDRESS_SIZE * 2; | ||
| LOG_TRACE("Self INIT", "Tox ID: %.*s" , (int)self.id_str_length, self.id_str); | ||
|
|
||
| /* Get nospam */ | ||
| self.nospam = tox_self_get_nospam(tox); | ||
| self.old_nospam = self.nospam; | ||
| sprintf(self.nospam_str, "%08X", self.nospam); | ||
| edit_setstr(&edit_nospam, self.nospam_str, sizeof(uint32_t) * 2); | ||
|
|
||
| avatar_init_self(); | ||
| } |