void messages_set_typing(MESSAGES *m, MSG_DATA *p, int UNUSED(typing)) { if(m->data == p) { // MSG_DATA associated with typing notification // corresponds to given MESSAGES, so update their height. messages_updateheight(m); } }
void panel_update(PANEL *p, int x, int y, int width, int height) { FUNC(); if(p->type == PANEL_MESSAGES) { MESSAGES *m = (void*)p; m->width = width; if(!p->disabled) { messages_updateheight(m); } } PANEL **pp = p->child, *subp; if(pp) { while((subp = *pp++)) { panel_update(subp, x, y, width, height); } } }
static void panel_update(PANEL *p, int x, int y, int width, int height) { FIX_XY_CORDS_FOR_SUBPANELS(); switch (p->type) { case PANEL_NONE: { if (p == &panel_settings_devices) { #ifdef ENABLE_MULTIDEVICE devices_update_ui(); #endif } break; } case PANEL_MESSAGES: { if (p->object) { MESSAGES *m = p->object; m->width = width; messages_updateheight(m, width); } break; } default: { break; } } PANEL **pp = p->child; if (pp) { if (p->update) { p->update(width, height, ui_scale); } PANEL *subp; while ((subp = *pp++)) { panel_update(subp, x, y, width, height); } } }
// TODO move this out of here! static void show_page(ITEM *i){ // TODO!! // panel_item[selected_item->item - 1].disabled = 1; // panel_item[i->item - 1].disabled = 0; edit_resetfocus(); /* First things first, we need to deselect and store the old data. */ switch (selected_item->item){ case ITEM_FRIEND: { FRIEND *f = selected_item->data; free(f->typed); f->typed_length = edit_msg.length; f->typed = malloc(edit_msg.length); memcpy(f->typed, edit_msg.data, edit_msg.length); f->msg.scroll = messages_friend.panel.content_scroll->d; f->edit_history = edit_msg.history; f->edit_history_cur = edit_msg.history_cur; f->edit_history_length = edit_msg.history_length; panel_friend_chat.disabled = 1; } case ITEM_FRIEND_ADD: { panel_chat.disabled = 1; panel_friend_request.disabled = 1; break; } case ITEM_GROUP: { GROUPCHAT *g = selected_item->data; free(g->typed); g->typed_length = edit_msg_group.length; g->typed = malloc(edit_msg_group.length); memcpy(g->typed, edit_msg_group.data, edit_msg_group.length); g->msg.scroll = messages_group.panel.content_scroll->d; g->edit_history = edit_msg_group.history; g->edit_history_cur = edit_msg_group.history_cur; g->edit_history_length = edit_msg_group.history_length; panel_chat.disabled = 1; panel_group_chat.disabled = 1; break; } case ITEM_SETTINGS: { button_settings.disabled = 0; panel_settings_master.disabled = 1; panel_overhead.disabled = 1; break; } case ITEM_ADD: { button_add.disabled = 0; panel_add_friend.disabled = 1; break; } case ITEM_TRANSFER: { button_transfer.disabled = 0; panel_change_profile.disabled = 1; break; } /* End of last case */ } /* End of switch */ /* Now we activate/select the new page, and load stored data */ switch (i->item) { case ITEM_FRIEND_ADD: { panel_chat.disabled = 0; panel_friend_request.disabled = 0; break; } case ITEM_FRIEND: { FRIEND *f = i->data; #ifdef UNITY if (unity_running) { mm_rm_entry(f->cid); } #endif memcpy(edit_msg.data, f->typed, f->typed_length); edit_msg.length = f->typed_length; messages_friend.data = &f->msg; messages_updateheight(&messages_friend); messages_friend.iover = MSG_IDX_MAX; messages_friend.panel.content_scroll->content_height = f->msg.height; messages_friend.panel.content_scroll->d = f->msg.scroll; f->msg.id = f - friend; f->notify = 0; edit_msg.history = f->edit_history; edit_msg.history_cur = f->edit_history_cur; edit_msg.history_length = f->edit_history_length; edit_setfocus(&edit_msg); panel_chat.disabled = 0; panel_friend_chat.disabled = 0; break; } case ITEM_GROUP: { GROUPCHAT *g = i->data; memcpy(edit_msg_group.data, g->typed, g->typed_length); edit_msg_group.length = g->typed_length; messages_group.data = &g->msg; messages_updateheight(&messages_group); messages_group.iover = MSG_IDX_MAX; messages_group.panel.content_scroll->content_height = g->msg.height; messages_group.panel.content_scroll->d = g->msg.scroll; edit_setfocus(&edit_msg_group); g->msg.id = g - group; edit_msg_group.history = g->edit_history; edit_msg_group.history_cur = g->edit_history_cur; edit_msg_group.history_length = g->edit_history_length; panel_chat.disabled = 0; panel_group_chat.disabled = 0; break; } case ITEM_SETTINGS: { button_settings.disabled = 1; panel_overhead.disabled = 0; panel_settings_master.disabled = 0; break; } case ITEM_ADD: { button_add.disabled = 1; panel_overhead.disabled = 0; panel_add_friend.disabled = 0; edit_setfocus(&edit_add_id); break; } case ITEM_TRANSFER: { button_transfer.disabled = 1; panel_overhead.disabled = 0; panel_change_profile.disabled = 0; break; } // Last case } // Switch selected_item = i; addfriend_status = 0; // I think we shouldn't call this just here, redrawing should only be done when panel_draw is called, and now, we // don't even need to call the root tree, we can call subtrees/roots and should be able to increase performance. // redraw(); }