Index: apps/lang/deutsch.lang =================================================================== --- apps/lang/deutsch.lang (Revision 22914) +++ apps/lang/deutsch.lang (Arbeitskopie) @@ -12680,3 +12680,20 @@ *: "Oben" + + id: LANG_TOUCHSCREEN_MODE_EQ + desc: in Settings -> General -> Display -> Touchscreen Settings + user: core + + *: none + touchscreen: "Touchscreen Mode in Equalizer" + + + *: none + touchscreen: "Touchscreen-Modus im Equalizer" + + + *: none + touchscreen: "Touchscreen-Modus im Equalizer" + + Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (Revision 22914) +++ apps/lang/english.lang (Arbeitskopie) @@ -13075,3 +13075,20 @@ swcodec: "Release Time" + + id: LANG_TOUCHSCREEN_MODE_EQ + desc: in Settings -> General -> Display -> Touchscreen Settings + user: core + + *: none + touchscreen: "Touchscreen Mode in Equalizer" + + + *: none + touchscreen: "Touchscreen Mode in Equalizer" + + + *: none + touchscreen: "Touchscreen Mode in Equalizer" + + Index: apps/settings.h =================================================================== --- apps/settings.h (Revision 22914) +++ apps/settings.h (Arbeitskopie) @@ -786,7 +786,10 @@ int compressor_makeup_gain; int compressor_knee; int compressor_release_time; +#ifdef HAVE_TOUCHSCREEN + int touch_mode_eq; #endif +#endif }; Index: apps/menus/display_menu.c =================================================================== --- apps/menus/display_menu.c (Revision 22914) +++ apps/menus/display_menu.c (Arbeitskopie) @@ -481,14 +481,21 @@ } MENUITEM_SETTING(touch_mode, &global_settings.touch_mode, touch_mode_callback); +#if CONFIG_CODEC == SWCODEC +MENUITEM_SETTING(touch_mode_eq, &global_settings.touch_mode_eq, NULL); +#endif + MENUITEM_FUNCTION(touchscreen_menu_calibrate, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE), calibrate, NULL, NULL, Icon_NOICON); MENUITEM_FUNCTION(touchscreen_menu_reset_calibration, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION), reset_mapping, NULL, NULL, Icon_NOICON); MAKE_MENU(touchscreen_menu, ID2P(LANG_TOUCHSCREEN_SETTINGS), NULL, Icon_NOICON, &touch_mode, - &touchscreen_menu_calibrate, &touchscreen_menu_reset_calibration); +#if CONFIG_CODEC == SWCODEC + &touch_mode_eq, #endif + &touchscreen_menu_calibrate, &touchscreen_menu_reset_calibration); +#endif MENUITEM_SETTING(codepage_setting, &global_settings.default_codepage, NULL); Index: apps/menus/eq_menu.c =================================================================== --- apps/menus/eq_menu.c (Revision 22914) +++ apps/menus/eq_menu.c (Arbeitskopie) @@ -172,6 +172,27 @@ { &cutoff_3, &q_3, &gain_3 } }; +#ifdef HAVE_TOUCHSCREEN +typedef struct { + int x[3]; + int y[5]; + int width[3]; + int height; +}eq_setting_item_data; + +typedef struct { + int x; + int y[5]; + int height; + int length; +}eq_slider_data; + +struct eq{ + eq_setting_item_data setting_item; + eq_slider_data slider; +}eq; +#endif + static char* centerband_get_name(int selected_item, void * data, char *buffer) { (void)selected_item; @@ -240,11 +261,8 @@ HIGH_SHELF }; -/* Size of just the slider/srollbar */ -#define SCROLLBAR_SIZE 6 - /* Draw the UI for a whole EQ band */ -static int draw_eq_slider(struct screen * screen, int x, int y, +static int draw_eq_slider(struct screen * screen, int x, int y, int slider_height, int width, int cutoff, int q, int gain, bool selected, enum eq_slider_mode mode, int band) { @@ -304,6 +322,15 @@ screen->lcdwidth >= 160 ? "dB" : ""); screen->putsxy(x1, y1, buf); screen->getstringsize(buf, &w, &h); +#ifdef HAVE_TOUCHSCREEN + eq.setting_item.y[band] = y1 - 1; + if (!eq.setting_item.x[0]) + { /* we need this once only */ + eq.setting_item.x[0] = x1; + eq.setting_item.height = h + 2; + eq.setting_item.width[0] = w; + } +#endif x1 += w; /* Print out Q part of status line (right justify) */ @@ -318,6 +345,14 @@ x2 = x + width - w - 2; screen->putsxy(x2, y1, buf); +#ifdef HAVE_TOUCHSCREEN + if (!eq.setting_item.x[2]) + { /* we need this once only */ + eq.setting_item.x[2] = x2; + eq.setting_item.width[2] = w; + } +#endif + /* Print out cutoff part of status line (center between gain & Q) */ if (mode == CUTOFF && selected) screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); @@ -330,29 +365,63 @@ x1 = x1 + (x2 - x1 - w)/2; screen->putsxy(x1, y1, buf); +#ifdef HAVE_TOUCHSCREEN + if (!eq.setting_item.x[1]) + { /* we need this once only */ + eq.setting_item.x[1] = x1; + eq.setting_item.width[1] = w; + } +#endif + /* Draw selection box */ - total_height = 3 + h + 1 + SCROLLBAR_SIZE + 3; + total_height = 3 + h + 1 + slider_height + 3; screen->set_drawmode(DRMODE_SOLID); if (selected) { screen->drawrect(x, y, width, total_height); } /* Draw horizontal slider. Reuse scrollbar for this */ - gui_scrollbar_draw(screen, x + 3, y1 + h + 1, width - 6, SCROLLBAR_SIZE, - steps, min_item, max_item, HORIZONTAL); - + gui_scrollbar_draw(screen, x + 3, y1 + h + 1, width - 6, + slider_height, steps, min_item, max_item, HORIZONTAL); return total_height; } +#define SCROLLBAR_SIZE 6 + +#ifdef HAVE_TOUCHSCREEN + #define EQ_L_BORDER 6 /* left and right border for better control on touchscreen */ + #define EQ_R_BORDER 12 +#else + #define EQ_L_BORDER 0 + #define EQ_R_BORDER 0 +#endif + /* Draw's all the EQ sliders. Returns the total height of the sliders drawn */ static void draw_eq_sliders(struct screen * screen, int x, int y, - int nb_eq_sliders, int start_item, + int nb_eq_sliders, int slider_height, int start_item, int current_band, enum eq_slider_mode mode) { int i, gain, q, cutoff; int height = y; int *setting = &global_settings.eq_band0_cutoff; +#ifdef HAVE_TOUCHSCREEN + eq.setting_item.height = 0; + eq.slider.height = 0; + eq.slider.length = 0; + eq.slider.x = 0; + for (i = 0; i <= 2; i++) + { + eq.setting_item.x[i] = 0; + eq.setting_item.width[i] = 0; + } + for (i = 0; i <= 5; i++) + { + eq.setting_item.y[i] = 0; + eq.slider.y[i] = 0; + } +#endif + start_item = MIN(start_item, 5-nb_eq_sliders); for (i=0; i<5; i++) { cutoff = *setting++; @@ -363,12 +432,20 @@ break; if (i >= start_item) { - height += draw_eq_slider(screen, x, height, screen->lcdwidth - x - 1, - cutoff, q, gain, i == current_band, mode, - i); + height += draw_eq_slider(screen, x, height, slider_height, + screen->lcdwidth - x - 1 - EQ_R_BORDER, cutoff, q, gain, + i == current_band, mode, i); +#ifdef HAVE_TOUCHSCREEN + eq.slider.y[i] = height - slider_height; +#endif /* add a margin */ height++; } +#ifdef HAVE_TOUCHSCREEN + eq.slider.x = x + 6; /* borders + 3 px edge for better touchscreen control */ + eq.slider.length = screen->lcdwidth - eq.slider.x - EQ_L_BORDER - EQ_R_BORDER; + eq.slider.height = slider_height; +#endif } if (nb_eq_sliders != 5) gui_scrollbar_draw(screen, 0, y, SCROLLBAR_SIZE - 1, @@ -392,18 +469,43 @@ char buf[24]; int i, w, h, height, start_item, nb_eq_sliders[NB_SCREENS]; int barsenabled = viewportmanager_set_statusbar(VP_SB_HIDE_ALL); + int slider_height[NB_SCREENS]; +#ifdef HAVE_TOUCHSCREEN + touchscreen_set_mode(global_settings.touch_mode_eq); +#endif FOR_NB_SCREENS(i) { screens[i].set_viewport(NULL); - screens[i].setfont(FONT_SYSFIXED); - screens[i].clear_display(); - /* Figure out how many sliders can be drawn on the screen */ + /* Select the font and figure out how many sliders can be drawn on */ + /* the screen. Use the theme font if possible */ + + screens[i].setfont(FONT_UI); screens[i].getstringsize("A", &w, &h); + if (w * 25 > screens[i].lcdwidth) + { /* 3 x 5 characters for setting items, 2 x 3 spaces, 1 x 4 for band label */ + screens[i].setfont(FONT_SYSFIXED); + screens[i].getstringsize("A", &w, &h); + } + slider_height[i] = (screens[i].lcdheight - h - 2 - 5 * + (3 + h + 1 + 3) - screens[i].lcdheight * 0.05) / 5; + /* calculate slider height so that the screen is filled out and 5% */ + /* free space is left at the buttom */ + if (slider_height[i] > 25) + { + slider_height[i] = 25; + } + else if (slider_height[i] < 6) + { + slider_height[i] = 6; + screens[i].setfont(FONT_SYSFIXED); + screens[i].getstringsize("A", &w, &h); + } + screens[i].clear_display(); /* Total height includes margins (1), text, slider, and line selector (1) */ - height = 3 + h + 1 + SCROLLBAR_SIZE + 3; + height = 3 + h + 1 + slider_height[i] + 3; nb_eq_sliders[i] = screens[i].lcdheight / height; /* Make sure the "Edit Mode" text fits too */ @@ -485,20 +587,139 @@ } else { start_item = current_band - 1; } - x = SCROLLBAR_SIZE; + x = SCROLLBAR_SIZE + EQ_L_BORDER; } else { - x = 1; + x = 1 + EQ_L_BORDER; start_item = 0; } /* Draw equalizer band details */ - draw_eq_sliders(&screens[i], x, y, nb_eq_sliders[i], start_item, - current_band, mode); + draw_eq_sliders(&screens[i], x, y, nb_eq_sliders[i], slider_height[i], + start_item, current_band, mode); screens[i].update(); } button = get_action(CONTEXT_SETTINGS_EQ,TIMEOUT_BLOCK); +#ifdef HAVE_TOUCHSCREEN + +#define EQ_ITEM 1 +#define SLIDER 2 + + static bool slider_change = false; + static bool band_changed = false; + + if ((button == ACTION_TOUCHSCREEN && + touchscreen_get_mode() == TOUCHSCREEN_POINT) || + slider_change || band_changed) + { + short touched_item = 0; + short selected_band, selected_mode; + int button_touchscreen; + short touch_x = 0, touch_y = 0; + + button_touchscreen = action_get_touchscreen_press(&touch_x, &touch_y); + + if (touch_y < eq.setting_item.y[0] && touch_x > eq.slider.x) + { + button = ACTION_STD_CANCEL; + slider_change = false; + band_changed = false; + /* leave the menue when "Edit Mode" line is touched */ + } + else + { + button = BUTTON_NONE; + selected_band = 0; + if (touch_x >= eq.slider.x && !band_changed) + { + do { /* find out which item and band has been touched */ + if ( touch_y >= eq.setting_item.y[selected_band] && + (touch_y <= (eq.slider.y[selected_band] + + eq.slider.height))) + { + if (touch_y <= eq.setting_item.y[selected_band] + + eq.setting_item.height) + { + touched_item = EQ_ITEM; + } + else + { + touched_item = SLIDER; + } + } + else + { + selected_band++; + } + } while (selected_band <= 5 && !touched_item); + } + + if (touched_item) { + if (touch_x >= eq.setting_item.x[0] && + (touch_x <= eq.setting_item.x[0] + eq.setting_item.width[0])) + { + selected_mode = GAIN; + } + else if (touch_x >= eq.setting_item.x[1] && + (touch_x <= eq.setting_item.x[1] + eq.setting_item.width[1])) + { + selected_mode = CUTOFF; + } + else if (touch_x >= eq.setting_item.x[2] && + (touch_x <= eq.setting_item.x[2] + eq.setting_item.width[2])) + { + selected_mode = Q; + } + } + } + + if (!slider_change && touched_item) + { + if (touched_item == EQ_ITEM) { + mode = selected_mode; + } + if (current_band != selected_band) { + band_changed = true; + current_band = selected_band; + } + else if (touched_item == SLIDER) { + slider_change = true; + } + } + + if (slider_change && !band_changed) { + int value; + if (mode == GAIN) { + value = max * 2 * (touch_x - eq.slider.x - + eq.slider.length/2) / eq.slider.length; + } + else { + value = min + (max-min) * (touch_x - + eq.slider.x) / eq.slider.length; + } + if (value < min) { + *(setting) = min; + } + else if (value > max) { + *(setting) = max; + } + else { + *(setting) = value; + } + has_changed = true; + } + + if (slider_change && (button_touchscreen & BUTTON_REL)) { + slider_change = false; + } + + if (band_changed && (button_touchscreen & BUTTON_REL)) { + band_changed = false; + } + } +#endif + switch (button) { case ACTION_SETTINGS_DEC: case ACTION_SETTINGS_DECREPEAT: @@ -553,6 +774,9 @@ case ACTION_STD_CANCEL: exit_request = true; result = false; +#ifdef HAVE_TOUCHSCREEN + touchscreen_set_mode(global_settings.touch_mode); +#endif break; default: if(default_event_handler(button) == SYS_USB_CONNECTED) { Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (Revision 22914) +++ apps/settings_list.c (Arbeitskopie) @@ -1597,7 +1597,12 @@ CHOICE_SETTING(0, touch_mode, LANG_TOUCHSCREEN_MODE, TOUCHSCREEN_BUTTON, "touchscreen mode", "point,grid", NULL, 2, ID2P(LANG_TOUCHSCREEN_POINT), ID2P(LANG_TOUCHSCREEN_GRID)), - CUSTOM_SETTING(0, ts_calibration_data, -1, +#if CONFIG_CODEC == SWCODEC + CHOICE_SETTING(0, touch_mode_eq, LANG_TOUCHSCREEN_MODE_EQ, TOUCHSCREEN_BUTTON, + "touchscreen mode equalizer", "point,grid", NULL, 2, + ID2P(LANG_TOUCHSCREEN_POINT), ID2P(LANG_TOUCHSCREEN_GRID)), +#endif + CUSTOM_SETTING(0, ts_calibration_data, -1, &default_calibration_parameters, "touchscreen calibration", tsc_load_from_cfg, tsc_write_to_cfg, tsc_is_changed, tsc_set_default),