Exemplo n.º 1
0
Arquivo: ui.c Projeto: Matsu616/uTox
void ui_set_scale(uint8_t scale) {
    if (scale >= 5 && scale <= 25) {
        ui_scale = scale;
    } else if (scale != 0) {
        return ui_set_scale(10);
    }
}
Exemplo n.º 2
0
static void dropdown_language_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
    LANG = (UI_LANG_ID)i;
    /* The draw functions need the fonts' and scale to be reset when changing languages. */
    ui_set_scale(ui_scale);
}
Exemplo n.º 3
0
static void dropdown_dpi_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
    ui_set_scale(i + 6);
}
Exemplo n.º 4
0
// TODO refactor to match same order in main.h
UTOX_SAVE *config_load(void) {
    UTOX_SAVE *save = utox_load_config();

    // TODO: Remove this in ~0.18.0 release
    if (!save) {
        LOG_NOTE("Settings", "Unable to load uTox settings from %s. Trying old %s.", config_file_name, config_file_name_old);
        save = utox_data_load_utox();
    }

    if (!save) {
        LOG_ERR("Settings", "Unable to load uTox settings. Use defaults.");
        save = init_default_settings();
    }

    if (save->scale > 30) {
        save->scale = 30;
    } else if (save->scale < 5) {
        save->scale = 10;
    }

    if (save->window_width < MAIN_WIDTH) {
        save->window_width = MAIN_WIDTH;
    }
    if (save->window_height < MAIN_HEIGHT) {
        save->window_height = MAIN_HEIGHT;
    }

    /* UX Settings */

    dropdown_language.selected = dropdown_language.over = settings.language = save->language;

    dropdown_dpi.selected = dropdown_dpi.over = save->scale - 5;

    switch_save_chat_history.switch_on = save->logging_enabled;
    switch_close_to_tray.switch_on     = save->close_to_tray;
    switch_start_in_tray.switch_on     = save->start_in_tray;
    switch_mini_contacts.switch_on     = save->use_mini_flist;
    switch_magic_sidebar.switch_on     = save->magic_flist_enabled;

    switch_ipv6.switch_on             = save->enableipv6;
    switch_udp.switch_on              = !save->disableudp;
    switch_udp.panel.disabled         = save->force_proxy;
    switch_proxy.switch_on            = save->proxyenable;
    switch_proxy_force.switch_on      = save->force_proxy;
    switch_proxy_force.panel.disabled = !save->proxyenable;

    switch_auto_startup.switch_on       = save->auto_startup;
    switch_auto_update.switch_on        = save->auto_update;

    settings.group_notifications = dropdown_global_group_notifications.selected =
        dropdown_global_group_notifications.over = save->group_notifications;

    switch_audible_notifications.switch_on = save->audible_notifications_enabled;
    switch_audio_filtering.switch_on       = save->audio_filtering_enabled;
    switch_push_to_talk.switch_on          = save->push_to_talk;
    switch_status_notifications.switch_on  = save->status_notifications;

    dropdown_theme.selected = dropdown_theme.over = save->theme;

    switch_typing_notes.switch_on = !save->no_typing_notifications;

    flist_set_filter(save->filter); /* roster list filtering */

    /* Network settings */
    settings.enable_ipv6 = save->enableipv6;
    settings.enable_udp  = !save->disableudp;
    settings.use_proxy   = !!save->proxyenable;
    settings.proxy_port  = save->proxy_port;
    settings.force_proxy = save->force_proxy;

    if (strlen((char *)save->proxy_ip) <= proxy_address_size){
        strcpy((char *)proxy_address, (char *)save->proxy_ip);
    }

    edit_proxy_ip.length = strlen((char *)save->proxy_ip);

    strcpy((char *)edit_proxy_ip.data, (char *)save->proxy_ip);

    if (save->proxy_port) {
        edit_proxy_port.length =
            snprintf((char *)edit_proxy_port.data, edit_proxy_port.maxlength + 1, "%u", save->proxy_port);
        if (edit_proxy_port.length >= edit_proxy_port.maxlength + 1) {
            edit_proxy_port.length = edit_proxy_port.maxlength;
        }
    }

    /* UX settings */
    settings.logging_enabled      = save->logging_enabled;
    settings.close_to_tray        = save->close_to_tray;
    settings.start_in_tray        = save->start_in_tray;
    settings.start_with_system    = save->auto_startup;
    settings.use_mini_flist       = save->use_mini_flist;
    settings.magic_flist_enabled  = save->magic_flist_enabled;
    settings.use_long_time_msg    = save->use_long_time_msg;

    settings.ringtone_enabled     = save->audible_notifications_enabled;
    settings.audiofilter_enabled  = save->audio_filtering_enabled;

    settings.send_typing_status   = !save->no_typing_notifications;
    settings.status_notifications = save->status_notifications;

    settings.window_width         = save->window_width;
    settings.window_height        = save->window_height;

    settings.last_version         = save->utox_last_version;

    loaded_audio_out_device       = save->audio_device_out;
    loaded_audio_in_device        = save->audio_device_in;

    settings.auto_update          = save->auto_update;
    switch_auto_update.switch_on  = save->auto_update;
    settings.update_to_develop    = save->update_to_develop;
    settings.send_version         = save->send_version;

    settings.video_fps = save->video_fps ? save->video_fps : 25;

    edit_video_fps.length =
        snprintf((char *)edit_video_fps.data, edit_video_fps.maxlength + 1, "%u", save->video_fps);
    if (edit_video_fps.length > edit_video_fps.maxlength) {
        edit_video_fps.length = edit_video_fps.maxlength;
    }

    // TODO: Don't clobber (and start saving) commandline flags.

    // Allow users to override theme on the cmdline.
    if (settings.theme == UINT32_MAX) {
        settings.theme = save->theme;
    }

    ui_set_scale(save->scale);

    if (save->push_to_talk) {
        init_ptt();
    }

    return save;
}
Exemplo n.º 5
0
Arquivo: ui.c Projeto: Matsu616/uTox
void ui_rescale(uint8_t scale) {
    ui_set_scale(scale);

    flist_re_scale();
    setscale_fonts();
    setfont(FONT_SELF_NAME);

    /* DEFAULT positions */

    panel_main.y = 0;

    scrollbar_settings.panel.y        = 32;  /* TODO magic numbers are bad */
    scrollbar_settings.content_height = 300; /* TODO magic numbers are bad */

    panel_settings_master.y        = 0;
    panel_settings_devices.y       = 32;
    panel_settings_adv.y           = 32;

    scrollbar_friend.panel.y      = MAIN_TOP;
    scrollbar_friend.panel.height = CHAT_BOX_TOP;
    messages_friend.y             = MAIN_TOP;
    messages_friend.height        = CHAT_BOX_TOP - 10;
    messages_friend.width         = -SCROLL_WIDTH;

    scrollbar_group.panel.y      = MAIN_TOP;
    scrollbar_group.panel.height = CHAT_BOX_TOP;
    messages_group.y             = MAIN_TOP;
    messages_group.height        = CHAT_BOX_TOP;
    messages_group.width         = -SCROLL_WIDTH;

    setfont(FONT_SELF_NAME);

    sidepanel_USERBADGE();
    sidepanel_FLIST();

    settings_PROFILE();
    settings_UI();
    settings_AV();
    settings_NOTIFY();
    settings_ADV();

    // FIXME for testing, remove
    CREATE_BUTTON(notify_create, 2, 2, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT);
    CREATE_BUTTON(notify_one, 0, -50, 40, 50);
    CREATE_BUTTON(notify_two, 200, -50, 40, 50);
    CREATE_BUTTON(notify_three, -40, -50, 40, 50);

    CREATE_BUTTON(move_notify, -40, -40, 40, 40);


    /* Setting pages */
    uint32_t settings_x = 4;
    CREATE_BUTTON(settings_sub_profile,         settings_x, 0, 12, 28);
    settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(PROFILE_BUTTON));

#ifdef ENABLE_MULTIDEVICE
    CREATE_BUTTON(settings_sub_devices,         settings_x, 0, 12, 28);
    settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(DEVICES_BUTTON));
#endif

    CREATE_BUTTON(settings_sub_ui,              settings_x, 0, 12, 28);
    settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(USER_INTERFACE_BUTTON));

    CREATE_BUTTON(settings_sub_av,              settings_x, 0, 12, 28);
    settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(AUDIO_VIDEO_BUTTON));

    CREATE_BUTTON(settings_sub_notifications,   settings_x, 0, 12, 28);
    settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(NOTIFICATIONS_BUTTON));

    CREATE_BUTTON(settings_sub_adv,             settings_x, 0, 12, 28);


    /* Devices */
    CREATE_BUTTON(add_new_device_to_self, -10 - BM_SBUTTON_WIDTH, 28, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT);

    CREATE_EDIT(add_new_device_to_self, 10, 27, 0 - UTOX_STR_WIDTH(ADD) - BM_SBUTTON_WIDTH, 24);


    /* Friend Add Page */
    CREATE_BUTTON(send_friend_request, -10 - _BM_SBUTTON_WIDTH, MAIN_TOP + 168, _BM_SBUTTON_WIDTH,
                  _BM_SBUTTON_HEIGHT);
    CREATE_BUTTON(accept_friend, -60, -80, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT);

    /* Friend Settings Page */
    CREATE_BUTTON(export_chatlog, 10, 208, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT);

    CREATE_EDIT(friend_pubkey,          10, 88, -10, 24);
    CREATE_EDIT(friend_alias,           10, 138, -10, 24);

    CREATE_SWITCH(friend_autoaccept_ft, 10, 168, _BM_SWITCH_WIDTH, _BM_SWITCH_HEIGHT);

    /* Group Settings */
    CREATE_EDIT(group_topic, 10, 95, -10, 24);

    /* Friend / Group Page  */
    CREATE_BUTTON(call_decline, -186, 10, _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT);
    CREATE_BUTTON(call_audio,   -124, 10, _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT);
    CREATE_BUTTON(call_video,    -62, 10, _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT);
    CREATE_BUTTON(group_audio,   -62, 10, _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT);

    CREATE_BUTTON(send_file,         6, -46, _BM_CHAT_BUTTON_WIDTH, _BM_CHAT_BUTTON_HEIGHT);
    CREATE_BUTTON(send_screenshot,   8 + _BM_CHAT_BUTTON_WIDTH, -46, _BM_CHAT_BUTTON_WIDTH, _BM_CHAT_BUTTON_HEIGHT);

    CREATE_BUTTON(chat_send_friend, -6 - _BM_CHAT_SEND_WIDTH, -46, _BM_CHAT_SEND_WIDTH, _BM_CHAT_SEND_HEIGHT);
    CREATE_BUTTON(chat_send_group,  -6 - _BM_CHAT_SEND_WIDTH, -46, _BM_CHAT_SEND_WIDTH, _BM_CHAT_SEND_HEIGHT);

    setfont(FONT_TEXT);

    // Add friend panel
    CREATE_EDIT(add_new_friend_id, 10, 28 + MAIN_TOP, -10, 24);
    CREATE_EDIT(add_new_friend_msg, 10, 76 + MAIN_TOP, -10, 84);

    /* Message entry box for friends and groups */
    CREATE_EDIT(chat_msg_friend, 10 + _BM_CHAT_BUTTON_WIDTH * 2, /* Make space for the left button  */
                -46, -64, 40); /* text is 8 high. 8 * 2.5 = 20. */

    CREATE_EDIT(chat_msg_group, 6, -46, -10 - BM_CHAT_SEND_WIDTH, 40);

    /* Confirm deletion */
    CREATE_BUTTON(confirm_deletion, 10, MAIN_TOP + 40, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT);
    CREATE_BUTTON(deny_deletion,    110, MAIN_TOP + 40, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT);

    setscale();
}