diff --git a/acinclude.m4 b/acinclude.m4 index 6212c1f25..be7f8f602 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -21,6 +21,14 @@ if test "$DEBUG" = "yes"; then AC_DEFINE(DEBUG,1,[Enable debug messages]) fi +AC_ARG_ENABLE(reschange, + AS_HELP_STRING(--enable-reschange,enable change the osd resolution (default for hd2))) + +AM_CONDITIONAL(ENABLE_RESCHANGE,test "$enable_reschange" = "yes") +if test "$enable_reschange" = "yes"; then + AC_DEFINE(ENABLE_CHANGE_OSD_RESOLUTION,1,[enable change the osd resolution]) +fi + AC_MSG_CHECKING(target) if test "$TARGET" = "native"; then @@ -354,6 +362,7 @@ if test "$BOXMODEL" = "hd1"; then AC_DEFINE(BOXMODEL_CS_HD1, 1, [coolstream hd1/neo/neo2/zee]) elif test "$BOXMODEL" = "hd2"; then AC_DEFINE(BOXMODEL_CS_HD2, 1, [coolstream tank/trinity/trinity v2/trinity duo/zee2/link]) + AC_DEFINE(ENABLE_CHANGE_OSD_RESOLUTION,1,[enable change the osd resolution]) elif test "$BOXMODEL" = "raspi"; then AC_DEFINE(BOXMODEL_RASPI, 1, [Raspberry pi]) fi diff --git a/configure.ac b/configure.ac index 3808be4dc..222dafeb5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(Neutrino-MP,3.4.2) +AC_INIT(Neutrino-MP,3.5.0) AM_INIT_AUTOMAKE([1.0.1 nostdinc]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) diff --git a/data/cables.xml b/data/cables.xml index e05516a44..fa4baec60 100644 --- a/data/cables.xml +++ b/data/cables.xml @@ -534,7 +534,7 @@ - + diff --git a/data/icons/filetypes/Makefile.am b/data/icons/filetypes/Makefile.am index ec9f09d5a..d71903773 100644 --- a/data/icons/filetypes/Makefile.am +++ b/data/icons/filetypes/Makefile.am @@ -3,4 +3,6 @@ installdir = $(ICONSDIR) install_DATA = \ file.png \ folder.png \ - movie.png + movie.png \ + mp3.png \ + picture.png diff --git a/data/icons/filetypes/mp3.png b/data/icons/filetypes/mp3.png new file mode 100644 index 000000000..7c4bb1eb8 Binary files /dev/null and b/data/icons/filetypes/mp3.png differ diff --git a/data/icons/filetypes/picture.png b/data/icons/filetypes/picture.png new file mode 100644 index 000000000..f1f450c78 Binary files /dev/null and b/data/icons/filetypes/picture.png differ diff --git a/data/icons/headers/Makefile.am b/data/icons/headers/Makefile.am index 29328dcbf..faf172967 100644 --- a/data/icons/headers/Makefile.am +++ b/data/icons/headers/Makefile.am @@ -17,10 +17,10 @@ install_DATA = \ language.png \ lcd.png \ mainmenue.png \ - mp3.png \ multimedia.png \ network.png \ personalize.png \ + pictureviewer.png \ recording.png \ settings.png \ shell.png \ diff --git a/data/icons/headers/pictureviewer.png b/data/icons/headers/pictureviewer.png new file mode 100755 index 000000000..9f4414adf Binary files /dev/null and b/data/icons/headers/pictureviewer.png differ diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 9d855f39a..51e9dd804 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1,5 +1,5 @@ AUDIOSelectMenue.head Auswahl der Tonspur -EPGMenu.epgplus Vorschauübersicht +EPGMenu.epgplus Vorschau-Übersicht EPGMenu.eventinfo Info zur Sendung EPGMenu.eventlist Vorschau aktuelles Programm EPGMenu.head EPG - Programminformation @@ -7,7 +7,7 @@ EPGMenu.streaminfo Technische Information EPGPlus.actions Aktionen EPGPlus.bybouquet_mode bouquetweise EPGPlus.bypage_mode seitenweise -EPGPlus.head Vorschau Übersicht (EPG Plus) +EPGPlus.head Vorschau-Übersicht (EPG Plus) EPGPlus.next_bouquet Bouquet vor EPGPlus.options Optionen EPGPlus.page_down Seite zurück @@ -19,7 +19,7 @@ EPGPlus.remind Vormerken EPGPlus.scroll_mode Scroll-Modus EPGPlus.stretch_mode Stretch-Modus EPGPlus.swap_mode Blättern -EPGPlus.view_mode Modus +EPGPlus.view_mode Ansicht GENRE.ALL aus GENRE.ARTS Kultur GENRE.ARTS.0 Kunst/Kultur @@ -160,10 +160,10 @@ audioplayer.add_loc Lokale Radioliste audioplayer.add_sc SHOUTcast audioplayer.artist_title Interpret, Titel audioplayer.building_search_index Erstelle Suchindex -audioplayer.button_select_title_by_id Suche n. ID -audioplayer.button_select_title_by_name Suche n. Name -audioplayer.defdir Start-Verz. -audioplayer.delete entfernen +audioplayer.button_select_title_by_id Suche nach ID +audioplayer.button_select_title_by_name Suche nach Name +audioplayer.defdir Start-Verzeichnis +audioplayer.delete Entfernen audioplayer.deleteall Alle entfernen audioplayer.display_order Anzeige audioplayer.enable_sc_metadata Aktiviere SHOUTcast Meta-Daten Parsing @@ -322,10 +322,10 @@ colormenu.clock_textcolor Ziffernfarbe colormenu.fade Ein-/Ausblenden colormenu.font Verwendete Schriftart colormenu.font_ttx Teletext Schriftart -colormenu.hd_preset LCD colormenu.menucolors Farben colormenu.osd_preset Monitor Auswahl -colormenu.sd_preset CRT +colormenu.osd_resolution OSD-Auflösung +colormenu.shadow_color Schattenfarbe colormenu.textcolor Textfarbe colormenu.themeselect Theme auswählen colormenu.timing Timeouts @@ -593,11 +593,11 @@ filebrowser.prevpage Seite zurück filebrowser.scan Durchsuche Verzeichnisse filebrowser.select Auswählen filebrowser.showrights Dateirechte anzeigen -filebrowser.sort.date (Datum) -filebrowser.sort.name (Dateiname) -filebrowser.sort.namedirsfirst (Dateiname2) -filebrowser.sort.size (Größe) -filebrowser.sort.type (Typ) +filebrowser.sort.date Datum +filebrowser.sort.name Name +filebrowser.sort.namedirsfirst Name, Verz. zuerst +filebrowser.sort.size Größe +filebrowser.sort.type Typ filesystem.is.utf8 Dateisystem filesystem.is.utf8.option.iso8859.1 ISO-8859-1 filesystem.is.utf8.option.utf8 UTF-8 @@ -885,7 +885,7 @@ languagesetup.select Sprache lcd_info_line Zeige in Infozeile lcd_info_line_channel Kanalname lcd_info_line_clock Uhrzeit -lcdcontroler.brightness normale +lcdcontroler.brightness Normalbetrieb lcdcontroler.brightnessdeepstandby Deep-Standby lcdcontroler.brightnessstandby Standby lcdmenu.dim_brightness nach Dimm-Timeout @@ -1037,6 +1037,7 @@ menu.hint_color_gradient_separator_enable Farbverlauf für Menü-Trennlinien akt menu.hint_colored_events Definiert, ob die aktuelle oder nächste Sendung in einer anderen Farbe dargestellt werden soll menu.hint_colored_events_textcolor Ändern Sie die Farbe für farbige Events in der Kanalliste und der Infobar menu.hint_colors Konfigurieren Sie die Menü-Farben +menu.hint_colors_shadow Einstellen der Schattenfarbe menu.hint_content_back Ändern Sie die Hintergrundfarbe für den Fensterinhalt menu.hint_content_textcolor Ändern Sie die Textfarbe für den Fensterinhalt menu.hint_dboxinfo Informationen über CPU und Arbeitsspeicher der Box @@ -1254,6 +1255,7 @@ menu.hint_opkg_upgrade Aktualisiert alle installierten Pakete auf die neueste ve menu.hint_osd Farben, Schriftarten, Anzeigegröße, Ansichtsoptionen der Menüs usw. menu.hint_osd_language Wählen Sie ihre Menü-Sprache menu.hint_osd_preset Wählen Sie zwischen Röhren-TV (CRT) oder Flachbildschirm (LCD) +menu.hint_osd_resolution Wählen Sie eine OSD-Auflösung menu.hint_osd_timing Einblendzeit, die das OSD auf dem TV angezeigt wird menu.hint_other_fonts Ändern Sie andere Schriftgrößen menu.hint_parentallock_changepin Geben Sie den 4-stelligen PIN-Code ein, der dann ggf. abgefragt wird @@ -1669,6 +1671,7 @@ moviebrowser.cut_failed Fehler beim Schneiden. Sind Sprungmarken und genug freie moviebrowser.cutting Schneide Film, bitte warten ... moviebrowser.delete_all Alle markierten Filme ohne weitere Nachfrage löschen? moviebrowser.delete_info Lösche Dateien, bitte warten ... +moviebrowser.delete_movie Film löschen moviebrowser.delete_screenshot Lösche Screenshot? moviebrowser.dir Pfad moviebrowser.directories Verzeichnisse @@ -2021,7 +2024,7 @@ personalize.usermenu_plugin_types Anzuzeigende Plugin-Typen wählen personalize.usermenu_preferred_buttons Bevorzugte Tasten zuweisen personalize.usermenu_show_cancel Zeige Schalter "Abbrechen" personalize.visible sichtbar -pictureviewer.defdir Start-Verz. +pictureviewer.defdir Start-Verzeichnis pictureviewer.head Bildbetrachter pictureviewer.help1 Menü-Modus pictureviewer.help10 Bild neu einlesen @@ -2055,8 +2058,8 @@ pictureviewer.scaling Skalierung pictureviewer.show Anzeigen pictureviewer.slide_time Diaschau-Anzeigedauer pictureviewer.slideshow Diaschau -pictureviewer.sortorder.date Sortierreihenf. ändern (Datum) -pictureviewer.sortorder.filename Sortierreihenf. ändern (Dateiname) +pictureviewer.sortorder.date Sortierreihenfolge: Datum +pictureviewer.sortorder.filename Sortierreihenfolge: Dateiname ping.ok ist erreichbar (ping) ping.protocol ist nicht erreichbar (Host- oder Protokoll-Fehler) ping.socket ist nicht erreichbar (Socket-Fehler) @@ -2320,9 +2323,11 @@ streaminfo.framerate Bildrate streaminfo.framerate_unknown unbekannt streaminfo.head Tech. Information streaminfo.not_available nicht verfügbar +streaminfo.osd_resolution OSD-Auflösung streaminfo.resolution Auflösung streaminfo.signal Empfangssignal -streaming.busy Ein oder mehrere Aufnahmeprozesse sind aktiv.\nSollte die Aufnahme eigentlich beendet sein,\nschafft ein Neustart von Neutrino Abhilfe. +streaminfo.videosystem Videosystem +streaming.busy Einer oder mehrere Aufnahmeprozesse sind aktiv.\nSollte die Aufnahme eigentlich beendet sein,\nschafft ein Neustart der GUI Abhilfe. streaming.dir_not_writable Das Aufnahmeverzeichnis ist nicht beschreibbar.\nAufnahmen sind daher nicht möglich. streaming.overflow Aufnahme-Puffer Überlauf! Bitte ggf. einige Aufnahmen beenden. streaming.slow System oder Datenträger zu langsam! Bitte ggf. einige Aufnahmen beenden. diff --git a/data/locale/english.locale b/data/locale/english.locale index c99706c86..c503c753c 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -2,24 +2,24 @@ AUDIOSelectMenue.head Audio Selection EPGMenu.epgplus Eventlist overview EPGMenu.eventinfo Details current program EPGMenu.eventlist Eventlist current programm -EPGMenu.head EPG - Program Information -EPGMenu.streaminfo technical information +EPGMenu.head EPG - Program information +EPGMenu.streaminfo Technical information EPGPlus.actions Actions EPGPlus.bybouquet_mode by bouquet EPGPlus.bypage_mode by page -EPGPlus.head Eventlist Overview (EPG Plus) -EPGPlus.next_bouquet next bouquet -EPGPlus.options options -EPGPlus.page_down page down -EPGPlus.page_up page up -EPGPlus.prev_bouquet prev bouquet +EPGPlus.head Eventlist overview (EPG Plus) +EPGPlus.next_bouquet Next bouquet +EPGPlus.options Options +EPGPlus.page_down Page down +EPGPlus.page_up Page up +EPGPlus.prev_bouquet Prev bouquet EPGPlus.record Record EPGPlus.refresh_epg Refresh EPGPlus.remind Schedule -EPGPlus.scroll_mode Scroll Mode -EPGPlus.stretch_mode Stretch Mode -EPGPlus.swap_mode swap mode -EPGPlus.view_mode view mode +EPGPlus.scroll_mode Scroll mode +EPGPlus.stretch_mode Stretch mode +EPGPlus.swap_mode Swap mode +EPGPlus.view_mode View mode GENRE.ALL off GENRE.ARTS Arts GENRE.ARTS.0 arts/culture @@ -159,46 +159,46 @@ audioplayer.add_ic Icecast audioplayer.add_loc Local radio list audioplayer.add_sc SHOUTcast audioplayer.artist_title Artist, Title -audioplayer.building_search_index building search index -audioplayer.button_select_title_by_id search by ID -audioplayer.button_select_title_by_name search by name -audioplayer.defdir start dir. +audioplayer.building_search_index Building search index +audioplayer.button_select_title_by_id Search by ID +audioplayer.button_select_title_by_name Search by name +audioplayer.defdir Start directory audioplayer.delete Remove -audioplayer.deleteall remove all -audioplayer.display_order display order -audioplayer.enable_sc_metadata enable SHOUTcast meta data parsing -audioplayer.fastforward fast forw. -audioplayer.follow auto select current +audioplayer.deleteall Remove all +audioplayer.display_order Display order +audioplayer.enable_sc_metadata Enable SHOUTcast meta data parsing +audioplayer.fastforward Fast forward +audioplayer.follow Auto select current audioplayer.head Audio Playlist audioplayer.highprio High decode priority -audioplayer.jump_backwards jump backwards +audioplayer.jump_backwards Jump backwards audioplayer.jump_dialog_hint1 Please enter jump target audioplayer.jump_dialog_hint2 (relative, in seconds) audioplayer.jump_dialog_title Enter jump target -audioplayer.jump_forwards jump forwards -audioplayer.keylevel key level +audioplayer.jump_forwards Jump forwards +audioplayer.keylevel Key level audioplayer.load_radio_stations Load internet radios audioplayer.name Audioplayer -audioplayer.pause pause +audioplayer.pause Pause audioplayer.play Play -audioplayer.playing Current Track +audioplayer.playing Current track audioplayer.playlist_fileerror_msg File could not be created: audioplayer.playlist_fileoverwrite_msg Do you want to overwrite this file: audioplayer.playlist_fileoverwrite_title Overwrite? -audioplayer.playlist_name filename of the play list +audioplayer.playlist_name Filename of the play list audioplayer.playlist_name_hint1 Please enter the filename of the playlist audioplayer.playlist_name_hint2 The extension .m3u will be added automatically -audioplayer.reading_files reading files -audioplayer.receiving_list Receiving list, please wait -audioplayer.repeat_on enable repeat mode -audioplayer.rewind rewind -audioplayer.save_playlist save play list -audioplayer.select_title_by_name search title by name (SMS) -audioplayer.show_playlist Show Playlist -audioplayer.shuffle shuffle -audioplayer.spectrum lcd a-spectrum +audioplayer.reading_files Reading files +audioplayer.receiving_list Receiving list, please wait ... +audioplayer.repeat_on Enable repeat mode +audioplayer.rewind Rewind +audioplayer.save_playlist Save play list +audioplayer.select_title_by_name Search title by name (SMS) +audioplayer.show_playlist Show playlist +audioplayer.shuffle Shuffle +audioplayer.spectrum LCD spectrum audioplayer.stop Stop -audioplayer.title_artist Title, Artist +audioplayer.title_artist Title, artist bookmarkmanager.delete delete bookmarkmanager.name bookmarks bookmarkmanager.rename rename @@ -233,52 +233,52 @@ buildinfo.creator Creator buildinfo.kernel Kernel version buildinfo.menu Build information cablesetup.provider cable provider -channellist.additional Additional informations -channellist.additional_off off -channellist.additional_on on -channellist.additional_on_minitv on (with MiniTV) -channellist.current_tp Current transponder +channellist.additional Additional Informations +channellist.additional_off Off +channellist.additional_on On +channellist.additional_on_minitv On (with MiniTV) +channellist.current_tp Current Transponder channellist.edit Edit -channellist.epgtext_align_left left -channellist.epgtext_align_right right -channellist.extended Show event progress +channellist.epgtext_align_left Left +channellist.epgtext_align_right Right +channellist.extended Show Event Progress channellist.extended_colored with colored progressbar channellist.extended_simple with simple progressbar -channellist.favs Favoriten +channellist.favs Favorites channellist.foot Channel Information channellist.foot_freq Sat/Freq Info -channellist.foot_next next Event -channellist.foot_off off -channellist.foot_sort_alpha sorted[alpha] -channellist.foot_sort_chnum sorted[number] -channellist.foot_sort_freq sorted[freq] -channellist.foot_sort_sat sorted[sat] +channellist.foot_next Next Event +channellist.foot_off Off +channellist.foot_sort_alpha Sorted[Alpha] +channellist.foot_sort_chnum Sorted[Number] +channellist.foot_sort_freq Sorted[Freq] +channellist.foot_sort_sat Sorted[Sat] channellist.head All Services channellist.history History -channellist.history_clear Clear history -channellist.keep_numbers Persistent channel numbers +channellist.history_clear Clear History +channellist.keep_numbers Persistent Channel Numbers channellist.make_hdlist Create list of HD channels channellist.make_newlist Create list of new channels channellist.make_removedlist Create list of removed channels channellist.make_webtvlist Create list of WebTV channels -channellist.new_zap_mode Quickzap in list -channellist.new_zap_mode_active active -channellist.new_zap_mode_allow allow -channellist.new_zap_mode_off off +channellist.new_zap_mode Quickzap in List +channellist.new_zap_mode_active Active +channellist.new_zap_mode_allow Allow +channellist.new_zap_mode_off Off channellist.nonefound No channels were found!\nPlease execute a scan\n(MENU-key -> service) -channellist.numeric_adjust Numeric zap adjust +channellist.numeric_adjust Numeric Zap Adjust channellist.provs Providers channellist.recording_not_possible Recording not possible! channellist.remember Last used channellist.reset_all Reset 'new' flag for all channels channellist.reset_flags Reset 'new' channel flag channellist.sats Satellites -channellist.show_channellogo Show channel logos -channellist.show_channelnumber Show channel numbers -channellist.show_empty_favs Show empty favorites bouquets -channellist.show_infobox Show bottom infobox -channellist.since since -channellist.start starts +channellist.show_channellogo Show Channel Logos +channellist.show_channelnumber Show Channel Numbers +channellist.show_empty_favs Show empty Favorites Bouquets +channellist.show_infobox Show Bottom Infobox +channellist.since Since +channellist.start Starts ci.clock CI clock (Mhz) ci.empty No CAM in slot ci.ignore_msg Ignore CA messages @@ -322,10 +322,10 @@ colormenu.clock_textcolor Digit color colormenu.fade Fade GUI colormenu.font Select GUI font colormenu.font_ttx Select Teletext font -colormenu.hd_preset LCD colormenu.menucolors Colors colormenu.osd_preset TV preset -colormenu.sd_preset CRT +colormenu.osd_resolution OSD resolution +colormenu.shadow_color Shadow Color colormenu.textcolor Text color colormenu.themeselect Select theme colormenu.timing Timeouts @@ -593,11 +593,11 @@ filebrowser.prevpage Prev. Page filebrowser.scan Scaning folder filebrowser.select Select filebrowser.showrights Show file rights -filebrowser.sort.date (date) -filebrowser.sort.name (name) -filebrowser.sort.namedirsfirst (name, dir first) -filebrowser.sort.size (Size) -filebrowser.sort.type (type) +filebrowser.sort.date Date +filebrowser.sort.name Name +filebrowser.sort.namedirsfirst Name, dirs first +filebrowser.sort.size Size +filebrowser.sort.type Type filesystem.is.utf8 file system filesystem.is.utf8.option.iso8859.1 ISO-8859-1 filesystem.is.utf8.option.utf8 UTF-8 @@ -885,9 +885,9 @@ languagesetup.select OSD Language lcd_info_line show in infoline lcd_info_line_channel Channelname lcd_info_line_clock clock -lcdcontroler.brightness normal Brightness -lcdcontroler.brightnessdeepstandby DeepStandby Brightness -lcdcontroler.brightnessstandby Standby Brightness +lcdcontroler.brightness Normal mode +lcdcontroler.brightnessdeepstandby Deep standby +lcdcontroler.brightnessstandby Standby lcdmenu.dim_brightness Brightness after dim timeout lcdmenu.dim_time Dim timeout lcdmenu.head VFD/LED Settings @@ -1037,6 +1037,7 @@ menu.hint_color_gradient_separator_enable Disable/enable color gradient for menu menu.hint_colored_events Use different color for current or next event menu.hint_colored_events_textcolor Change color for colored events in channellist and infobar menu.hint_colors Configure GUI colors +menu.hint_colors_shadow Setup for shadow color. menu.hint_content_back Change GUI window background color menu.hint_content_textcolor Change GUI window text color menu.hint_dboxinfo Information about box cpu and storage @@ -1172,7 +1173,7 @@ menu.hint_key_volumedown Assign button to decrease volume menu.hint_key_volumeup Assign button to increase volume menu.hint_keys Remote control repeat rate\nEdit key bindings menu.hint_lang_pref Configure preferred audio, EPG\nand subtitle languages -menu.hint_language OSD language, timezone\nPreffered audio and subtitles languages +menu.hint_language OSD language, timezone\nPrefered audio and subtitles languages menu.hint_last_radio Start box on selected channel\nif last mode is Radio menu.hint_last_tv Start box on selected channel\nif last mode is TV menu.hint_last_use Start box on last used channel @@ -1254,6 +1255,7 @@ menu.hint_opkg_upgrade Updates all installed packages to the most recent version menu.hint_osd Colors, fonts, screen size\nGUI look and feel options menu.hint_osd_language Select OSD language menu.hint_osd_preset Pre-configured screen margins for CRT and LCD TV +menu.hint_osd_resolution Change OSD resolution menu.hint_osd_timing After this time the OSD will be faded out menu.hint_other_fonts Change other font sizes menu.hint_parentallock_changepin Change PIN code @@ -1669,6 +1671,7 @@ moviebrowser.cut_failed Cut failed, are there jump bookmarks and enough free spa moviebrowser.cutting Cutting movie, please wait ... moviebrowser.delete_all Delete all selected movies without any questions? moviebrowser.delete_info Delete files, please wait ... +moviebrowser.delete_movie Delete movie moviebrowser.delete_screenshot Delete screenshot? moviebrowser.dir Path moviebrowser.directories Directories @@ -2021,14 +2024,14 @@ personalize.usermenu_plugin_types Choose Plugin types to show personalize.usermenu_preferred_buttons Assigning of preferred keys personalize.usermenu_show_cancel Show "Cancel"-Button personalize.visible Visible -pictureviewer.defdir start dir. +pictureviewer.defdir Start directory pictureviewer.head Picture viewer pictureviewer.help1 menu mode pictureviewer.help10 reread image pictureviewer.help11 previous image pictureviewer.help12 next image -pictureviewer.help13 Zoom out -pictureviewer.help14 Zoom in +pictureviewer.help13 zoom out +pictureviewer.help14 zoom in pictureviewer.help15 scroll up pictureviewer.help16 scroll left pictureviewer.help17 scroll right @@ -2051,12 +2054,12 @@ pictureviewer.help9 show mode pictureviewer.resize.color_average advanced pictureviewer.resize.none none pictureviewer.resize.simple simple -pictureviewer.scaling scaling -pictureviewer.show show -pictureviewer.slide_time slideshow display time -pictureviewer.slideshow slideshow -pictureviewer.sortorder.date change sort order (date) -pictureviewer.sortorder.filename change sort order (filename) +pictureviewer.scaling Scaling +pictureviewer.show Show +pictureviewer.slide_time Slideshow display time +pictureviewer.slideshow Slideshow +pictureviewer.sortorder.date Sort order: Date +pictureviewer.sortorder.filename Sort order: Filename ping.ok is reachable (ping) ping.protocol is unreachable (host or protocol error) ping.socket is unreachable (socket error) @@ -2320,9 +2323,11 @@ streaminfo.framerate Framerate streaminfo.framerate_unknown unknown streaminfo.head Stream-Information streaminfo.not_available not available +streaminfo.osd_resolution OSD resolution streaminfo.resolution Resolution streaminfo.signal Receipt signal -streaming.busy One or several recording processes are active.\nIf you encounter this message and no recording is active, please restart Neutrino. +streaminfo.videosystem Videosystem +streaming.busy One or several recording processes are active.\nIf you encounter this message and no recording is active, please restart GUI. streaming.dir_not_writable The recording directory is not writable.\nRecording will not work. streaming.overflow Record buffer overflow, consider to stop some records streaming.slow System/hdd too slow, consider to stop some records diff --git a/lib/hardware/coolstream/hardware_caps.cpp b/lib/hardware/coolstream/hardware_caps.cpp index 592202285..1bd491123 100644 --- a/lib/hardware/coolstream/hardware_caps.cpp +++ b/lib/hardware/coolstream/hardware_caps.cpp @@ -19,7 +19,7 @@ hw_caps_t *get_hwcaps(void) { return ∩︀ int rev = cs_get_revision(); int chip = cs_get_chip_type(); - caps.has_fan = (rev < 8); + caps.has_fan = (rev < 8); // see dirty part of hw_caps in neutrino.cpp caps.has_HDMI = 1; caps.has_SCART = (rev != 10); caps.has_SCART_input = 0; @@ -41,8 +41,9 @@ hw_caps_t *get_hwcaps(void) { strcpy(caps.boxname, "HD1"); caps.force_tuner_2G = 1; break; - case 8: // TODO: Neo2 - Twin - strcpy(caps.boxname, "Neo"); + case 8: + strcpy(caps.boxname, "Neo"); // see dirty part of hw_caps in neutrino.cpp + strcpy(caps.boxarch, "Nevis"); caps.force_tuner_2G = 1; break; case 9: @@ -64,6 +65,7 @@ hw_caps_t *get_hwcaps(void) { strcpy(caps.boxname, "Trinity V2"); strcpy(caps.boxarch, "Kronos"); } + caps.can_set_display_brightness = 0; break; case 12: strcpy(caps.boxname, "Zee2"); @@ -76,6 +78,7 @@ hw_caps_t *get_hwcaps(void) { case 14: strcpy(caps.boxname, "Trinity Duo"); strcpy(caps.boxarch, "Kronos"); + caps.can_set_display_brightness = 0; break; default: strcpy(caps.boxname, "UNKNOWN_BOX"); diff --git a/lib/libmd5sum/md5.c b/lib/libmd5sum/md5.c index e433782e8..aece50d10 100644 --- a/lib/libmd5sum/md5.c +++ b/lib/libmd5sum/md5.c @@ -132,7 +132,7 @@ md5_stream (stream, resblock) /* Important: BLOCKSIZE must be a multiple of 64. */ #define BLOCKSIZE 4096 struct md5_ctx ctx; - char buffer[BLOCKSIZE + 72]; + char buffer[BLOCKSIZE + 72] = {0}; size_t sum; /* Initialize the computation context. */ diff --git a/lib/libtuxtxt/Makefile.am b/lib/libtuxtxt/Makefile.am index f3dc7d972..537cb307c 100644 --- a/lib/libtuxtxt/Makefile.am +++ b/lib/libtuxtxt/Makefile.am @@ -5,7 +5,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/libconfigfile \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/zapit/include \ - $(FREETYPE_CFLAGS) \ + @FREETYPE_CFLAGS@ \ @SIGC_CFLAGS@ \ @HWLIB_CFLAGS@ diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 4fec1c501..102efd4c1 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -47,6 +47,9 @@ static int cfg_national_subset; static int screen_x, screen_y, screen_w, screen_h; +void FillRect(int x, int y, int w, int h, fb_pixel_t color, bool modeFullColor=false); +void FillBorder(fb_pixel_t color, bool modeFullColor=false); + fb_pixel_t *getFBp(int *y) { if (*y < (int)var_screeninfo.yres) @@ -56,30 +59,31 @@ fb_pixel_t *getFBp(int *y) return lbb; } -void FillRect(int x, int y, int w, int h, int color) +void FillRect(int x, int y, int w, int h, fb_pixel_t color, bool modeFullColor/*=false*/) { fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); p += x + y * stride; - if (w > 0) + if (w > 0) { + fb_pixel_t col = (modeFullColor) ? color : bgra[color]; for (int count = 0; count < h; count++) { fb_pixel_t *dest0 = p; for (int i = 0; i < w; i++) - *(dest0++) = bgra[color]; + *(dest0++) = col; p += stride; } + } } - -void FillBorder(int color) +void FillBorder(fb_pixel_t color, bool modeFullColor/*=false*/) { int ys = (var_screeninfo.yres-var_screeninfo.yoffset); - FillRect(0 , ys ,StartX ,var_screeninfo.yres ,color); - FillRect(StartX, ys ,displaywidth,StartY ,color); - FillRect(StartX, ys+StartY+25*fontheight,displaywidth,var_screeninfo.yres-(StartY+25*fontheight),color); + FillRect(0 , ys ,StartX ,var_screeninfo.yres ,color, modeFullColor); + FillRect(StartX, ys ,displaywidth,StartY ,color, modeFullColor); + FillRect(StartX, ys+StartY+25*fontheight,displaywidth,var_screeninfo.yres-(StartY+25*fontheight),color, modeFullColor); if (screenmode == 0 ) - FillRect(StartX+displaywidth, ys,var_screeninfo.xres-(StartX+displaywidth),var_screeninfo.yres ,color); + FillRect(StartX+displaywidth, ys,var_screeninfo.xres-(StartX+displaywidth),var_screeninfo.yres ,color, modeFullColor); } int getIndexOfPageInHotlist() @@ -254,7 +258,7 @@ void RenderClearMenuLineBB(char *p, tstPageAttr *attrcol, tstPageAttr *attr) memset(p-TOPMENUCHARS, ' ', TOPMENUCHARS); /* init with spaces */ } -void ClearBB(int color) +void ClearBB(fb_pixel_t color) { FillRect(0, (var_screeninfo.yres - var_screeninfo.yoffset), var_screeninfo.xres, var_screeninfo.yres, color); } @@ -266,7 +270,7 @@ void ClearFB(int /*color*/) } #if 0 //never used -void ClearB(int color) +void ClearB(fb_pixel_t color) { FillRect(0, 0, var_screeninfo.xres, var_screeninfo.yres, color); /* framebuffer */ FillRect(0, var_screeninfo.yres, var_screeninfo.xres, var_screeninfo.yres, color); /* backbuffer */ @@ -837,7 +841,7 @@ int eval_triplet(int iOData, tstCachedPage *pstCachedPage, { *pAPy = RowAddress2Row(iAddress); /* new Active Row */ - int color = iData & 0x1f; + fb_pixel_t color = iData & 0x1f; int row = *pAPy0 + *pAPy; int maxrow; #if TUXTXT_DEBUG @@ -888,7 +892,7 @@ int eval_triplet(int iOData, tstCachedPage *pstCachedPage, *pAPx = *pAPy = 0; /* new Active Position 0,0 */ if (*endcol == 40) /* active object */ { - int color = iData & 0x1f; + fb_pixel_t color = iData & 0x1f; int row = *pAPy0; // + *pAPy; int maxrow; @@ -4092,7 +4096,7 @@ void RenderDRCS( //FIX ME } -void DrawVLine(int x, int y, int l, int color) +void DrawVLine(int x, int y, int l, fb_pixel_t color) { fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, 0, l); @@ -4105,7 +4109,7 @@ void DrawVLine(int x, int y, int l, int color) } } -void DrawHLine(int x, int y, int l, int color) +void DrawHLine(int x, int y, int l, fb_pixel_t color) { int ltmp; fb_pixel_t *p = getFBp(&y); @@ -4126,7 +4130,7 @@ void FillRectMosaicSeparated(int x, int y, int w, int h, int fgcolor, int bgcolo } } -void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, int color) +void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, fb_pixel_t color) { fb_pixel_t *p = getFBp(&y0); MARK_FB(x0, y0, l0, h); @@ -4785,7 +4789,7 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { for (Bit = 0x80; Bit; Bit >>= 1) { - int color; + fb_pixel_t color; if (--pixtodo < 0) break; @@ -5234,7 +5238,7 @@ void RenderPage() { page_atrb[32].fg = yellow; page_atrb[32].bg = menu1; - int showpage = tuxtxt_cache.page_receiving; + int showpage = tuxtxt_cache.page_receiving < 0 ? 0 : tuxtxt_cache.page_receiving; int showsubpage = tuxtxt_cache.subpagetable[showpage]; if (showsubpage!=0xff) { @@ -5524,7 +5528,7 @@ void CopyBB2FB() { fb_pixel_t *src, *dst, *topsrc; int fillcolor, i, screenwidth, swtmp; -#if defined(HAVE_SPARK_HARDWARE) || defined(BOXMODEL_CS_HD2) +#if defined(HAVE_SPARK_HARDWARE) || defined(HAVE_COOL_HARDWARE) CFrameBuffer *f = CFrameBuffer::getInstance(); #endif @@ -5537,15 +5541,25 @@ void CopyBB2FB() { #ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, 0, true); -#elif defined BOXMODEL_CS_HD2 +#elif defined(HAVE_COOL_HARDWARE) f->fbCopyArea(var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, var_screeninfo.yres); #else - memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); + if ((uint32_t)stride > var_screeninfo.xres) { + fb_pixel_t *lfb_ = lfb; + fb_pixel_t *lbb_ = lbb; + for (uint32_t i1 = 0; i1 < var_screeninfo.yres; i1++) { + memcpy(lfb_, lbb_, var_screeninfo.xres * sizeof(fb_pixel_t)); + lfb_ += stride; + lbb_ += stride; + } + } + else + memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); #endif /* adapt background of backbuffer if changed */ if (StartX > 0 && *lfb != *lbb) { - FillBorder(*lbb); + FillBorder(*lbb, true); // ClearBB(*(lfb + var_screeninfo.xres * var_screeninfo.yoffset)); } @@ -5576,7 +5590,7 @@ void CopyBB2FB() if (screenmode == 1) { screenwidth = ( TV43STARTX ); -#if defined(HAVE_SPARK_HARDWARE) || defined(BOXMODEL_CS_HD2) +#if defined(HAVE_SPARK_HARDWARE) int cx = var_screeninfo.xres - TV43STARTX; /* x start */ int cw = TV43STARTX; /* width */ int cy = StartY; @@ -5584,8 +5598,6 @@ void CopyBB2FB() #endif #ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, cw, ch, cx, cy, cx, cy, true); -#elif defined BOXMODEL_CS_HD2 - f->fbCopyArea(cw, ch, cx, cy, cx, cy+var_screeninfo.yres); #else fb_pixel_t *topdst = dst; size_t width = (ex - screenwidth) * sizeof(fb_pixel_t); diff --git a/lib/libtuxtxt/tuxtxt_common.h b/lib/libtuxtxt/tuxtxt_common.h index 52f9d419e..c6e6c7bd8 100644 --- a/lib/libtuxtxt/tuxtxt_common.h +++ b/lib/libtuxtxt/tuxtxt_common.h @@ -704,8 +704,9 @@ void *tuxtxt_CacheThread(void * /*arg*/) tuxtxt_cache.current_subpage[magazine] = -1; continue; } - +#if 0 /* ? */ b1 &= 3; +#endif b3 &= 7; if (tuxtxt_is_dec(tuxtxt_cache.page_receiving)) /* ignore other subpage bits for hex pages */ diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index adbef6c4b..a19c4fadb 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -47,6 +47,8 @@ libneutrino_driver_a_SOURCES = \ volume.cpp if BOXTYPE_COOL +libneutrino_driver_a_SOURCES += \ + fb_accel_cs_hdx.cpp if BOXMODEL_CS_HD2 libneutrino_driver_a_SOURCES += \ fb_accel_cs_hd2.cpp \ diff --git a/src/driver/audiodec/ffmpegdec.cpp b/src/driver/audiodec/ffmpegdec.cpp index b85592897..02ccdb412 100644 --- a/src/driver/audiodec/ffmpegdec.cpp +++ b/src/driver/audiodec/ffmpegdec.cpp @@ -33,15 +33,19 @@ #include #include #include + +#include #include #include #include // UTF8 #include "ffmpegdec.h" + extern "C" { #include #include #include } + #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1) #define av_frame_alloc avcodec_alloc_frame #define av_frame_unref avcodec_get_frame_defaults @@ -63,8 +67,6 @@ extern cAudio * audioDecoder; #define ProgName "FfmpegDec" -#define COVERDIR "/tmp/cover" - static OpenThreads::Mutex mutex; static int cover_count = 0; @@ -223,7 +225,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state, Status=DATA_ERR; return Status; } -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext *c = avc->streams[best_stream]->codec; #else AVCodecContext *c = avcodec_alloc_context3(codec); @@ -456,7 +458,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover) if (!is_stream) { GetMeta(avc->metadata); for(unsigned int i = 0; i < avc->nb_streams; i++) { -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) if (avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) #else if (avc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) @@ -477,7 +479,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover) DeInit(); return false; } -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) if (!codec) codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id); samplerate = avc->streams[best_stream]->codec->sample_rate; @@ -507,7 +509,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover) printf("CFfmpegDec: format %s (%s) duration %ld\n", avc->iformat->name, type_info.c_str(), total_time); for(unsigned int i = 0; i < avc->nb_streams; i++) { -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) if (avc->streams[i]->codec->bit_rate > 0) bitrate += avc->streams[i]->codec->bit_rate; #else @@ -517,7 +519,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover) if (save_cover && (avc->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)) { mkdir(COVERDIR, 0755); std::string cover(COVERDIR); - cover += "/" + to_string(cover_count++) + ".jpg"; + cover += "/cover_" + to_string(cover_count++) + ".jpg"; FILE *f = fopen(cover.c_str(), "wb"); if (f) { AVPacket *pkt = &avc->streams[i]->attached_pic; diff --git a/src/driver/audiodec/mp3dec.cpp b/src/driver/audiodec/mp3dec.cpp index dc921f788..789f5f0cd 100644 --- a/src/driver/audiodec/mp3dec.cpp +++ b/src/driver/audiodec/mp3dec.cpp @@ -1389,9 +1389,10 @@ bool CMP3Dec::SaveCover(FILE * in, CAudioMetaData * const m) data = id3_field_getbinarydata(field, &size); if ( data ) { + mkdir(COVERDIR, 0755); std::ostringstream cover; - cover.str(""); - cover << "/tmp/cover_" << cover_count++ << ".jpg"; + cover.str(COVERDIR); + cover << "/cover_" << cover_count++ << ".jpg"; FILE * pFile; pFile = fopen ( cover.str().c_str() , "wb" ); if (pFile) diff --git a/src/driver/audiometadata.cpp b/src/driver/audiometadata.cpp index 7dbe1bd08..8d48a0f10 100644 --- a/src/driver/audiometadata.cpp +++ b/src/driver/audiometadata.cpp @@ -64,6 +64,7 @@ CAudioMetaData::CAudioMetaData( const CAudioMetaData& src ) hasInfoOrXingTag( src.hasInfoOrXingTag ), artist( src.artist ), title( src.title ), album( src.album ), sc_station( src.sc_station ), date( src.date ), genre( src.genre ), track( src.track ),cover(src.cover), + logo( src.logo ), url( src.url ), cover_temporary( false ), changed( src.changed ) { @@ -97,9 +98,10 @@ void CAudioMetaData::operator=( const CAudioMetaData& src ) genre = src.genre; track = src.track; cover = src.cover; + logo = src.logo; + url = src.url; sc_station = src.sc_station; changed = src.changed; - changed = src.changed; cover_temporary = false; } @@ -125,6 +127,8 @@ void CAudioMetaData::clear() if (cover_temporary && !cover.empty()) unlink(cover.c_str()); cover.clear(); + logo.clear(); + url.clear(); cover_temporary=false; changed=false; } diff --git a/src/driver/audiometadata.h b/src/driver/audiometadata.h index 3f25fd79e..5220b0877 100644 --- a/src/driver/audiometadata.h +++ b/src/driver/audiometadata.h @@ -96,6 +96,8 @@ public: std::string genre; std::string track; std::string cover; + std::string logo; + std::string url; bool cover_temporary; bool changed; }; diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 72bca8aa5..6343056f9 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -78,17 +78,41 @@ class CFbAccelSTi void setBlendLevel(int); }; -class CFbAccelCSHD1 +class CFbAccelCSHDx : public CFbAccel { private: + + protected: + OpenThreads::Mutex mutex; + + int fbCopy(uint32_t *mem_p, int width, int height, int dst_x, int dst_y, int src_x, int src_y, int mode); + int fbFill(int sx, int sy, int width, int height, fb_pixel_t color, int mode=0); + + public: + CFbAccelCSHDx(); +// ~CFbAccelCSHDx(); + +#if 0 + /* TODO: Run this functions with hardware acceleration */ + void SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp); + void RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp); + void Clear(); +#endif +}; + +class CFbAccelCSHD1 + : public CFbAccelCSHDx +{ + private: fb_pixel_t lastcol; + fb_pixel_t *backbuffer; int devmem_fd; /* to access the GXA register we use /dev/mem */ unsigned int smem_start; /* as aquired from the fbdev, the framebuffers physical start address */ volatile uint8_t *gxa_base; /* base address for the GXA's register access */ + void setColor(fb_pixel_t col); - void run(void); - fb_pixel_t *backbuffer; + public: CFbAccelCSHD1(); ~CFbAccelCSHD1(); @@ -109,13 +133,16 @@ class CFbAccelCSHD1 void setBlendLevel(int); void add_gxa_sync_marker(void); void setupGXA(void); + void setOsdResolutions(); }; class CFbAccelCSHD2 - : public CFbAccel + : public CFbAccelCSHDx { private: fb_pixel_t *backbuffer; + int sysRev; + bool IsApollo; public: CFbAccelCSHD2(); @@ -130,6 +157,9 @@ class CFbAccelCSHD2 fb_pixel_t * getBackBufferPointer() const; void setBlendMode(uint8_t); void setBlendLevel(int); + int scale2Res(int size); + bool fullHdAvailable(); + void setOsdResolutions(); uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); bool needAlign4Blit() { return true; }; }; diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index 2672dfd58..2b6b0e0dd 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -264,13 +264,21 @@ void CFbAccelCSHD1::paintBoxRel(const int x, const int y, const int dx, const in void CFbAccelCSHD1::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y) { + if ((width == 0) || (height == 0)) + return; + uint32_t w_, h_; w_ = (width > xRes) ? xRes : width; h_ = (height > yRes) ? yRes : height; - //printf("\033[33m>>>>\033[0m [CFbAccelCSHD1::%s:%d] fb_copyarea w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); - printf("\033[31m>>>>\033[0m [CFbAccelCSHD1::%s:%d] sw blit w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); - CFrameBuffer::fbCopyArea(width, height, dst_x, dst_y, src_x, src_y); + int mode = CS_FBCOPY_FB2FB; + uint32_t src_y_ = src_y; + if (src_y >= yRes) { + mode = CS_FBCOPY_BB2FB; + src_y_ -= yRes; + } + fbCopy(NULL, w_, h_, dst_x, dst_y, src_x, src_y_, mode); +// printf("\033[31m>>>>\033[0m%s hw blit w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func_ext__, w_, h_, dst_x, dst_y, src_x, src_y); } void CFbAccelCSHD1::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) @@ -336,9 +344,26 @@ void CFbAccelCSHD1::setupGXA() add_gxa_sync_marker(); } -/* wrong name... */ +void CFbAccelCSHD1::setOsdResolutions() +{ + /* FIXME: Infos available in driver? */ + osd_resolution_t res; + osd_resolutions.clear(); + res.xRes = 1280; + res.yRes = 720; + res.bpp = 32; + res.mode = OSDMODE_720; + osd_resolutions.push_back(res); +} + int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) { + if (!available&&!active) + return -1; + + if (osd_resolutions.empty()) + setOsdResolutions(); + fb_fix_screeninfo _fix; if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { @@ -353,6 +378,10 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; printf(LOGTAG "%dx%dx%d line length %d. using %s graphics accelerator.\n", xRes, yRes, bpp, stride, _fix.id); + + if (videoDecoder != NULL) + videoDecoder->updateOsdScreenInfo(); + int needmem = stride * yRes * 2; if (available >= needmem) { diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index ce20ce051..cfafaf4bf 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -28,7 +28,9 @@ CFbAccelCSHD2::CFbAccelCSHD2() { - fb_name = "Coolstream HD2 framebuffer"; + fb_name = "Coolstream HD2 framebuffer"; + IsApollo = false; + sysRev = -1; } /* @@ -143,11 +145,22 @@ void CFbAccelCSHD2::paintBoxRel(const int x, const int y, const int dx, const in void CFbAccelCSHD2::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, uint32_t dst_y, uint32_t src_x, uint32_t src_y) { + if ((width == 0) || (height == 0)) + return; + uint32_t w_, h_; w_ = (width > xRes) ? xRes : width; h_ = (height > yRes) ? yRes : height; - if(!(w_%4)) { + if (sysRev < 0) { + sysRev = cs_get_revision(); + IsApollo = (sysRev == 9); + } + + if(!(w_ % 4) && !IsApollo) { + /* workaround for bad fb driver */ + w_ -= 1; + h_ -= 1; fb_copyarea area; area.dx = dst_x; area.dy = dst_y; @@ -156,11 +169,18 @@ void CFbAccelCSHD2::fbCopyArea(uint32_t width, uint32_t height, uint32_t dst_x, area.sx = src_x; area.sy = src_y; ioctl(fd, FBIO_COPY_AREA, &area); - //printf("\033[33m>>>>\033[0m [CFbAccelCSHD2::%s:%d] fb_copyarea w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); - return; +// printf("\033[33m>>>>\033[0m%s fb_copyarea w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func_ext__, w_, h_, dst_x, dst_y, src_x, src_y); + } + else { + int mode = CS_FBCOPY_FB2FB; + uint32_t src_y_ = src_y; + if (src_y >= yRes) { + mode = CS_FBCOPY_BB2FB; + src_y_ -= yRes; + } + fbCopy(NULL, w_, h_, dst_x, dst_y, src_x, src_y_, mode); +// printf("\033[31m>>>>\033[0m%s fbCopy w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func_ext__, w_, h_, dst_x, dst_y, src_x, src_y); } - //printf("\033[31m>>>>\033[0m [CFbAccelCSHD2::%s:%d] sw blit w: %d, h: %d, dst_x: %d, dst_y: %d, src_x: %d, src_y: %d\n", __func__, __LINE__, w_, h_, dst_x, dst_y, src_x, src_y); - CFrameBuffer::fbCopyArea(width, height, dst_x, dst_y, src_x, src_y); } void CFbAccelCSHD2::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) @@ -207,22 +227,91 @@ void CFbAccelCSHD2::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_ CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); } -int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) +void CFbAccelCSHD2::setOsdResolutions() { + /* FIXME: Infos available in driver? */ + osd_resolution_t res; + osd_resolutions.clear(); + res.xRes = 1280; + res.yRes = 720; + res.bpp = 32; + res.mode = OSDMODE_720; + osd_resolutions.push_back(res); + if (fullHdAvailable()) { + res.xRes = 1920; + res.yRes = 1080; + res.bpp = 32; + res.mode = OSDMODE_1080; + osd_resolutions.push_back(res); + } +} + +int CFbAccelCSHD2::setMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp) +{ + if (!available&&!active) + return -1; + + if (osd_resolutions.empty()) + setOsdResolutions(); + + unsigned int nxRes_ = nxRes; + unsigned int nyRes_ = nyRes; + unsigned int nbpp_ = nbpp; + if (!fullHdAvailable()) { + nxRes_ = 1280; + nyRes_ = 720; + nbpp_ = 32; + } + screeninfo.xres=nxRes_; + screeninfo.yres=nyRes_; + screeninfo.xres_virtual=nxRes_; + screeninfo.yres_virtual=nyRes_*2; + screeninfo.height=0; + screeninfo.width=0; + screeninfo.xoffset=screeninfo.yoffset=0; + screeninfo.bits_per_pixel=nbpp_; + + if (ioctl(fd, FBIOPUT_VSCREENINFO, &screeninfo)<0) + perror(LOGTAG "FBIOPUT_VSCREENINFO"); + + printf(LOGTAG "SetMode: %dbits, red %d:%d green %d:%d blue %d:%d transp %d:%d\n", + screeninfo.bits_per_pixel, screeninfo.red.length, screeninfo.red.offset, screeninfo.green.length, screeninfo.green.offset, screeninfo.blue.length, screeninfo.blue.offset, screeninfo.transp.length, screeninfo.transp.offset); + if ((screeninfo.xres != nxRes_) || + (screeninfo.yres != nyRes_) || + (screeninfo.bits_per_pixel != nbpp_)) { + printf(LOGTAG "SetMode failed: wanted: %dx%dx%d, got %dx%dx%d\n", + nxRes_, nyRes_, nbpp_, + screeninfo.xres, screeninfo.yres, screeninfo.bits_per_pixel); + return -1; + } + fb_fix_screeninfo _fix; if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { - perror("FBIOGET_FSCREENINFO"); + perror(LOGTAG "FBIOGET_FSCREENINFO"); return -1; } stride = _fix.line_length; swidth = stride / sizeof(fb_pixel_t); if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) - printf("screen unblanking failed\n"); + printf(LOGTAG "screen unblanking failed\n"); xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; - printf(LOGTAG "%dx%dx%d line length %d. using hd2 graphics accelerator.\n", xRes, yRes, bpp, stride); + printf(LOGTAG "%dx%dx%d line length %d. using %s graphics accelerator.\n", xRes, yRes, bpp, stride, _fix.id); + +/* +max res 1280x720 + available 14745600 + stride 5120 +max res 1920x1080 + available 16588800 + stride 7680 +*/ + + if (videoDecoder != NULL) + videoDecoder->updateOsdScreenInfo(); + int needmem = stride * yRes * 2; if (available >= needmem) { @@ -260,6 +349,30 @@ void CFbAccelCSHD2::setBlendLevel(int level) usleep(20000); } +int CFbAccelCSHD2::scale2Res(int size) +{ + /* + The historic resolution 1280x720 is default for some values/sizes. + So let's scale these values to other resolutions. + */ + +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + if (screeninfo.xres == 1920) + size += size/2; +#endif + + return size; +} + +bool CFbAccelCSHD2::fullHdAvailable() +{ +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + if (available >= 16588800) /* new fb driver with maxres 1920x1080(*8) */ + return true; +#endif + return false; +} + /* align for hw blit */ uint32_t CFbAccelCSHD2::getWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max) { diff --git a/src/driver/fb_accel_cs_hdx.cpp b/src/driver/fb_accel_cs_hdx.cpp new file mode 100644 index 000000000..3ab238f35 --- /dev/null +++ b/src/driver/fb_accel_cs_hdx.cpp @@ -0,0 +1,122 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The common functions for coolstream hd1/hd2 graphic chips + are represented in this class. + + (C) 2017 M. Liebmann + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "fb_accel_cs_hdx_inc.h" + +#define LOGTAG "[fb_accel_cs_hdx] " + +CFbAccelCSHDx::CFbAccelCSHDx() +{ + fb_name = "CST HDx framebuffer"; +} + +/* +CFbAccelCSHDx::~CFbAccelCSHDx() +{ +} +*/ + +int CFbAccelCSHDx::fbCopy(uint32_t *mem_p, int width, int height, + int dst_x, int dst_y, int src_x, int src_y, int mode) +{ + if (videoDecoder == NULL) { + if (dst_y < (int)yRes) { + uint32_t src_y_ = src_y; + if (mode == CS_FBCOPY_BB2FB) + src_y_ += yRes; + CFrameBuffer::fbCopyArea(width, height, dst_x, dst_y, src_x, src_y_); + return 0; + } + return -1; + } + + mutex.lock(); + setActive(false); + int ret = videoDecoder->fbCopy(mem_p, width, height, dst_x, dst_y, src_x, src_y, mode); + add_gxa_sync_marker(); + setActive(true); + mutex.unlock(); + return ret; +} + +int CFbAccelCSHDx::fbFill(int sx, int sy, int width, int height, fb_pixel_t color, int mode/*=0*/) +{ + if (videoDecoder == NULL) { + CFbAccel::paintRect(sx, sy, width, height, color); + return 0; + } + + mutex.lock(); + setActive(false); + int ret = videoDecoder->fbFill(sx, sy, width, height, color, mode); + add_gxa_sync_marker(); + setActive(true); + mutex.unlock(); + return ret; +} + +#if 0 +/* TODO: Run this functions with hardware acceleration */ +void CFbAccelCSHDx::SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) +{ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + fb_pixel_t * pos = getFrameBufferPointer() + x + swidth * y; + fb_pixel_t * bkpos = memp; + for (int count = 0; count < dy; count++) { + fb_pixel_t * dest = (fb_pixel_t *)pos; + for (int i = 0; i < dx; i++) + *(bkpos++) = *(dest++); + pos += swidth; + } + checkFbArea(x, y, dx, dy, false); +printf("%s\n", __func_ext__); +} + +void CFbAccelCSHDx::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) +{ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + fb_pixel_t * fbpos = getFrameBufferPointer() + x + swidth * y; + fb_pixel_t * bkpos = memp; + for (int count = 0; count < dy; count++) + { + memmove(fbpos, bkpos, dx * sizeof(fb_pixel_t)); + fbpos += swidth; + bkpos += dx; + } + mark(x, y, x + dx, y + dy); + checkFbArea(x, y, dx, dy, false); +printf("%s\n", __func_ext__); +} + +void CFbAccelCSHDx::Clear() +{ + paintBackground(); +printf("%s\n", __func_ext__); +} +#endif diff --git a/src/driver/fb_accel_cs_hdx_inc.h b/src/driver/fb_accel_cs_hdx_inc.h index cd38baa72..5f98cd34b 100644 --- a/src/driver/fb_accel_cs_hdx_inc.h +++ b/src/driver/fb_accel_cs_hdx_inc.h @@ -1,6 +1,6 @@ /* Framebuffer acceleration hardware abstraction functions. - The hardware dependent acceleration functions for coolstream hdx graphic chips + The common functions for coolstream hd1/hd2 graphic chips are represented in this class. (C) 2017 M. Liebmann @@ -23,6 +23,8 @@ along with this program. If not, see . */ +#ifndef FB_ACCEL_CS_HDX_INC_H +#define FB_ACCEL_CS_HDX_INC_H #include #include @@ -31,8 +33,16 @@ #include #include #include -#include -#include +#include +#include +#include +#include #include +#include +#include #include + +extern cVideo * videoDecoder; + +#endif // FB_ACCEL_CS_HDX_INC_H diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 6d470ade6..ad9f77d34 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -206,16 +207,9 @@ nolfb: lbb = lfb = NULL; } - CFrameBuffer::~CFrameBuffer() { - std::map::iterator it; - - for(it = icon_cache.begin(); it != icon_cache.end(); ++it) { - /* printf("FB: delete cached icon %s: %x\n", it->first.c_str(), (int) it->second.data); */ - cs_free_uncached(it->second.data); - } - icon_cache.clear(); + clearIconCache(); if (background) { delete[] background; @@ -350,8 +344,34 @@ int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsign if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) { printf("screen unblanking failed\n"); } + return 0; } + +void CFrameBuffer::setOsdResolutions() +{ + /* FIXME: Infos available in driver? */ + osd_resolution_t res; + osd_resolutions.clear(); + res.xRes = 1280; + res.yRes = 720; + res.bpp = 32; + res.mode = OSDMODE_720; + osd_resolutions.push_back(res); +} + +size_t CFrameBuffer::getIndexOsdResolution(uint32_t mode) +{ + if (osd_resolutions.size() == 1) + return 0; + + for (size_t i = 0; i < osd_resolutions.size(); i++) { + if (osd_resolutions[i].mode == mode) + return i; + } + return 0; +} + #if 0 //never used void CFrameBuffer::setTransparency( int /*tr*/ ) @@ -894,6 +914,17 @@ _display: return true; } +void CFrameBuffer::clearIconCache() +{ + std::map::iterator it; + + for(it = icon_cache.begin(); it != icon_cache.end(); ++it) { + /* printf("FB: delete cached icon %s: %x\n", it->first.c_str(), (int) it->second.data); */ + cs_free_uncached(it->second.data); + } + icon_cache.clear(); +} + void CFrameBuffer::loadPal(const std::string & filename, const unsigned char offset, const unsigned char endidx) { if (!getActive()) diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index c3b9a6f4c..4b68e1e18 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -39,6 +39,14 @@ typedef struct fb_var_screeninfo t_fb_var_screeninfo; +typedef struct osd_resolution_t +{ + uint32_t yRes; + uint32_t xRes; + uint32_t bpp; + uint32_t mode; +} osd_resolution_struct_t; + typedef struct gradientData_t { fb_pixel_t* gradientBuf; @@ -184,6 +192,7 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? virtual void setupGXA() { return; }; // reinitialize stuff + virtual void add_gxa_sync_marker() { return; }; virtual bool needAlign4Blit() { return false; }; virtual uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); @@ -230,6 +239,7 @@ class CFrameBuffer : public sigc::trackable const int h = 0, const unsigned char offset = 1, bool paint = true, bool paintBg = false, const fb_pixel_t colBg = 0); bool paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset = 0); void loadPal (const std::string & filename, const unsigned char offset = 0, const unsigned char endidx = 255); + void clearIconCache(); bool loadPicture2Mem (const std::string & filename, fb_pixel_t * const memp); bool loadPicture2FrameBuffer(const std::string & filename); @@ -269,6 +279,13 @@ class CFrameBuffer : public sigc::trackable virtual void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); virtual void mark(int x, int y, int dx, int dy); +/* Remove this when pu/fb-setmode branch is merged to master */ +#define SCALE2RES_DEFINED + virtual int scale2Res(int size) { return size; }; + virtual bool fullHdAvailable() { return false; }; + virtual void setOsdResolutions(); + std::vector osd_resolutions; + size_t getIndexOsdResolution(uint32_t mode); enum { diff --git a/src/driver/file.cpp b/src/driver/file.cpp index ce4c809f5..7e02bdf10 100644 --- a/src/driver/file.cpp +++ b/src/driver/file.cpp @@ -34,43 +34,65 @@ #include #endif /* HAVE_CONFIG_H */ -#include #include #include #include -/* ATTENTION: the array file_extension_list MUST BE SORTED ASCENDING (cf. sort, man bsearch) - otherwise bsearch will not work correctly! */ -const char * const file_extension_list[] = -{ - "aac", "asf", "avi", "bin", "bmp", "cdr", "crw", - "dts", "flac", "flv", "gif", "imu", "ipk", "iso", "jpeg", "jpg", - "m2a", "m3u", "m3u8", "m4a", "mkv", "mp2", "mp3", - "mpa", "ogg", "opk", "pls", "png", "sh", - "txt", "url", "wav", "xml" +struct file_ext_s { + const char *ext; + const CFile::FileType type; }; -/* ATTENTION: the array file_extension_list MUST BE SORTED ASCENDING (cf. sort, man bsearch) - otherwise bsearch will not work correctly! */ -const CFile::FileType file_type_list[] = +// ATTENTION: the array MUST BE SORTED ASCENDING (cf. sort, man bsearch) - otherwise bsearch will not work correctly! +static const file_ext_s file_ext[] = { - CFile::FILE_AAC , CFile::FILE_ASF , CFile::FILE_AVI , CFile::FILE_BIN_PACKAGE ,CFile::FILE_PICTURE , CFile::FILE_CDR , CFile::FILE_PICTURE , - CFile::FILE_WAV , CFile::FILE_FLAC , CFile::FILE_FLV , CFile::FILE_PICTURE , CFile::STREAM_PICTURE , CFile::FILE_PKG_PACKAGE ,CFile::FILE_ISO , CFile::FILE_PICTURE , CFile::FILE_PICTURE , - CFile::FILE_MP3 , CFile::FILE_PLAYLIST , CFile::FILE_PLAYLIST , CFile::FILE_AAC , CFile::FILE_MKV , CFile::FILE_MP3 , CFile::FILE_MP3 , - CFile::FILE_MP3 , CFile::FILE_OGG , CFile::FILE_PKG_PACKAGE, CFile::FILE_PLAYLIST , CFile::FILE_PICTURE , CFile::FILE_TEXT , - CFile::FILE_TEXT , CFile::STREAM_AUDIO , CFile::FILE_WAV , CFile::FILE_XML + { "aac", CFile::FILE_AAC }, + { "asf", CFile::FILE_ASF }, + { "avi", CFile::FILE_AVI }, + { "bin", CFile::FILE_BIN_PACKAGE }, + { "bmp", CFile::FILE_PICTURE }, + { "cdr", CFile::FILE_CDR }, + { "crw", CFile::FILE_PICTURE }, + { "dts", CFile::FILE_WAV }, + { "flac", CFile::FILE_FLAC }, + { "flv", CFile::FILE_MPG }, + { "gif", CFile::FILE_PICTURE }, + { "imu", CFile::STREAM_PICTURE }, + { "ipk", CFile::FILE_PKG_PACKAGE }, + { "iso", CFile::FILE_ISO }, + { "jpeg", CFile::FILE_PICTURE }, + { "jpg", CFile::FILE_PICTURE }, + { "m2a", CFile::FILE_MP3 }, + { "m3u", CFile::FILE_PLAYLIST }, + { "m3u8", CFile::FILE_PLAYLIST }, + { "m4a", CFile::FILE_AAC }, + { "mkv", CFile::FILE_MKV }, + { "mp2", CFile::FILE_MP3 }, + { "mp3", CFile::FILE_MP3 }, + { "mp4", CFile::FILE_MPG }, + { "mpa", CFile::FILE_MP3 }, + { "mpeg", CFile::FILE_MPG }, + { "mpg", CFile::FILE_MPG }, + { "ogg", CFile::FILE_OGG }, + { "opk", CFile::FILE_PKG_PACKAGE }, + { "pls", CFile::FILE_PLAYLIST }, + { "png", CFile::FILE_PICTURE }, + { "sh", CFile::FILE_TEXT }, + { "ts", CFile::FILE_TS }, + { "txt", CFile::FILE_TEXT }, + { "url", CFile::STREAM_AUDIO }, + { "vob", CFile::FILE_VOB }, + { "wav", CFile::FILE_WAV }, + { "xml", CFile::FILE_XML } }; int mycasecmp(const void * a, const void * b) { - return strcasecmp(*(const char * *)a, *(const char * *)b); + return strcasecmp(((file_ext_s *)a)->ext, ((file_ext_s *)b)->ext); } -//------------------------------------------------------------------------ -//------------------------------------------------------------------------ - -CFile::CFile() - : Size( 0 ), Mode( 0 ), Marked( false ), Time( 0 ) +CFile::CFile() : Size( 0 ), Mode( 0 ), Marked( false ), Time( 0 ) { - Type = -1; } CFile::FileType CFile::getType(void) const @@ -78,24 +100,17 @@ CFile::FileType CFile::getType(void) const if(S_ISDIR(Mode)) return FILE_DIR; - if (Type < 0) { - Type = (int) FILE_UNKNOWN; - std::string::size_type ext_pos = Name.rfind('.'); + std::string::size_type ext_pos = Name.rfind('.'); - if (ext_pos != std::string::npos) { - const char * key = &(Name.c_str()[ext_pos + 1]); - - void * result = ::bsearch(&key, file_extension_list, sizeof(file_extension_list) / sizeof(const char *), sizeof(const char *), mycasecmp); - - if (result != NULL) - Type = (int) file_type_list[(const char * *)result - (const char * *)&file_extension_list]; - } + if (ext_pos != std::string::npos) { + const char * key = &(Name.c_str()[ext_pos + 1]); + void * result = ::bsearch(&key, file_ext, sizeof(file_ext) / sizeof(file_ext_s), sizeof(file_ext_s), mycasecmp); + if (result) + return ((file_ext_s *)result)->type; } - return (CFile::FileType) Type; + return FILE_UNKNOWN; } -//------------------------------------------------------------------------ - std::string CFile::getFileName(void) const // return name.extension or folder name without trailing / { std::string::size_type namepos = Name.rfind('/'); @@ -103,8 +118,6 @@ std::string CFile::getFileName(void) const // return name.extension or folder n return (namepos == std::string::npos) ? Name : Name.substr(namepos + 1); } -//------------------------------------------------------------------------ - std::string CFile::getPath(void) const // return complete path including trailing / { int pos = 0; diff --git a/src/driver/file.h b/src/driver/file.h index e8d7ff8b8..60801a871 100644 --- a/src/driver/file.h +++ b/src/driver/file.h @@ -59,25 +59,28 @@ class CFile { FILE_UNKNOWN = 0, FILE_AAC, - FILE_AVI, FILE_ASF, - FILE_DIR, - FILE_ISO, - FILE_TEXT, + FILE_AVI, + FILE_BIN_PACKAGE, FILE_CDR, - FILE_MP3, - FILE_MKV, - FILE_OGG, - FILE_WAV, + FILE_DIR, FILE_FLAC, FILE_FLV, - FILE_XML, - FILE_PLAYLIST, - STREAM_AUDIO, + FILE_ISO, + FILE_MKV, + FILE_MP3, + FILE_MPG, + FILE_OGG, FILE_PICTURE, - STREAM_PICTURE, - FILE_BIN_PACKAGE, - FILE_PKG_PACKAGE + FILE_PKG_PACKAGE, + FILE_PLAYLIST, + FILE_TEXT, + FILE_TS, + FILE_VOB, + FILE_WAV, + FILE_XML, + STREAM_AUDIO, + STREAM_PICTURE }; FileType getType(void) const; diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 3f212842c..b9927a508 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -99,7 +99,7 @@ FBFontRenderClass::~FBFontRenderClass() for (fontListEntry * f = font; f; f = g) { g = f->next; - delete f; + delete f; f = NULL; } FTC_Manager_Done(cacheManager); diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index 8c200a301..64da5fe44 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -92,14 +92,18 @@ void CNeutrinoFonts::InitDynFonts() CNeutrinoFonts::~CNeutrinoFonts() { if (!v_share_fonts.empty()) { - for (unsigned int i = 0; i < v_share_fonts.size(); i++) + for (unsigned int i = 0; i < v_share_fonts.size(); i++){ delete v_share_fonts[i].font; + v_share_fonts[i].font = NULL; + } v_share_fonts.clear(); } if (!v_dyn_fonts.empty()) { - for (unsigned int i = 0; i < v_dyn_fonts.size(); i++) + for (unsigned int i = 0; i < v_dyn_fonts.size(); i++){ delete v_dyn_fonts[i].font; + v_dyn_fonts[i].font = NULL; + } v_dyn_fonts.clear(); } if (!vDynSize.empty()) { @@ -176,12 +180,15 @@ void CNeutrinoFonts::SetupNeutrinoFonts(bool initRenderClass/*=true*/) fontStyle[2] = "Italic"; } + int fontSize; for (int i = 0; i < SNeutrinoSettings::FONT_TYPE_COUNT; i++) { if (g_Font[i]) delete g_Font[i]; - g_Font[i] = g_fontRenderer->getFont(fontDescr.name.c_str(), fontStyle[neutrino_font[i].style].c_str(), CNeutrinoApp::getInstance()->getConfigFile()->getInt32(locale_real_names[neutrino_font[i].name], neutrino_font[i].defaultsize) + neutrino_font[i].size_offset * fontDescr.size_offset); + fontSize = CFrameBuffer::getInstance()->scale2Res(CNeutrinoApp::getInstance()->getConfigFile()->getInt32(locale_real_names[neutrino_font[i].name], neutrino_font[i].defaultsize)) + neutrino_font[i].size_offset * fontDescr.size_offset; + g_Font[i] = g_fontRenderer->getFont(fontDescr.name.c_str(), fontStyle[neutrino_font[i].style].c_str(), fontSize); } if (g_SignalFont) delete g_SignalFont; - g_SignalFont = g_fontRenderer->getFont(fontDescr.name.c_str(), fontStyle[signal_font.style].c_str(), signal_font.defaultsize + signal_font.size_offset * fontDescr.size_offset); + fontSize = CFrameBuffer::getInstance()->scale2Res(signal_font.defaultsize) + signal_font.size_offset * fontDescr.size_offset; + g_SignalFont = g_fontRenderer->getFont(fontDescr.name.c_str(), fontStyle[signal_font.style].c_str(), fontSize); } void CNeutrinoFonts::refreshDynFonts() @@ -242,7 +249,7 @@ int CNeutrinoFonts::getFontHeight(Font* fnt) int CNeutrinoFonts::getDynFontSize(int dx, int dy, std::string text, int style) { int dynSize = dy/1.6; - if (dx == 0) dx = 1280; + if (dx == 0) dx = CFrameBuffer::getInstance()->getScreenWidth(true); if (!vDynSize.empty()) { for (size_t i = 0; i < vDynSize.size(); i++) { @@ -399,8 +406,10 @@ void CNeutrinoFonts::deleteDynFontExtAll() { if (!v_dyn_fonts_ext.empty()) { for (size_t i = 0; i < v_dyn_fonts_ext.size(); ++i) { - if (v_dyn_fonts_ext[i].font != NULL) + if (v_dyn_fonts_ext[i].font != NULL){ delete v_dyn_fonts_ext[i].font; + v_dyn_fonts_ext[i].font = NULL; + } } v_dyn_fonts_ext.clear(); } diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 8b22b68aa..90947fe39 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -123,6 +123,7 @@ std::string CPictureViewer::DownloadImage(std::string url) curl_easy_setopt(ch, CURLOPT_URL, url.c_str()); curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3); curl_easy_setopt(ch, CURLOPT_TIMEOUT, 4); + curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 0L); CURLcode res = curl_easy_perform(ch); if (res != CURLE_OK){ printf("[%s] curl_easy_perform() failed:%s\n",__func__, curl_easy_strerror(res)); @@ -853,12 +854,38 @@ unsigned char * CPictureViewer::ResizeA(unsigned char *orgin, int ox, int oy, in return int_Resize(orgin, ox, oy, dx, dy, COLOR, NULL, true); } +static size_t getCachedMemSize(void) +{ + FILE *procmeminfo = fopen("/proc/meminfo", "r"); + size_t cached = 0; + if (procmeminfo) { + char buf[80] = {0}, a[80] = {0}; + size_t v = 0; + while (fgets(buf, sizeof(buf), procmeminfo)) { + char unit[10]; + *unit = 0; + if ((3 == sscanf(buf, "%[^:]: %zu %s", a, &v, unit)) + || (2 == sscanf(buf, "%[^:]: %zu", a, &v))) { + if (*unit == 'k') + v <<= 10; + if (!strcasecmp(a, "Cached")){ + cached = v; + break; + } + } + } + fclose(procmeminfo); + } + return cached; +} + bool CPictureViewer::checkfreemem(size_t bufsize) { struct sysinfo info; sysinfo( &info ); - if(bufsize + 4096 > (size_t)info.freeram + (size_t)info.freeswap){ - dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory: need %zu > free %zu\n", __func__, __LINE__,bufsize,(size_t)info.freeram + (size_t)info.freeswap); + size_t cached = getCachedMemSize(); + if(bufsize + sysconf(_SC_PAGESIZE) > (size_t)info.freeram + (size_t)info.freeswap + (size_t)info.bufferram + cached){ + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory: need %zu > free %zu\n", __func__, __LINE__,bufsize,(size_t)info.freeram + (size_t)info.freeswap + (size_t)info.bufferram + cached); return false; } return true; diff --git a/src/driver/radiotext.cpp b/src/driver/radiotext.cpp index 28f1c8186..b74aa9ef0 100644 --- a/src/driver/radiotext.cpp +++ b/src/driver/radiotext.cpp @@ -836,7 +836,7 @@ void CRadioText::RassDecode(unsigned char *mtext, int len) slidenumr = Rass_SlideFoto; } // - char *filepath; + char *filepath = asprintf(&filepath, "%s/Rass_%d.error", DataDir, slidenumr); (filetype == 2) ? asprintf(&filepath, "%s/Rass_%d.def", DataDir, slidenumr) : asprintf(&filepath, "%s/Rass_%d.mpg", DataDir, slidenumr); if ((fd = fopen(filepath, "wb")) != NULL) { diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 1f872a55d..f2455010f 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -469,7 +469,7 @@ int CRCInput::addTimer(uint64_t Interval, bool oneshot, bool correct_time ) _newtimer.correct_time = correct_time; -//printf("adding timer %d (0x%llx, 0x%llx)\n", _newtimer.id, _newtimer.times_out, Interval); +printf("adding timer %d (0x%llx, 0x%llx)\n", _newtimer.id, _newtimer.times_out, Interval); std::vector::iterator e; for ( e= timers.begin(); e!= timers.end(); ++e ) @@ -482,7 +482,7 @@ int CRCInput::addTimer(uint64_t Interval, bool oneshot, bool correct_time ) void CRCInput::killTimer(uint32_t &id) { -//printf("killing timer %d\n", id); +printf("killing timer %d\n", id); if(id == 0) return; diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 379acea4c..dc1d52fe7 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1942,7 +1942,7 @@ void CStreamRec::FillMovieInfo(CZapitChannel * /*channel*/, APIDList & /*apid_li for (unsigned i = 0; i < ofcx->nb_streams; i++) { AVStream *st = ofcx->streams[i]; -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext * codec = st->codec; #else AVCodecParameters * codec = st->codecpar; @@ -2175,7 +2175,7 @@ bool CStreamRec::Open(CZapitChannel * channel) stream_index = -1; int stid = 0x200; for (unsigned i = 0; i < ifcx->nb_streams; i++) { -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext * iccx = ifcx->streams[i]->codec; AVStream *ost = avformat_new_stream(ofcx, iccx->codec); avcodec_copy_context(ost->codec, iccx); @@ -2231,7 +2231,7 @@ void CStreamRec::run() break; if (pkt.stream_index < 0) continue; -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec; #else AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar; diff --git a/src/driver/scanepg.cpp b/src/driver/scanepg.cpp index 7367175d2..da91163ea 100644 --- a/src/driver/scanepg.cpp +++ b/src/driver/scanepg.cpp @@ -39,7 +39,7 @@ #include #include -#define EPG_RESCAN_TIME (24*60*60) +//#define EPG_RESCAN_TIME (24*60*60) extern CBouquetList * bouquetList; extern CBouquetList * TVfavList; @@ -322,8 +322,9 @@ int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) void CEpgScan::AddTimer() { if (rescan_timer == 0) - rescan_timer = g_RCInput->addTimer(EPG_RESCAN_TIME*1000ULL*1000ULL, true); + rescan_timer = g_RCInput->addTimer((g_settings.epg_scan_rescan*60*60)*1000ULL*1000ULL, true); INFO("rescan timer id %d", rescan_timer); + INFO("rescan time is %d*60*60", g_settings.epg_scan_rescan); } void CEpgScan::EnterStandby() diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index d889b9f8b..dbb673fcf 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -63,6 +63,7 @@ CScreenShot::CScreenShot(const std::string fname, screenshot_format_t fmt) fd = NULL; xres = 0; yres = 0; + extra_osd = false; scs_thread = 0; pthread_mutex_init(&thread_mutex, NULL); pthread_mutex_init(&getData_mutex, NULL); @@ -78,9 +79,66 @@ CScreenShot::~CScreenShot() // printf("[CScreenShot::%s:%d] thread: %p\n", __func__, __LINE__, this); } +#ifdef BOXMODEL_CS_HD2 + +bool CScreenShot::mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData) +{ + uint8_t* d = (uint8_t *)pixel_data; + fb_pixel_t* d2; + + for (uint32_t count = 0; count < dy; count++ ) { + fb_pixel_t *pixpos = (fb_pixel_t*)&osdData[count*dx]; + d2 = (fb_pixel_t*)d; + for (uint32_t count2 = 0; count2 < dx; count2++ ) { + //don't paint backgroundcolor (*pixpos = 0x00000000) + if (*pixpos) { + fb_pixel_t pix = *pixpos; + if ((pix & 0xff000000) == 0xff000000) + *d2 = (pix & 0x00ffffff); + else { + uint8_t *in = (uint8_t *)(pixpos); + uint8_t *out = (uint8_t *)d2; + int a = in[3]; + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + } + } + d2++; + pixpos++; + } + d += dx*sizeof(fb_pixel_t); + } + return true; +} +#endif + /* try to get video frame data in ARGB format, restore GXA state */ bool CScreenShot::GetData() { +#ifdef BOXMODEL_CS_HD2 + /* Workaround for broken osd screenshot with new fb driver and 1280x720 resolution */ + CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); + fb_pixel_t* screenBuf = NULL; + uint32_t _xres = 0, _yres = 0; + if (frameBuffer->fullHdAvailable() && (frameBuffer->getScreenWidth(true) == 1280)) { + _xres = xres = 1280; + _yres = yres = 720; + get_osd = false; + extra_osd = true; + screenBuf = new fb_pixel_t[_xres*_yres*sizeof(fb_pixel_t)]; + if (screenBuf == NULL) { + printf("[CScreenShot::%s:%d] memory error\n", __func__, __LINE__); + return false; + } + printf("\n[CScreenShot::%s:%d] Read osd screen...", __func__, __LINE__); + frameBuffer->SaveScreen(0, 0, _xres, _yres, screenBuf); + printf(" done.\n"); + } +#endif + bool res = false; pthread_mutex_lock(&getData_mutex); @@ -89,6 +147,21 @@ bool CScreenShot::GetData() #endif if (videoDecoder->getBlank()) get_video = false; + +#ifdef BOXMODEL_CS_HD2 + if (extra_osd && !get_video) { + uint32_t memSize = xres * yres * sizeof(fb_pixel_t) * 2; + pixel_data = (uint8_t*)cs_malloc_uncached(memSize); + if (pixel_data == NULL) { + printf("[CScreenShot::%s:%d] memory error\n", __func__, __LINE__); + pthread_mutex_unlock(&getData_mutex); + return false; + } + memset(pixel_data, 0, memSize); + res = true; + } + else +#endif #ifdef SCREENSHOT res = videoDecoder->GetScreenImage(pixel_data, xres, yres, get_video, get_osd, scale_to_video); #endif @@ -97,7 +170,7 @@ bool CScreenShot::GetData() /* sort of hack. GXA used to transfer/convert live image to RGB, * so setup GXA back */ CFrameBuffer::getInstance()->setupGXA(); - //CFrameBuffer::getInstance()->add_gxa_sync_marker(); + CFrameBuffer::getInstance()->add_gxa_sync_marker(); CFrameBuffer::getInstance()->setActive(true); #endif pthread_mutex_unlock(&getData_mutex); @@ -106,6 +179,14 @@ bool CScreenShot::GetData() return false; } +#ifdef BOXMODEL_CS_HD2 + if (extra_osd && screenBuf) { + printf("[CScreenShot::%s:%d] Merge osd screen to screenshot...", __func__, __LINE__); + mergeOsdScreen(_xres, _yres, screenBuf); + delete[] screenBuf; + printf(" done.\n \n"); + } +#endif printf("[CScreenShot::%s:%d] data: %p %d x %d\n", __func__, __LINE__, pixel_data, xres, yres); return true; } @@ -163,6 +244,7 @@ void CScreenShot::cleanupThread(void *arg) /* start ::run in new thread to save file in selected format */ bool CScreenShot::Start() { + set_threadname("n:screenshot"); bool ret = false; if (GetData()) ret = startThread(); @@ -308,7 +390,7 @@ bool CScreenShot::SaveJpg() int xres2 = xres1+2; for (int x = 0; x < xres; x++) { int x2 = x*3; - memmove(pixel_data + x2 + xres1, pixel_data + x*4 + y*xres*4, 3); + memcpy(pixel_data + x2 + xres1, pixel_data + x*4 + y*xres*4, 3); SWAP(pixel_data[x2 + xres1], pixel_data[x2 + xres2]); } } diff --git a/src/driver/screenshot.h b/src/driver/screenshot.h index fefaf7c78..bf17e72bf 100644 --- a/src/driver/screenshot.h +++ b/src/driver/screenshot.h @@ -40,6 +40,7 @@ class CScreenShot unsigned char * pixel_data; int xres; int yres; + bool extra_osd; bool get_osd; bool get_video; bool scale_to_video; @@ -61,6 +62,10 @@ class CScreenShot void runThread(); static void cleanupThread(void *arg); +#ifdef BOXMODEL_CS_HD2 + bool mergeOsdScreen(uint32_t dx, uint32_t dy, fb_pixel_t* osdData); +#endif + public: CScreenShot(const std::string fname = "", screenshot_format_t fmt = CScreenShot::FORMAT_JPG); ~CScreenShot(); diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index f69dcea08..7c6012675 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -57,6 +57,7 @@ #include #include #include + #include #include @@ -849,7 +850,7 @@ bool CStreamStream::Open() av_dict_copy(&ofcx->metadata, ifcx->metadata, 0); int stid = 0x200; for (unsigned i = 0; i < ifcx->nb_streams; i++) { -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext * iccx = ifcx->streams[i]->codec; AVStream *ost = avformat_new_stream(ofcx, iccx->codec); avcodec_copy_context(ost->codec, iccx); @@ -922,7 +923,7 @@ void CStreamStream::run() if (pkt.stream_index < 0) continue; -#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,5,0 )) +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec; #else AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar; diff --git a/src/driver/wav.h b/src/driver/wav.h deleted file mode 100644 index 1b108b746..000000000 --- a/src/driver/wav.h +++ /dev/null @@ -1,65 +0,0 @@ -static unsigned char click[] = { -0xE5, 0xF5, 0xFF, 0xF7, 0x18, 0xFA, 0x7F, 0xFB, 0x98, 0xFD, 0xFF, 0xFE, 0x17, 0x01, 0x31, 0x03, -0x4A, 0x05, 0xB1, 0x06, 0xCA, 0x08, 0xCA, 0x0F, 0xCA, 0x16, 0x97, 0x12, 0x17, 0x0F, 0xFE, 0x13, -0xE4, 0x18, 0x7E, 0x17, 0x17, 0x16, 0x64, 0x15, 0x64, 0x15, 0xE4, 0x18, 0x17, 0x1D, 0xCA, 0x1D, -0x7E, 0x1E, 0xCA, 0x24, 0x17, 0x2B, 0xE4, 0x26, 0x64, 0x23, 0x31, 0x2D, 0xFE, 0x36, 0x7E, 0x33, -0xB1, 0x30, 0x17, 0x32, 0x7E, 0x33, 0x64, 0x2A, 0x4A, 0x21, 0x64, 0x15, 0x7E, 0x09, 0x97, 0x04, -0xB2, 0xFF, 0xB2, 0xF1, 0xB2, 0xE3, 0xFF, 0xE2, 0x4B, 0xE2, 0x32, 0xD9, 0xCB, 0xD0, 0x7F, 0xD1, -0xE5, 0xD2, 0x18, 0xD0, 0x4B, 0xCD, 0x65, 0xC8, 0x7F, 0xC3, 0xCB, 0xC2, 0x18, 0xC2, 0x18, 0xC2, -0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0xCB, 0xC2, -0x7F, 0xC3, 0x18, 0xC9, 0xB2, 0xCE, 0xFF, 0xD4, 0x4B, 0xDB, 0x4B, 0xE2, 0x4B, 0xE9, 0xE5, 0xEE, -0x32, 0xF5, 0x7F, 0xFB, 0xCA, 0x01, 0x17, 0x08, 0x17, 0x0F, 0xFE, 0x13, 0x97, 0x19, 0xCA, 0x1D, -0xB1, 0x22, 0x31, 0x26, 0xB1, 0x29, 0xCA, 0x2B, 0x97, 0x2E, 0x4A, 0x2F, 0xB1, 0x30, 0xFE, 0x2F, -0xFE, 0x2F, 0xE4, 0x2D, 0x7E, 0x2C, 0xFE, 0x28, 0x31, 0x26, 0xFE, 0x21, 0xCA, 0x1D, 0x31, 0x18, -0x4A, 0x13, 0xB1, 0x0D, 0x17, 0x08, 0xCA, 0x01, 0x7F, 0xFB, 0x32, 0xF5, 0x98, 0xEF, 0x4B, 0xE9, -0xB2, 0xE3, 0x18, 0xDE, 0x7F, 0xD8, 0x98, 0xD3, 0x65, 0xCF, 0x32, 0xCB, 0xB2, 0xC7, 0xE5, 0xC4, -0xCB, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x7F, 0xC3, 0x98, 0xC5, 0x65, 0xC8, -0xE5, 0xCB, 0x18, 0xD0, 0xFF, 0xD4, 0x98, 0xDA, 0x32, 0xE0, 0x7F, 0xE6, 0x7F, 0xED, 0x7F, 0xF4, -0x32, 0xFC, 0xE4, 0x03, 0x97, 0x0B, 0xE4, 0x11, 0x31, 0x18, 0x31, 0x1F, 0x31, 0x26, 0x7E, 0x2C, -0x7E, 0x33, 0xB1, 0x37, 0x97, 0x3C, 0x4A, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, -0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xFE, 0x3D, 0xCA, 0x39, -0x97, 0x35, 0xFE, 0x2F, 0x17, 0x2B, 0xCA, 0x24, 0x7E, 0x1E, 0x7E, 0x17, 0x7E, 0x10, 0x7E, 0x09, -0x31, 0x03, 0xE5, 0xFC, 0x4B, 0xF7, 0xFF, 0xF0, 0x65, 0xEB, 0x7F, 0xE6, 0x98, 0xE1, 0xCB, 0xDE, -0xFF, 0xDB, 0x32, 0xD9, 0x65, 0xD6, 0xFF, 0xD4, 0x4B, 0xD4, 0xFF, 0xD4, 0x65, 0xD6, 0x7F, 0xD8, -0x98, 0xDA, 0x65, 0xDD, 0xE5, 0xE0, 0x18, 0xE5, 0x4B, 0xE9, 0xE5, 0xEE, 0x32, 0xF5, 0xCB, 0xFA, -0x64, 0x00, 0xB1, 0x06, 0xFE, 0x0C, 0x4A, 0x13, 0x4A, 0x1A, 0xE4, 0x1F, 0x7E, 0x25, 0xB1, 0x29, -0x97, 0x2E, 0x17, 0x32, 0x4A, 0x36, 0x17, 0x39, 0x97, 0x3C, 0x97, 0x3C, 0x4A, 0x3D, 0x4A, 0x3D, -0x4A, 0x3D, 0x31, 0x3B, 0xCA, 0x39, 0x4A, 0x36, 0x7E, 0x33, 0x97, 0x2E, 0xB1, 0x29, 0x17, 0x24, -0x31, 0x1F, 0x31, 0x18, 0xE4, 0x11, 0xE4, 0x0A, 0xE4, 0x03, 0xE5, 0xFC, 0xE5, 0xF5, 0x98, 0xEF, -0x4B, 0xE9, 0xFF, 0xE2, 0x65, 0xDD, 0xCB, 0xD7, 0xE5, 0xD2, 0xB2, 0xCE, 0x32, 0xCB, 0x65, 0xC8, -0x4B, 0xC6, 0xE5, 0xC4, 0x7F, 0xC3, 0x32, 0xC4, 0xE5, 0xC4, 0xB2, 0xC7, 0x7F, 0xCA, 0xFF, 0xCD, -0x7F, 0xD1, 0x65, 0xD6, 0x4B, 0xDB, 0x98, 0xE1, 0xE5, 0xE7, 0x32, 0xEE, 0x32, 0xF5, 0x7F, 0xFB, -0x7E, 0x02, 0xCA, 0x08, 0xCA, 0x0F, 0x17, 0x16, 0x17, 0x1D, 0xFE, 0x21, 0xE4, 0x26, 0x17, 0x2B, -0x4A, 0x2F, 0x17, 0x32, 0x97, 0x35, 0x4A, 0x36, 0xB1, 0x37, 0xFE, 0x36, 0x4A, 0x36, 0x31, 0x34, -0x17, 0x32, 0x97, 0x2E, 0x17, 0x2B, 0x7E, 0x25, 0x97, 0x20, 0x4A, 0x1A, 0xB1, 0x14, 0x4A, 0x0C, -0x97, 0x04, 0x4B, 0xFE, 0xB2, 0xF8, 0x4B, 0xF0, 0xE5, 0xE7, 0x98, 0xE1, 0xFF, 0xDB, 0x65, 0xD6, -0xCB, 0xD0, 0x4B, 0xCD, 0x7F, 0xCA, 0x65, 0xC8, 0x4B, 0xC6, 0xE5, 0xC4, 0x7F, 0xC3, 0x98, 0xC5, -0x65, 0xC8, 0xCB, 0xC9, 0xE5, 0xCB, 0x18, 0xD0, 0xFF, 0xD4, 0xE5, 0xD9, 0x7F, 0xDF, 0x18, 0xE5, -0x65, 0xEB, 0xB2, 0xF1, 0xB2, 0xF8, 0xFF, 0xFE, 0xFE, 0x05, 0xFE, 0x0C, 0xFE, 0x13, 0x97, 0x19, -0xE4, 0x1F, 0x7E, 0x25, 0x17, 0x2B, 0x97, 0x2E, 0xCA, 0x32, 0x97, 0x35, 0x17, 0x39, 0xCA, 0x39, -0x7E, 0x3A, 0xCA, 0x39, 0x17, 0x39, 0xFE, 0x36, 0xE4, 0x34, 0xFE, 0x2F, 0x17, 0x2B, 0xCA, 0x24, -0x31, 0x1F, 0x7E, 0x17, 0x7E, 0x10, 0x17, 0x08, 0x64, 0x00, 0xFF, 0xF7, 0x98, 0xEF, 0x32, 0xE7, -0x7F, 0xDF, 0xCB, 0xD7, 0x18, 0xD0, 0xCB, 0xC9, 0x32, 0xC4, 0xCB, 0xC2, 0x18, 0xC2, 0x18, 0xC2, -0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x98, 0xC5, 0xCB, 0xC9, 0x18, 0xD0, -0x65, 0xD6, 0x18, 0xDE, 0xCB, 0xE5, 0x7F, 0xED, 0x32, 0xF5, 0xE5, 0xFC, 0x4A, 0x05, 0x97, 0x0B, -0x97, 0x12, 0x31, 0x18, 0x7E, 0x1E, 0xB1, 0x22, 0xE4, 0x26, 0xB1, 0x29, 0x7E, 0x2C, 0x31, 0x2D, -0x97, 0x2E, 0xE4, 0x2D, 0xE4, 0x2D, 0xCA, 0x2B, 0xB1, 0x29, 0x31, 0x26, 0x64, 0x23, 0x7E, 0x1E, -0x4A, 0x1A, 0xB1, 0x14, 0x17, 0x0F, 0xCA, 0x08, 0x7E, 0x02, 0x32, 0xFC, 0x98, 0xF6, 0xE5, 0xEE, -0xE5, 0xE7, 0xE5, 0xE0, 0x98, 0xDA, 0x65, 0xD6, 0x32, 0xD2, 0xFF, 0xCD, 0xCB, 0xC9, 0x98, 0xC5, -0x18, 0xC2, 0x18, 0xC2, 0x18, 0xC2, 0x32, 0xC4, 0xFF, 0xC6, 0xCB, 0xC9, 0x98, 0xCC, 0x32, 0xD2, -0x7F, 0xD8, 0xE5, 0xE0, 0xFF, 0xE9, 0x65, 0xF2, 0xCB, 0xFA, 0x31, 0x03, 0x97, 0x0B, 0xFE, 0x13, -0x64, 0x1C, 0x64, 0x23, 0x17, 0x2B, 0x97, 0x2E, 0x17, 0x32, 0x31, 0x34, 0x4A, 0x36, 0x4A, 0x36, -0x4A, 0x36, 0xCA, 0x32, 0x4A, 0x2F, 0x64, 0x2A, 0x7E, 0x25, 0xE4, 0x1F, 0x4A, 0x1A, 0x4A, 0x13, -0x4A, 0x0C, 0x4A, 0x05, 0x4B, 0xFE, 0xFF, 0xF7, 0x65, 0xF2, 0xCB, 0xEC, 0x32, 0xE7, 0xFF, 0xE2, -0xCB, 0xDE, 0x4B, 0xDB, 0xCB, 0xD7, 0xFF, 0xD4, 0xE5, 0xD2, 0x7F, 0xD1, 0x18, 0xD0, 0x18, 0xD0, -0xCB, 0xD0, 0x32, 0xD2, 0x98, 0xD3, 0x65, 0xD6, 0x32, 0xD9, 0x18, 0xDE, 0xFF, 0xE2, 0x4B, 0xE9, -0x98, 0xEF, 0x98, 0xF6, 0x4B, 0xFE, 0xB1, 0x06, 0x17, 0x0F, 0x7E, 0x17, 0xE4, 0x1F, 0x31, 0x26, -0x31, 0x2D, 0x64, 0x31, 0x4A, 0x36, 0x64, 0x38, 0x7E, 0x3A, 0x17, 0x39, 0x64, 0x38, 0x7E, 0x33, -0x97, 0x2E, 0x97, 0x27, 0x4A, 0x21, 0x97, 0x19, 0xE4, 0x11, 0xCA, 0x08, 0xB2, 0xFF, 0x4B, 0xF7, -0xE5, 0xEE, 0xE5, 0xE7, 0x98, 0xE1, 0xB2, 0xDC, 0xCB, 0xD7, 0xB2, 0xD5, 0x98, 0xD3, 0x98, 0xD3, -0x98, 0xD3, 0xFF, 0xD4, 0x65, 0xD6, 0x32, 0xD9, 0xFF, 0xDB, 0x7F, 0xDF, 0xFF, 0xE2, 0x7F, 0xE6, -0xB2, 0xEA, 0xE5, 0xEE, 0xCB, 0xF3, 0xB2, 0xF8, 0x98, 0xFD, 0x7E, 0x02, 0x17, 0x08, 0xB1, 0x0D, -0xFE, 0x13, 0x4A, 0x1A, 0x97, 0x20, 0x7E, 0x25, 0x17, 0x2B, 0x4A, 0x2F, 0x31, 0x34, 0x4A, 0x36, -0x64, 0x38, 0xFE, 0x36, 0x4A, 0x36, 0x17, 0x32, 0xE4, 0x2D, 0xE4, 0x26, 0xE4, 0x1F, 0x17, 0x16, -0x4A, 0x0C, 0xCA, 0x01, 0xFF, 0xF7, 0x32, 0xEE -}; diff --git a/src/global.h b/src/global.h index 65f55aff7..6d3c5497e 100644 --- a/src/global.h +++ b/src/global.h @@ -42,10 +42,13 @@ #define MOVIEPLAYER_START_SCRIPT CONFIGDIR "/movieplayer.start" #define MOVIEPLAYER_END_SCRIPT CONFIGDIR "/movieplayer.end" #define NEUTRINO_ENTER_FLASH_SCRIPT CONFIGDIR "/flash.start" +#define NEUTRINO_APP_START_SCRIPT CONFIGDIR "/neutrino.start" #define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" #define NEUTRINO_PARENTALLOCKED_FILE DATADIR "/neutrino/.plocked" +#define COVERDIR "/tmp/cover" + #define LOGODIR ICONSDIR "/logo" #define LOGODIR_VAR ICONSDIR_VAR "/logo" diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index cabaf9297..b4dcfc413 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -73,6 +73,7 @@ libneutrino_gui_a_SOURCES = \ network_setup.cpp \ nfs.cpp \ opkg_manager.cpp \ + osd_helpers.cpp \ osd_progressbar_setup.cpp \ osd_setup.cpp \ osdlang_setup.cpp \ diff --git a/src/gui/adzap.cpp b/src/gui/adzap.cpp index 0199bc779..bc251f253 100644 --- a/src/gui/adzap.cpp +++ b/src/gui/adzap.cpp @@ -66,15 +66,16 @@ CAdZapMenu::CAdZapMenu() sem_init(&sem, 0, 0); + channelId = -1; + armed = false; + monitor = false; + alerted = false; + pthread_t thr; if (pthread_create(&thr, 0, CAdZapMenu::Run, this)) fprintf(stderr, "ERROR: pthread_create(CAdZapMenu::CAdZapMenu)\n"); else pthread_detach(thr); - channelId = -1; - armed = false; - monitor = false; - alerted = false; } static bool sortByDateTime(const CChannelEvent & a, const CChannelEvent & b) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 35a971e7f..3e9a121e6 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1,37 +1,27 @@ /* - Neutrino-GUI - DBoxII-Project + Neutrino-GUI - DBoxII-Project - AudioPlayer by Dirch, Zwen - AudioPlayer by Dirch,Zwen + Copyright (C) 2001 Steffen Hehn 'McClean' + Copyright (C) 2002-2008 the tuxbox project contributors + Copyright (C) 2008 Novell, Inc. Author: Stefan Seyfried + Copyright (C) 2011-2013 Stefan Seyfried + Copyright (C) 2017 Sven Hoefer - (C) 2002-2008 the tuxbox project contributors - (C) 2008 Novell, Inc. Author: Stefan Seyfried - (C) 2011-2013 Stefan Seyfried + License: GPL - Homepage: http://dbox.cyberphoria.org/ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - Kommentar: + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ #ifdef HAVE_CONFIG_H #include @@ -47,7 +37,6 @@ #include #include #include -#include #include @@ -105,18 +94,15 @@ extern cVideo * videoDecoder; const char RADIO_STATION_XML_FILE[] = {DEFAULT_RADIOSTATIONS_XMLFILE}; -CAudiofileExt::CAudiofileExt() - : CAudiofile(), firstChar('\0') +CAudiofileExt::CAudiofileExt() : CAudiofile(), firstChar('\0') { } -CAudiofileExt::CAudiofileExt(std::string name, CFile::FileType type) - : CAudiofile(name, type), firstChar('\0') +CAudiofileExt::CAudiofileExt(std::string name, CFile::FileType type) : CAudiofile(name, type), firstChar('\0') { } -CAudiofileExt::CAudiofileExt(const CAudiofileExt& src) - : CAudiofile(src), firstChar(src.firstChar) +CAudiofileExt::CAudiofileExt(const CAudiofileExt& src) : CAudiofile(src), firstChar(src.firstChar) { } @@ -128,7 +114,8 @@ void CAudiofileExt::operator=(const CAudiofileExt& src) firstChar = src.firstChar; } -struct MemoryStruct { +struct MemoryStruct +{ char *memory; size_t size; }; @@ -143,14 +130,14 @@ static void *myrealloc(void *ptr, size_t size) return malloc(size); } -static size_t -WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) +static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) { size_t realsize = size * nmemb; struct MemoryStruct *mem = (struct MemoryStruct *)data; mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); - if (mem->memory) { + if (mem->memory) + { memmove(&(mem->memory[mem->size]), ptr, realsize); mem->size += realsize; mem->memory[mem->size] = 0; @@ -166,8 +153,9 @@ CAudioPlayerGui::CAudioPlayerGui(bool inetmode) m_frameBuffer = CFrameBuffer::getInstance(); m_visible = false; m_inetmode = inetmode; - dline = NULL; - ibox = NULL; + m_detailsline = NULL; + m_infobox = NULL; + m_titlebox = NULL; Init(); } @@ -187,12 +175,15 @@ void CAudioPlayerGui::Init(void) m_Path = "/"; audiofilefilter.Clear(); - if (m_inetmode) { + if (m_inetmode) + { audiofilefilter.addFilter("url"); audiofilefilter.addFilter("xml"); audiofilefilter.addFilter("m3u"); audiofilefilter.addFilter("pls"); - } else { + } + else + { audiofilefilter.addFilter("cdr"); audiofilefilter.addFilter("mp3"); audiofilefilter.addFilter("m2a"); @@ -218,10 +209,57 @@ CAudioPlayerGui::~CAudioPlayerGui() m_radiolist.clear(); m_filelist.clear(); m_title2Pos.clear(); - delete dline; - delete ibox; + delete m_detailsline; + delete m_infobox; + delete m_titlebox; } +const struct button_label AudioPlayerButtons[][4] = +{ + { + { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP }, + { NEUTRINO_ICON_BUTTON_BACKWARD , LOCALE_AUDIOPLAYER_REWIND }, + { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE }, + { NEUTRINO_ICON_BUTTON_FORWARD , LOCALE_AUDIOPLAYER_FASTFORWARD }, + }, + { + { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE }, + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, + { NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_AUDIOPLAYER_DELETEALL }, + { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_SHUFFLE }, + }, + { + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_JUMP_BACKWARDS }, + { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_JUMP_FORWARDS }, + }, + { + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_JUMP_BACKWARDS }, + { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_JUMP_FORWARDS }, + }, + { + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_SAVE_PLAYLIST }, + { NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_AUDIOPLAYER_BUTTON_SELECT_TITLE_BY_ID }, + }, + { + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_SAVE_PLAYLIST }, + { NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_AUDIOPLAYER_BUTTON_SELECT_TITLE_BY_NAME}, + }, + { + { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP }, + { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE }, + }, + { + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, + { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_INETRADIO_NAME }, + }, + { + { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE }, + { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, + { NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_AUDIOPLAYER_DELETEALL }, + { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_INETRADIO_NAME }, + }, +}; + int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) { @@ -237,8 +275,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) if (m_select_title_by_name != (g_settings.audioplayer_select_title_by_name==1)) { - if ((g_settings.audioplayer_select_title_by_name == 1) - && m_playlistHasChanged) + if ((g_settings.audioplayer_select_title_by_name == 1) && m_playlistHasChanged) { buildSearchTree(); } @@ -255,28 +292,25 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) m_width = m_frameBuffer->getScreenWidthRel(); m_height = m_frameBuffer->getScreenHeightRel(); - m_sheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight(); + m_header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + m_item_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - m_buttonHeight = std::max(25, m_sheight); - m_theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + m_meta_height = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); + m_title_height = 3*OFFSET_INNER_SMALL + 2*m_item_height + m_meta_height; + m_cover_width = 0; + m_info_height = 2*OFFSET_INNER_SMALL + 2*g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getHeight(); + m_button_height = ::paintButtons(AudioPlayerButtons[0], 4, 0, 0, 0, 0, 0, false, NULL, NULL); - int iw, ih; - m_frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &iw, &ih); - m_theight = std::max(m_theight, ih+4); + m_listmaxshow = (m_height - m_title_height - OFFSET_SHADOW - OFFSET_INTER - m_header_height - 2*m_button_height - OFFSET_SHADOW - OFFSET_INTER - m_info_height - OFFSET_SHADOW) / (m_item_height); + m_height = m_title_height + OFFSET_SHADOW + OFFSET_INTER + m_header_height + m_listmaxshow*m_item_height + 2*m_button_height + OFFSET_SHADOW + OFFSET_INTER + m_info_height + OFFSET_SHADOW; // recalc height - m_title_height = m_fheight*2 + 20 + m_sheight + 4; - m_info_height = m_fheight*2; - m_listmaxshow = (m_height - m_info_height - m_title_height - m_theight - 2*m_buttonHeight) / (m_fheight); - m_height = m_theight + m_info_height + m_title_height + 2*m_buttonHeight + m_listmaxshow * m_fheight; // recalc height - - m_x = getScreenStartX( m_width ); + m_x = getScreenStartX(m_width); if (m_x < DETAILSLINE_WIDTH) m_x = DETAILSLINE_WIDTH; - m_y = getScreenStartY( m_height ); + m_y = getScreenStartY(m_height); - m_idletime=time(NULL); - m_screensaver=false; + m_idletime = time(NULL); + m_screensaver = false; if (parent) parent->hide(); @@ -292,7 +326,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) // tell neutrino we're in audio mode m_LastMode = CNeutrinoApp::getInstance()->getMode(); - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_audio ); + CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_audio); puts("[audioplayer.cpp] executing " AUDIOPLAYER_START_SCRIPT "."); if (my_system(AUDIOPLAYER_START_SCRIPT) != 0) @@ -314,8 +348,8 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) CZapit::getInstance()->EnablePlayback(true); m_frameBuffer->stopFrame(); - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , m_LastMode ); - g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); + CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE , m_LastMode); + g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR, 0); CNeutrinoApp::getInstance()->StartSubtitles(); @@ -324,7 +358,7 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey) int CAudioPlayerGui::show() { - neutrino_msg_t msg; + neutrino_msg_t msg; neutrino_msg_data_t data; int ret = menu_return::RETURN_REPAINT; @@ -351,9 +385,11 @@ int CAudioPlayerGui::show() if (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_audio) loop = false; - if ((m_state != CAudioPlayerGui::STOP) && - (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && - (!m_playlist.empty())) + if ( + (m_state != CAudioPlayerGui::STOP) && + (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && + (!m_playlist.empty()) + ) { if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) playNext(); @@ -371,7 +407,7 @@ int CAudioPlayerGui::show() } g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display - if ( msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) + if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) { int delay = time(NULL) - m_idletime; int screensaver_delay = g_settings.screensaver_delay; @@ -389,7 +425,8 @@ int CAudioPlayerGui::show() m_frameBuffer->showFrame("mp3.jpg"); paint(); - if (msg <= CRCInput::RC_MaxRC) { + if (msg <= CRCInput::RC_MaxRC) + { // ignore first keypress - just quit the screensaver g_RCInput->clearRCMsg(); continue; @@ -449,7 +486,8 @@ int CAudioPlayerGui::show() else if (!m_playlist.empty()) { m_selected += m_listmaxshow; - if (m_selected >= m_playlist.size()) { + if (m_selected >= m_playlist.size()) + { if (((m_playlist.size() / m_listmaxshow) + 1) * m_listmaxshow == m_playlist.size() + m_listmaxshow) m_selected = 0; else @@ -462,10 +500,10 @@ int CAudioPlayerGui::show() } else if ((msg &~ CRCInput::RC_Repeat) == CRCInput::RC_up || (msg &~ CRCInput::RC_Repeat) == CRCInput::RC_page_up) { - if (m_show_playlist && !m_playlist.empty() ) + if (m_show_playlist && !m_playlist.empty()) { int prevselected = m_selected; - int step = msg == CRCInput::RC_page_up ? m_listmaxshow : 1; + int step = msg == CRCInput::RC_page_up ? m_listmaxshow : 1; m_selected -= step; if ((prevselected-step) < 0) @@ -486,13 +524,14 @@ int CAudioPlayerGui::show() } else if ((msg &~ CRCInput::RC_Repeat) == CRCInput::RC_down || (msg &~ CRCInput::RC_Repeat) == CRCInput::RC_page_down) { - if (m_show_playlist && !m_playlist.empty() ) + if (m_show_playlist && !m_playlist.empty()) { int prevselected = m_selected; - unsigned int step = msg == CRCInput::RC_page_down ? m_listmaxshow : 1; + unsigned int step = msg == CRCInput::RC_page_down ? m_listmaxshow : 1; m_selected += step; - if (m_selected >= m_playlist.size()) { + if (m_selected >= m_playlist.size()) + { if (((m_playlist.size() / m_listmaxshow) + 1) * m_listmaxshow == m_playlist.size() + m_listmaxshow) // last page has full entries m_selected = 0; else @@ -515,7 +554,8 @@ int CAudioPlayerGui::show() } else if (msg == CRCInput::RC_ok || msg == CRCInput::RC_play) { - if (!m_playlist.empty()) { + if (!m_playlist.empty()) + { if (!m_show_playlist) play(m_current); else @@ -583,10 +623,10 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - &seconds, - 5, - LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, - LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); + &seconds, + 5, + LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, + LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); int res = secondsInput.exec(NULL,""); if (seconds != 0 && res!= menu_return::RETURN_EXIT_ALL) rev(seconds); @@ -622,7 +662,8 @@ int CAudioPlayerGui::show() { if (m_key_level == 0) { - if (m_inetmode) { + if (m_inetmode) + { static int old_select = 0; char cnt[5]; CMenuWidget InputSelector(LOCALE_AUDIOPLAYER_LOAD_RADIO_STATIONS, NEUTRINO_ICON_AUDIO); @@ -632,16 +673,16 @@ int CAudioPlayerGui::show() // -- setup menue for inetradio input sprintf(cnt, "%d", count); InputSelector.addItem(new CMenuForwarder( - LOCALE_AUDIOPLAYER_ADD_LOC, true, NULL, InetRadioInputChanger, - cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); + LOCALE_AUDIOPLAYER_ADD_LOC, true, NULL, InetRadioInputChanger, + cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); sprintf(cnt, "%d", ++count); InputSelector.addItem(new CMenuForwarder( - LOCALE_AUDIOPLAYER_ADD_IC, true, NULL, InetRadioInputChanger, - cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); + LOCALE_AUDIOPLAYER_ADD_IC, true, NULL, InetRadioInputChanger, + cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); sprintf(cnt, "%d", ++count); InputSelector.addItem(new CMenuForwarder( - LOCALE_AUDIOPLAYER_ADD_SC, g_settings.shoutcast_enabled, NULL, InetRadioInputChanger, - cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); + LOCALE_AUDIOPLAYER_ADD_SC, g_settings.shoutcast_enabled, NULL, InetRadioInputChanger, + cnt, CRCInput::convertDigitToKey(count + 1)), old_select == count); //InputSelector.addItem(GenericMenuSeparator); hide(); @@ -651,26 +692,27 @@ int CAudioPlayerGui::show() if (select >= 0) old_select = select; - switch (select) { - case 0: - scanXmlFile(RADIO_STATION_XML_FILE); - CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); - paintLCD(); - break; - case 1: - readDir_ic(); - CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); - paintLCD(); - break; - case 2: - openSCbrowser(); - break; - default: - break; + switch (select) + { + case 0: + scanXmlFile(RADIO_STATION_XML_FILE); + CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); + paintLCD(); + break; + case 1: + readDir_ic(); + CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); + paintLCD(); + break; + case 2: + openSCbrowser(); + break; + default: + break; } update=true; } - else if ( shufflePlaylist() ) + else if (shufflePlaylist()) { update = true; } @@ -688,10 +730,10 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - &seconds, - 5, - LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, - LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); + &seconds, + 5, + LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, + LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); int res = secondsInput.exec(NULL,""); if (seconds != 0 && res!= menu_return::RETURN_EXIT_ALL) ff(seconds); @@ -699,7 +741,7 @@ int CAudioPlayerGui::show() } } } - else if ( (msg == CRCInput::RC_info) && (!m_playlist.empty()) ) + else if (msg == CRCInput::RC_info && !m_playlist.empty()) { pictureviewer = true; m_frameBuffer->Clear(); @@ -726,8 +768,7 @@ int CAudioPlayerGui::show() if (m_state != CAudioPlayerGui::STOP) { // jumping in streams not supported - if (m_key_level == 2 && - m_curr_audiofile.FileType == CFile::STREAM_AUDIO) + if (m_key_level == 2 && m_curr_audiofile.FileType == CFile::STREAM_AUDIO) { m_key_level = 0; } @@ -756,8 +797,10 @@ int CAudioPlayerGui::show() int w = 0; do { + //FIXME - remove fixed values + smsKey = m_SMSKeyInput.handleMsg(msg); - //printf(" new key: %c", smsKey); + //printf(" new key: %c", smsKey); /* show a hint box with current char (too slow at the moment?)*/ char selectedKey[1]; sprintf(selectedKey,"%c",smsKey); @@ -766,16 +809,14 @@ int CAudioPlayerGui::show() int h = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight(); w = std::max(w, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(selectedKey)); m_frameBuffer->paintBoxRel(x1 - 7, y1 - h - 5, w + 14, h + 10, COL_FRAME_PLUS_0, RADIUS_SMALL); - m_frameBuffer->paintBoxRel(x1 - 4, y1 - h - 3, w + 8, h + 6, COL_MENUCONTENTSELECTED_PLUS_0, RADIUS_SMALL); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP] - ->RenderString(x1,y1,w+1,selectedKey,COL_MENUCONTENTSELECTED_TEXT); + m_frameBuffer->paintBoxRel(x1 - 6, y1 - h - 4, w + 12, h + 8, COL_MENUCONTENTSELECTED_PLUS_0, RADIUS_SMALL); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(x1,y1,w+1,selectedKey,COL_MENUCONTENTSELECTED_TEXT); g_RCInput->getMsg_ms(&msg, &data, AUDIOPLAYERGUI_SMSKEY_TIMEOUT - 200); } while (CRCInput::isNumeric(msg) && !(m_playlist.empty())); - if (msg == CRCInput::RC_timeout - || msg == CRCInput::RC_nokey) + if (msg == CRCInput::RC_timeout || msg == CRCInput::RC_nokey) { //printf("selected key: %c\n",smsKey); selectTitle(smsKey); @@ -812,14 +853,16 @@ int CAudioPlayerGui::show() m_LastMode=data; } } - else if (msg == NeutrinoMessages::RECORD_START || + else if ( + msg == NeutrinoMessages::RECORD_START || msg == NeutrinoMessages::ZAPTO || msg == NeutrinoMessages::STANDBY_ON || msg == NeutrinoMessages::LEAVE_ALL || msg == NeutrinoMessages::SHUTDOWN || - ((msg == NeutrinoMessages::SLEEPTIMER) && !data)) + (msg == NeutrinoMessages::SLEEPTIMER && !data) + ) { - if(msg != NeutrinoMessages::RECORD_START ) + if (msg != NeutrinoMessages::RECORD_START) ret = menu_return::RETURN_EXIT_ALL; // Exit for Record/Zapto Timers loop = false; @@ -828,11 +871,11 @@ int CAudioPlayerGui::show() } else if (msg == NeutrinoMessages::EVT_TIMER) { - CNeutrinoApp::getInstance()->handleMsg( msg, data ); + CNeutrinoApp::getInstance()->handleMsg(msg, data); } else { - if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) + if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { ret = menu_return::RETURN_EXIT_ALL; loop = false; @@ -870,9 +913,11 @@ bool CAudioPlayerGui::playNext(bool allow_rotate) void CAudioPlayerGui::wantNextPlay() { - if ((m_state != CAudioPlayerGui::STOP) && + if ( + (m_state != CAudioPlayerGui::STOP) && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && - (!m_playlist.empty())) + (!m_playlist.empty()) + ) { if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) playNext(); @@ -947,12 +992,15 @@ bool CAudioPlayerGui::shufflePlaylist(void) void CAudioPlayerGui::addUrl2Playlist(const char *url, const char *name, const time_t bitrate) { - CAudiofileExt mp3( url, CFile::STREAM_AUDIO ); -// tmp = tmp.substr(0,tmp.length()-4); //remove .url -//printf("[addUrl2Playlist], name = %s, url = %s\n", name, url); - if (name != NULL) { + CAudiofileExt mp3(url, CFile::STREAM_AUDIO); + //tmp = tmp.substr(0,tmp.length()-4); //remove .url + //printf("[addUrl2Playlist], name = %s, url = %s\n", name, url); + if (name != NULL) + { mp3.MetaData.title = name; - } else { + } + else + { std::string tmp = mp3.Filename.substr(mp3.Filename.rfind('/')+1); mp3.MetaData.title = tmp; } @@ -973,7 +1021,7 @@ void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, cons printf("CAudioPlayerGui::processPlaylistUrl (%s, %s)\n", url, name); chunk.memory=NULL; /* we expect realloc(NULL, size) to work */ - chunk.size = 0; /* no data at this point */ + chunk.size = 0; /* no data at this point */ curl_global_init(CURL_GLOBAL_ALL); @@ -983,7 +1031,7 @@ void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, cons /* specify URL to get */ curl_easy_setopt(curl_handle, CURLOPT_URL, url); - /* send all data to this function */ + /* send all data to this function */ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); /* we pass our 'chunk' struct to the callback function */ @@ -1014,19 +1062,24 @@ void CAudioPlayerGui::processPlaylistUrl(const char *url, const char *name, cons */ long res_code; - if (curl_easy_getinfo(curl_handle, CURLINFO_HTTP_CODE/*CURLINFO_RESPONSE_CODE*/, &res_code ) == CURLE_OK) { - if (200 == res_code) { + if (curl_easy_getinfo(curl_handle, CURLINFO_HTTP_CODE/*CURLINFO_RESPONSE_CODE*/, &res_code) == CURLE_OK) + { + if (200 == res_code) + { //printf("\nchunk = %s\n", chunk.memory); std::istringstream iss; iss.str (std::string(chunk.memory, chunk.size)); char line[512]; char *ptr; - while (iss.rdstate() == std::ifstream::goodbit) { + while (iss.rdstate() == std::ifstream::goodbit) + { iss.getline(line, 512); - if (line[0] != '#') { + if (line[0] != '#') + { //printf("chunk: line = %s\n", line); ptr = strstr(line, "http://"); - if (ptr != NULL) { + if (ptr != NULL) + { char *tmp; // strip \n and \r characters from url tmp = strchr(line, '\r'); @@ -1065,7 +1118,7 @@ void CAudioPlayerGui::readDir_ic(void) curl_handle = curl_easy_init(); /* specify URL to get */ curl_easy_setopt(curl_handle, CURLOPT_URL, icecasturl.c_str()); - /* send all data to this function */ + /* send all data to this function */ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, CurlWriteToString); /* we pass our 'chunk' struct to the callback function */ curl_easy_setopt(curl_handle, CURLOPT_FILE, (void *)&answer); @@ -1092,7 +1145,7 @@ void CAudioPlayerGui::readDir_ic(void) { xmlDocPtr answer_parser = parseXml(answer.c_str()); scanBox->hide(); - scanXmlData(answer_parser, "server_name", "listen_url", "bitrate", true); + scanXmlData(answer_parser, "listen_url", "server_name", "bitrate", true); } else scanBox->hide(); @@ -1103,25 +1156,29 @@ void CAudioPlayerGui::readDir_ic(void) void CAudioPlayerGui::scanXmlFile(std::string filename) { xmlDocPtr answer_parser = parseXmlFile(filename.c_str()); - scanXmlData(answer_parser, "name", "url"); + scanXmlData(answer_parser, "url", "name"); } -void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, const char *urltag, - const char *bitratetag, bool usechild) +void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *urltag, const char *nametag, const char *bitratetag, bool usechild) { #define IC_typetag "server_type" - if (answer_parser != NULL) { + if (answer_parser != NULL) + { xmlNodePtr element = xmlDocGetRootElement(answer_parser); element = xmlChildrenNode(element); xmlNodePtr element_tmp = element; - if (element == NULL) { + if (element == NULL) + { printf("[openFilebrowser] No valid XML File.\n"); - } else { + } + else + { CProgressWindow progress; long maxProgress = 1; // count # of entries - while (element) { + while (element) + { maxProgress++; element = xmlNextNode(element); } @@ -1129,10 +1186,11 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, long listPos = -1; progress.setTitle(LOCALE_AUDIOPLAYER_LOAD_RADIO_STATIONS); progress.exec(this, ""); - neutrino_msg_t msg; + neutrino_msg_t msg; neutrino_msg_data_t data; g_RCInput->getMsg(&msg, &data, 0); - while (element && msg != CRCInput::RC_home) { + while (element && msg != CRCInput::RC_home) + { const char *ptr = NULL; const char *name = NULL; const char *url = NULL; @@ -1147,33 +1205,40 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, CVFD::getInstance()->setMode(CVFD::MODE_PROGRESSBAR); #endif // LCD_UPDATE - if (usechild) { + if (usechild) + { const char *type = NULL; xmlNodePtr child = xmlChildrenNode(element); - while (child) { + while (child) + { if (strcmp(xmlGetName(child), nametag) == 0) name = xmlGetData(child); else if (strcmp(xmlGetName(child), urltag) == 0) url = xmlGetData(child); else if (strcmp(xmlGetName(child), IC_typetag) == 0) type = xmlGetData(child); - else if (bitratetag && strcmp(xmlGetName(child), bitratetag) == 0) { + else if (bitratetag && strcmp(xmlGetName(child), bitratetag) == 0) + { ptr = xmlGetData(child); if (ptr) bitrate = atoi(ptr); } child = xmlNextNode(child); } - if(type){ - if (strcmp("audio/mpeg", type) == 0) skip = false; - else if (strcmp("application/ogg", type) == 0) skip = false; - else if (strcmp("mp3", type) == 0) skip = false; - else if (strcmp("application/mp3", type) == 0) skip = false; + if (type) + { + if (strcmp("audio/mpeg", type) == 0) skip = false; + else if (strcmp("application/ogg", type) == 0) skip = false; + else if (strcmp("mp3", type) == 0) skip = false; + else if (strcmp("application/mp3", type) == 0) skip = false; } - } else { + } + else + { url = xmlGetAttribute(element, urltag); name = xmlGetAttribute(element, nametag); - if (bitratetag) { + if (bitratetag) + { ptr = xmlGetAttribute(element, bitratetag); if (ptr) bitrate = atoi(ptr); @@ -1181,7 +1246,8 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, skip = false; } - if ((url != NULL) && !skip) { + if ((url != NULL) && !skip) + { progress.showStatusMessageUTF(url); //printf("Processing %s, %s\n", url, name); if (strstr(url, ".m3u") || strstr(url, ".pls")) @@ -1204,12 +1270,11 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag, bool CAudioPlayerGui::openFilebrowser(void) { bool result = false; - CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) - ? g_settings.network_nfs_audioplayerdir.c_str() : ""); + CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) ? g_settings.network_nfs_audioplayerdir.c_str() : ""); - filebrowser.Multi_Select = true; - filebrowser.Dirs_Selectable = true; - filebrowser.Filter = &audiofilefilter; + filebrowser.Multi_Select = true; + filebrowser.Dirs_Selectable = true; + filebrowser.Filter = &audiofilefilter; hide(); @@ -1244,16 +1309,17 @@ bool CAudioPlayerGui::openFilebrowser(void) CVFD::getInstance()->setMode(CVFD::MODE_PROGRESSBAR); #endif // LCD_UPDATE } - if ((files->getType() == CFile::FILE_CDR) - || (files->getType() == CFile::FILE_OGG) - || (files->getType() == CFile::FILE_MP3) - || (files->getType() == CFile::FILE_WAV) + if ( + (files->getType() == CFile::FILE_CDR) + || (files->getType() == CFile::FILE_OGG) + || (files->getType() == CFile::FILE_MP3) + || (files->getType() == CFile::FILE_WAV) #ifdef ENABLE_FFMPEGDEC - || (files->getType() == CFile::FILE_AAC) + || (files->getType() == CFile::FILE_AAC) #endif - || (files->getType() == CFile::FILE_FLAC) - || (files->getType() == CFile::FILE_FLV) - ) + || (files->getType() == CFile::FILE_FLAC) + || (files->getType() == CFile::FILE_FLV) + ) { CAudiofileExt audiofile(files->Name, files->getType()); @@ -1299,14 +1365,19 @@ bool CAudioPlayerGui::openFilebrowser(void) if (cLine[strlen(cLine)-1]=='\r') cLine[strlen(cLine)-1]=0; char *url = strstr(cLine, "http://"); - if (url != NULL) { + if (url != NULL) + { if (strstr(url, ".m3u") || strstr(url, ".pls")) processPlaylistUrl(url); else addUrl2Playlist(url, name, duration); - } else if ((url = strstr(cLine, "icy://")) != NULL) { + } + else if ((url = strstr(cLine, "icy://")) != NULL) + { addUrl2Playlist(url); - } else if ((url = strstr(cLine, "scast:://")) != NULL) { + } + else if ((url = strstr(cLine, "scast:://")) != NULL) + { addUrl2Playlist(url); } else @@ -1339,20 +1410,21 @@ bool CAudioPlayerGui::openFilebrowser(void) CFile playlistItem; playlistItem.Name = filename; CFile::FileType fileType = playlistItem.getType(); - if (fileType == CFile::FILE_CDR - || fileType == CFile::FILE_MP3 - || fileType == CFile::FILE_OGG - || fileType == CFile::FILE_WAV - || fileType == CFile::FILE_FLAC - || fileType == CFile::FILE_FLV - ) + if ( + fileType == CFile::FILE_CDR + || fileType == CFile::FILE_MP3 + || fileType == CFile::FILE_OGG + || fileType == CFile::FILE_WAV + || fileType == CFile::FILE_FLAC + || fileType == CFile::FILE_FLV + ) { CAudiofileExt audioFile(filename,fileType); addToPlaylist(audioFile); - } else + } + else { - printf("Audioplayer: file type (%d) is *not* supported in playlists\n(%s)\n", - fileType, filename.c_str()); + printf("Audioplayer: file type (%d) is *not* supported in playlists\n(%s)\n", fileType, filename.c_str()); } } } @@ -1378,18 +1450,19 @@ bool CAudioPlayerGui::openFilebrowser(void) printTimevalDiff(start,end); #endif //store last dir - if( (g_settings.network_nfs_audioplayerdir.size()) > m_Path.size() && g_settings.network_nfs_audioplayerdir != m_Path.c_str() ) + if (g_settings.network_nfs_audioplayerdir.size() > m_Path.size() && g_settings.network_nfs_audioplayerdir != m_Path.c_str()) g_settings.network_nfs_audioplayerdir = m_Path; result = true; } + m_idletime = time(NULL); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); paintLCD(); // if playlist is turned off -> start playing immediately if (!m_show_playlist && !m_playlist.empty()) play(m_selected); - return ( result); + return result; } bool CAudioPlayerGui::openSCbrowser(void) @@ -1400,9 +1473,9 @@ bool CAudioPlayerGui::openSCbrowser(void) CFileBrowser filebrowser(sc_base_dir, CFileBrowser::ModeSC); - filebrowser.Multi_Select = true; - filebrowser.Dirs_Selectable = true; - filebrowser.Filter = NULL;//&audiofilefilter; + filebrowser.Multi_Select = true; + filebrowser.Dirs_Selectable = true; + filebrowser.Filter = NULL;//&audiofilefilter; hide(); @@ -1423,7 +1496,7 @@ bool CAudioPlayerGui::openSCbrowser(void) m_Path = filebrowser.getCurrentDir(); CFileList::const_iterator files = filebrowser.getSelectedFiles().begin(); - neutrino_msg_t msg; + neutrino_msg_t msg; neutrino_msg_data_t data; g_RCInput->getMsg(&msg, &data, 0); for (; (files != filebrowser.getSelectedFiles().end()) && (msg != CRCInput::RC_home); ++files) @@ -1454,13 +1527,14 @@ bool CAudioPlayerGui::openSCbrowser(void) #endif result = true; } + m_idletime = time(NULL); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); paintLCD(); // if playlist is turned off -> start playing immediately if (!m_show_playlist && !m_playlist.empty()) play(m_selected); - return ( result); + return result; } void CAudioPlayerGui::hide() @@ -1468,10 +1542,8 @@ void CAudioPlayerGui::hide() // printf("hide(){\n"); if (m_visible) { - m_frameBuffer->paintBackgroundBoxRel(m_x - DETAILSLINE_WIDTH, m_y + m_title_height, - m_width + DETAILSLINE_WIDTH, m_height - m_title_height); - clearItemID3DetailsLine(); - m_frameBuffer->paintBackgroundBoxRel(m_x, m_y, m_width, m_title_height); + clearDetailsLine(); + m_frameBuffer->paintBackgroundBoxRel(m_x, m_y, m_width + OFFSET_SHADOW, m_height + OFFSET_SHADOW); m_visible = false; } } @@ -1481,7 +1553,7 @@ void CAudioPlayerGui::paintItem(int pos) if (!m_show_playlist) return; - int ypos = m_y + m_title_height + m_theight + pos*m_fheight; + int ypos = m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER + m_header_height + pos*m_item_height; unsigned int currpos = m_liststart + pos; bool i_selected = currpos == m_selected; @@ -1498,11 +1570,11 @@ void CAudioPlayerGui::paintItem(int pos) i_radius = RADIUS_LARGE; if (i_selected) - paintItemID3DetailsLine(pos); + paintDetailsLine(pos); if (i_radius) - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_fheight, COL_MENUCONTENT_PLUS_0); - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_fheight, bgcolor, i_radius); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, COL_MENUCONTENT_PLUS_0); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, bgcolor, i_radius); if (currpos < m_playlist.size()) { @@ -1511,23 +1583,22 @@ void CAudioPlayerGui::paintItem(int pos) std::string tmp = sNr; getFileInfoToDisplay(tmp, m_playlist[currpos]); - char dura[9]; + char dura[9] = {0}; if (m_inetmode) - snprintf(dura, 8, "%ldk", m_playlist[currpos].MetaData.total_time); + { + if (m_playlist[currpos].MetaData.total_time != 0) + snprintf(dura, 8, "%ldk", m_playlist[currpos].MetaData.total_time); + } else - snprintf(dura, 8, "%ld:%02ld", m_playlist[currpos].MetaData.total_time / 60, - m_playlist[currpos].MetaData.total_time % 60); - int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(dura) + 5; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + 10, ypos + m_fheight, m_width - 30 - w, - tmp, color, m_fheight); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + m_width - 15 - w, ypos + m_fheight, - w, dura, color, m_fheight); + snprintf(dura, 8, "%ld:%02ld", m_playlist[currpos].MetaData.total_time / 60, m_playlist[currpos].MetaData.total_time % 60); + + int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(dura); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + OFFSET_INNER_MID, ypos + m_item_height, m_width - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - w, tmp, color, m_item_height); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + m_width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, ypos + m_item_height, w, dura, color, m_item_height); if (currpos == m_selected) { if (m_state == CAudioPlayerGui::STOP) - CVFD::getInstance()->showAudioTrack(m_playlist[currpos].MetaData.artist, - m_playlist[currpos].MetaData.title, - m_playlist[currpos].MetaData.album); + CVFD::getInstance()->showAudioTrack(m_playlist[currpos].MetaData.artist, m_playlist[currpos].MetaData.title, m_playlist[currpos].MetaData.album); } } } @@ -1537,8 +1608,8 @@ void CAudioPlayerGui::paintHead() if (!m_show_playlist || m_screensaver) return; - CComponentsHeaderLocalized header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_MP3); - header.setCorner(RADIUS_MID, CORNER_TOP); + CComponentsHeader header(m_x, m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER, m_width, m_header_height, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_AUDIO); + header.enableShadow( CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); if (m_inetmode) header.setCaption(LOCALE_INETRADIO_NAME); @@ -1551,52 +1622,6 @@ void CAudioPlayerGui::paintHead() header.paint(CC_SAVE_SCREEN_NO); } -const struct button_label AudioPlayerButtons[][4] = -{ - { - { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP }, - { NEUTRINO_ICON_BUTTON_BACKWARD, LOCALE_AUDIOPLAYER_REWIND }, - { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE }, - { NEUTRINO_ICON_BUTTON_FORWARD , LOCALE_AUDIOPLAYER_FASTFORWARD }, - }, - { - { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE }, - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, - { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_DELETEALL }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_SHUFFLE }, - }, - { - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_JUMP_BACKWARDS }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_JUMP_FORWARDS }, - }, - { - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_JUMP_BACKWARDS }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_JUMP_FORWARDS }, - }, - { - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_SAVE_PLAYLIST }, - { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_BUTTON_SELECT_TITLE_BY_ID }, - }, - { - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_SAVE_PLAYLIST }, - { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_BUTTON_SELECT_TITLE_BY_NAME }, - }, - { - { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP }, - { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE }, - }, - { - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_INETRADIO_NAME }, - }, - { - { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE }, - { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD }, - { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_DELETEALL }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_INETRADIO_NAME }, - }, -}; - void CAudioPlayerGui::paintFoot() { if (m_screensaver) @@ -1604,107 +1629,129 @@ void CAudioPlayerGui::paintFoot() const struct button_label SecondLineButtons[3] = { - { NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY }, - { NEUTRINO_ICON_BUTTON_HELP , LOCALE_AUDIOPLAYER_KEYLEVEL }, - { NEUTRINO_ICON_BUTTON_INFO , LOCALE_PICTUREVIEWER_HEAD}, + { NEUTRINO_ICON_BUTTON_OKAY, LOCALE_AUDIOPLAYER_PLAY }, + { NEUTRINO_ICON_BUTTON_HELP, LOCALE_AUDIOPLAYER_KEYLEVEL }, + { NEUTRINO_ICON_BUTTON_INFO, LOCALE_PICTUREVIEWER_HEAD } }; - int top; - int c_rad_mid = RADIUS_MID; - if (m_show_playlist) - top = m_y + (m_height - m_info_height - 2 * m_buttonHeight); - else - top = m_y + (m_height - 2 * m_buttonHeight); + int radius = RADIUS_LARGE; + int button_y = m_y + m_height - OFFSET_SHADOW - m_info_height - OFFSET_INTER - OFFSET_SHADOW - 2*m_button_height; + int button_x = m_x; + int button_width = m_width; - m_frameBuffer->paintBoxRel(m_x, top, m_width, 2 * m_buttonHeight, COL_MENUFOOT_PLUS_0, c_rad_mid, (m_show_playlist ? CORNER_BOTTOM : CORNER_ALL)); - // why? m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_MENUFOOT_PLUS_0); + // ensure to get round corners in footer + if (!m_show_playlist && radius) + { + button_x += radius; + button_width -= 2*radius; + } + + // shadow + m_frameBuffer->paintBoxRel(m_x + OFFSET_SHADOW, button_y + OFFSET_SHADOW, m_width, 2*m_button_height, COL_SHADOW_PLUS_0, radius, (m_show_playlist ? CORNER_BOTTOM : CORNER_ALL)); + m_frameBuffer->paintBoxRel(m_x, button_y, m_width, 2*m_button_height, COL_MENUFOOT_PLUS_0, radius, (m_show_playlist ? CORNER_BOTTOM : CORNER_ALL)); - int bwidth = m_width - (2*c_rad_mid); if (!m_playlist.empty()) - ::paintButtons(m_x + c_rad_mid, top+m_buttonHeight, bwidth, 3, SecondLineButtons, bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y + m_button_height, button_width, 3, SecondLineButtons, button_width, m_button_height); if (m_key_level == 0) { if (m_playlist.empty()) { if (m_inetmode) - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[7], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[7], button_width, m_button_height); else - ::paintButtons(m_x + c_rad_mid, top, bwidth, 1, &(AudioPlayerButtons[7][0]), bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 1, &(AudioPlayerButtons[7][0]), button_width, m_button_height); } else if (m_inetmode) - ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[8], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 4, AudioPlayerButtons[8], button_width, m_button_height); else - ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[1], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 4, AudioPlayerButtons[1], button_width, m_button_height); } else if (m_key_level == 1) { if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) - ::paintButtons(m_x + c_rad_mid, top, bwidth, 4, AudioPlayerButtons[0], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 4, AudioPlayerButtons[0], button_width, m_button_height); else - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[6], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[6], button_width, m_button_height); } - else - { // key_level == 2 + else // key_level == 2 + { if (m_state == CAudioPlayerGui::STOP) { if (m_select_title_by_name) - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[5], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[5], button_width, m_button_height); else - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[4], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[4], button_width, m_button_height); } else { if (m_select_title_by_name) - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[3], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[3], button_width, m_button_height); else - ::paintButtons(m_x + c_rad_mid, top, bwidth, 2, AudioPlayerButtons[2], bwidth, m_buttonHeight); + ::paintButtons(button_x, button_y, button_width, 2, AudioPlayerButtons[2], button_width, m_button_height); } } } void CAudioPlayerGui::paintCover() { - int c_rad_mid = RADIUS_MID; - int title_height = m_title_height; const CAudioMetaData meta = CAudioPlayer::getInstance()->getMetaData(); - if (!m_show_playlist) // no playlist -> smaller Info-Box - title_height -= m_fheight; - std::string cover = m_curr_audiofile.Filename.substr(0, m_curr_audiofile.Filename.rfind('/')) + "/folder.jpg"; if (!meta.cover.empty()) cover = meta.cover; if (access(cover.c_str(), F_OK) == 0) - g_PicViewer->DisplayImage(cover, m_x + 2 + c_rad_mid/2, m_y + 2 + c_rad_mid/2, title_height - 14 - c_rad_mid, title_height - 14 - c_rad_mid, m_frameBuffer->TM_NONE); + { + int cover_x = m_x + OFFSET_INNER_MID; + int cover_y = m_y + OFFSET_INNER_SMALL; + m_cover_width = 0; + CComponentsPicture *cover_object = new CComponentsPicture(cover_x, cover_y, cover); + if (cover_object) + { + cover_object->doPaintBg(false); + cover_object->SetTransparent(CFrameBuffer::TM_BLACK); + cover_object->setHeight(m_title_height - 2*OFFSET_INNER_SMALL, true); + cover_object->paint(); + + m_cover_width = cover_object->getWidth() + OFFSET_INNER_MID; + } + } } -void CAudioPlayerGui::paintInfo() +void CAudioPlayerGui::paintTitleBox() { if (m_screensaver) return; - int c_rad_mid = RADIUS_MID; - int title_height = m_title_height; - if (m_state == CAudioPlayerGui::STOP && m_show_playlist) - m_frameBuffer->paintBackgroundBoxRel(m_x, m_y, m_width, m_title_height); + { + if (m_titlebox) + { + m_titlebox->kill(); + delete m_titlebox; m_titlebox = NULL; + } + } else { - if (!m_show_playlist) // no playlist -> smaller Info-Box - title_height -= m_fheight; - - m_frameBuffer->paintBoxRel(m_x + 1, m_y + 1 , m_width - 2, title_height - 12, COL_MENUCONTENTSELECTED_PLUS_0, c_rad_mid); - m_frameBuffer->paintBoxFrame(m_x, m_y, m_width, title_height - 10, 2, COL_FRAME_PLUS_0, c_rad_mid); - + // title box + if (!m_titlebox) + { + m_titlebox = new CComponentsShapeSquare(m_x, m_y, m_width, m_title_height, NULL, CC_SHADOW_ON); + m_titlebox->enableFrame(true, FRAME_WIDTH_MIN); + m_titlebox->setCorner(RADIUS_LARGE); + } + m_titlebox->paint(false); paintCover(); // first line (Track number) std::string tmp; - if (m_inetmode) { + if (m_inetmode) + { tmp = m_curr_audiofile.MetaData.album; - } else { + } + else + { char sNr[20]; sprintf(sNr, ": %2d", m_current + 1); tmp = g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYING); @@ -1712,11 +1759,10 @@ void CAudioPlayerGui::paintInfo() } int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp); - int xstart = (m_width - w) / 2; - if (xstart < 10) - xstart = 10; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + xstart, m_y + 4 + 1*m_fheight, m_width - 20, - tmp, COL_MENUCONTENTSELECTED_TEXT); + int xstart = (m_width - w)/2; + if (xstart < OFFSET_INNER_MID + m_cover_width) + xstart = OFFSET_INNER_MID + m_cover_width; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + xstart, m_y + OFFSET_INNER_SMALL + 1*m_item_height, m_width - OFFSET_INNER_MID - xstart, tmp, COL_MENUHEAD_TEXT); //caption "current track" // second line (Artist/Title...) GetMetaData(m_curr_audiofile); @@ -1728,27 +1774,27 @@ void CAudioPlayerGui::paintInfo() else if (g_settings.audioplayer_display == TITLE_ARTIST) { tmp = m_curr_audiofile.MetaData.title; - tmp += " / "; + tmp += " - "; tmp += m_curr_audiofile.MetaData.artist; } - else //if(g_settings.audioplayer_display == ARTIST_TITLE) + else //if (g_settings.audioplayer_display == ARTIST_TITLE) { tmp = m_curr_audiofile.MetaData.artist; - tmp += " / "; + tmp += " - "; tmp += m_curr_audiofile.MetaData.title; } w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp); - xstart=(m_width-w)/2; - if (xstart < 10) - xstart=10; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x+xstart, m_y +4+ 2*m_fheight, m_width- 20, tmp, COL_MENUCONTENTSELECTED_TEXT); + xstart = (m_width - w)/2; + if (xstart < OFFSET_INNER_MID + m_cover_width) + xstart = OFFSET_INNER_MID + m_cover_width; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + xstart, m_y + OFFSET_INNER_SMALL + 2*m_item_height, m_width - OFFSET_INNER_MID - xstart, tmp, COL_MENUHEAD_TEXT); //artist - title // reset so fields get painted always m_metainfo.clear(); m_time_total = 0; m_time_played = 0; - updateMetaData(); + updateMetaData(); updateTimes(true); } } @@ -1758,66 +1804,64 @@ void CAudioPlayerGui::paint() if (m_show_playlist) { unsigned int tmp_max = m_listmaxshow; - if(!tmp_max) + if (!tmp_max) tmp_max = 1; m_liststart = (m_selected / tmp_max) * m_listmaxshow; paintHead(); for (unsigned int count=0; countpaintBoxRel(m_x + m_width - 15, ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); + // scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, m_playlist.size(), m_listmaxshow, m_selected); - int sbc = ((m_playlist.size() - 1) / tmp_max) + 1; - int sbs = (m_selected / tmp_max); - if (sbc < 1) - sbc = 1; - - m_frameBuffer->paintBoxRel(m_x + m_width - 13, ypos + 2 + sbs*(sb-4)/sbc , 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0, RADIUS_SMALL); + paintScrollBar(m_x + m_width - SCROLLBAR_WIDTH, m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER + m_header_height, SCROLLBAR_WIDTH, m_item_height*m_listmaxshow, total_pages, current_page, CC_SHADOW_ON); } - paintInfo(); + paintTitleBox(); paintFoot(); m_visible = true; } -void CAudioPlayerGui::clearItemID3DetailsLine () +void CAudioPlayerGui::clearDetailsLine() { - paintItemID3DetailsLine(-1); + paintDetailsLine(-1); } -void CAudioPlayerGui::paintItemID3DetailsLine (int pos) +void CAudioPlayerGui::paintDetailsLine(int pos) { - int xpos = m_x - DETAILSLINE_WIDTH; - int ypos1 = m_y + m_title_height + m_theight + pos*m_fheight; - int ypos2 = m_y + (m_height - m_info_height) + OFFSET_INTER; - int ypos1a = ypos1 + (m_fheight / 2); + int xpos = m_x - DETAILSLINE_WIDTH; + int ypos1 = m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER + m_header_height + pos*m_item_height; + int ypos2 = m_y + (m_height - OFFSET_SHADOW - m_info_height); + int ypos1a = ypos1 + (m_item_height / 2); int ypos2a = ypos2 + (m_info_height / 2); // clear details line - if (dline != NULL) + if (m_detailsline != NULL) { - dline->kill(); - dline = NULL; + m_detailsline->kill(); + m_detailsline = NULL; } // paint Line if detail info (and not valid list pos) and info box if (!m_playlist.empty() && (pos >= 0)) { //details line - if (dline == NULL) - dline = new CComponentsDetailsLine(xpos, ypos1a, ypos2a, m_fheight/2, m_info_height-RADIUS_LARGE*2); - dline->paint(false); + if (m_detailsline == NULL) + m_detailsline = new CComponentsDetailsLine(xpos, ypos1a, ypos2a, m_item_height/2, m_info_height - RADIUS_LARGE*2); + m_detailsline->paint(false); // paint id3 infobox - if (ibox == NULL){ - ibox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height); - ibox->setFrameThickness(2); - ibox->setCorner(RADIUS_LARGE); - ibox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); - ibox->setTextColor(COL_MENUCONTENTDARK_TEXT); - ibox->forceTextPaint(false); + if (m_infobox == NULL) + { + m_infobox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height); + m_infobox->setFrameThickness(2); + m_infobox->setCorner(RADIUS_LARGE); + m_infobox->setColorFrame(COL_FRAME_PLUS_0); + m_infobox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); + m_infobox->enableShadow(CC_SHADOW_ON, -1, true); + m_infobox->forceTextPaint(false); } //title @@ -1844,15 +1888,18 @@ void CAudioPlayerGui::paintItemID3DetailsLine (int pos) text_info += ')'; } - ibox->setText(text_info, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO], COL_MENUCONTENT_TEXT); - ibox->paint(false); + // 'simulate' a second line; maybe usefull for some more informations e.g. url or so + text_info += "\n "; + + m_infobox->setText(text_info, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO], COL_MENUCONTENTDARK_TEXT); + m_infobox->paint(false); } else { - if (dline != NULL) - dline->kill(); - if (ibox != NULL) - ibox->kill(); + if (m_detailsline != NULL) + m_detailsline->kill(); + if (m_infobox != NULL) + m_infobox->kill(); } } @@ -1866,7 +1913,7 @@ void CAudioPlayerGui::stop() //LCD paintLCD(); //Display - paintInfo(); + paintTitleBox(); m_key_level = 0; paintFoot(); } @@ -1877,9 +1924,11 @@ void CAudioPlayerGui::stop() void CAudioPlayerGui::pause() { - if (m_state == CAudioPlayerGui::PLAY - || m_state == CAudioPlayerGui::FF - || m_state == CAudioPlayerGui::REV) + if ( + m_state == CAudioPlayerGui::PLAY + || m_state == CAudioPlayerGui::FF + || m_state == CAudioPlayerGui::REV + ) { m_state = CAudioPlayerGui::PAUSE; CAudioPlayer::getInstance()->pause(); @@ -1899,9 +1948,11 @@ void CAudioPlayerGui::ff(unsigned int seconds) m_state = CAudioPlayerGui::PLAY; CAudioPlayer::getInstance()->ff(seconds); } - else if (m_state == CAudioPlayerGui::PLAY - || m_state == CAudioPlayerGui::PAUSE - || m_state == CAudioPlayerGui::REV) + else if ( + m_state == CAudioPlayerGui::PLAY + || m_state == CAudioPlayerGui::PAUSE + || m_state == CAudioPlayerGui::REV + ) { m_state = CAudioPlayerGui::FF; CAudioPlayer::getInstance()->ff(seconds); @@ -1916,9 +1967,11 @@ void CAudioPlayerGui::rev(unsigned int seconds) m_state = CAudioPlayerGui::PLAY; CAudioPlayer::getInstance()->rev(seconds); } - else if (m_state == CAudioPlayerGui::PLAY - || m_state == CAudioPlayerGui::PAUSE - || m_state == CAudioPlayerGui::FF) + else if ( + m_state == CAudioPlayerGui::PLAY + || m_state == CAudioPlayerGui::PAUSE + || m_state == CAudioPlayerGui::FF + ) { m_state = CAudioPlayerGui::REV; CAudioPlayer::getInstance()->rev(seconds); @@ -1983,7 +2036,7 @@ void CAudioPlayerGui::play(unsigned int pos) //LCD paintLCD(); // Display - paintInfo(); + paintTitleBox(); m_key_level = 1; paintFoot(); } @@ -2010,27 +2063,25 @@ void CAudioPlayerGui::updateMetaData() bool updateLcd = false; bool updateScreen = false; - if (m_state == CAudioPlayerGui::STOP || !m_show_playlist) + if (m_state == CAudioPlayerGui::STOP) return; - if ( CAudioPlayer::getInstance()->hasMetaDataChanged() - || m_metainfo.empty() ) + if (CAudioPlayer::getInstance()->hasMetaDataChanged() || m_metainfo.empty()) { - const CAudioMetaData meta = - CAudioPlayer::getInstance()->getMetaData(); + const CAudioMetaData meta = CAudioPlayer::getInstance()->getMetaData(); std::stringstream info; info.precision(3); - if ( meta.bitrate > 0 ) + if (meta.bitrate > 0) { info << " / "; - if ( meta.vbr ) + if (meta.vbr) info << "VBR "; info << meta.bitrate/1000 << "kbps"; } - if ( meta.samplerate > 0 ) + if (meta.samplerate > 0) info << " / " << meta.samplerate/1000 << "." << (meta.samplerate/100)%10 <<"kHz"; m_metainfo = meta.type_info + info.str(); @@ -2054,7 +2105,7 @@ void CAudioPlayerGui::updateMetaData() updateLcd = true; } - if (!meta.sc_station.empty() && meta.sc_station != m_curr_audiofile.MetaData.album) + if (!meta.sc_station.empty() && meta.sc_station != m_curr_audiofile.MetaData.album) { m_curr_audiofile.MetaData.album = meta.sc_station; updateLcd = true; @@ -2071,15 +2122,17 @@ void CAudioPlayerGui::updateMetaData() paintLCD(); if (updateScreen) - paintInfo(); + paintTitleBox(); if (updateMeta || updateScreen) { - m_frameBuffer->paintBoxRel(m_x + 10 + m_title_height, m_y + 4 + 2*m_fheight, m_width - 20 - m_title_height, m_sheight, COL_MENUCONTENTSELECTED_PLUS_0); - int xstart = ((m_width - 20 - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(m_metainfo))/2)+10; - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL] - ->RenderString(m_x + xstart, m_y + 4 + 2*m_fheight + m_sheight, - m_width- 2*xstart, m_metainfo, COL_MENUCONTENTSELECTED_TEXT); + m_frameBuffer->paintBoxRel(m_x + OFFSET_INNER_MID + m_cover_width, m_y + OFFSET_INNER_SMALL + 2*m_item_height + OFFSET_INNER_SMALL, m_width - 2*OFFSET_INNER_MID - m_cover_width, m_meta_height, m_titlebox->getColorBody()); + + int w = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(m_metainfo); + int xstart = (m_width - w)/2; + if (xstart < OFFSET_INNER_MID) + xstart = OFFSET_INNER_MID; + g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(m_x + xstart, m_y + OFFSET_INNER_SMALL + 2*m_item_height + OFFSET_INNER_SMALL + m_meta_height, m_width - 2*xstart, m_metainfo, COL_MENUHEAD_TEXT); } } @@ -2108,35 +2161,42 @@ void CAudioPlayerGui::updateTimes(const bool force) } if (!m_screensaver) { - char tot_time[11]; - snprintf(tot_time, 10, " / %ld:%02ld", m_time_total / 60, m_time_total % 60); - char tmp_time[8]; - snprintf(tmp_time, 7, "%ld:00", m_time_total / 60); - char play_time[8]; - snprintf(play_time, 7, "%ld:%02ld", m_time_played / 60, m_time_played % 60); + char total_time[11]; + snprintf(total_time, 10, " / %ld:%02ld", m_time_total / 60, m_time_total % 60); + char played_time[8]; + snprintf(played_time, 7, "%ld:%02ld", m_time_played / 60, m_time_played % 60); - int w1 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tot_time); - int w2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp_time); + int w_total_time = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(total_time); + int w_faked_time = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("000:00"); + int w_played_time = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(played_time); - if (updateTotal) + // in inetmode we havn't a total_time + if (m_inetmode) + w_total_time = 0; + + int x_total_time = m_x + m_width - OFFSET_INNER_MID - w_total_time - 2*m_titlebox->getFrameThickness(); + // played time offset to align this value on the right side + int o_played_time = std::max(w_faked_time - w_played_time, 0); + int x_faked_time = m_x + m_width - OFFSET_INNER_MID - w_total_time - w_faked_time; + int x_played_time = x_faked_time + o_played_time; + int y_times = m_y + OFFSET_INNER_SMALL; + + if (updateTotal && !m_inetmode) { - m_frameBuffer->paintBoxRel(m_x + m_width - w1 - 10, m_y + 4, w1 + 4, - m_fheight, COL_MENUCONTENTSELECTED_PLUS_0); + m_frameBuffer->paintBoxRel(x_total_time, y_times, w_total_time + OFFSET_INNER_MID, m_item_height, m_titlebox->getColorBody()); if (m_time_total > 0) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + m_width - w1 - 10, m_y + 4 + m_fheight, - w1, tot_time, COL_MENUCONTENTSELECTED_TEXT); + { + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x_total_time, y_times + m_item_height, w_total_time, total_time, COL_MENUHEAD_TEXT); //total time + } } if (updatePlayed || (m_state == CAudioPlayerGui::PAUSE)) { - //m_frameBuffer->paintBoxRel(m_x + m_width - w1 - w2 - 15, m_y + 4, w2 + 4, m_fheight, - m_frameBuffer->paintBoxRel(m_x + m_width - w1 - w2 - 16, m_y + 4, w2 + 5, m_fheight, - COL_MENUCONTENTSELECTED_PLUS_0); + m_frameBuffer->paintBoxRel(x_faked_time, y_times, w_faked_time, m_item_height, m_titlebox->getColorBody()); struct timeval tv; gettimeofday(&tv, NULL); if ((m_state != CAudioPlayerGui::PAUSE) || (tv.tv_sec & 1)) { - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(m_x + m_width - w1 - w2 - 11, m_y + 4 + m_fheight, - w2+4, play_time, COL_MENUCONTENTSELECTED_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x_played_time, y_times + m_item_height, w_played_time, played_time, COL_MENUHEAD_TEXT); //elapsed time } } } @@ -2151,32 +2211,28 @@ void CAudioPlayerGui::paintLCD() { switch (m_state) { - case CAudioPlayerGui::STOP: - CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_STOP); - CVFD::getInstance()->showAudioProgress(0); - break; - case CAudioPlayerGui::PLAY: - CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_PLAY); - CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, - m_curr_audiofile.MetaData.album); - if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO && m_time_total != 0) - CVFD::getInstance()->showAudioProgress(uint8_t(100 * m_time_played / m_time_total)); - break; - case CAudioPlayerGui::PAUSE: - CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_PAUSE); - CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, - m_curr_audiofile.MetaData.album); - break; - case CAudioPlayerGui::FF: - CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_FF); - CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, - m_curr_audiofile.MetaData.album); - break; - case CAudioPlayerGui::REV: - CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_REV); - CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, - m_curr_audiofile.MetaData.album); - break; + case CAudioPlayerGui::STOP: + CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_STOP); + CVFD::getInstance()->showAudioProgress(0); + break; + case CAudioPlayerGui::PLAY: + CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_PLAY); + CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, m_curr_audiofile.MetaData.album); + if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO && m_time_total != 0) + CVFD::getInstance()->showAudioProgress(uint8_t(100 * m_time_played / m_time_total)); + break; + case CAudioPlayerGui::PAUSE: + CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_PAUSE); + CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, m_curr_audiofile.MetaData.album); + break; + case CAudioPlayerGui::FF: + CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_FF); + CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, m_curr_audiofile.MetaData.album); + break; + case CAudioPlayerGui::REV: + CVFD::getInstance()->showAudioPlayMode(CVFD::AUDIO_MODE_REV); + CVFD::getInstance()->showAudioTrack(m_curr_audiofile.MetaData.artist, m_curr_audiofile.MetaData.title, m_curr_audiofile.MetaData.album); + break; } } void CAudioPlayerGui::screensaver(bool on) @@ -2199,15 +2255,13 @@ void CAudioPlayerGui::GetMetaData(CAudiofileExt &File) bool ret = 1; if (File.FileType != CFile::STREAM_AUDIO && !File.MetaData.bitrate) - ret = CAudioPlayer::getInstance()->readMetaData( &File, - m_state != CAudioPlayerGui::STOP && - !g_settings.audioplayer_highprio); + ret = CAudioPlayer::getInstance()->readMetaData(&File, m_state != CAudioPlayerGui::STOP && !g_settings.audioplayer_highprio); - if (!ret || (File.MetaData.artist.empty() && File.MetaData.title.empty() )) + if (!ret || (File.MetaData.artist.empty() && File.MetaData.title.empty())) { //Set from Filename std::string tmp = File.Filename.substr(File.Filename.rfind('/') + 1); - tmp = tmp.substr(0,tmp.length()-4); //remove extension (.mp3) + tmp = tmp.substr(0,tmp.length() - 4); //remove extension (.mp3) std::string::size_type i = tmp.rfind(" - "); if (i != std::string::npos) { // Trennzeichen " - " gefunden @@ -2226,11 +2280,13 @@ void CAudioPlayerGui::GetMetaData(CAudiofileExt &File) File.MetaData.title = tmp; } File.MetaData.artist = FILESYSTEM_ENCODING_TO_UTF8_STRING(File.MetaData.artist); - File.MetaData.title = FILESYSTEM_ENCODING_TO_UTF8_STRING(File.MetaData.title ); + File.MetaData.title = FILESYSTEM_ENCODING_TO_UTF8_STRING(File.MetaData.title); } } -bool CAudioPlayerGui::getNumericInput(neutrino_msg_t& msg, int& val) { +bool CAudioPlayerGui::getNumericInput(neutrino_msg_t& msg, int& val) +{ + //FIXME - remove fixed values neutrino_msg_data_t data; int x1 = (g_settings.screen_EndX - g_settings.screen_StartX) / 2 + g_settings.screen_StartX - 50; @@ -2238,12 +2294,13 @@ bool CAudioPlayerGui::getNumericInput(neutrino_msg_t& msg, int& val) { char str[11]; do { + val = val * 10 + CRCInput::getNumericValue(msg); sprintf(str, "%d", val); int w = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(str); int h = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight(); m_frameBuffer->paintBoxRel(x1 - 7, y1 - h - 5, w + 14, h + 10, COL_FRAME_PLUS_0); - m_frameBuffer->paintBoxRel(x1 - 4, y1 - h - 3, w + 8, h + 6, COL_MENUCONTENTSELECTED_PLUS_0); + m_frameBuffer->paintBoxRel(x1 - 6, y1 - h - 4, w + 12, h + 8, COL_MENUCONTENTSELECTED_PLUS_0); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(x1, y1, w + 1, str, COL_MENUCONTENTSELECTED_TEXT); while (true) { @@ -2267,7 +2324,8 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &fileInfo, CAudiofileExt std::string artist; std::string title; - if (!m_inetmode) { + if (!m_inetmode) + { artist ="Artist?"; title = "Title?"; } @@ -2286,7 +2344,7 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &fileInfo, CAudiofileExt if (!title.empty() && !artist.empty()) fileInfo += ", "; fileInfo += artist; } - else //if(g_settings.audioplayer_display == ARTIST_TITLE) + else //if (g_settings.audioplayer_display == ARTIST_TITLE) { fileInfo += artist; if (!title.empty() && !artist.empty()) fileInfo += ", "; @@ -2310,10 +2368,12 @@ void CAudioPlayerGui::getFileInfoToDisplay(std::string &fileInfo, CAudiofileExt void CAudioPlayerGui::addToPlaylist(CAudiofileExt &file) { //printf("add2Playlist: %s\n", file.Filename.c_str()); - if (m_select_title_by_name) { + if (m_select_title_by_name) + { std::string t = ""; getFileInfoToDisplay(t,file); - } else + } + else GetMetaData(file); m_playlist.push_back(file); @@ -2333,7 +2393,6 @@ void CAudioPlayerGui::removeFromPlaylist(long pos) if (m_select_title_by_name) { - #ifdef AUDIOPLAYER_TIME_DEBUG timeval start; gettimeofday(&start,NULL); @@ -2356,12 +2415,10 @@ void CAudioPlayerGui::removeFromPlaylist(long pos) // decrease position information for all titles with a position // behind item to delete long p = 0; - for (CTitle2Pos::iterator title=m_title2Pos.begin(); - title!=m_title2Pos.end(); ++title) + for (CTitle2Pos::iterator title=m_title2Pos.begin(); title!=m_title2Pos.end(); ++title) { CPosList newList; - for (CPosList::iterator posIt=title->second.begin(); - posIt!=title->second.end(); ++posIt) + for (CPosList::iterator posIt=title->second.begin(); posIt!=title->second.end(); ++posIt) { p = *(posIt); if (*posIt > pos) @@ -2398,7 +2455,7 @@ void CAudioPlayerGui::selectTitle(unsigned char selectionChar) } else { - if ( !it->second.empty() ) + if (!it->second.empty()) { i = *(it->second.begin()); //printf("using begin i: %ld\n",i); @@ -2435,13 +2492,11 @@ void CAudioPlayerGui::selectTitle(unsigned char selectionChar) void CAudioPlayerGui::printSearchTree() { - for (CTitle2Pos::iterator it=m_title2Pos.begin(); - it!=m_title2Pos.end(); ++it) + for (CTitle2Pos::iterator it=m_title2Pos.begin(); it!=m_title2Pos.end(); ++it) { printf("key: %c\n",it->first); long pos=-1; - for (CPosList::iterator it2=it->second.begin(); - it2!=it->second.end(); ++it2) + for (CPosList::iterator it2=it->second.begin(); it2!=it->second.end(); ++it2) { pos++; printf(" val: %ld ",*it2); @@ -2454,9 +2509,8 @@ void CAudioPlayerGui::printSearchTree() void CAudioPlayerGui::buildSearchTree() { - - // printf("before\n"); - // printSearchTree(); + //printf("before\n"); + //printSearchTree(); #ifdef AUDIOPLAYER_TIME_DEBUG timeval start; @@ -2472,15 +2526,13 @@ void CAudioPlayerGui::buildSearchTree() m_title2Pos.clear(); long listPos = -1; - for (CAudioPlayList::iterator it=m_playlist.begin(); - it!=m_playlist.end(); ++it) + for (CAudioPlayList::iterator it=m_playlist.begin(); it!=m_playlist.end(); ++it) { listPos++; progress.showStatus(100*listPos / maxProgress); progress.showStatusMessageUTF(it->Filename); unsigned char firstChar = getFirstChar(*it); - const std::pair item = - m_title2Pos.insert(CTitle2PosItem(firstChar,CPosList())); + const std::pair item = m_title2Pos.insert(CTitle2PosItem(firstChar,CPosList())); item.first->second.insert(listPos); } progress.hide(); @@ -2492,7 +2544,7 @@ void CAudioPlayerGui::buildSearchTree() printf("searchtree took: "); printTimevalDiff(start,end); #endif - // printf("after:\n"); + //printf("after:\n"); //printSearchTree(); } @@ -2510,7 +2562,6 @@ unsigned char CAudioPlayerGui::getFirstChar(CAudiofileExt &file) #ifdef AUDIOPLAYER_TIME_DEBUG void CAudioPlayerGui::printTimevalDiff(timeval &start, timeval &end) { - long secs = end.tv_sec - start.tv_sec; long usecs = end.tv_usec -start.tv_usec; if (usecs < 0) @@ -2609,17 +2660,15 @@ void CAudioPlayerGui::savePlaylist() // an error occured const int msgsize = 255; char msg[msgsize] = ""; - snprintf(msg, - msgsize, - "%s\n%s", - g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEERROR_MSG), - absPlaylistFilename.c_str()); + snprintf(msg, msgsize, + "%s\n%s", + g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEERROR_MSG), + absPlaylistFilename.c_str()); DisplayErrorMessage(msg); // refresh view this->paint(); - std::cout << "CAudioPlayerGui: could not create play list file " - << absPlaylistFilename << std::endl; + std::cout << "CAudioPlayerGui: could not create play list file " << absPlaylistFilename << std::endl; return; } // writing .m3u file @@ -2628,8 +2677,7 @@ void CAudioPlayerGui::savePlaylist() CAudioPlayList::const_iterator it; for (it = m_playlist.begin(); it!=m_playlist.end(); ++it) { - playlistFile << "#EXTINF:" << it->MetaData.total_time << "," - << it->MetaData.artist << " - " << it->MetaData.title << std::endl; + playlistFile << "#EXTINF:" << it->MetaData.total_time << "," << it->MetaData.artist << " - " << it->MetaData.title << std::endl; if (m_inetmode) playlistFile << it->Filename << std::endl; else @@ -2644,14 +2692,11 @@ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) { char msg[filename.length() + 127]; - snprintf(msg, - filename.length() + 126, - "%s\n%s", - g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG), - filename.c_str()); - bool res = (ShowMsg(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, - msg,CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) - == CMsgBox::mbrYes); + snprintf(msg, filename.length() + 126, + "%s\n%s", + g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG), + filename.c_str()); + bool res = (ShowMsg(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, msg, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes); this->paint(); return res; } @@ -2664,8 +2709,8 @@ std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir, int length = fromDir.length() < absFilename.length() ? fromDir.length() : absFilename.length(); int lastSlash = 0; // find common prefix for both paths - // fromDir: /foo/bar/angle/1 (length: 16) - // absFilename: /foo/bar/devil/2/fire.mp3 (length: 19) + // fromDir: /foo/bar/angle/1 (length: 16) + // absFilename: /foo/bar/devil/2/fire.mp3 (length: 19) // -> /foo/bar/ is prefix, lastSlash will be 8 for (int i=0; i. */ #ifndef __audioplayergui__ @@ -55,212 +46,210 @@ typedef std::pair CTitle2PosItem; class CFrameBuffer; class CAudiofileExt : public CAudiofile { -public: + public: + CAudiofileExt(); - CAudiofileExt(); + CAudiofileExt(std::string name, CFile::FileType type); - CAudiofileExt(std::string name, CFile::FileType type); + CAudiofileExt(const CAudiofileExt& src); - CAudiofileExt(const CAudiofileExt& src); + void operator=(const CAudiofileExt& src); - void operator=(const CAudiofileExt& src); - - - char firstChar; + char firstChar; }; typedef std::vector CAudioPlayList; class RandomNumber { - public: - RandomNumber() - { - std::srand(time(0)); - } + public: + RandomNumber() { std::srand(time(0)); } - int operator()(int n){ - return std::rand() / (1.0 + RAND_MAX) * n; - } + int operator()(int n) { return std::rand() / (1.0 + RAND_MAX) * n; } }; class CAudioPlayerGui : public CMenuTarget { - public: - enum State - { - PLAY=0, - STOP, - PAUSE, - FF, - REV - }; + public: + enum State + { + PLAY=0, + STOP, + PAUSE, + FF, + REV + }; - enum DisplayOrder {ARTIST_TITLE = 0, TITLE_ARTIST=1}; + enum DisplayOrder + { + ARTIST_TITLE = 0, + TITLE_ARTIST=1 + }; - private: - void Init(void); - CFrameBuffer * m_frameBuffer; - unsigned int m_selected; - int m_current; - unsigned int m_liststart; - unsigned int m_listmaxshow; - int m_fheight; // Fonthoehe Playlist-Inhalt - int m_theight; // Fonthoehe Playlist-Titel - int m_sheight; // Fonthoehe MP Info - int m_buttonHeight; - int m_title_height; - int m_info_height; - int m_key_level; - bool m_visible; - State m_state; - time_t m_time_total; - time_t m_time_played; - std::string m_metainfo; - bool m_select_title_by_name; - bool m_show_playlist; + private: + void Init(void); + CFrameBuffer * m_frameBuffer; + unsigned int m_selected; + int m_current; + unsigned int m_liststart; + unsigned int m_listmaxshow; + int m_item_height; + int m_header_height; + int m_meta_height; + int m_button_height; + int m_title_height; + int m_cover_width; + int m_info_height; + int m_key_level; + bool m_visible; + State m_state; + time_t m_time_total; + time_t m_time_played; + std::string m_metainfo; + bool m_select_title_by_name; + bool m_show_playlist; + bool m_playlistHasChanged; - bool m_playlistHasChanged; + CAudioPlayList m_playlist; + CAudioPlayList m_radiolist; + CAudioPlayList m_filelist; + CTitle2Pos m_title2Pos; + CAudiofileExt m_curr_audiofile; + std::string m_Path; - CAudioPlayList m_playlist; - CAudioPlayList m_radiolist; - CAudioPlayList m_filelist; - CTitle2Pos m_title2Pos; - CAudiofileExt m_curr_audiofile; - std::string m_Path; + int m_width; + int m_height; + int m_x; + int m_y; + int m_title_w; - int m_width; - int m_height; - int m_x; - int m_y; - int m_title_w; + int m_LastMode; + int m_idletime; + bool m_screensaver; + bool m_inetmode; + CComponentsDetailsLine *m_detailsline; + CComponentsInfoBox *m_infobox; + CComponentsShapeSquare *m_titlebox; - int m_LastMode; - int m_idletime; - bool m_screensaver; - bool m_inetmode; - CComponentsDetailsLine *dline; - CComponentsInfoBox *ibox; + SMSKeyInput m_SMSKeyInput; - SMSKeyInput m_SMSKeyInput; + void paintItem(int pos); + void paint(); + void paintHead(); + void paintFoot(); + void paintTitleBox(); + void paintCover(); + void paintLCD(); + void paintDetailsLine(int pos); + void clearDetailsLine(); + void hide(); - void paintItem(int pos); - void paint(); - void paintHead(); - void paintFoot(); - void paintInfo(); - void paintCover(); - void paintLCD(); - void hide(); + void get_id3(CAudiofileExt * audiofile); + void get_mp3info(CAudiofileExt * audiofile); + CFileFilter audiofilefilter; + void ff(unsigned int seconds=0); + void rev(unsigned int seconds=0); + int getNext(); + void GetMetaData(CAudiofileExt &File); + void updateMetaData(); + void updateTimes(const bool force = false); + void showMetaData(); + void screensaver(bool on); + bool getNumericInput(neutrino_msg_t& msg, int& val); - void get_id3(CAudiofileExt * audiofile); - void get_mp3info(CAudiofileExt * audiofile); - CFileFilter audiofilefilter; - void paintItemID3DetailsLine (int pos); - void clearItemID3DetailsLine (); - void ff(unsigned int seconds=0); - void rev(unsigned int seconds=0); - int getNext(); - void GetMetaData(CAudiofileExt &File); - void updateMetaData(); - void updateTimes(const bool force = false); - void showMetaData(); - void screensaver(bool on); - bool getNumericInput(neutrino_msg_t& msg,int& val); + void addToPlaylist(CAudiofileExt &file); + void removeFromPlaylist(long pos); - void addToPlaylist(CAudiofileExt &file); - void removeFromPlaylist(long pos); + /** + * Adds an url (shoutcast, ...) to the to the audioplayer playlist + */ + void addUrl2Playlist(const char *url, const char *name = NULL, const time_t bitrate = 0); - /** - * Adds an url (shoutcast, ...) to the to the audioplayer playlist - */ - void addUrl2Playlist(const char *url, const char *name = NULL, const time_t bitrate = 0); + /** + * Adds a url which points to an .m3u format (playlist, ...) to the audioplayer playlist + */ + void processPlaylistUrl(const char *url, const char *name = NULL, const time_t bitrate = 0); - /** - * Adds a url which points to an .m3u format (playlist, ...) to the audioplayer playlist - */ - void processPlaylistUrl(const char *url, const char *name = NULL, const time_t bitrate = 0); + /** + * Loads a given XML file of internet audiostreams or playlists and processes them + */ + void scanXmlFile(std::string filename); - /** - * Loads a given XML file of internet audiostreams or playlists and processes them - */ - void scanXmlFile(std::string filename); + /** + * Processes a loaded XML file/data of internet audiostreams or playlists + */ + void scanXmlData(xmlDocPtr answer_parser, const char *urltag, const char *nametag, const char *bitratetag = NULL, bool usechild = false); - /** - * Processes a loaded XML file/data of internet audiostreams or playlists - */ - void scanXmlData(xmlDocPtr answer_parser, const char *nametag, const char *urltag, const char *bitratetag = NULL, bool usechild = false); + /** + * Reads the icecast directory (XML file) and calls scanXmlData + */ + void readDir_ic(void); - /** - * Reads the icecast directory (XML file) and calls scanXmlData - */ - void readDir_ic(void); + void selectTitle(unsigned char selectionChar); - void selectTitle(unsigned char selectionChar); - /** - * Appends the file information to the given string. - * @param fileInfo a string where the file information will be appended - * @param file the file to return the information for - */ - void getFileInfoToDisplay(std::string& fileInfo, CAudiofileExt &file); + /** + * Appends the file information to the given string. + * @param fileInfo a string where the file information will be appended + * @param file the file to return the information for + */ + void getFileInfoToDisplay(std::string& fileInfo, CAudiofileExt &file); - void printSearchTree(); + void printSearchTree(); - void buildSearchTree(); + void buildSearchTree(); - unsigned char getFirstChar(CAudiofileExt &file); + unsigned char getFirstChar(CAudiofileExt &file); - void printTimevalDiff(timeval &start, timeval &end); + void printTimevalDiff(timeval &start, timeval &end); - /** - * Saves the current playlist into a .m3u playlist file. - */ - void savePlaylist(); + /** + * Saves the current playlist into a .m3u playlist file. + */ + void savePlaylist(); - /** - * Converts an absolute filename to a relative one - * as seen from a file in fromDir. - * Example: - * absFilename: /mnt/audio/A/abc.mp3 - * fromDir: /mnt/audio/B - * => ../A/abc.mp3 will be returned - * @param fromDir the directory from where we want to - * access the file - * @param absFilename the file we want to access in a - * relative way from fromDir (given as an absolute path) - * @return the location of absFilename as seen from fromDir - * (relative path) - */ - std::string absPath2Rel(const std::string& fromDir, - const std::string& absFilename); + /** + * Converts an absolute filename to a relative one + * as seen from a file in fromDir. + * Example: + * absFilename: /mnt/audio/A/abc.mp3 + * fromDir: /mnt/audio/B + * => ../A/abc.mp3 will be returned + * @param fromDir the directory from where we want to + * access the file + * @param absFilename the file we want to access in a + * relative way from fromDir (given as an absolute path) + * @return the location of absFilename as seen from fromDir + * (relative path) + */ + std::string absPath2Rel(const std::string& fromDir, const std::string& absFilename); - /** - * Asks the user if the file filename should be overwritten or not - * @param filename the name of the file - * @return true if file should be overwritten, false otherwise - */ - bool askToOverwriteFile(const std::string& filename); - bool openFilebrowser(void); - bool openSCbrowser(void); - bool clearPlaylist(void); - bool shufflePlaylist(void); + /** + * Asks the user if the file filename should be overwritten or not + * @param filename the name of the file + * @return true if file should be overwritten, false otherwise + */ + bool askToOverwriteFile(const std::string& filename); - bool pictureviewer; + bool openFilebrowser(void); + bool openSCbrowser(void); + bool clearPlaylist(void); + bool shufflePlaylist(void); - public: - CAudioPlayerGui(bool inetmode = false); - ~CAudioPlayerGui(); - int show(); - int exec(CMenuTarget* parent, const std::string & actionKey); + bool pictureviewer; - void wantNextPlay(); - void pause(); - void play(unsigned int pos); - void stop(); - bool playNext(bool allow_rotate = false); - bool playPrev(bool allow_rotate = false); - int getAudioPlayerM_current() {return m_current;} + public: + CAudioPlayerGui(bool inetmode = false); + ~CAudioPlayerGui(); + int show(); + int exec(CMenuTarget* parent, const std::string & actionKey); + + void wantNextPlay(); + void pause(); + void play(unsigned int pos); + void stop(); + bool playNext(bool allow_rotate = false); + bool playPrev(bool allow_rotate = false); + int getAudioPlayerM_current() { return m_current; } }; - #endif diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 5e2e348c8..a5b2d6ebc 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -66,7 +66,7 @@ CBEBouquetWidget::CBEBouquetWidget() void CBEBouquetWidget::paintItem(int pos) { - int ypos = y+ theight+0 + pos*iheight; + int ypos = y + theight + pos*iheight; unsigned int current = liststart + pos; bool i_selected = current == selected; @@ -92,8 +92,8 @@ void CBEBouquetWidget::paintItem(int pos) } if (i_radius) - frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius); if (current < Bouquets->size()) { if ((i_selected) && (state == beMoving)) @@ -125,22 +125,15 @@ void CBEBouquetWidget::paint() paintItem(count); } - int ypos = y+ theight; - int sb = iheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - int sbc= ((Bouquets->size()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); - if (sbc < 1) - sbc = 1; - - //scrollbar - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, Bouquets->size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, iheight*listmaxshow, total_pages, current_page); } void CBEBouquetWidget::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeaderLocalized::CC_BTN_EXIT); + CComponentsHeader header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeader::CC_BTN_EXIT); header.paint(CC_SAVE_SCREEN_NO); } @@ -157,7 +150,7 @@ const struct button_label CBEBouquetWidgetButtons[6] = void CBEBouquetWidget::paintFoot() { size_t numbuttons = sizeof(CBEBouquetWidgetButtons)/sizeof(CBEBouquetWidgetButtons[0]); - footer.paintButtons(x, y+height, width, ButtonHeight, numbuttons, CBEBouquetWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID, 0, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]); + footer.paintButtons(x, y+height, width, ButtonHeight, numbuttons, CBEBouquetWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID); } void CBEBouquetWidget::hide() diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 9fade03d4..26d7815cd 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -121,8 +121,8 @@ void CBEChannelWidget::paintItem(int pos) } if (i_radius) - frameBuffer->paintBoxRel(x, ypos, width- 15, iheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, width- 15, iheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius); if ((current == selected) && (state == beMoving)) { frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID, ypos, iheight); @@ -131,13 +131,12 @@ void CBEChannelWidget::paintItem(int pos) if ((*Channels)[current]->bLocked) { frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + OFFSET_INNER_MID + iconoffset, ypos, iheight); } - //g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10, ypos+ fheight, width- numwidth- 20- 15, (*Channels)[current]->getName(), color); //FIXME numwidth ? we not show chan numbers g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 2*OFFSET_INNER_MID + 2*iconoffset, ypos + iheight - (iheight-fheight)/2, width - 3*OFFSET_INNER_MID - 2*iconoffset, (*Channels)[current]->getName(), color); if((*Channels)[current]->scrambled) - frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - 15 - OFFSET_INNER_MID - iconoffset, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight); else if (!(*Channels)[current]->getUrl().empty()) - frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - 15 - OFFSET_INNER_MID - iconoffset, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight); } } @@ -159,19 +158,10 @@ void CBEChannelWidget::paint() paintItem(count); } - int ypos = y+ theight; - int sb = iheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - int sbc= ((Channels->size()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); - if (sbc < 1) - sbc = 1; - int sbh= (sb- 4)/ sbc; - - if (sbh == 0) - return; - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * sbh, 11, sbh, COL_SCROLLBAR_ACTIVE_PLUS_0); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, Channels->size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, iheight*listmaxshow, total_pages, current_page); } void CBEChannelWidget::paintHead() @@ -194,7 +184,7 @@ const struct button_label CBEChannelWidgetButtons[6] = void CBEChannelWidget::paintFoot() { size_t numbuttons = sizeof(CBEChannelWidgetButtons)/sizeof(CBEChannelWidgetButtons[0]); - footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, CBEChannelWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID, 0, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]); + footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, CBEChannelWidgetButtons, width/numbuttons-2*OFFSET_INNER_MID); } std::string CBEChannelWidget::getInfoText(int index) diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index c80a182b2..e9ee12385 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -129,8 +129,8 @@ void CBEChannelSelectWidget::paintItem(uint32_t itemNr, int paintNr, bool pselec } if (i_radius) - frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x,ypos, width- 15, iheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor, i_radius); if(itemNr < getItemCount()) { @@ -141,9 +141,9 @@ void CBEChannelSelectWidget::paintItem(uint32_t itemNr, int paintNr, bool pselec g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 2*OFFSET_INNER_MID + 2*iconoffset, ypos + iheight - (iheight-fheight)/2, width - 3*OFFSET_INNER_MID - 2*iconoffset, Channels[itemNr]->getName(), color); if(Channels[itemNr]->scrambled) - frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - 15 - OFFSET_INNER_MID - iconoffset, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight); else if (!Channels[itemNr]->getUrl().empty()) - frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - 15 - OFFSET_INNER_MID - iconoffset, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_STREAMING, x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iconoffset, ypos, fheight); } } @@ -251,7 +251,7 @@ void CBEChannelSelectWidget::paintFoot() break; } - footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, Button, width/numbuttons-20); + footer.paintButtons(x, y + (height-footerHeight), width, footerHeight, numbuttons, Button, width/numbuttons-2*OFFSET_INNER_MID); } std::string CBEChannelSelectWidget::getInfoText(int index) diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 420cc0be6..7ea3d68c7 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -412,7 +412,7 @@ void CBookmarkManager::hide() //------------------------------------------------------------------------ void CBookmarkManager::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeaderLocalized::CC_BTN_HELP); + CComponentsHeader header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeader::CC_BTN_HELP); header.paint(CC_SAVE_SCREEN_NO); } @@ -460,7 +460,7 @@ void CBookmarkManager::paint() { int ypos = y+ theight; int sb = 2*fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); + frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PLUS_0); unsigned int tmp_max = listmaxshow; if(!tmp_max) tmp_max = 1; diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 5be580abb..9a23f8c62 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -3,6 +3,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2009,2011,2013,2015-2017 Stefan Seyfried + Copyright (C) 2017 Sven Hoefer License: GPL @@ -68,7 +69,6 @@ CBouquetList::CBouquetList(const char * const Name) name = g_Locale->getText(LOCALE_BOUQUETLIST_HEAD); else name = Name; - } CBouquetList::~CBouquetList() @@ -412,34 +412,41 @@ int CBouquetList::show(bool bShowChannelList) int h_max_icon = 0; favonly = !bShowChannelList; - for(unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]);count++){ - int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale)); + for (unsigned int count = 0; count < sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); count++) + { + int w_text = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT]->getRenderWidth(g_Locale->getText(CBouquetListButtons[count].locale)); w_max_text = std::max(w_max_text, w_text); frameBuffer->getIconSize(CBouquetListButtons[count].button, &icol_w, &icol_h); w_max_icon = std::max(w_max_icon, icol_w); h_max_icon = std::max(h_max_icon, icol_h); } - int need_width = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0])*(w_max_icon + w_max_text + 20); - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, ""); - fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); + item_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); - width = w_max (need_width, 20); - height = h_max (16 * fheight, 40); + /* + We align width to needed footer space, + but this manual calculation isn't a good idea. + It would be better to get the needed width from + CComponententsFooter class. + */ + width = (sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]))*(w_max_icon + w_max_text + 2*OFFSET_INNER_MID); + height = 16*item_height; - footerHeight = std::max(h_max_icon+8, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight()+8); - theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - listmaxshow = (height - theight - footerHeight)/fheight; - height = theight + footerHeight + listmaxshow * fheight; // recalc height + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + footer_height = header_height; + listmaxshow = (height - header_height - footer_height)/item_height; + height = header_height + footer_height + listmaxshow*item_height; // recalc height - x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; - y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; + x = getScreenStartX(width); + y = getScreenStartY(height); int lmaxpos= 1; int i= Bouquets.size(); while ((i= i/10)!=0) lmaxpos++; + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, ""); + COSDFader fader(g_settings.theme.menu_Content_alpha); fader.StartFadeIn(); @@ -472,7 +479,7 @@ int CBouquetList::show(bool bShowChannelList) { selected = oldselected; if(fader.StartFadeOut()) { - timeoutEnd = CRCInput::calcTimeoutEnd( 1 ); + timeoutEnd = CRCInput::calcTimeoutEnd(1); msg = 0; } else loop=false; @@ -564,7 +571,7 @@ int CBouquetList::show(bool bShowChannelList) pos = 1; } } else { - chn = chn * 10 + CRCInput::getNumericValue(msg); + chn = chn*10 + CRCInput::getNumericValue(msg); pos++; } @@ -592,6 +599,7 @@ int CBouquetList::show(bool bShowChannelList) fader.StopFade(); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + if (save_bouquets) { save_bouquets = false; #if 0 @@ -603,7 +611,8 @@ int CBouquetList::show(bool bShowChannelList) if (g_settings.epg_scan == CEpgScan::SCAN_SEL) CEpgScan::getInstance()->Start(); } - if(zapOnExit) + + if (zapOnExit) return (selected); return (res); @@ -611,13 +620,13 @@ int CBouquetList::show(bool bShowChannelList) void CBouquetList::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height+10); + frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW); CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked()); } void CBouquetList::paintItem(int pos) { - int ypos = y+ theight+0 + pos*fheight; + int ypos = y + header_height + pos*item_height; bool iscurrent = true; int npos = liststart + pos; const char * lname = NULL; @@ -634,8 +643,8 @@ void CBouquetList::paintItem(int pos) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius); if (npos < (int) Bouquets.size()) lname = (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bFav) ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : Bouquets[npos]->channelList->getName(); @@ -658,33 +667,33 @@ void CBouquetList::paintItem(int pos) } } - if(npos < (int) Bouquets.size()) { - char tmp[10]; - sprintf((char*) tmp, "%d", npos+ 1); + if (npos < (int) Bouquets.size()) { + char num[10]; + sprintf((char*) num, "%d", npos + 1); int iw = 0, ih = 0; if ((g_settings.epg_scan == CEpgScan::SCAN_SEL) && Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bScanEpg) { frameBuffer->getIconSize(NEUTRINO_ICON_EPG, &iw, &ih); if (iw && ih) { - int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw; - frameBuffer->paintIcon(NEUTRINO_ICON_EPG, icon_x - iw, ypos, fheight); - iw = iw + 4 + RADIUS_LARGE/2; + int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw; + frameBuffer->paintIcon(NEUTRINO_ICON_EPG, icon_x, ypos, item_height); + iw = iw + OFFSET_INNER_MID; } } if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI) { - int iw2; - frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED2, &iw2, &ih); + int iw2 = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &iw2, &ih); if (iw2 && ih) { - int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw - iw2 - 2; - frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED2, icon_x - iw2, ypos, fheight); - iw = iw + iw2 + 4 + RADIUS_LARGE/2; + int icon_x = x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - iw - iw2; + frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, icon_x, ypos, item_height); + iw = iw + iw2 + OFFSET_INNER_MID; } } - int numpos = x+5+numwidth- g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos,ypos+fheight, numwidth+5, tmp, color, fheight); + int numpos = x + OFFSET_INNER_MID + numwidth - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(num); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos, ypos + item_height, numwidth + OFFSET_INNER_SMALL, num, color, item_height); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 5+ numwidth+ 10, ypos+ fheight, width- numwidth- 20- 15 - iw, lname, color); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID, ypos + item_height, width - numwidth - 2*OFFSET_INNER_MID - iw - SCROLLBAR_WIDTH, lname, color); //CVFD::getInstance()->showMenuText(0, bouq->channelList->getName(), -1, true); } } @@ -692,7 +701,8 @@ void CBouquetList::paintItem(int pos) void CBouquetList::paintHead() { std::string icon(""); - CComponentsHeader header(x, y, width, theight, name, icon, CComponentsHeader::CC_BTN_LEFT | CComponentsHeader::CC_BTN_RIGHT | CComponentsHeader::CC_BTN_MENU); + CComponentsHeader header(x, y, width, header_height, name, icon, CComponentsHeader::CC_BTN_LEFT | CComponentsHeader::CC_BTN_RIGHT | CComponentsHeader::CC_BTN_MENU); + header.enableShadow( CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); header.paint(CC_SAVE_SCREEN_NO); } @@ -702,7 +712,6 @@ void CBouquetList::paint() CInfoClock::getInstance()->disableInfoClock(); liststart = (selected/listmaxshow)*listmaxshow; int lastnum = liststart + listmaxshow; - int bsize = Bouquets.empty() ? 1 : Bouquets.size(); numwidth = 0; int maxDigitWidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getMaxDigitWidth(); @@ -712,33 +721,25 @@ void CBouquetList::paint() _lastnum /= 10; } - frameBuffer->paintBoxRel(x, y+theight, width, height - theight - footerHeight, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, y + header_height, width, height - header_height - footer_height, COL_MENUCONTENT_PLUS_0); - int numbuttons = sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); -#if 0 - if (favonly) /* this actually shows favorites and providers button, but both are active anyway */ - numbuttons = 2; + // no buttons in favonly mode + int numButtons = (favonly) ? 0 : sizeof(CBouquetListButtons)/sizeof(CBouquetListButtons[0]); - ::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight); -#endif - if (favonly) - frameBuffer->paintBoxRel(x, y + (height - footerHeight), width, footerHeight, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); //round - else - ::paintButtons(x, y + (height - footerHeight), width, numbuttons, CBouquetListButtons, width, footerHeight); + CComponentsFooter footer; + footer.enableShadow(CC_SHADOW_ON, -1, true); + footer.paintButtons(x, y + height - footer_height, width, footer_height, numButtons, CBouquetListButtons); - if(!Bouquets.empty()) + if (!Bouquets.empty()) { - for(unsigned int count=0;countpaintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - int listmaxshow_tmp = listmaxshow ? listmaxshow : 1;//avoid division by zero - int sbc= ((bsize - 1)/ listmaxshow_tmp)+ 1; /* bsize is > 0, so sbc is also > 0 */ - int sbs= (selected/listmaxshow_tmp); - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, Bouquets.size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page, CC_SHADOW_RIGHT_CORNER_ALL); } diff --git a/src/gui/bouquetlist.h b/src/gui/bouquetlist.h index 04043e34e..94c7a617e 100644 --- a/src/gui/bouquetlist.h +++ b/src/gui/bouquetlist.h @@ -87,9 +87,9 @@ class CBouquetList : public CListHelpers unsigned int liststart; unsigned int listmaxshow; unsigned int numwidth; - int fheight; // Fonthoehe Bouquetlist-Inhalt - int theight; // Fonthoehe Bouquetlist-Titel - int footerHeight; + int item_height; + int header_height; + int footer_height; int width; int height; diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp index 2d31e834e..e7e98785b 100644 --- a/src/gui/buildinfo.cpp +++ b/src/gui/buildinfo.cpp @@ -37,13 +37,13 @@ using namespace std; -CBuildInfo::CBuildInfo(bool show) : CComponentsWindow(0, 0, 700, 500, LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO) +CBuildInfo::CBuildInfo(bool show) : CComponentsWindow(0, 0, CCW_PERCENT 85, CCW_PERCENT 85, LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO) { initVarBuildInfo(); if (show) exec(NULL, ""); else - InitInfoItems(); + GetData(); } //init all var members @@ -54,8 +54,7 @@ void CBuildInfo::initVarBuildInfo() font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]; setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); - - shadow = true; + shadow = CC_SHADOW_ON; } @@ -66,13 +65,13 @@ int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/) if (parent) parent->hide(); - InitInfoItems(); - //exit if no informations available - if (!HasData()){ + if (!GetData()){ return res; } + InitInfoItems(); + //paint window if (!is_painted) paint(); @@ -119,7 +118,7 @@ void CBuildInfo::setFontType(Font* font_text) InitInfoItems(); } -bool CBuildInfo::HasData() +bool CBuildInfo::GetData() { v_info.clear(); @@ -168,20 +167,20 @@ bool CBuildInfo::HasData() void CBuildInfo::InitInfoItems() { //get and checkup required informations - if (!HasData()) + if (!GetData()) return; //ensure a clean body ccw_body->clear(); //define size and position - int x_info = 10; + int x_info = OFFSET_INNER_MID; int h_info = ccw_body->getHeight()/v_info.size(); //default height int w_info = width-2*x_info; //init info texts for(size_t i=0; igetText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body); + CComponentsExtTextForm *info = new CComponentsExtTextForm(OFFSET_INNER_MID, CC_APPEND, w_info, h_info, g_Locale->getText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body); info->setLabelAndTextFont(font); info->setTextModes(CTextBox::TOP , CTextBox::AUTO_HIGH | CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS); info->doPaintBg(false); diff --git a/src/gui/buildinfo.h b/src/gui/buildinfo.h index 154cba8bb..30a1033be 100644 --- a/src/gui/buildinfo.h +++ b/src/gui/buildinfo.h @@ -52,7 +52,7 @@ class CBuildInfo : public CMenuTarget, public CComponentsWindow void initVarBuildInfo(); void InitInfoItems(); - bool HasData(); + bool GetData(); public: //type_id's for infos diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 04c4740bf..015da7f1a 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -68,6 +68,7 @@ #else #include #endif +#include #include #include @@ -95,7 +96,6 @@ extern bool autoshift; static CComponentsPIP *cc_minitv = NULL; extern CBouquetManager *g_bouquetManager; extern int old_b_id; -static CComponentsChannelLogoScalable* CChannelLogo = NULL; static CComponentsHeader *header = NULL; extern bool timeset; @@ -119,13 +119,11 @@ CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vl fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); fdescrheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(); - previous_channellist_additional = -1; + previous_channellist_additional = g_settings.channellist_additional; eventFont = SNeutrinoSettings::FONT_TYPE_CHANNELLIST_EVENT; dline = NULL; - cc_minitv = NULL; - logo_off = 0; - pig_on_win = false; - CChannelLogo = NULL; + + minitv_is_active = false; headerNew = true; bouquet = NULL; chanlist = &channels; @@ -134,6 +132,8 @@ CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vl channelsChanged = false; paint_events_index = -2; + CFrameBuffer::getInstance()->OnAfterSetPallette.connect(sigc::mem_fun(this, &CChannelList::ResetModules)); + CNeutrinoApp::getInstance()->OnAfterSetupFonts.connect(sigc::mem_fun(this, &CChannelList::ResetModules)); } CChannelList::~CChannelList() @@ -298,7 +298,7 @@ int CChannelList::doChannelMenu(void) int shortcut = 0; static int old_selected = 0; char cnt[5]; - bool unlocked = true; + int ret = 0; if(g_settings.minimode) @@ -360,94 +360,100 @@ int CChannelList::doChannelMenu(void) CBouquetList *blist = tvmode ? TVfavList : RADIOfavList; bool fav_found = true; switch(select) { - case 0: // edit mode - if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED) { - int pl_z = g_settings.parentallock_zaptime * 60; - if (g_settings.personalize[SNeutrinoSettings::P_MSER_BOUQUET_EDIT] == CPersonalizeGui::PERSONALIZE_MODE_PIN) { - unlocked = false; - } else if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked) { - /* on locked bouquet, enough to check any channel */ - unlocked = ((*chanlist)[selected]->last_unlocked_time + pl_z > time_monotonic()); + case 0: // edit mode + { + bool unlocked = true; + if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED) { + int pl_z = g_settings.parentallock_zaptime * 60; + + if (g_settings.personalize[SNeutrinoSettings::P_MSER_BOUQUET_EDIT] == CPersonalizeGui::PERSONALIZE_MODE_PIN) { + unlocked = false; + } else if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked) { + /* on locked bouquet, enough to check any channel */ + unlocked = ((*chanlist)[selected]->last_unlocked_time + pl_z > time_monotonic()); + } else { + /* check all locked channels for last_unlocked_time, overwrite only if already unlocked */ + for (unsigned int j = 0 ; j < (*chanlist).size(); j++) { + if ((*chanlist)[j]->bLocked) + unlocked = unlocked && ((*chanlist)[j]->last_unlocked_time + pl_z > time_monotonic()); + } + } + if (!unlocked) { + CZapProtection *zp = new CZapProtection(g_settings.parentallock_pincode, 0x100); + unlocked = zp->check(); + delete zp; + } + } + if (unlocked) + editMode(true); + + ret = -1; + break; + } + case 1: // add to + if (!addChannelToBouquet()) + return -1; + ret = 1; + break; + case 2: // add to my favorites + for (unsigned n = 0; n < AllFavBouquetList->Bouquets.size(); n++) { + if (AllFavBouquetList->Bouquets[n]->zapitBouquet && AllFavBouquetList->Bouquets[n]->zapitBouquet->bFav) { + CZapitChannel *ch = AllFavBouquetList->Bouquets[n]->zapitBouquet->getChannelByChannelID(channel_id); + if (ch == NULL) { + AllFavBouquetList->Bouquets[n]->zapitBouquet->addService((*chanlist)[selected]); + fav_found = false; + } + break; + } + } + for (unsigned n = 0; n < blist->Bouquets.size() && !fav_found; n++) { + if (blist->Bouquets[n]->zapitBouquet && blist->Bouquets[n]->zapitBouquet->bFav) { + blist->Bouquets[n]->zapitBouquet->getChannels(blist->Bouquets[n]->channelList->channels, tvmode); + saveChanges(); + fav_found = true; + break; + } + } + if (!fav_found) { + CNeutrinoApp::getInstance()->MarkFavoritesChanged(); + CNeutrinoApp::getInstance()->MarkChannelsInit(); + } + ret = 1; + break; + case 3: // reset new + case 4: // reset all new + if (select == 3) { + (*chanlist)[selected]->flags = CZapitChannel::UPDATED; } else { - /* check all locked channels for last_unlocked_time, overwrite only if already unlocked */ - for (unsigned int j = 0 ; j < (*chanlist).size(); j++) { - if ((*chanlist)[j]->bLocked) - unlocked = unlocked && ((*chanlist)[j]->last_unlocked_time + pl_z > time_monotonic()); - } + for (unsigned int j = 0 ; j < (*chanlist).size(); j++) + (*chanlist)[j]->flags = CZapitChannel::UPDATED; } - if (!unlocked) { - CZapProtection *zp = new CZapProtection(g_settings.parentallock_pincode, 0x100); - unlocked = zp->check(); - delete zp; + CNeutrinoApp::getInstance()->MarkChannelsChanged(); + /* if make_new_list == ON, signal to re-init services */ + if(g_settings.make_new_list) + CNeutrinoApp::getInstance()->MarkChannelsInit(); + break; + case 5: // clear channel history + { + CNeutrinoApp::getInstance()->channelList->getLastChannels().clear(); + printf("%s:%d lastChList cleared\n", __FUNCTION__, __LINE__); + ret = -2; // exit channellist } - } - if (unlocked) - editMode(true); - ret = -1; - break; - case 1: // add to - if (!addChannelToBouquet()) - return -1; - ret = 1; - break; - case 2: // add to my favorites - for (unsigned n = 0; n < AllFavBouquetList->Bouquets.size(); n++) { - if (AllFavBouquetList->Bouquets[n]->zapitBouquet && AllFavBouquetList->Bouquets[n]->zapitBouquet->bFav) { - CZapitChannel *ch = AllFavBouquetList->Bouquets[n]->zapitBouquet->getChannelByChannelID(channel_id); - if (ch == NULL) { - AllFavBouquetList->Bouquets[n]->zapitBouquet->addService((*chanlist)[selected]); - fav_found = false; - } - break; + break; + case 6: // settings + { + previous_channellist_additional = g_settings.channellist_additional; + COsdSetup osd_setup; + osd_setup.showContextChanlistMenu(this); + hide(); + ResetModules(); + //FIXME check font/options changed ? + calcSize(); + ret = -1; } - } - for (unsigned n = 0; n < blist->Bouquets.size() && !fav_found; n++) { - if (blist->Bouquets[n]->zapitBouquet && blist->Bouquets[n]->zapitBouquet->bFav) { - blist->Bouquets[n]->zapitBouquet->getChannels(blist->Bouquets[n]->channelList->channels, tvmode); - saveChanges(); - fav_found = true; - break; - } - } - if (!fav_found) { - CNeutrinoApp::getInstance()->MarkFavoritesChanged(); - CNeutrinoApp::getInstance()->MarkChannelsInit(); - } - ret = 1; - break; - case 3: // reset new - case 4: // reset all new - if (select == 3) { - (*chanlist)[selected]->flags = CZapitChannel::UPDATED; - } else { - for (unsigned int j = 0 ; j < (*chanlist).size(); j++) - (*chanlist)[j]->flags = CZapitChannel::UPDATED; - } - CNeutrinoApp::getInstance()->MarkChannelsChanged(); - /* if make_new_list == ON, signal to re-init services */ - if(g_settings.make_new_list) - CNeutrinoApp::getInstance()->MarkChannelsInit(); - break; - case 5: // clear channel history - { - CNeutrinoApp::getInstance()->channelList->getLastChannels().clear(); - printf("%s:%d lastChList cleared\n", __FUNCTION__, __LINE__); - ret = -2; // exit channellist - } - break; - case 6: // settings - { - previous_channellist_additional = g_settings.channellist_additional; - COsdSetup osd_setup; - osd_setup.showContextChanlistMenu(this); - //FIXME check font/options changed ? - hide(); - calcSize(); - ret = -1; - } - break; - default: - break; + break; + default: + break; } } return ret; @@ -483,9 +489,9 @@ void CChannelList::calcSize() fheight = 1; /* avoid div-by-zero crash on invalid font */ footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight()+6; - pig_on_win = ( (g_settings.channellist_additional == 2) /* with miniTV */ && (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_ts) ); + minitv_is_active = ( (g_settings.channellist_additional == SNeutrinoSettings::CHANNELLIST_ADDITIONAL_MODE_MINITV) && (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_ts) ); // calculate width - full_width = pig_on_win ? (frameBuffer->getScreenWidth()-2*DETAILSLINE_WIDTH) : frameBuffer->getScreenWidthRel(); + full_width = minitv_is_active ? (frameBuffer->getScreenWidth()-2*DETAILSLINE_WIDTH) : frameBuffer->getScreenWidthRel(); if (g_settings.channellist_additional) width = full_width / 3 * 2; @@ -498,10 +504,10 @@ void CChannelList::calcSize() // calculate height (the infobox below mainbox is handled outside height) if (g_settings.channellist_show_infobox) - info_height = 2*fheight + fdescrheight + 10; + info_height = 2*fheight + fdescrheight + 2*OFFSET_INNER_SMALL; else info_height = 0; - height = pig_on_win ? frameBuffer->getScreenHeight(): frameBuffer->getScreenHeightRel(); + height = minitv_is_active ? frameBuffer->getScreenHeight() : frameBuffer->getScreenHeightRel(); height = height - OFFSET_INTER - info_height; // calculate x position @@ -525,7 +531,7 @@ void CChannelList::calcSize() // calculate width/height of right info_zone and pip-box infozone_width = full_width - width; pig_width = infozone_width; - if ( pig_on_win /* with miniTV */ ) + if (minitv_is_active) pig_height = (pig_width * 9) / 16; else pig_height = 0; @@ -950,22 +956,21 @@ int CChannelList::show() void CChannelList::hide() { paint_events(-2); // cancel paint_events thread - if ((g_settings.channellist_additional == 2) || (previous_channellist_additional == 2)) // with miniTV + if ((g_settings.channellist_additional == SNeutrinoSettings::CHANNELLIST_ADDITIONAL_MODE_MINITV) || (previous_channellist_additional == SNeutrinoSettings::CHANNELLIST_ADDITIONAL_MODE_MINITV)) // with miniTV { - if (cc_minitv) - delete cc_minitv; - cc_minitv = NULL; + if (cc_minitv){ + delete cc_minitv; cc_minitv = NULL; + } } if(header) header->kill(); - if (CChannelLogo){ - CChannelLogo->kill(); - delete CChannelLogo; - CChannelLogo = NULL; - } frameBuffer->paintBackgroundBoxRel(x, y, full_width, height + OFFSET_INTER + info_height); - clearItem2DetailsLine(); + + //remove details line + if (dline) + dline->kill(); + CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked()); } @@ -1280,7 +1285,7 @@ int CChannelList::numericZap(int key) } return res; } - size_t maxchansize = MaxChanNr().size(); + size_t maxchansize = MaxChanNr().size(); int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getMaxDigitWidth(); int sx = maxchansize * fw + (fw/2); int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6; @@ -1562,8 +1567,8 @@ void CChannelList::paintDetails(int index) std::string text1= p_event->description; std::string text2= p_event->text; - int xstart = 10; - if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1) > (full_width - 30 - seit_len) ) + int xstart = OFFSET_INNER_MID; + if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1) > (full_width - 3*OFFSET_INNER_MID - seit_len) ) { // zu breit, Umbruch versuchen... int pos; @@ -1571,7 +1576,7 @@ void CChannelList::paintDetails(int index) pos = text1.find_last_of("[ -.]+"); if ( pos!=-1 ) text1 = text1.substr( 0, pos ); - } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1) > (full_width - 30 - seit_len) ) ); + } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1) > (full_width - 3*OFFSET_INNER_MID - seit_len) ) ); std::string text3 = ""; /* not perfect, but better than crashing... */ if (p_event->description.length() > text1.length()) @@ -1581,7 +1586,7 @@ void CChannelList::paintDetails(int index) text3= text3+ " - "; xstart += g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text3); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + 2*fheight, full_width - 30- noch_len, text3, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID, ypos_a + 2*fheight, full_width - 3*OFFSET_INNER_MID - noch_len, text3, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); } if (!(text2.empty())) { @@ -1590,7 +1595,7 @@ void CChannelList::paintDetails(int index) text2 = text2.substr( 0, text2.find('\n') ); #if 0 //FIXME: to discuss, eat too much cpu time if string long enough int pos = 0; - while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text2) > (full_width - 30 - noch_len) ) ) { + while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text2) > (full_width - 3*OFFSET_INNER_MID - noch_len) ) ) { pos = text2.find_last_of(" "); if ( pos!=-1 ) { @@ -1598,18 +1603,18 @@ void CChannelList::paintDetails(int index) } } #endif - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ xstart, ypos_a + fdescrheight+ fheight, full_width- xstart- 30- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + xstart, ypos_a + fdescrheight+ fheight, full_width- xstart- 3*OFFSET_INNER_MID- noch_len, text2, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); } - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + fheight, full_width - 30 - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- seit_len, ypos_a + fheight , seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- noch_len, ypos_a + fdescrheight+ fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ OFFSET_INNER_MID, ypos_a + fheight, full_width - 3*OFFSET_INNER_MID - seit_len, text1, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- OFFSET_INNER_MID- seit_len, ypos_a + fheight , seit_len, cSeit, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- OFFSET_INNER_MID- noch_len, ypos_a + fdescrheight+ fheight, noch_len, cNoch, colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); } else if (IS_WEBTV((*chanlist)[index]->getChannelID())) { - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + fheight, full_width - 30, (*chanlist)[index]->getDesc(), colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ OFFSET_INNER_MID, ypos_a + fheight, full_width - 3*OFFSET_INNER_MID, (*chanlist)[index]->getDesc(), colored_event_C ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT, 0, true); } if (g_settings.channellist_foot == 0 && IS_WEBTV((*chanlist)[index]->getChannelID())) { - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + 2*fheight + fdescrheight, full_width - 30, (*chanlist)[index]->getUrl(), COL_MENUCONTENTDARK_TEXT, 0, true); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ OFFSET_INNER_MID, ypos_a + 2*fheight + fdescrheight, full_width - 3*OFFSET_INNER_MID, (*chanlist)[index]->getUrl(), COL_MENUCONTENTDARK_TEXT, 0, true); } else if(g_settings.channellist_foot == 0) { transponder t; CServiceManager::getInstance()->GetTransponder((*chanlist)[index]->getTransponderId(), t); @@ -1620,7 +1625,7 @@ void CChannelList::paintDetails(int index) else desc = desc + " (" + CServiceManager::getInstance()->GetSatelliteName((*chanlist)[index]->getSatellitePosition()) + ")"; - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + 2*fheight +fdescrheight, full_width - 30, desc.c_str(), COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ OFFSET_INNER_MID, ypos_a + 2*fheight +fdescrheight, full_width - 3*OFFSET_INNER_MID, desc.c_str(), COL_MENUCONTENTDARK_TEXT); } else if( !displayNext && g_settings.channellist_foot == 1) { // next Event @@ -1634,8 +1639,8 @@ void CChannelList::paintDetails(int index) snprintf(buf, sizeof(buf), "%s", CurrentNext.next_name.c_str()); int from_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cFrom); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ 10, ypos_a + 2*fheight+ fdescrheight, full_width - 30 - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_TEXT :COL_MENUCONTENTDARK_TEXT); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- 10- from_len, ypos_a + 2*fheight+ fdescrheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x+ OFFSET_INNER_MID, ypos_a + 2*fheight+ fdescrheight, full_width - 3*OFFSET_INNER_MID - from_len, buf, colored_event_N ? COL_COLORED_EVENTS_TEXT :COL_MENUCONTENTDARK_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x+ full_width- OFFSET_INNER_MID- from_len, ypos_a + 2*fheight+ fdescrheight, from_len, cFrom, colored_event_N ? COL_COLORED_EVENTS_TEXT : COL_MENUCONTENTDARK_TEXT); } } } @@ -1647,12 +1652,6 @@ void CChannelList::clearItem2DetailsLine() void CChannelList::paintItem2DetailsLine (int pos) { - if (dline){ - dline->kill(); //kill details line - delete dline; - dline = NULL; - } - if (!g_settings.channellist_show_infobox) return; @@ -1662,9 +1661,15 @@ void CChannelList::paintItem2DetailsLine (int pos) // paint Line if detail info (and not valid list pos) if (pos >= 0) { - if (dline == NULL) + if (!dline){ dline = new CComponentsDetailsLine(xpos, ypos1, ypos2, fheight/2, info_height-RADIUS_LARGE*2); - dline->paint(false); + }else{ + dline->setPos(xpos, ypos1); + dline->setYPosDown(ypos2); + dline->setHMarkTop(fheight/2); + dline->setHMarkDown(info_height-RADIUS_LARGE*2); + } + dline->paint(); } } @@ -1679,36 +1684,19 @@ void CChannelList::paintAdditionals(int index) } } -void CChannelList::showChannelLogo() //TODO: move into an own handler, eg. header, channel logo should be paint inside header object +void CChannelList::showChannelLogo() { if ((*chanlist).empty()) return; - if(g_settings.channellist_show_channellogo){ - int logo_w_max = full_width / 4; - int logo_h_max = theight - 2*OFFSET_INNER_MIN; - if (CChannelLogo) { - if (headerNew) - CChannelLogo->clearSavedScreen(); - else - CChannelLogo->hide(); - delete CChannelLogo; - } - CChannelLogo = new CComponentsChannelLogoScalable(0, 0, (*chanlist)[selected]->getName(), (*chanlist)[selected]->getChannelID()); - if (CChannelLogo->hasLogo()){ - CChannelLogo->setWidth(min(CChannelLogo->getWidth(), logo_w_max), true); - if (CChannelLogo->getHeight() > logo_h_max) - CChannelLogo->setHeight(logo_h_max, true); - CChannelLogo->setXPos(x + full_width - logo_off - CChannelLogo->getWidth()); - CChannelLogo->setYPos(y + (theight - CChannelLogo->getHeight()) / 2); - CChannelLogo->paint(); - } else { - CChannelLogo->hide(); - delete CChannelLogo; - CChannelLogo = NULL; - } - headerNew = false; + if(g_settings.channellist_show_channellogo){ + header->setChannelLogo((*chanlist)[selected]->getChannelID(), (*chanlist)[selected]->getName()); + header->getChannelLogoObject()->hide(); + header->getChannelLogoObject()->clearSavedScreen(); + header->getChannelLogoObject()->paint(); } + else + header->setChannelLogo(0, string()); } #define NUM_LIST_BUTTONS_SORT 9 @@ -1894,7 +1882,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint) color = COL_MENUCONTENTINACTIVE_TEXT; if (!firstpaint || i_selected || getKey(curr) == CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber()) - frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, fheight, bgcolor, i_radius); if(curr < (*chanlist).size()) { char nameAndDescription[255]; @@ -1903,10 +1891,10 @@ void CChannelList::paintItem(int pos, const bool firstpaint) int prg_offset = 0; int title_offset = 0; int rec_mode; - if(g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF) + if (g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF) { prg_offset = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("00:00"); - title_offset = OFFSET_INNER_SMALL; + title_offset = OFFSET_INNER_MID; } snprintf(tmp, sizeof(tmp), "%d", this->historyMode ? pos : chan->number); @@ -1948,7 +1936,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint) int icon_w = 0; int icon_h = 0; int offset_right = OFFSET_INNER_MID; - int icon_x_right = x + width - 15 - offset_right; + int icon_x_right = x + width - SCROLLBAR_WIDTH - offset_right; if (scramble_icon) { @@ -1997,16 +1985,16 @@ void CChannelList::paintItem(int pos, const bool firstpaint) if (curr == selected && move_state == beMoving) { frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icon_w, &icon_h); - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_SMALL + numwidth - icon_w, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_YELLOW, x + OFFSET_INNER_MID + numwidth - icon_w, ypos, fheight); } else if (edit_state && chan->bLocked) { frameBuffer->getIconSize(NEUTRINO_ICON_LOCK, &icon_w, &icon_h); - frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + OFFSET_INNER_SMALL + numwidth - icon_w, ypos, fheight); + frameBuffer->paintIcon(NEUTRINO_ICON_LOCK, x + OFFSET_INNER_MID + numwidth - icon_w, ypos, fheight); } else if (g_settings.channellist_show_numbers) { - int numpos = x + OFFSET_INNER_SMALL + numwidth - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); + int numpos = x + OFFSET_INNER_MID + numwidth - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos, ypos + fheight, numwidth + 5, tmp, color, fheight); } else if (!edit_state) @@ -2020,9 +2008,9 @@ void CChannelList::paintItem(int pos, const bool firstpaint) else l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->getName().c_str()); - int pb_space = prg_offset - title_offset; + int pb_width = prg_offset; int pb_height = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getDigitHeight(); - CProgressBar pb(x + OFFSET_INNER_SMALL + numwidth + title_offset, ypos + (fheight-pb_height)/2, pb_space + 2, pb_height, COL_MENUCONTENT_PLUS_0); + CProgressBar pb(x + OFFSET_INNER_MID + numwidth + title_offset, ypos + (fheight-pb_height)/2, pb_width, pb_height, COL_MENUCONTENT_PLUS_0); pb.setType(CProgressBar::PB_TIMESCALE); pb.setDesign(g_settings.theme.progressbar_design_channellist); pb.setCornerType(0); @@ -2035,28 +2023,28 @@ void CChannelList::paintItem(int pos, const bool firstpaint) } pb.setFrameThickness(pb_frame); pb.doPaintBg(false); - int pb_max = pb_space - 4; if (!(p_event->description.empty())) { - snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l,g_settings.channellist_epgtext_align_right ? " ":" - "); + snprintf(nameAndDescription+l, sizeof(nameAndDescription)-l, g_settings.channellist_epgtext_align_right ? " " : " - "); unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription); unsigned int ch_desc_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(p_event->description); - int max_desc_len = width - numwidth - prg_offset - ch_name_len - 15 - 2*OFFSET_INNER_MID - offset_right; // 15 = scrollbar + int max_desc_len = width - numwidth - prg_offset - ch_name_len - SCROLLBAR_WIDTH - 3*OFFSET_INNER_MID - offset_right; if (max_desc_len < 0) max_desc_len = 0; if ((int) ch_desc_len > max_desc_len) ch_desc_len = max_desc_len; - if(g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF) { + if (g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF) + { if(displayNext) { struct tm *pStartZeit = localtime(&p_event->startTime); snprintf(tmp, sizeof(tmp), "%02d:%02d", pStartZeit->tm_hour, pStartZeit->tm_min); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(x + OFFSET_INNER_SMALL + numwidth + 6, ypos + fheight, width - numwidth - 15 - prg_offset - 2*OFFSET_INNER_MID, tmp, ecolor, fheight); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID, ypos + fheight, width - numwidth - SCROLLBAR_WIDTH - prg_offset - 2*OFFSET_INNER_MID, tmp, ecolor, fheight); } else { @@ -2066,32 +2054,34 @@ void CChannelList::paintItem(int pos, const bool firstpaint) if (((jetzt - p_event->startTime + 30) / 60) < 0 ) runningPercent= 0; else - runningPercent=(jetzt-p_event->startTime) * pb_max / p_event->duration; + runningPercent=(jetzt-p_event->startTime) * pb_width / p_event->duration; - pb.setValues(runningPercent, pb_max); + pb.setValues(runningPercent, pb_width); pb.paint(); } } - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_SMALL + numwidth + OFFSET_INNER_MID + prg_offset, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - 15 - prg_offset, nameAndDescription, color); - if (g_settings.channellist_epgtext_align_right) { + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - SCROLLBAR_WIDTH - prg_offset, nameAndDescription, color); + if (g_settings.channellist_epgtext_align_right) + { // align right - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + width - 15 - offset_right - ch_desc_len, ypos + fheight, ch_desc_len, p_event->description, ecolor); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + width - SCROLLBAR_WIDTH - offset_right - ch_desc_len, ypos + fheight, ch_desc_len, p_event->description, ecolor); } - else { + else + { // align left - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + OFFSET_INNER_SMALL + numwidth + OFFSET_INNER_MID + ch_name_len + OFFSET_INNER_SMALL + prg_offset, ypos + fheight, ch_desc_len, p_event->description, ecolor); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID + ch_name_len, ypos + fheight, ch_desc_len, p_event->description, ecolor); } } else { if (g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF) { - pb.setValues(0, pb_max); + pb.setValues(0, pb_width); pb.paint(); } //name - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_SMALL + numwidth + OFFSET_INNER_MID + prg_offset, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - 15 - prg_offset, nameAndDescription, color); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID + numwidth + OFFSET_INNER_MID + prg_offset + OFFSET_INNER_MID, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - SCROLLBAR_WIDTH - prg_offset, nameAndDescription, color); } if (!firstpaint && curr == selected) updateVfd(); @@ -2139,6 +2129,7 @@ void CChannelList::paintHead() } header->setDimensionsAll(x, y, full_width, theight); + header->setCorner(RADIUS_LARGE, CORNER_TOP); if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked != g_settings.parentallock_defaultlocked) header->setIcon(NEUTRINO_ICON_LOCK); @@ -2147,12 +2138,7 @@ void CChannelList::paintHead() fb_pixel_t header_txt_col = (edit_state ? COL_RED : COL_MENUHEAD_TEXT); header->setColorBody(COL_MENUHEAD_PLUS_0); - header->setCaption(header_txt, CTextBox::NO_AUTO_LINEBREAK, header_txt_col); - - if (header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0)){ - if (CChannelLogo) - CChannelLogo->clearFbData(); - } + header->setCaption(header_txt, DEFAULT_TITLE_ALIGN, header_txt_col); if (timeset) { if(!edit_state){ @@ -2160,9 +2146,9 @@ void CChannelList::paintHead() if (!header->getContextBtnObject()->empty()) header->removeContextButtons(); header->enableClock(true, "%H:%M", "%H %M", true); - logo_off = header->getClockObject()->getWidth() + 10; - header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); + if (header->getClockObject()) + header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); }else{ if (header->getClockObject()){ header->disableClock(); @@ -2170,21 +2156,23 @@ void CChannelList::paintHead() } } } - else - logo_off = 10; header->paint(CC_SAVE_SCREEN_NO); } CComponentsHeader* CChannelList::getHeaderObject() { - return header; + if (header) + return header; + return NULL; } void CChannelList::ResetModules() { - delete header; - header = NULL; + if (header){ + delete header; + header = NULL; + } if(dline){ delete dline; dline = NULL; @@ -2193,10 +2181,6 @@ void CChannelList::ResetModules() delete cc_minitv; cc_minitv = NULL; } - if (CChannelLogo) { - delete CChannelLogo; - CChannelLogo = NULL; - } } void CChannelList::paintBody() @@ -2211,7 +2195,7 @@ void CChannelList::paintBody() liststart = (selected/listmaxshow)*listmaxshow; updateEvents(this->historyMode ? 0:liststart, this->historyMode ? 0:(liststart + listmaxshow)); - if (pig_on_win) // with miniTV + if (minitv_is_active) paintPig(x+width, y+theight, pig_width, pig_height); // paint background for main box @@ -2229,16 +2213,11 @@ void CChannelList::paintBody() for(unsigned int count = 0; count < listmaxshow; count++) paintItem(count, true); - const int ypos = y+ theight; - const int sb = height - theight - footerHeight; // paint scrollbar over full height of main box - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - unsigned int listmaxshow_tmp = listmaxshow ? listmaxshow : 1;//avoid division by zero - int sbc= (((*chanlist).size()- 1)/ listmaxshow_tmp)+ 1; - const int sbs= (selected/listmaxshow_tmp); - if (sbc < 1) - sbc = 1; + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, (*chanlist).size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, height - theight - footerHeight, total_pages, current_page); - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); showChannelLogo(); if ((*chanlist).empty()) paintButtonBar(false); @@ -2292,22 +2271,17 @@ bool CChannelList::SameTP(CZapitChannel * channel) return iscurrent; } -std::string CChannelList::MaxChanNr() +std::string CChannelList::MaxChanNr() { - zapit_list_it_t chan_it; - std::stringstream ss; - std::string maxchansize; - int chan_nr_max = 1; - unsigned int nr = 0; - for (chan_it=(*chanlist).begin(); chan_it!=(*chanlist).end(); ++chan_it) { - chan_nr_max = std::max(chan_nr_max, (*chanlist)[nr++]->number); + int n = 1; + for (zapit_list_it_t it = (*chanlist).begin(); it != (*chanlist).end(); ++it) + { + n = std::max(n, (*it)->number); } - ss << chan_nr_max; - ss >> maxchansize; - return maxchansize; + return to_string(n); } -void CChannelList::paintPig (int _x, int _y, int w, int h) +void CChannelList::paintPig(int _x, int _y, int w, int h) { //init minitv object with basic properties if (cc_minitv == NULL){ @@ -2390,7 +2364,7 @@ void CChannelList::paint_events(CChannelEventList &evtlist) frameBuffer->paintBoxRel(x+ width,y+ theight+pig_height, infozone_width, infozone_height,COL_MENUCONTENT_PLUS_0); char startTime[10]; - int eventStartTimeWidth = 4 * g_Font[eventFont]->getMaxDigitWidth() + g_Font[eventFont]->getRenderWidth(":") + 5; // use a fixed value + int eventStartTimeWidth = 4 * g_Font[eventFont]->getMaxDigitWidth() + g_Font[eventFont]->getRenderWidth(":") + OFFSET_INNER_SMALL; // use a fixed value int startTimeWidth = 0; CChannelEventList::iterator e; time_t azeit; @@ -2439,9 +2413,9 @@ void CChannelList::paint_events(CChannelEventList &evtlist) strftime(startTime, sizeof(startTime), "%H:%M", tmStartZeit ); //printf("%s %s\n", startTime, e->description.c_str()); startTimeWidth = eventStartTimeWidth; - g_Font[eventFont]->RenderString(x+ width+5, y+ theight+ pig_height + i*ffheight, startTimeWidth, startTime, color); + g_Font[eventFont]->RenderString(x+ width+ OFFSET_INNER_MID, y+ theight+ pig_height + i*ffheight, startTimeWidth, startTime, color); } - g_Font[eventFont]->RenderString(x+ width+5+startTimeWidth, y+ theight+ pig_height + i*ffheight, infozone_width - startTimeWidth - 20, e->description, color); + g_Font[eventFont]->RenderString(x+ width+ OFFSET_INNER_MID +startTimeWidth, y+ theight+ pig_height + i*ffheight, infozone_width - startTimeWidth - 2*OFFSET_INNER_MID, e->description, color); } else { diff --git a/src/gui/channellist.h b/src/gui/channellist.h index f5addbe68..40d2c74d1 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -67,7 +67,7 @@ enum { class CFrameBuffer; class CBouquet; -class CChannelList : public CListHelpers +class CChannelList : public CListHelpers, public sigc::trackable { private: enum state_ @@ -112,7 +112,6 @@ private: int info_height; // the infobox below mainbox is handled outside height int x; int y; - int logo_off; int pig_width; int pig_height; int infozone_width; @@ -131,7 +130,7 @@ private: bool vlist; // "virtual" list, not bouquet bool displayNext; bool displayList; - bool pig_on_win; + bool minitv_is_active; bool headerNew; diff --git a/src/gui/color.cpp b/src/gui/color.cpp index 519674667..ad9cec7e2 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -231,7 +231,7 @@ void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv) hsv->v = f_V; } -void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected, bool marked, bool switch_background) +void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected, bool marked, bool toggle_background, bool toggle_enlighten) { if (selected && marked) { @@ -255,6 +255,6 @@ void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected, bool marked, boo } // default - t = switch_background ? COL_MENUCONTENTDARK_TEXT : COL_MENUCONTENT_TEXT; - b = switch_background ? COL_MENUCONTENTDARK_PLUS_0 : COL_MENUCONTENT_PLUS_0; + t = toggle_background ? (toggle_enlighten ? COL_MENUCONTENT_TEXT : COL_MENUCONTENTDARK_TEXT) : COL_MENUCONTENT_TEXT; + b = toggle_background ? (toggle_enlighten ? COL_MENUCONTENT_PLUS_1 : COL_MENUCONTENTDARK_PLUS_0) : COL_MENUCONTENT_PLUS_0; } diff --git a/src/gui/color.h b/src/gui/color.h index 61305ca4e..bcce61d8c 100644 --- a/src/gui/color.h +++ b/src/gui/color.h @@ -120,18 +120,20 @@ #endif // some wrappers to get more readability -#define COL_FRAME COL_MENUCONTENT_PLUS_6 -#define COL_FRAME_PLUS_0 COL_FRAME +#define COL_FRAME COL_MENUCONTENT_PLUS_6 +#define COL_FRAME_PLUS_0 COL_FRAME -#define COL_SCROLLBAR_ACTIVE COL_MENUCONTENT_PLUS_3 -#define COL_SCROLLBAR_ACTIVE_PLUS_0 COL_SCROLLBAR_ACTIVE -#define COL_SCROLLBAR_PASSIVE COL_MENUCONTENT_PLUS_1 -#define COL_SCROLLBAR_PASSIVE_PLUS_0 COL_SCROLLBAR_PASSIVE +#define COL_SCROLLBAR COL_MENUCONTENT_PLUS_1 +#define COL_SCROLLBAR_PLUS_0 COL_SCROLLBAR +#define COL_SCROLLBAR_ACTIVE COL_MENUCONTENT_PLUS_3 +#define COL_SCROLLBAR_ACTIVE_PLUS_0 COL_SCROLLBAR_ACTIVE +#define COL_SCROLLBAR_PASSIVE COL_MENUCONTENT_PLUS_2 +#define COL_SCROLLBAR_PASSIVE_PLUS_0 COL_SCROLLBAR_PASSIVE -#define COL_PROGRESSBAR_ACTIVE COL_MENUCONTENT_PLUS_7 -#define COL_PROGRESSBAR_ACTIVE_PLUS_0 COL_PROGRESSBAR_ACTIVE -#define COL_PROGRESSBAR_PASSIVE COL_MENUCONTENT_PLUS_1 -#define COL_PROGRESSBAR_PASSIVE_PLUS_0 COL_PROGRESSBAR_PASSIVE +#define COL_PROGRESSBAR_ACTIVE COL_MENUCONTENT_PLUS_7 +#define COL_PROGRESSBAR_ACTIVE_PLUS_0 COL_PROGRESSBAR_ACTIVE +#define COL_PROGRESSBAR_PASSIVE COL_MENUCONTENT_PLUS_1 +#define COL_PROGRESSBAR_PASSIVE_PLUS_0 COL_PROGRESSBAR_PASSIVE int convertSetupColor2RGB(unsigned char r, unsigned char g, unsigned char b); int convertSetupAlpha2Alpha(unsigned char alpha); @@ -161,6 +163,6 @@ uint8_t SysColor2Hsv(fb_pixel_t color, HsvColor *hsv); void Hsv2Rgb(HsvColor *hsv, RgbColor *rgb); void Rgb2Hsv(RgbColor *rgb, HsvColor *hsv); -void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected = false, bool marked = false, bool switch_background = false); +void getItemColors(fb_pixel_t &t, fb_pixel_t &b, bool selected = false, bool marked = false, bool toggle_background = false, bool toggle_enlighten = false); #endif diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 0089ac8a1..e43158b13 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -18,6 +18,7 @@ noinst_LIBRARIES = libneutrino_gui_components.a libneutrino_gui_components_a_SOURCES = \ cc_base.cpp \ + cc_button_select.cpp \ cc_detailsline.cpp \ cc_draw.cpp \ cc_extra.cpp \ diff --git a/src/gui/components/cc_button_select.cpp b/src/gui/components/cc_button_select.cpp new file mode 100644 index 000000000..cb396d7cb --- /dev/null +++ b/src/gui/components/cc_button_select.cpp @@ -0,0 +1,82 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "config.h" +#include "cc_button_select.h" +#include + +CCButtonSelect::CCButtonSelect() +{ + btn_container = NULL; +} + +CComponentsFrmChain* CCButtonSelect::getButtonChainObject() +{ + return btn_container; +} + +CComponentsButton* CCButtonSelect::getSelectedButtonObject() +{ + CComponentsButton* ret = static_cast(btn_container->getSelectedItemObject()); + return ret; +} + +int CCButtonSelect::getSelectedButton() +{ + if (btn_container) + return btn_container->getSelectedItem(); + return -1; +} + +void CCButtonSelect::setSelectedButton(size_t item_id, + const fb_pixel_t& fr_col, + const fb_pixel_t& sel_fr_col, + const fb_pixel_t& bg_col, + const fb_pixel_t& sel_bg_col, + const fb_pixel_t& text_col, + const fb_pixel_t& sel_text_col, + const int& frame_width, + const int& sel_frame_width) +{ + CComponentsButton *btn = NULL; + if (btn_container){ + for (size_t i= 0; i< btn_container->size(); i++){ + CComponentsItem *item = btn_container->getCCItem(i); + if (item->getItemType() >= CC_ITEMTYPE_BUTTON && item->getItemType() <= CC_ITEMTYPE_BUTTON_BLUE){ + btn = static_cast(item); + btn->setButtonTextColor(text_col); + } + } + if (!btn) + dprintf(DEBUG_NORMAL, "\033[33m[CCButtonSelect]\t[%s - %d], no button object found...\033[0m\n", __func__, __LINE__); + + fb_pixel_t sel_col = fr_col; + if (btn_container->size() > 1) + sel_col = sel_fr_col; //TODO: make it configurable + btn_container->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width); + + getSelectedButtonObject()->setButtonTextColor(sel_text_col); + } +} + + diff --git a/src/gui/components/cc_button_select.h b/src/gui/components/cc_button_select.h new file mode 100644 index 000000000..ecf35b8dc --- /dev/null +++ b/src/gui/components/cc_button_select.h @@ -0,0 +1,81 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __CC_BTN_SEL_H__ +#define __CC_BTN_SEL_H__ + + +#include "cc_frm_button.h" + +/*! +Class for inheritation of button select handling inside other CComponentsForm objects and their derivations +*/ +class CCButtonSelect +{ + protected: + CComponentsFrmChain *btn_container; + + public: + CCButtonSelect(); + + ///returns selected button object, return value as pointer to object, NULL means nothing is selected + CComponentsButton* getSelectedButtonObject(); + + ///returns pointer to internal button container + CComponentsFrmChain* getButtonChainObject(); + + ///returns id of select button, return value as int, -1 = nothing is selected + int getSelectedButton(); + + /**Select a definied button inside button chain object + * @param[in] item_id + * @li optional: expects type size_t + * @param[in] fr_col + * @li optional: expects type fb_pixel_t, as default frame color + * @param[in] sel_fr_col + * @li optional: expects type fb_pixel_t, as selected frame color + * @param[in] bg_col + * @li optional: expects type fb_pixel_t, as default background color + * @param[in] sel_bg_col + * @li optional: expects type fb_pixel_t, as selected background color + * @param[in] text_col + * @li optional: expects type fb_pixel_t, as default text color + * @param[in] sel_text_col + * @li optional: expects type fb_pixel_t, as selected text color + * @param[in] frame_width + * @li optional: expects type int, default = 1 + * @param[in] sel_frame_width + * @li optional: expects type int, default = 1 + */ + void setSelectedButton(size_t item_id, + const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2, + const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0, + const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0, + const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0, + const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT, + const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT, + const int& frame_width = 1, + const int& sel_frame_width = 1); +}; + +#endif //__CC_BTN_SEL_H__ diff --git a/src/gui/components/cc_detailsline.cpp b/src/gui/components/cc_detailsline.cpp index 81da16c5e..82dd27cca 100644 --- a/src/gui/components/cc_detailsline.cpp +++ b/src/gui/components/cc_detailsline.cpp @@ -61,7 +61,7 @@ void CComponentsDetailsLine::initVarDline( const int& x_pos, const int& y_pos_to shadow_w = 1; //CComponentsDetailsLine - thickness = 4; /* MUST be an even value! */ + dl_w = CFrameBuffer::getInstance()->scale2Res(3); cc_body_gradient_enable = false; } @@ -101,6 +101,7 @@ void CComponentsDetailsLine::paint(bool do_save_bg) int y_mark_top = y-h_mark_top/2; int y_mark_down = y_down-h_mark_down/2; + int dx_c = dl_w%2; //correction for odd values cc_fbdata_t fbdata[] = { @@ -108,26 +109,26 @@ void CComponentsDetailsLine::paint(bool do_save_bg) {true, CC_FBDATA_TYPE_BGSCREEN, x, y_mark_top, width, y_mark_down-y_mark_top+h_mark_down+sw, 0, 0, 0, 0, NULL, NULL, NULL, false}, /* vertical item mark | */ - {true, CC_FBDATA_TYPE_BOX, x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_body, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+width-dl_w-sw, y_mark_top, dl_w, h_mark_top, col_body, 0, 0, 0, NULL, NULL, NULL, false}, {true, CC_FBDATA_TYPE_BOX, x+width-sw, y_mark_top+sw, sw, h_mark_top-sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, - {true, CC_FBDATA_TYPE_BOX, x+width-thickness, y_mark_top+h_mark_top, thickness, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+width-dl_w, y_mark_top+h_mark_top, dl_w, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, /* horizontal item line - */ - {true, CC_FBDATA_TYPE_BOX, x, y-thickness/2, width-thickness-sw, thickness, col_body, 0, 0, 0, NULL, NULL, NULL, false}, - {true, CC_FBDATA_TYPE_BOX, x+thickness, y+thickness/2, width-2*thickness-sw, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x, y-dl_w/2, width-dl_w-sw, dl_w, col_body, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+dl_w, y+dl_w/2+dx_c, width-2*dl_w-sw, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, /* vertical connect line [ */ - {true, CC_FBDATA_TYPE_BOX, x, y+thickness/2, thickness, y_down-y-thickness, col_body, 0, 0, 0, NULL, NULL, NULL, false}, - {true, CC_FBDATA_TYPE_BOX, x+thickness, y+thickness/2+sw, sw, y_down-y-thickness-sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x, y+dl_w/2+dx_c, dl_w, y_down-y-dl_w, col_body, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+dl_w, y+dl_w/2+dx_c, sw, y_down-y-dl_w, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, /* horizontal info line - */ - {true, CC_FBDATA_TYPE_BOX, x, y_down-thickness/2, width-thickness-sw, thickness, col_body, 0, 0, 0, NULL, NULL, NULL, false}, - {true, CC_FBDATA_TYPE_BOX, x+sw, y_down+thickness/2, width-thickness-2*sw, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x, y_down-dl_w/2, width-dl_w-sw, dl_w, col_body, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+sw, y_down+dl_w/2+dx_c, width-dl_w-2*sw, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, /* vertical info mark | */ - {true, CC_FBDATA_TYPE_BOX, x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_body, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+width-dl_w-sw, y_mark_down, dl_w, h_mark_down, col_body, 0, 0, 0, NULL, NULL, NULL, false}, {true, CC_FBDATA_TYPE_BOX, x+width-sw, y_mark_down+sw, sw, h_mark_down-sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, - {true, CC_FBDATA_TYPE_BOX, x+width-thickness, y_mark_down+h_mark_down,thickness, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, + {true, CC_FBDATA_TYPE_BOX, x+width-dl_w, y_mark_down+h_mark_down,dl_w, sw, col_shadow, 0, 0, 0, NULL, NULL, NULL, false}, }; for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) diff --git a/src/gui/components/cc_detailsline.h b/src/gui/components/cc_detailsline.h index be07ef57f..66197f51f 100644 --- a/src/gui/components/cc_detailsline.h +++ b/src/gui/components/cc_detailsline.h @@ -40,8 +40,8 @@ Not usable as CCItem! class CComponentsDetailsLine : public CComponents { private: - ///property: line thickness - int thickness; + ///property: line width + int dl_w; ///property: lowest y position int y_down; ///property: height of top marker @@ -73,6 +73,8 @@ class CComponentsDetailsLine : public CComponents ///set all positions and dimensions of details line at once void setDimensionsAll(const int& x_pos,const int& y_pos, const int& y_pos_down, const int& h_mark_top_ , const int& h_mark_down_) {setXPos(x_pos); setYPos(y_pos); setYPosDown(y_pos_down); setHMarkTop(h_mark_top_); setHMarkDown(h_mark_down_);} + ///property: set line thickness + void setLineWidth(const int& w){dl_w = w;} ///paint all to screen void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index dbca41d93..0ac6128c0 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -35,8 +35,8 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha) { frameBuffer = CFrameBuffer::getInstance(); - x = cc_xr = x_old = 0; - y = cc_yr = y_old = 0; + x = cc_xr = cc_xr_old = x_old = 0; + y = cc_yr = cc_yr_old = y_old = 0; height = height_old = CC_HEIGHT_MIN; width = width_old = CC_WIDTH_MIN; @@ -95,14 +95,16 @@ CCDraw::~CCDraw() inline bool CCDraw::applyPosChanges() { bool ret = false; - if (x != x_old){ - dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes x %d != x_old %d...\033[0m\n", __func__, __LINE__, x, x_old); + if (x != x_old || cc_xr != cc_xr_old){ + dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes x %d != x_old %d... [cc_xr = %d cc_xr_old = %d]\033[0m\n", __func__, __LINE__, x, x_old, cc_xr, cc_xr_old); x_old = x; + cc_xr_old = cc_xr; ret = true; } - if (y != y_old){ - dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes y %d != y_old %d...\033[0m\n", __func__, __LINE__, y, y_old); + if (y != y_old || cc_yr != cc_yr_old){ + dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes y %d != y_old %d... [cc_yr = %d cc_yr_old = %d]\033[0m\n", __func__, __LINE__, y, y_old, cc_yr, cc_yr_old); y_old = y; + cc_yr_old = cc_yr; ret = true; } @@ -374,15 +376,16 @@ bool CCDraw::clearFbGradientData() for(size_t i =0; i< v_fbdata.size() ;i++) { if (v_fbdata[i].gradient_data){ if (v_fbdata[i].gradient_data->gradientBuf){ + dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], clean up gradientBuf \t %p...\033[0m\n", __func__, __LINE__, v_fbdata[i].gradient_data->gradientBuf); free(v_fbdata[i].gradient_data->gradientBuf); v_fbdata[i].gradient_data->gradientBuf = NULL; - dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], clean up gradientBuf...\033[0m\n", __func__, __LINE__); } if (v_fbdata[i].gradient_data->boxBuf){ + dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], clean up boxBuf \t %p...\033[0m\n", __func__, __LINE__, v_fbdata[i].gradient_data->boxBuf); cs_free_uncached(v_fbdata[i].gradient_data->boxBuf); v_fbdata[i].gradient_data->boxBuf = NULL; - dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], clean up boxBuf...\033[0m\n", __func__, __LINE__); } + dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], clean up gradient data \t %p...\033[0m\n", __func__, __LINE__, v_fbdata[i].gradient_data); delete v_fbdata[i].gradient_data; v_fbdata[i].gradient_data = NULL; ret = true; @@ -439,11 +442,13 @@ bool CCDraw::CheckFbData(const cc_fbdata_t& fbdata, const char* func, const int //screen area save fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) { + fb_pixel_t* pixbuf = NULL; + if (dx < 1 || dy < 1 || dx * dy == 0) return NULL; + else + pixbuf = new fb_pixel_t[dx * dy]; - dprintf(DEBUG_INFO, "[CCDraw] INFO! [%s - %d], ax = %d, ay = %d, dx = %d, dy = %d\n", __func__, __LINE__, ax, ay, dx, dy); - fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; frameBuffer->waitForIdle("CCDraw::getScreen()"); frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); return pixbuf; @@ -452,8 +457,14 @@ fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) cc_screen_data_t CCDraw::getScreenData(const int& ax, const int& ay, const int& dx, const int& dy) { cc_screen_data_t res; + res.x = res.y = res.dx = res.dy = 0; res.pixbuf = getScreen(ax, ay, dx, dy); - res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + + if (res.pixbuf){ + res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + } + else + dprintf(DEBUG_NORMAL, "\033[33m[CCDraw]\[%s - %d], Warning: initialize of screen buffer failed!\033[0m\n", __func__, __LINE__); return res; } @@ -720,14 +731,21 @@ void CCDraw::hide() //erase or paint over rendered objects void CCDraw::kill(const fb_pixel_t& bg_color, const int& corner_radius, const int& fblayer_type /*fbdata_type*/) { + int layers = fblayer_type; + + if (fblayer_type & ~CC_FBDATA_TYPES) + layers = CC_FBDATA_TYPES; + for(size_t i =0; i< v_fbdata.size() ;i++){ - if (fblayer_type == CC_FBDATA_TYPES || v_fbdata[i].fbdata_type & fblayer_type){ -#if 0 - if (bg_color != COL_BACKGROUND_PLUS_0) -#endif - int r = v_fbdata[i].r; - if (corner_radius > -1) - r = corner_radius; + if (v_fbdata[i].fbdata_type & layers){ + + int r = 0; + + if (corner_radius > -1){ + r = v_fbdata[i].r; + if (corner_radius != v_fbdata[i].r) + r = corner_radius; + } if (v_fbdata[i].dx > 0 && v_fbdata[i].dy > 0){ frameBuffer->paintBoxRel(v_fbdata[i].x, @@ -736,31 +754,28 @@ void CCDraw::kill(const fb_pixel_t& bg_color, const int& corner_radius, const in v_fbdata[i].dy, bg_color, r, - corner_type); + v_fbdata[i].rtype); + + if (v_fbdata[i].fbdata_type & CC_FBDATA_TYPE_FRAME){ + if (v_fbdata[i].frame_thickness) + frameBuffer->paintBoxFrame(v_fbdata[i].x, + v_fbdata[i].y, + v_fbdata[i].dx, + v_fbdata[i].dy, + v_fbdata[i].frame_thickness, + bg_color, + v_fbdata[i].r, + v_fbdata[i].rtype); + } }else dprintf(DEBUG_DEBUG, "\033[33m[CCDraw][%s - %d], WARNING! render with bad dimensions [dx = %d dy = %d]\033[0m\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy ); - if (v_fbdata[i].frame_thickness) - frameBuffer->paintBoxFrame(v_fbdata[i].x, - v_fbdata[i].y, - v_fbdata[i].dx, - v_fbdata[i].dy, - v_fbdata[i].frame_thickness, - bg_color, - r, - corner_type); v_fbdata[i].is_painted = false; -#if 0 - else - frameBuffer->paintBackgroundBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy); -#endif } } - if (fblayer_type == CC_FBDATA_TYPES){ - firstPaint = true; - is_painted = false; - } + firstPaint = true; + is_painted = false; } void CCDraw::killShadow(const fb_pixel_t& bg_color, const int& corner_radius) diff --git a/src/gui/components/cc_draw.h b/src/gui/components/cc_draw.h index 26b8875d5..76b047f4c 100644 --- a/src/gui/components/cc_draw.h +++ b/src/gui/components/cc_draw.h @@ -62,9 +62,9 @@ class CCDraw : public COSDFader, public CComponentsSignals ///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED int y, y_old; ///property: contains real x-position on screen - int cc_xr; + int cc_xr, cc_xr_old; ///property: contains real y-position on screen - int cc_yr; + int cc_yr, cc_yr_old; ///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll() int height, height_old; ///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll() @@ -184,17 +184,6 @@ class CCDraw : public COSDFader, public CComponentsSignals ///to set the real screen position, look at setRealPos() virtual void setPos(const int& xpos, const int& ypos){setXPos(xpos); setYPos(ypos);} - ///sets real x position on screen. Use this, if item is added to a parent form - virtual void setRealXPos(const int& xr){cc_xr = xr;} - ///sets real y position on screen. Use this, if item is added to a parent form - virtual void setRealYPos(const int& yr){cc_yr = yr;} - ///sets real x and y position on screen at once. Use this, if item is added to a parent form - virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;} - ///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form - virtual int getRealXPos(){return cc_xr;} - ///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form - virtual int getRealYPos(){return cc_yr;} - ///set height of component on screen virtual void setHeight(const int& h); ///set width of component on screen @@ -284,6 +273,8 @@ class CCDraw : public COSDFader, public CComponentsSignals virtual void enableSaveBg(bool save_bg = true); ///disable background buffering, does the same like enableSaveBg(false), NOTE: cleans existant pixbuffer content! virtual void disableSaveBg(){enableSaveBg(false);} + ///returns background buffering mode. Mode is assigned with paint() or enableSaveBg()/disableSaveBg()) + bool SaveBg(){return cc_save_bg;} ///allow/disalows paint of item and its contents, but initialize of other properties are not touched ///this can be understood as a counterpart to isPainted(), but before paint and value of is_painted is modified temporarily till next paint of item //TODO: is this sufficiently? @@ -394,7 +385,7 @@ class CCDraw : public COSDFader, public CComponentsSignals * Shadow paint must be reworked, because dimensions of shadow containes not the real defined size. Parts of item are killed too. * */ - virtual void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, const int& corner_radius = -1, const int& fblayer_type = CC_FBDATA_TYPES); + virtual void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, const int& corner_radius = -1, const int& fblayer_type = ~CC_FBDATA_TYPES); /**Erase shadow around rendered item. * This is similar with the kill() member, but shadow will be handled only. diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index dd414b5fb..1ff0184a4 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -68,7 +68,7 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w, page_count = 1; cur_page = 0; sb = NULL; - w_sb = 15; + w_sb = SCROLLBAR_WIDTH; page_scroll_mode = PG_SCROLL_M_UP_DOWN_KEY; @@ -186,9 +186,7 @@ void CComponentsForm::clear() for(size_t i=0; igetItemType()); - + dprintf(DEBUG_DEBUG, "[CComponentsForm] %s... delete form cc-item %d of %d (type=%d)\taddress = %p\n", __func__, (int)i+1, (int)v_cc_items.size(), v_cc_items[i]->getItemType(), v_cc_items[i]); delete v_cc_items[i]; v_cc_items[i] = NULL; } @@ -259,6 +257,16 @@ CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) return NULL; } +CComponentsItem* CComponentsForm::getPrevCCItem(CComponentsItem* current_cc_item) +{ + return getCCItem(getCCItemId(current_cc_item) - 1); +} + +CComponentsItem* CComponentsForm::getNextCCItem(CComponentsItem* current_cc_item) +{ + return getCCItem(getCCItemId(current_cc_item) + 1); +} + void CComponentsForm::replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item) { if (!v_cc_items.empty()){ @@ -375,6 +383,7 @@ void CComponentsForm::paintCCItems() if (cc_parent){ this_x = auto_x = cc_xr; this_y = auto_y = cc_yr; + w_parent_frame = cc_parent->getFrameThickness(); } //init and handle scrollbar @@ -482,7 +491,7 @@ void CComponentsForm::paintCCItems() //Is it too wide or too high, it will be shortened and displayed in the log. //This should be avoid! //checkwidth and adapt if required - int right_frm = (cc_parent ? cc_xr : x) + this_w - 2*fr_thickness; + int right_frm = (cc_parent ? cc_xr : x) + this_w/* - 2*fr_thickness*/; int right_item = cc_item->getRealXPos() + w_item; int w_diff = right_item - right_frm; int new_w = w_item - w_diff; @@ -517,7 +526,7 @@ void CComponentsForm::paintCCItems() //finally paint current item, but only required contents of page if (cc_item->getPageNumber() == cur_page) - cc_item->paint(CC_SAVE_SCREEN_NO); + cc_item->paint(cc_item->SaveBg()); //restore defined old visibility mode of item after paint cc_item->allowPaint(item_visible); @@ -531,6 +540,12 @@ void CComponentsForm::killCCItems(const fb_pixel_t& bg_color, bool ignore_parent v_cc_items[i]->kill(bg_color, ignore_parent); } +void CComponentsForm::hideCCItems() +{ + for(size_t i=0; ihide(); +} + void CComponentsForm::setPageCount(const u_int8_t& pageCount) { u_int8_t new_val = pageCount; @@ -680,3 +695,21 @@ bool CComponentsForm::enableColBodyGradient(const int& enable_mode, const fb_pix } return false; } + +int CComponentsForm::getUsedDY() +{ + int y_res = 0; + for (size_t i= 0; i< v_cc_items.size(); i++) + y_res = max(v_cc_items[i]->getYPos() + v_cc_items[i]->getHeight(), y_res); + + return y_res; +} + +int CComponentsForm::getUsedDX() +{ + int x_res = 0; + for (size_t i= 0; i< v_cc_items.size(); i++) + x_res = max(v_cc_items[i]->getXPos() + v_cc_items[i]->getWidth(), x_res); + + return x_res; +} diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 3561e495a..ca8daa31f 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -28,7 +28,7 @@ #include "config.h" #include "cc_base.h" #include "cc_item.h" -#include "cc_frm_scrollbar.h" + class CComponentsForm : public CComponentsItem { @@ -81,6 +81,16 @@ class CComponentsForm : public CComponentsItem ///NOTE: Items always have parent bindings to "this" and use the parent background color as default! Set parameter 'ignore_parent=true' to ignore parent background color! virtual void killCCItems(const fb_pixel_t& bg_color, bool ignore_parent); + /** + Removes possible contained items and finally removes + current form from screen and + restores last displayed background before form was painted. + */ + void hide(){hideCCItems(); CCDraw::hide();} + + ///restore background for all items inside form, + void hideCCItems(); + ///add an item to form collection, returns id virtual int addCCItem(CComponentsItem* cc_Item); ///add items from a vector to form collection, returns size/count of items @@ -96,8 +106,39 @@ class CComponentsForm : public CComponentsItem virtual void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item); virtual void exchangeCCItem(const uint& item_id_a, const uint& item_id_b); virtual void exchangeCCItem(CComponentsItem* item_a, CComponentsItem* item_b); - virtual int getCCItemId(CComponentsItem* cc_Item); - virtual CComponentsItem* getCCItem(const uint& cc_item_id); + + /**Function to get current item id from passed item. + * @param[in] cc_Item + * @li CComponentsItem* + * @return + * int, in case of not found item returns -1 + */ + int getCCItemId(CComponentsItem* cc_Item); + + /**Function to get current item from item collection. + * @param[in] cc_item_id + * @li item id as unsigned int + * @return + * CComponentsItem*, in case of not found item returns NULL + */ + CComponentsItem* getCCItem(const uint& cc_item_id); + + /**Function to get previous item from item collection. + * @param[in] current_cc_item + * @li CComponentsItem* + * @return + * CComponentsItem*, in case of not found item returns NULL + */ + CComponentsItem* getPrevCCItem(CComponentsItem* current_cc_item); + + /**Function to get next item from item collection. + * @param[in] current_cc_item + * @li CComponentsItem* + * @return + * CComponentsItem*, in case of not found item returns NULL + */ + CComponentsItem* getNextCCItem(CComponentsItem* current_cc_item); + virtual void paintCCItems(); ///clean up and deallocate existant items from v_cc_items at once @@ -142,12 +183,37 @@ class CComponentsForm : public CComponentsItem virtual void setScrollBarWidth(const int& scrollbar_width){w_sb = scrollbar_width;}; ///returns id of selected item, return value as int, returns -1: if is nothing selected virtual int getSelectedItem(); + + /**Function to get consumed space of items inside form in y direction. + * @return + * int, used lines + */ + int getUsedDY(); + + /**Function to get consumed space of items inside form in x direction. + * @return + * int, used lines + */ + int getUsedDX(); + + /**Function to get free usable space of items inside form in y direction. + * @return + * int, free lines + */ + int getFreeDY(){return height - getUsedDY();} + + /**Function to get free usable space of items inside form in x direction. + * @return + * int, free lines + */ + int getFreeDX(){return width - getUsedDX();} + ///returns pointer to selected item, return value as CComponentsItem*, returns NULL: if is nothing selected virtual CComponentsItem* getSelectedItemObject(); ///select a definied item, parameter1 as size_t virtual void setSelectedItem( int item_id, const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0, + const fb_pixel_t& frame_col = COL_FRAME_PLUS_0, const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0, const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0, const int& frame_w = 3, @@ -155,7 +221,7 @@ class CComponentsForm : public CComponentsItem ///select a definied item, parameter1 as CComponentsItem* virtual void setSelectedItem( CComponentsItem* cc_item, const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0, + const fb_pixel_t& frame_col = COL_FRAME_PLUS_0, const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0, const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0, const int& frame_w = 3, diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index b7e964356..c0c0039b0 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -106,13 +106,13 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const cc_body_gradient_enable = CC_COLGRAD_OFF/*g_settings.gradiant*/; //TODO: gradient is prepared for use but disabled at the moment till some other parts of gui parts are provide gradient setColBodyGradient(cc_body_gradient_enable/*CColorGradient::gradientLight2Dark*/, CFrameBuffer::gradientVertical, CColorGradient::light); col_frame = color_frame; - col_body = cc_body_gradient_enable? COL_DARK_GRAY : color_body; + col_body = col_body_old = cc_body_gradient_enable? COL_DARK_GRAY : color_body; col_shadow = color_shadow; cc_item_enabled = enabled; cc_item_selected = selected; fr_thickness = 0; //TODO: parts of the GUI still don't use framed buttons - append_x_offset = 6; + append_x_offset = OFFSET_INTER; append_y_offset = 0; corner_rad = RADIUS_SMALL; @@ -187,6 +187,7 @@ void CComponentsButton::initCaption() } //set basic properties + int x_offset = (!cc_btn_text_obj || !cc_btn_icon_obj) ? 0 : append_x_offset; int w_frame = fr_thickness; int reduce = 2*w_frame; if (cc_btn_text_obj){ @@ -198,7 +199,7 @@ void CComponentsButton::initCaption() if (cc_btn_font == NULL) cc_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT]; - int w_cap = min(width - append_x_offset - x_cap - reduce, cc_btn_font->getRenderWidth(cc_btn_text)); + int w_cap = min(width - x_offset - x_cap - reduce, cc_btn_font->getRenderWidth(cc_btn_text)); int h_cap = min(height - reduce, cc_btn_font->getHeight()); /*NOTE: paint of centered text in y direction without y_offset @@ -235,10 +236,10 @@ void CComponentsButton::initCaption() } //handle common position of icon and text inside container required for alignment - int w_required = w_frame + append_x_offset; - w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0; + int w_required = w_frame + x_offset; + w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + x_offset : 0; w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_text) : 0; - w_required += append_x_offset + w_frame; + w_required += x_offset + w_frame; //dynamic width if (w_required > width){ @@ -247,10 +248,10 @@ void CComponentsButton::initCaption() } //do center - int x_icon = width/2 - w_required/2 /*+ fr_thickness + append_x_offset*/; + int x_icon = width/2 - w_required/2 /*+ fr_thickness + x_offset*/; int w_icon = 0; if (cc_btn_icon_obj){ - x_icon += w_frame + append_x_offset; + x_icon += w_frame + x_offset; cc_btn_icon_obj->setXPos(x_icon); w_icon = cc_btn_icon_obj->getWidth(); /*in case of dynamic changed height of caption or button opbject itself, @@ -260,7 +261,7 @@ void CComponentsButton::initCaption() cc_btn_icon_obj->setYPos(y_icon); } if (cc_btn_text_obj){ - cc_btn_text_obj->setXPos(x_icon + w_icon + append_x_offset); + cc_btn_text_obj->setXPos(x_icon + w_icon + x_offset); cc_btn_text_obj->setWidth(width - cc_btn_text_obj->getXPos()); } } diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 1e36bd826..c85777ff7 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -103,7 +103,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const neutrino_locale_t& caption_locale, @@ -112,7 +112,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const neutrino_locale_t& caption_locale, @@ -121,7 +121,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption, @@ -130,7 +130,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); ///set text color void setButtonTextColor(fb_pixel_t caption_color){cc_btn_text_col = caption_color;}; @@ -246,7 +246,7 @@ class CComponentsButtonRed : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_RED; @@ -257,7 +257,7 @@ class CComponentsButtonRed : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_RED; @@ -277,7 +277,7 @@ class CComponentsButtonGreen : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_GREEN; @@ -289,7 +289,7 @@ class CComponentsButtonGreen : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_GREEN; @@ -309,7 +309,7 @@ class CComponentsButtonYellow : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW; @@ -320,7 +320,7 @@ class CComponentsButtonYellow : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW; @@ -340,7 +340,7 @@ class CComponentsButtonBlue : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_BLUE; @@ -351,7 +351,7 @@ class CComponentsButtonBlue : public CComponentsButton bool selected = false, bool enabled = true, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) + fb_pixel_t color_frame = COL_FRAME_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0) :CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_BUTTON_BLUE; diff --git a/src/gui/components/cc_frm_chain.cpp b/src/gui/components/cc_frm_chain.cpp index 4910e469c..dcc261265 100644 --- a/src/gui/components/cc_frm_chain.cpp +++ b/src/gui/components/cc_frm_chain.cpp @@ -27,6 +27,25 @@ using namespace std; + +/* general chain form shema + + x/y + / + +---------------------------------------width----------------------------------------+ + | chn_t_offset | + | +--------+ +--------+ +--------+ | + |chn_l_offset| item |append_x_offset| item |append_x_offset| item |chn_r_offset| + | +--------+ +--------+ +--------+ | + | append_y_offset |height + | +--------+ +--------+ +--------+ | + | | item | | item | | item | | + | +--------+ +--------+ +--------+ | + | chn_b_offset | + +------------------------------------------------------------------------------------+ +*/ + + //------------------------------------------------------------------------------------------------------- //sub class CComponentsFrmChain CComponentsFrmChain::CComponentsFrmChain( const int& x_pos, const int& y_pos, const int& w, const int& h, @@ -59,11 +78,14 @@ void CComponentsFrmChain::initVarChain( const int& x_pos, const int& y_pos, cons width = w; height = h; + chn_l_offset = chn_r_offset = 0; + chn_t_offset = chn_b_offset = 0; + shadow = shadow_mode; col_frame = color_frame; col_body = color_body; col_shadow = color_shadow; - + chn_direction = direction; if (v_items) @@ -86,23 +108,65 @@ void CComponentsFrmChain::initChainItems() return; //set new values - int w_tmp = append_x_offset; - int h_tmp = append_y_offset; + int w_tmp = 0, h_tmp = 0; + int w_item = 0, h_item = 0; + size_t i_count = v_cc_items.size(); - for (size_t i= 0; i< v_cc_items.size(); i++){ - int x_item = v_cc_items[i]->getXPos(); - int y_item = v_cc_items[i]->getYPos(); + + for (size_t i= 0; i< i_count; i++){ +// x_item = v_cc_items[i]->getXPos(); +// y_item = v_cc_items[i]->getYPos(); + w_item = v_cc_items[i]->getWidth(); + h_item = v_cc_items[i]->getHeight(); if (chn_direction & CC_DIR_X){ - w_tmp += v_cc_items[i]->getWidth(); - w_tmp += append_x_offset; - v_cc_items[i]->setPos(max(CC_APPEND, x_item), max(CC_CENTERED, y_item)); + if (i == 0){ + v_cc_items[i]->setXPos(chn_l_offset); + w_tmp += chn_l_offset; + w_tmp += w_item; + if (i_count == 1) + w_tmp += chn_r_offset; + } + + if (i_count > 1){ + if (i == i_count-1){ + w_tmp += w_item; + w_tmp += append_x_offset; + v_cc_items[i]->setXPos(w_tmp - v_cc_items[i]->getWidth()); + w_tmp += chn_r_offset; + } + } + + if (i != 0 && i != i_count-1){ + w_tmp += w_item; + w_tmp += append_x_offset; + v_cc_items[i]->setXPos(w_tmp - v_cc_items[i]->getWidth()); + } } if (chn_direction & CC_DIR_Y){ - h_tmp += v_cc_items[i]->getHeight(); - h_tmp += append_y_offset; - v_cc_items[i]->setPos(max(CC_CENTERED, x_item), max(CC_APPEND, y_item)); + if (i == 0){ + v_cc_items[i]->setYPos(chn_t_offset); + h_tmp += chn_t_offset; + h_tmp += h_item; + if (i_count == 1) + h_tmp += chn_b_offset; + } + + if (i_count > 1){ + if (i == i_count-1){ + h_tmp += h_item; + h_tmp += append_y_offset; + v_cc_items[i]->setYPos(h_tmp - v_cc_items[i]->getHeight()); + h_tmp += chn_b_offset; + } + } + + if (i != 0 && i != i_count-1){ + h_tmp += h_item; + h_tmp += append_y_offset; + v_cc_items[i]->setYPos(h_tmp - v_cc_items[i]->getHeight()); + } } } width = max (w_tmp, width); diff --git a/src/gui/components/cc_frm_chain.h b/src/gui/components/cc_frm_chain.h index a33f63ed8..560984a5e 100644 --- a/src/gui/components/cc_frm_chain.h +++ b/src/gui/components/cc_frm_chain.h @@ -55,6 +55,10 @@ class CComponentsFrmChain : public CComponentsForm fb_pixel_t& color_frame, fb_pixel_t& color_body, fb_pixel_t& color_shadow); + + int chn_l_offset, chn_r_offset; + int chn_t_offset, chn_b_offset; + protected: ///property: mode for arrangement direction of items, see also setDirection(), getDirection() int chn_direction; @@ -75,7 +79,26 @@ class CComponentsFrmChain : public CComponentsForm ///defines mode for arrangement direction of items, see also chn_direction virtual void setDirection(int direction); ///gets the mode of arrangment direction - virtual int getDirection(){return chn_direction;}; + virtual int getDirection(){return chn_direction;} + + /**Members to set border offsets + * @param[in] offset + * @li expects type int as offset value + * @return + * void + */ + void setLeftOffset(const int& offset){chn_l_offset = offset;} + void setRightOffset(const int& offset){chn_r_offset = offset;} + void setTopOffset(const int& offset){chn_t_offset = offset;} + void setBottomOffset(const int& offset){chn_b_offset = offset;} + + void setBorderOffsets(const int& left_offset, const int& right_offset, const int& top_offset, const int& bottom_offset) + { + setLeftOffset(left_offset); + setRightOffset(right_offset); + setTopOffset(top_offset); + setBottomOffset(bottom_offset); + } }; #endif diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index a13193e09..1beb3d70f 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -59,8 +59,8 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, { cc_item_type = CC_ITEMTYPE_FRM_CLOCK; - x = x_pos; - y = y_pos; + x = cc_xr = x_old = x_pos; + y = cc_yr = y_old = y_pos; shadow = shadow_mode; shadow_w = OFFSET_SHADOW; @@ -74,6 +74,9 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, setClockFormat(prformat_str, secformat_str); cl_col_text = COL_MENUCONTENT_TEXT; + //enable refresh of all segments on each interval as default + cl_force_repaint = true; + //init default font cl_font = font; cl_font_style = font_style; @@ -81,15 +84,12 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, initClockFont(0, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight()); //init general clock dimensions - height = cl_font->getHeight(); - width = cl_font->getRenderWidth(cl_format_str); + height = height_old= cl_font->getHeight(); + width = width_old = cl_font->getRenderWidth(cl_format_str); //set default text background behavior cc_txt_save_screen = false; - //enable refresh of all segments on each interval as default - cl_force_repaint = true; - //set default running clock properties cl_interval = interval_seconds; cl_timer = NULL; @@ -112,8 +112,9 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, CComponentsFrmClock::~CComponentsFrmClock() { - if (cl_timer) - delete cl_timer; + if (cl_timer){ + delete cl_timer; cl_timer = NULL; + } } void CComponentsFrmClock::initClockFont(int dx, int dy) @@ -325,12 +326,14 @@ bool CComponentsFrmClock::startClock() if (cl_timer == NULL){ cl_timer = new CComponentsTimer(0); cl_timer->setThreadName("frmClock"); - if (cl_timer->OnTimer.empty()){ - dprintf(DEBUG_INFO,"\033[33m[CComponentsFrmClock]\t[%s] init slot...\033[0m\n", __func__); - cl_timer->OnTimer.connect(cl_sl_show); - force_paint_bg = true; - } } + + if (cl_timer->OnTimer.empty()){ + dprintf(DEBUG_INFO,"\033[33m[CComponentsFrmClock]\t[%s] init slot...\033[0m\n", __func__); + cl_timer->OnTimer.connect(cl_sl_show); + force_paint_bg = true; + } + cl_timer->setTimerInterval(cl_interval); if (cl_timer->startTimer()) @@ -390,7 +393,7 @@ void CComponentsFrmClock::paint(bool do_save_bg) void CComponentsFrmClock::setClockFont(Font *font, const int& style) { - if (cl_font != font || (cl_font != font)){ + if (cl_font != font || cl_font_style != style){ if (cl_font != font) cl_font = font; if (style != -1) @@ -429,9 +432,9 @@ void CComponentsFrmClock::setHeight(const int& h) int f_height = cl_font->getHeight(); if (h != f_height){ dprintf(DEBUG_DEBUG, "\033[33m[CComponentsFrmClock]\t[%s - %d], font height is different than current height [%d], using [%d] ...\033[0m\n", __func__, __LINE__, h, f_height); - CCDraw::setHeight(f_height); + CComponentsItem::setHeight(f_height); }else - CCDraw::setHeight(h); + CComponentsItem::setHeight(h); initCCLockItems(); } @@ -443,9 +446,9 @@ void CComponentsFrmClock::setWidth(const int& w) int f_width = cl_font->getRenderWidth(cl_format_str); if (w != f_width){ dprintf(DEBUG_NORMAL, "\033[33m[CComponentsFrmClock]\t[%s - %d], font width is different than current width [%d], using [%d] ...\033[0m\n", __func__, __LINE__, w, f_width); - CCDraw::setWidth(f_width); + CComponentsItem::setWidth(f_width); }else - CCDraw::setWidth(w); + CComponentsItem::setWidth(w); initCCLockItems(); } diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 864336d91..0587d90db 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -31,7 +31,8 @@ #include -#define DEF_HEIGHT 27 +#define DEF_HEIGHT CFrameBuffer::getInstance()->scale2Res(27) +#define DEF_WIDTH CFrameBuffer::getInstance()->scale2Res(300) #define DEF_LABEL_WIDTH_PERCENT 30 using namespace std; @@ -39,7 +40,7 @@ using namespace std; CComponentsExtTextForm::CComponentsExtTextForm(CComponentsForm* parent) { Font* t_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]; - initVarExtTextForm(0, 0, 300, t_font->getHeight(), "", "", t_font, parent, CC_SHADOW_OFF, COL_MENUCONTENTINACTIVE_TEXT, COL_MENUCONTENT_TEXT, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); + initVarExtTextForm(0, 0, DEF_WIDTH, t_font->getHeight(), "", "", t_font, parent, CC_SHADOW_OFF, COL_MENUCONTENTINACTIVE_TEXT, COL_MENUCONTENT_TEXT, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); initCCTextItems(); } @@ -86,8 +87,7 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p width = w; //init ccx_label_width and ccx_text_width //default ccx_label_width = 30% of form width - ccx_percent_label_w = DEF_LABEL_WIDTH_PERCENT; - ccx_label_width = ccx_percent_label_w * width/100; + ccx_label_width = DEF_LABEL_WIDTH_PERCENT * width/100; ccx_text_width = width-ccx_label_width; height = h; @@ -223,7 +223,8 @@ void CComponentsExtTextForm::initCCTextItems() void CComponentsExtTextForm::setLabelWidthPercent(const uint8_t& percent_val) { - ccx_percent_label_w = (int)percent_val; + ccx_label_width = (int)percent_val * width/100; + ccx_text_width = width-ccx_label_width; initCCTextItems(); } diff --git a/src/gui/components/cc_frm_ext_text.h b/src/gui/components/cc_frm_ext_text.h index 837eb8c18..4e37efd0f 100644 --- a/src/gui/components/cc_frm_ext_text.h +++ b/src/gui/components/cc_frm_ext_text.h @@ -49,8 +49,6 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen int ccx_text_width; ///property: font type of both items (label and text), see also setLabelAndText() Font* ccx_font; - ///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent() - uint8_t ccx_percent_label_w; ///centered y position of label and text int y_text; diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 335b578b7..5ff2a5200 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -35,7 +35,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------- //sub class CComponentsFooter inherit from CComponentsHeader -CComponentsFooter::CComponentsFooter(CComponentsForm* parent) +CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect() { //CComponentsFooter initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0); @@ -47,7 +47,7 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int shadow_mode, fb_pixel_t color_frame, fb_pixel_t color_body, - fb_pixel_t color_shadow ) + fb_pixel_t color_shadow ):CCButtonSelect() { //CComponentsFooter initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow); @@ -95,7 +95,6 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const corner_type = CORNER_BOTTOM; ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment - chain = NULL; addContextButton(buttons); initCCItems(); @@ -108,8 +107,11 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width) { /* clean up before init*/ - if (chain) - chain->clear(); + if (btn_container) + btn_container->clear(); + + if (label_count == 0) + return; /* set general available full basic space for button chain, * in this case this is footer width @@ -121,8 +123,8 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con * If already existing some items then subtract those width from footer width. * ...so we have the possible usable size for button container. */ - if(!v_cc_items.empty()){ //FIXME: footer container seems always not empty here, so here j initialized with = 1. I dont't know where it comes from! dbt! - for (size_t j= 1; j< size(); j++) + if(!v_cc_items.empty()){ + for (size_t j= 0; j< size(); j++) w_chain -= getCCItem(j)->getWidth(); } @@ -147,11 +149,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con int y_chain = height/2 - h_chain/2; if (cch_icon_obj) x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset; - if (chain == NULL){ - chain = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body); - chain->setAppendOffset(0, 0); - chain->setCorner(this->corner_rad, this->corner_type); - chain->doPaintBg(false); + if (btn_container == NULL){ + btn_container = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body); + btn_container->setAppendOffset(0, 0); + btn_container->setCorner(this->corner_rad, this->corner_type); + btn_container->doPaintBg(false); } /* Calculate usable width of button labels inside button object container @@ -163,11 +165,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con * button objects itself. */ int w_offset = int((label_count-1)*cch_offset); - int w_btn = chain->getWidth()/label_count - w_offset; + int w_btn = btn_container->getWidth()/label_count - w_offset; if (label_width){ int w_label = label_width; int w_defined = int(label_width*label_count); - int w_max = chain->getWidth() - w_offset; + int w_max = btn_container->getWidth() - w_offset; while (w_defined > w_max){ w_label--; w_defined = int(w_label*label_count) - w_offset; @@ -179,7 +181,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con * with default width to chain object. */ vector v_btns; - int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width; + int h_btn = /*(ccf_enable_button_bg ? */btn_container->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width; for (size_t i= 0; i< label_count; i++){ string txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale); string icon_name = string(content[i].button); @@ -190,7 +192,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con continue; } - int y_btn = chain->getHeight()/2 - h_btn/2; + int y_btn = btn_container->getHeight()/2 - h_btn/2; dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width); CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow); @@ -221,27 +223,27 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con btn->setButtonFont(NULL); } - dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%zu] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, chain->getWidth()); + dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%zu] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, btn_container->getWidth()); } /* add generated button objects to chain object. */ if (!v_btns.empty()){ /*add all buttons into button container*/ - chain->addCCItem(v_btns); + btn_container->addCCItem(v_btns); /* set position of labels, as centered inside button container*/ int w_chain_used = 0; - for (size_t a= 0; a< chain->size(); a++) - w_chain_used += chain->getCCItem(a)->getWidth(); - w_chain_used += (chain->size()-1)*cch_offset; + for (size_t a= 0; a< btn_container->size(); a++) + w_chain_used += btn_container->getCCItem(a)->getWidth(); + w_chain_used += (btn_container->size()-1)*cch_offset; - int x_btn = chain->getWidth()/2 - w_chain_used/2; - chain->getCCItem(0)->setXPos(x_btn); + int x_btn = btn_container->getWidth()/2 - w_chain_used/2; + btn_container->getCCItem(0)->setXPos(x_btn); - for (size_t c= 1; c< chain->size(); c++){ - x_btn += chain->getCCItem(c-1)->getWidth()+ cch_offset; - chain->getCCItem(c)->setXPos(x_btn); + for (size_t c= 1; c< btn_container->size(); c++){ + x_btn += btn_container->getCCItem(c-1)->getWidth()+ cch_offset; + btn_container->getCCItem(c)->setXPos(x_btn); } } } @@ -314,49 +316,12 @@ void CComponentsFooter::setButtonLabel( const char *button_icon, void CComponentsFooter::enableButtonBg(bool enable) { ccf_enable_button_bg = enable; - if (chain) { - for (size_t i= 0; i< chain->size(); i++) - chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg); + if (btn_container) { + for (size_t i= 0; i< btn_container->size(); i++) + btn_container->getCCItem(i)->doPaintBg(ccf_enable_button_bg); } } -void CComponentsFooter::setSelectedButton(size_t item_id, - const fb_pixel_t& fr_col, const fb_pixel_t& sel_fr_col, - const fb_pixel_t& bg_col, const fb_pixel_t& sel_bg_col, - const fb_pixel_t& text_col, const fb_pixel_t& sel_text_col, - const int& frame_width, - const int& sel_frame_width) -{ - if (chain){ - for (size_t i= 0; i< chain->size(); i++){ - CComponentsButton *btn = static_cast(chain->getCCItem(i)); - btn->setButtonTextColor(text_col); - } - fb_pixel_t sel_col = fr_col; - if (chain->size() > 1) - sel_col = sel_fr_col; //TODO: make it configurable - chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width); - - getSelectedButtonObject()->setButtonTextColor(sel_text_col); - } -} - -int CComponentsFooter::getSelectedButton() -{ - int ret = -1; - if (chain) - ret = chain->getSelectedItem(); - - return ret; -} - -CComponentsButton* CComponentsFooter::getSelectedButtonObject() -{ - CComponentsButton* ret = static_cast(chain->getSelectedItemObject()); - return ret; -} - - void CComponentsFooter::paintButtons(const int& x_pos, const int& y_pos, const int& w, @@ -372,7 +337,6 @@ void CComponentsFooter::paintButtons(const int& x_pos, this->setButtonFont(font); this->setContextButton(context_buttons); this->setButtonLabels(content, label_count, 0, label_width); - this->paint(do_save_bg); } @@ -393,12 +357,12 @@ void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bo ccf_enable_button_shadow = mode; ccf_button_shadow_width = shadow_width; ccf_button_shadow_force_paint = force_paint; - if (chain){ - for(size_t i=0; isize(); i++){ - chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint); + if (btn_container){ + for(size_t i=0; isize(); i++){ + btn_container->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint); //int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width; - int y_btn = chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2; - chain->getCCItem(i)->setYPos(y_btn); + int y_btn = btn_container->getHeight()/2 - btn_container->getCCItem(i)->getHeight()/2; + btn_container->getCCItem(i)->setYPos(y_btn); } } } diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index 852faaae1..2586d1772 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -26,6 +26,8 @@ #include "cc_frm_header.h" #include "cc_frm_button.h" +#include "cc_button_select.h" + #include #include //for compatibility with 'button_label' type @@ -39,7 +41,7 @@ to add button labels known by older button handler, to find in gui/widget/button functionality. Why limited ?: old parameter 'struct button_label' doesn't provide newer parameters. Missing parameters are filled with default values and must be assigned afterward, if required. */ -class CComponentsFooter : public CComponentsHeader +class CComponentsFooter : public CComponentsHeader, public CCButtonSelect { private: void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h, @@ -67,9 +69,6 @@ class CComponentsFooter : public CComponentsHeader ///init default fonts for size modes virtual void initDefaultFonts(); - ///container for button objects - CComponentsFrmChain *chain; - public: CComponentsFooter(CComponentsForm *parent = NULL); CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, @@ -114,40 +113,6 @@ class CComponentsFooter : public CComponentsHeader ///disables background of buttons void disableButtonBg(){enableButtonBg(false);} - /**Select a definied button inside button chain object - * @param[in] item_id - * @li optional: exepts type size_t - * @param[in] fr_col - * @li optional: exepts type fb_pixel_t, as default frame color - * @param[in] sel_fr_col - * @li optional: exepts type fb_pixel_t, as selected frame color - * @param[in] bg_col - * @li optional: exepts type fb_pixel_t, as default background color - * @param[in] sel_bg_col - * @li optional: exepts type fb_pixel_t, as selected background color - * @param[in] text_col - * @li optional: exepts type fb_pixel_t, as default text color - * @param[in] sel_text_col - * @li optional: exepts type fb_pixel_t, as selected text color - * @param[in] frame_width - * @li optional: exepts type int, default = 1 - * @param[in] sel_frame_width - * @li optional: exepts type int, default = 2 - */ - void setSelectedButton(size_t item_id, - const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2, - const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0, - const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT, - const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT, - const int& frame_width = 1, - const int& sel_frame_width = 1); - ///returns id of select button, return value as int, -1 = nothing is selected - int getSelectedButton(); - ///returns selected button object, return value as pointer to object, NULL means nothing is selected - CComponentsButton* getSelectedButtonObject(); - /*! Sets a new text to an already predefined button. 1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string @@ -164,10 +129,6 @@ class CComponentsFooter : public CComponentsHeader ///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font void setButtonFont(Font* font){ccf_btn_font = font;}; - ///returns pointer to internal button container - CComponentsFrmChain* getButtonChainObject(){return chain;}; - - ///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input ///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required void paintButtons( const int& x_pos, @@ -196,4 +157,6 @@ class CComponentsFooter : public CComponentsHeader void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);} }; + + #endif diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index e780b86b2..4d61a3bfc 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -31,6 +31,9 @@ #include "cc_frm_header.h" #include #include +#include + +extern CPictureViewer * g_PicViewer; using namespace std; @@ -62,21 +65,18 @@ CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const initVarHeader(x_pos, y_pos, w, h, caption, icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow); } -CComponentsHeaderLocalized::CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h, - neutrino_locale_t caption_locale, - const std::string& icon_name, - const int& buttons, - CComponentsForm* parent, - int shadow_mode, - fb_pixel_t color_frame, - fb_pixel_t color_body, - fb_pixel_t color_shadow) - :CComponentsHeader( x_pos, y_pos, w, h, - g_Locale->getText(caption_locale), - icon_name, buttons, - parent, - shadow_mode, - color_frame, color_body, color_shadow){}; +CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h, + neutrino_locale_t caption_locale, + const std::string& icon_name, + const int& buttons, + CComponentsForm* parent, + int shadow_mode, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow) +{ + initVarHeader(x_pos, y_pos, w, h, g_Locale->getText(caption_locale), icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow); +}; void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption, @@ -91,8 +91,8 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cc_item_type = CC_ITEMTYPE_FRM_HEADER; clear(); cc_txt_save_screen = false; - x = x_old = x_pos; - y = y_old = y_pos; + x = cc_xr = x_old = x_pos; + y = cc_yr = y_old = y_pos; //init header width width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w; @@ -121,8 +121,13 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_text_obj = NULL; cch_btn_obj = NULL; cch_cl_obj = NULL; + cch_logo_obj = NULL; + cch_logo.Id = 0; + cch_logo.Name = ""; + cch_logo.dy_max = -1; + cch_logo.Align = DEFAULT_LOGO_ALIGN; cch_col_text = COL_MENUHEAD_TEXT; - cch_caption_align = CTextBox::NO_AUTO_LINEBREAK; + cch_caption_align = DEFAULT_TITLE_ALIGN; cch_items_y = CC_CENTERED; cch_offset = OFFSET_INNER_MID; cch_icon_x = cch_offset; @@ -155,7 +160,7 @@ CComponentsHeader::~CComponentsHeader() v_cch_btn.clear(); } -void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode, const fb_pixel_t& text_color) +void CComponentsHeader::setCaption(const std::string& caption, const cc_title_alignment_t& align_mode, const fb_pixel_t& text_color) { if (cch_cl_obj) cch_cl_obj->Stop(); @@ -164,7 +169,7 @@ void CComponentsHeader::setCaption(const std::string& caption, const int& align_ cch_col_text = text_color; } -void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& align_mode, const fb_pixel_t& text_color) +void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const cc_title_alignment_t& align_mode, const fb_pixel_t& text_color) { setCaption(string(g_Locale->getText(caption_locale)), align_mode, text_color); } @@ -224,8 +229,10 @@ void CComponentsHeader::initIcon() //init cch_icon_obj only if an icon available if (cch_icon_name.empty()) { cch_icon_w = 0; - if (cch_icon_obj) + if (cch_icon_obj){ removeCCItem(cch_icon_obj); + cch_icon_obj = NULL; + } return; } @@ -248,7 +255,7 @@ void CComponentsHeader::initIcon() //set corner mode of icon item int cc_icon_corner_type = CORNER_LEFT; - if (corner_type == CORNER_TOP_LEFT || corner_type == CORNER_TOP) + if (corner_type & CORNER_TOP_LEFT || corner_type & CORNER_TOP) cc_icon_corner_type = CORNER_TOP_LEFT; cch_icon_obj->setCorner(corner_rad-fr_thickness, cc_icon_corner_type); @@ -264,6 +271,97 @@ void CComponentsHeader::initIcon() } } +void CComponentsHeader::initLogo() +{ + // init logo with required height and logo + int h_logo = cch_logo.dy_max == -1 ? height - 2*OFFSET_INNER_MIN : cch_logo.dy_max; + + if(!cch_logo_obj) + cch_logo_obj = new CComponentsChannelLogoScalable(1, height/2 - h_logo/2, cch_logo.Name, cch_logo.Id, this); + else + cch_logo_obj->setChannel(cch_logo.Id, cch_logo.Name); + + // use value 1 as initial value for logo width, ensures downscale with stupid available logo space + cch_logo_obj->setHeight(1, true); + + //ensure logo is not larger than original size if in auto mode + if (cch_logo.dy_max == -1){ + int dx_orig = 0, dy_orig = 0 ; + cch_logo_obj->getRealSize(&dx_orig, &dy_orig); + if (h_logo > dy_orig) + h_logo = dy_orig; + } + + // manage logo position + if (cch_logo_obj->hasLogo()){ + cch_logo_obj->setHeight(h_logo, true); + + /* Detect next and previous items, + * current item is logo item. + */ + int logo_id = getCCItemId(cch_logo_obj); + CComponentsItem *prev_item = getCCItem((cch_caption_align & CC_TITLE_RIGHT) ? logo_id - 2 : logo_id - 1); + CComponentsItem *next_item = getCCItem((cch_caption_align & CC_TITLE_RIGHT) ? logo_id - 1 : logo_id + 1); + + /* + * FIXME: Workaround to fix next item in case of wrong order of items. + */ + if (next_item){ + if (next_item->getItemType() == CC_ITEMTYPE_FRM_ICONFORM) + next_item = cch_cl_obj; + } + + /* + * Adjust usable space for logo. + */ + int x_logo_left = prev_item ? prev_item->getXPos() + prev_item->getWidth() : cch_offset; + int x_logo_right = next_item ? next_item->getXPos() : width - cch_offset; + int logo_space = x_logo_right - x_logo_left; + + /* + * Reduce logo width if logo space too small + * and adjust logo new width if required. + */ + int w_logo = min(cch_logo_obj->getWidth(), logo_space); + cch_logo_obj->setWidth(w_logo, true); + + /* + * Adjust logo x position depends of align parameters. + */ + int x_logo = x_logo_left; + if (cch_logo.Align & CC_LOGO_RIGHT) + x_logo = x_logo_right - w_logo; + + if (cch_logo.Align & CC_LOGO_LEFT) + x_logo = x_logo_left; + + if (cch_logo.Align & CC_LOGO_CENTER){ + x_logo = logo_space/2 - w_logo/2; + /* + * We are using centered mode as default, + * but we must notice possible overlapp + * with previous or next item. + */ + if (cch_caption_align & CC_TITLE_LEFT){ + int left_tag = prev_item->getXPos() + prev_item->getWidth(); + if (x_logo <= left_tag) + x_logo = left_tag + logo_space/2 - w_logo/2; + } + + if (cch_caption_align & CC_TITLE_RIGHT){ + if (x_logo + w_logo >= next_item->getXPos()) + x_logo = next_item->getXPos() - logo_space/2 - w_logo/2; + } + } + + /* + * Finally set logo x position + */ + cch_logo_obj->setXPos(x_logo); + cch_logo_obj->setYPos(height/2 - cch_logo_obj->getHeight()/2); + } +} + void CComponentsHeader::addContextButton(const std::string& button_name) { v_cch_btn.push_back(button_name); @@ -344,8 +442,9 @@ void CComponentsHeader::initButtons() //set button form properties if (cch_btn_obj){ cch_btn_obj->setYPos(cch_items_y); - cch_btn_obj->doPaintBg(false); + cch_btn_obj->doPaintBg(false);; cch_btn_obj->setAppendOffset(cch_buttons_space, 0); + cch_btn_obj->setRightOffset(cch_buttons_space); cch_btn_obj->removeAllIcons(); cch_btn_obj->addIcon(v_cch_btn); @@ -408,12 +507,12 @@ void CComponentsHeader::initClock() if (cch_cl_obj == NULL){ dprintf(DEBUG_DEBUG, "[CComponentsHeader]\n [%s - %d] init clock...\n", __func__, __LINE__); cch_cl_obj = new CComponentsFrmClock(0, cch_items_y, cch_font, cch_cl_format, NULL, false, 1, this); + cch_cl_obj->disableForceSegmentPaint(); cch_cl_obj->doPaintBg(false); } //set clock form properties if (cch_cl_obj){ - cch_cl_obj->setYPos(cch_items_y); cch_cl_obj->setHeight(height); //disallow paint of clock, if disabled and exit method @@ -451,7 +550,7 @@ void CComponentsHeader::initCaption() } //calc width of text object in header - cc_text_w = width-cch_text_x-cch_offset; + cc_text_w = width-cch_text_x/*-cch_offset*/; //context buttons int buttons_w = 0; @@ -463,7 +562,7 @@ void CComponentsHeader::initCaption() cch_btn_obj->setXPos(width - buttons_w); //set required width of caption object - cc_text_w -= (buttons_w + cch_offset); + cc_text_w -= buttons_w; } //clock @@ -475,10 +574,10 @@ void CComponentsHeader::initCaption() int clock_w = cch_cl_enable ? cch_cl_obj->getWidth() : 0; //set x position of clock - cch_cl_obj->setXPos(width - buttons_w - clock_w - cch_offset); + cch_cl_obj->setXPos(width - buttons_w - clock_w); //set required width of caption object - cc_text_w -= (clock_w + cch_offset); + cc_text_w -= clock_w; //stop clock if disabled or option run is disabled and clock is running if (cch_cl_enable){ @@ -502,17 +601,26 @@ void CComponentsHeader::initCaption() //set header text properties if (cch_text_obj){ + int w_free = cc_text_w; + + //recalc caption width + cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)) + cch_offset; + //set alignment of text item in dependency from text alignment - if (cch_caption_align == CTextBox::CENTER) - cch_text_x = CC_CENTERED; + if (cch_caption_align & CC_TITLE_CENTER) + cch_text_x = width/2 - cc_text_w/2; + + if (cch_caption_align & CC_TITLE_RIGHT){ //FIXME: does not work correct with some conditions, but still not used at the moment + cch_text_x += w_free; + cch_text_x -= max(cc_text_w, cch_font->getRenderWidth(cch_text)); + } //assign general properties cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height); cch_text_obj->setColorBody(col_body); if (cc_body_gradient_enable != cc_body_gradient_enable_old) cch_text_obj->getCTextBoxObject()->clearScreenBuffer(); - cch_text_obj->setTextColor(cch_col_text); - cch_text_obj->setText(cch_text, cch_caption_align, cch_font); + cch_text_obj->setText(cch_text, cch_caption_align, cch_font, cch_col_text); cch_text_obj->enableTboxSaveScreen(cc_body_gradient_enable || cc_txt_save_screen); //corner of text item @@ -549,6 +657,9 @@ void CComponentsHeader::initCCItems() //init text initCaption(); + + //init logo + initLogo(); } void CComponentsHeader::paint(bool do_save_bg) diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index eb4a6d607..2f96c7baf 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -32,11 +32,47 @@ #include "cc_frm_clock.h" #include +#define DEFAULT_LOGO_ALIGN CCHeaderTypes::CC_LOGO_RIGHT +#define DEFAULT_TITLE_ALIGN CCHeaderTypes::CC_TITLE_LEFT + +class CCHeaderTypes +{ + public: + ///logo position options + typedef enum + { + CC_LOGO_RIGHT = 0x01, + CC_LOGO_LEFT = 0x02, + CC_LOGO_CENTER = 0x04 + }cc_logo_alignment_t; + + ///title position options + typedef enum + { /*for compatibilty use CTextBox enums values*/ + CC_TITLE_LEFT = 0x400, + CC_TITLE_CENTER = 0x40 , + CC_TITLE_RIGHT = 0x80 + }cc_title_alignment_t; + + protected: + ///required logo data type + typedef struct cch_logo_t + { + uint64_t Id; + std::string Name; + int32_t dx_max; + int32_t dy_max; + cc_logo_alignment_t Align; + } cch_logo_struct_t; +}; + + //! Sub class of CComponentsForm. Shows a header with prepared items. /*! CComponentsHeader provides prepared items like icon, caption and context button icons, mostly for usage in menues or simple windows */ -class CComponentsHeader : public CComponentsForm, public CCTextScreen + +class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderTypes { private: ///member: init genaral variables, parameters for mostly used properties @@ -59,6 +95,11 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen CComponentsIconForm * cch_btn_obj; ///object: clock object CComponentsFrmClock * cch_cl_obj; + ///object: logo object + CComponentsChannelLogoScalable * cch_logo_obj; + + ///attributes for logos + cch_logo_t cch_logo; ///property: caption text, see also setCaption() std::string cch_text; @@ -89,8 +130,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen std::vector v_cch_btn; ///property: size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL int cch_size_mode; - ///property: alignment of caption within header, see also setCaptionAlignment(), possible values are CTextBox::CENTER, default = CTextBox::NO_AUTO_LINEBREAK (left) - int cch_caption_align; + ///property: alignment of caption within header, see also setCaptionAlignment() + cc_title_alignment_t cch_caption_align; ///property: enable/disable of clock, see also enableClock() bool cch_cl_enable; ///property: clock format @@ -112,6 +153,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen void initButtons(); ///sub: init clock object void initClock(); + ///sub: init logo object + void initLogo(); + ///int repaint slot void initRepaintSlot(); @@ -126,7 +170,17 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen CComponentsHeader(CComponentsForm *parent = NULL); CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, const std::string& caption = std::string(), - const std::string& = std::string(), + const std::string& icon_name = std::string(), + const int& buttons = 0, + CComponentsForm *parent = NULL, + int shadow_mode = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_FRAME_PLUS_0, + fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + + CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, + const std::string& icon_name = std::string(), const int& buttons = 0, CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, @@ -137,12 +191,12 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen virtual ~CComponentsHeader(); ///set caption text, parameters: string, int align_mode (default left) - virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); + virtual void setCaption(const std::string& caption, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); ///set caption text, parameters: loacle, int align_mode (default left) - virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); + virtual void setCaption(neutrino_locale_t caption_locale, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); - ///set alignment of caption within header, possible paramters are CTextBox::CENTER, CTextBox::NO_AUTO_LINEBREAK - virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;} + ///set alignment of caption within header, possible paramters are CComponentsHeader::CC_TITLE_LEFT, CComponentsHeader::CC_TITLE_RIGHT, CComponentsHeader::CC_TITLE_CENTER + virtual void setCaptionAlignment(const cc_title_alignment_t& align_mode){cch_caption_align = align_mode;} /**Set text font for title. * Internal default font is g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE] and @@ -258,7 +312,7 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen } ///returns the clock object - virtual CComponentsFrmClock* getClockObject(){return cch_cl_obj;} + CComponentsFrmClock* getClockObject(){return cch_cl_obj;} ///enable display of clock, parameter bool enable, const char* format, bool run virtual void enableClock(bool enable = true, const char* format = "%H:%M", const char* sec_format_str = NULL, bool run = false); @@ -269,31 +323,37 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); ///hides item, arg: no_restore see hideCCItem() - void hide(){disableClock(); CComponents::hide();} + void hide(){disableClock(); CComponentsForm::hide();} ///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer - void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, const int& corner_radius = -1, const int& fblayer_type = CC_FBDATA_TYPES, bool disable_clock = true); + void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, const int& corner_radius = -1, const int& fblayer_type = ~CC_FBDATA_TYPES, bool disable_clock = true); ///set color gradient on/off, returns true if gradient mode was changed virtual bool enableColBodyGradient(const int& enable_mode, const fb_pixel_t& sec_color = 255 /*=COL_BACKGROUND*/, const int& direction = -1); -}; -//! Sub class of CComponentsHeader. -/*! -CComponentsHeaderLocalized provides prepared items like icon, caption and context button icons, mostly for usage in menues or simple windows -Caption is defined with locales. -*/ -class CComponentsHeaderLocalized : public CComponentsHeader -{ - public: - CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, - neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, - const std::string& = "", - const int& buttons = 0, - CComponentsForm *parent = NULL, - int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_FRAME_PLUS_0, - fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + /**Methode to set channel logo into header body via id and/or channel name + * @param[in] channelId + * @li required channel id as uint64_t + * @param[in] channelIName + * @li required channel name as std::string + * @param[in] alignment + * @li optional alingment parameter as cc_logo_alignment_t (enum)\n + * Possible values are:\n + * CC_LOGO_RIGHT \n + * CC_LOGO_CENTER (default)\n + * CC_LOGO_RIGHT \n + * @param[in] dy + * @li optional logo height, default = -1 (auto) + * @note In auto mode, logo use full height minus inner offset but not larger than original logo height. + */ + void setChannelLogo( const uint64_t& channelId, + const std::string& channelName, + cc_logo_alignment_t alignment = DEFAULT_LOGO_ALIGN, + const int& dy = -1) + {cch_logo.Id = channelId; cch_logo.Name = channelName, cch_logo.Align = alignment, cch_logo.dy_max = dy; initCCItems();} + /**Methode to get channel logo object for direct access to its properties and methodes + * @return CComponentsChannelLogoScalable* + */ + CComponentsChannelLogoScalable* getChannelLogoObject(){return cch_logo_obj;} }; #endif diff --git a/src/gui/components/cc_frm_scrollbar.cpp b/src/gui/components/cc_frm_scrollbar.cpp index 2fcfd737c..13006e722 100644 --- a/src/gui/components/cc_frm_scrollbar.cpp +++ b/src/gui/components/cc_frm_scrollbar.cpp @@ -32,29 +32,39 @@ using namespace std; /* base schema - x,y - +-----------------+ - |+---------------+| - ||sb_up_obj || - || || - |+---------------+| - |+---------------+| - ||sb_segments_obj|| - ||+-------------+|| - ||| segment ||| - ||| id 0 ||| - ||| ||| - ||+-------------+|| - ||| segment ||| - ||| id 1 ||| - ||| ||| - ||+-------------+|| - |+---------------+| - |+---------------+| - ||sb_up_obj || - || || - |+---------------+| - +-----------------+ + + x,y width (w) + /(x_pos, y_pos) ^ + +---------------------+ + | +-----------------+ | + | | sb_up_obj (icon)| |/color_frame + | | /\ | | + | +-----------------+ | |/color_shadow + | col_body | | + | | + | +-sb_segments_obj+ | + | | | | + | | +---segment---+ | | + | | | id 0 | | | + | | | active | | | + | | | color_select| | | + | | +-------------+ | | + | | append_y_offset | | + | | +---segment---+ | | + | | | id 1 | | | + | | | passive | | | + | | |color_passive| | | + | | +-------------+ | | + | | (count = 2) | | + | | other segments | | + | | are possible | | + | +-----------------+ | + | | + | +-----------------+ | + | | sb_up_obj (icon)| | + | | \/ | | + | +-----------------+ | + +---------------------+-> height (h) */ //sub class CComponentsScrollBar inherit from CComponentsFrmChain @@ -64,13 +74,15 @@ CComponentsScrollBar::CComponentsScrollBar( const int &x_pos, const int &y_pos, int shadow_mode, fb_pixel_t color_frame, fb_pixel_t color_body, - fb_pixel_t color_shadow) + fb_pixel_t color_shadow, + fb_pixel_t color_select, + fb_pixel_t color_passive) :CComponentsFrmChain(x_pos, y_pos, w, h, NULL, CC_DIR_Y, parent, shadow_mode, color_frame, color_body, color_shadow) { - initVarSbForm(count); + initVarSbForm(count, color_select, color_passive); } -void CComponentsScrollBar::initVarSbForm(const int& count) +void CComponentsScrollBar::initVarSbForm(const int& count, const fb_pixel_t& color_select, const fb_pixel_t& color_passive) { cc_item_type = CC_ITEMTYPE_FRM_SCROLLBAR; fr_thickness = 0; @@ -82,7 +94,7 @@ void CComponentsScrollBar::initVarSbForm(const int& count) sb_down_obj = NULL; sb_segments_obj = NULL; - setCorner(RADIUS_MIN, CORNER_ALL); + corner_type = CORNER_NONE; sb_up_icon = frameBuffer->getIconPath(NEUTRINO_ICON_BUTTON_UP) ; sb_down_icon = frameBuffer->getIconPath(NEUTRINO_ICON_BUTTON_DOWN); @@ -90,6 +102,10 @@ void CComponentsScrollBar::initVarSbForm(const int& count) sb_segments_count = count; sb_mark_id = 0; + sb_visual_enable = false; + sb_segment_col_sel = color_select; + sb_segment_col = color_passive; + initCCItems(); } @@ -131,14 +147,10 @@ void CComponentsScrollBar::initBottomNaviIcon() void CComponentsScrollBar::initSegments() { //init dimensions for segments - int w_seg = width - 2*fr_thickness - 2*append_x_offset; - if (w_seg < 0) - w_seg = 0; + int w_seg = max(0, width - 2*fr_thickness - 2*append_x_offset); //calculate height of segment container - int h_seg_obj = height - 2*fr_thickness - 2*sb_up_obj->getHeight() - 2*append_y_offset; - if (h_seg_obj < 0) - h_seg_obj = 0; + int h_seg_obj = max(0, height - 2*fr_thickness - 2*sb_up_obj->getHeight() - 2*append_y_offset); //init segment container if (sb_segments_obj == NULL){ @@ -153,40 +165,78 @@ void CComponentsScrollBar::initSegments() //clean up segment container before add new segments sb_segments_obj->clear(); + //hold segment count in this scope + uint32_t tmp_segments = sb_segments_count; + //set y position of 1st segment and set height of segments int y_seg = append_y_offset; - int h_seg = sb_segments_obj->getHeight()/sb_segments_count - append_y_offset; - if (h_seg < 0) - h_seg = 0; + int h_seg = max(0, int(sb_segments_obj->getHeight()/tmp_segments - append_y_offset)); + + //reduce required segment count and create a moderate segment height for better visibility of slider if we have very much segments. + uint32_t tmp_quot = 1; + if (h_seg == 0){ + h_seg = w_seg - append_y_offset; + tmp_segments = max(1, sb_segments_obj->getHeight() / (h_seg+append_y_offset)); + tmp_quot = uint32_t((float)sb_segments_count/(float)tmp_segments + 0.5); + } + + fb_pixel_t passive_col = sb_visual_enable ? sb_segment_col : col_body; //create and add segments to segment container - for(u_int8_t i=0; igetCCItemId(item); //set color for marked id - if (sb_mark_id == id){ - item->setColorBody(COL_SCROLLBAR_ACTIVE); + if ((tmp_segments == sb_segments_count && sb_mark_id == id) || (tmp_segments != sb_segments_count && int(sb_mark_id/tmp_quot) == id)) + { + item->setColorBody(sb_segment_col_sel); #if 0 item->enableColBodyGradient(CC_COLGRAD_COL_A_2_COL_B); item->setColBodyGradient(CColorGradient::gradientDark2Light2Dark, CFrameBuffer::gradientHorizontal); #endif } - else{ - item->setColorBody(COL_SCROLLBAR_PASSIVE); + else + { + item->setColorBody(passive_col); #if 0 item->disableColBodyGradient(); #endif } - } - //set corner types - sb_segments_obj->front()->setCorner(RADIUS_MIN, CORNER_TOP); - sb_segments_obj->back()->setCorner(RADIUS_MIN, CORNER_BOTTOM); + //set different corner types for segments with possible conditions + if (passive_col == col_body){ + item->setCorner(RADIUS_MIN, CORNER_ALL); + continue; + }else if (tmp_segments == 1){ + item->setCorner(RADIUS_MIN, CORNER_ALL); + break; + }else if(i == 0){ + item->setCorner(RADIUS_MIN, CORNER_TOP); + continue; + }else if(i == tmp_segments - 1){ + item->setCorner(RADIUS_MIN, CORNER_BOTTOM); + break; + }else if((i > 0 && i < tmp_segments - 1)){ + item->setCorner(RADIUS_NONE, CORNER_NONE); + }else{ + item->setCorner(RADIUS_NONE, CORNER_NONE); + } + } } +void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item) +{ + // avoid divison by zero and fix wrong values + total_items = std::max(total_items, 1); + items_per_page = std::max(items_per_page, 1); + selected_item = std::max(selected_item, 0); + + *total_pages = ((total_items - 1) / items_per_page) + 1; + *current_page = selected_item / items_per_page; +} void paintScrollBar( const int &x_pos, const int &y_pos, @@ -197,9 +247,11 @@ void paintScrollBar( const int &x_pos, int shadow_mode, fb_pixel_t color_frame, fb_pixel_t color_body, - fb_pixel_t color_shadow) + fb_pixel_t color_shadow, + fb_pixel_t color_select, + fb_pixel_t color_passive) { - CComponentsScrollBar scrollbar(x_pos, y_pos, w, h, count, NULL, shadow_mode, color_frame, color_body, color_shadow); + CComponentsScrollBar scrollbar(x_pos, y_pos, w, h, count, NULL, shadow_mode, color_frame, color_body, color_shadow, color_select, color_passive); scrollbar.setMarkID(current_num); scrollbar.paint0(); } diff --git a/src/gui/components/cc_frm_scrollbar.h b/src/gui/components/cc_frm_scrollbar.h index 778349ac1..0b902d591 100644 --- a/src/gui/components/cc_frm_scrollbar.h +++ b/src/gui/components/cc_frm_scrollbar.h @@ -42,8 +42,14 @@ class CComponentsScrollBar : public CComponentsFrmChain ///names of navi icons std::string sb_up_icon, sb_down_icon; + ///visualize count mode + bool sb_visual_enable; + + ///segment colors + fb_pixel_t sb_segment_col, sb_segment_col_sel; + ///count of segments - int sb_segments_count; + uint32_t sb_segments_count; ///mark id int sb_mark_id; @@ -55,11 +61,11 @@ class CComponentsScrollBar : public CComponentsFrmChain ///init segements void initSegments(); - + ///init all items void initCCItems(); - void initVarSbForm( const int& count); + void initVarSbForm( const int& count, const fb_pixel_t& color_select, const fb_pixel_t& color_passive); public: /**Class constructor to generate individual scrollbar objects @@ -73,9 +79,11 @@ class CComponentsScrollBar : public CComponentsFrmChain * usual paraemters: * @param[in] parent optional, exepts type pointer to a parent CComponentsForm object, default NULL * @param[in] shadow_mode optional, exepts type int defined by shadow mode enums, default CC_SHADOW_OFF - * @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0 - * @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0 + * @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PLUS_0 + * @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PLUS_0 * @param[in] color_shadow optional, exepts type fb_pixel_t, default COL_SHADOW_PLUS_0 + * @param[in] color_select optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0 + * @param[in] color_passive optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0 */ CComponentsScrollBar( const int &x_pos, const int &y_pos, @@ -84,9 +92,11 @@ class CComponentsScrollBar : public CComponentsFrmChain const int& count = 1, CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0, - fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_SCROLLBAR_PLUS_0, + fb_pixel_t color_body = COL_SCROLLBAR_PLUS_0, + fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, + fb_pixel_t color_select = COL_SCROLLBAR_ACTIVE_PLUS_0, + fb_pixel_t color_passive = COL_SCROLLBAR_PASSIVE_PLUS_0); // ~CComponentsScrollBar(); //inherited from CComponentsForm /**Set current page number @@ -123,8 +133,20 @@ class CComponentsScrollBar : public CComponentsFrmChain * @see setSegmentCount() */ int getSegmentCount(){return sb_segments_count;} + + /**Enable/disable vizualized count of possible scroll items + * @param[in] enable optional, exepts type bool. + * @note Default mode is disabled. + */ + void enableVisualize(bool enable = true){sb_visual_enable = enable;} + + /**Disable vizualized count of possible scroll items + */ + void disableVisualize(){enableVisualize(false);} }; +void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item); + /**Small and easy to apply scrollbar paint methode without expilcit object declaration * @return void * @@ -138,9 +160,11 @@ class CComponentsScrollBar : public CComponentsFrmChain * usual paraemters: * @param[in] parent optional, exepts type pointer to a parent CComponentsForm object, default NULL * @param[in] shadow_mode optional, exepts type int defined by shadow mode enums, default CC_SHADOW_OFF - * @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0 - * @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0 + * @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PLUS_0 + * @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PLUS_0 * @param[in] color_shadow optional, exepts type fb_pixel_t, default COL_SHADOW_PLUS_0 + * @param[in] color_select optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0 + * @param[in] color_passive optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0 */ void paintScrollBar( const int &x_pos, const int &y_pos, @@ -149,8 +173,10 @@ void paintScrollBar( const int &x_pos, const int& count, const int& current_num, int shadow_mode = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0, - fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0, - fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); + fb_pixel_t color_frame = COL_SCROLLBAR_PLUS_0, + fb_pixel_t color_body = COL_SCROLLBAR_PLUS_0, + fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, + fb_pixel_t color_select = COL_SCROLLBAR_ACTIVE_PLUS_0, + fb_pixel_t color_passive = COL_SCROLLBAR_PASSIVE_PLUS_0); #endif diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index 018ad066f..1ef19cbd4 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -34,7 +34,7 @@ #include #include -#define SB_MIN_HEIGHT 12 +#define SB_MIN_HEIGHT OFFSET_INNER_MID #define REF_PERCENT_TXT "100% " using namespace std; @@ -55,8 +55,8 @@ void CSignalBar::initVarSigBar(const int& xpos, const int& ypos, const int& w, c corner_rad = 0; corner_type = 0; - append_x_offset = 2; - append_y_offset = 2; + append_x_offset = OFFSET_INNER_MIN; + append_y_offset = OFFSET_INNER_MIN; sb_scale_height = -1; dy_font = CNeutrinoFonts::getInstance(); @@ -330,7 +330,7 @@ void CSignalBox::initSignalItems() sbar->setScaleHeight(scale_h); sbar->enableTboxSaveScreen(cc_txt_save_screen); - snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : 1, sbar_w, sbar_h); + snrbar->setDimensionsAll(vertical ? sbar_x : sbar->getXPos() + sbar->getWidth() + append_x_offset, vertical ? sbar->getYPos() + sbar->getHeight() + append_y_offset : 1, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setTextColor(sbx_caption_color); snrbar->setActiveColor(sbx_active_color); diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 80455a5ad..5c05a19ed 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -150,10 +150,10 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const ccw_buttons = 0; //no header buttons ccw_show_footer = true; ccw_show_header = true; - ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK; + ccw_align_mode = DEFAULT_TITLE_ALIGN; ccw_show_l_sideber = false; ccw_show_r_sideber = false; - ccw_w_sidebar = 40; + ccw_w_sidebar = SIDEBAR_WIDTH; ccw_col_head = COL_MENUHEAD_PLUS_0; ccw_col_head_text = COL_MENUHEAD_TEXT; ccw_col_footer = COL_MENUFOOT_PLUS_0; @@ -169,9 +169,13 @@ void CComponentsWindow::initWindowSize() if (cc_parent) return; + if (width < 0 && width >= -100) //percentage conversion TODO: behavior inside parent + width = frameBuffer->getScreenWidth()*abs(width)/100; if (width == 0 || (unsigned)width > frameBuffer->getScreenWidth()) width = frameBuffer->getScreenWidth(); + if (height < 0 && height >= -100) //percentage conversion TODO: behavior inside parent + height = frameBuffer->getScreenHeight()*abs(height)/100; if (height == 0 || (unsigned)height > frameBuffer->getScreenHeight()) height = frameBuffer->getScreenHeight(); } @@ -187,7 +191,7 @@ void CComponentsWindow::initWindowPos() y = frameBuffer->getScreenY(); } -void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) +void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const cc_title_alignment_t& align_mode) { ccw_caption = g_Locale->getText(locale_text); ccw_align_mode = align_mode; @@ -201,7 +205,7 @@ void CComponentsWindow::initHeader() //set header properties //TODO: assigned properties with internal header objekt have no effect! if (ccw_head){ ccw_head->setWidth(width-2*fr_thickness); - ccw_head->setPos(0, 0); + ccw_head->setPos(fr_thickness, fr_thickness); ccw_head->setIcon(ccw_icon_name); ccw_head->setCaption(ccw_caption, ccw_align_mode, ccw_col_head_text); ccw_head->setContextButton(ccw_buttons); @@ -219,8 +223,8 @@ void CComponentsWindow::initFooter() if (ccw_footer){ if (ccw_h_footer) ccw_footer->setHeight(ccw_h_footer); - ccw_footer->setPos(0, cc_yr + height - ccw_footer->getHeight()- fr_thickness); - ccw_footer->setWidth(width-2*fr_thickness); + ccw_footer->setPos(cc_xr + fr_thickness, cc_yr + height - ccw_footer->getHeight()- fr_thickness); + ccw_footer->setWidth(width/*-2*fr_thickness*/); ccw_footer->enableShadow(false/*shadow*/); ccw_footer->setCorner(corner_rad-fr_thickness, CORNER_BOTTOM); ccw_footer->setButtonFont(ccw_button_font); diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 7b2f71796..6dfe67df8 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -29,6 +29,8 @@ #include "cc_frm_header.h" #include "cc_frm_footer.h" +#define CCW_PERCENT - //placeholder for negative sign '-', used for discret dimensions parameters + //! Sub class of CComponentsForm. Shows a window with prepared items. /*! CComponentsWindow provides prepared items like header, footer and a container for @@ -52,7 +54,7 @@ items like text, labels, pictures ... */ -class CComponentsWindow : public CComponentsForm +class CComponentsWindow : public CComponentsForm, CCHeaderTypes { protected: ///object: header object, to get access to header properties see also getHeaderObject() @@ -68,7 +70,7 @@ class CComponentsWindow : public CComponentsForm ///property: caption in header, see also getHeaderObject() std::string ccw_caption; ///property: alignment mode for header caption - int ccw_align_mode; + cc_title_alignment_t ccw_align_mode; ///property: icon name in header, see also getHeaderObject() std::string ccw_icon_name; ///property: assigned default icon buttons in header, see also getHeaderObject() @@ -128,10 +130,56 @@ class CComponentsWindow : public CComponentsForm { CC_WINDOW_ITEM_HEADER = 0 }; - ///simple constructor for CComponentsWindow, this shows a window over full screen + + enum + { + CC_WINDOW_LEFT_SIDEBAR = 1, + CC_WINDOW_RIGHT_SIDEBAR = 2 + }; + + + /**simple constructor for CComponentsWindow, this shows a window over full screen + * @param[in] parent + * @li optional: expects type CComponentsForm * as possible parent object, default = NULL + */ CComponentsWindow(CComponentsForm *parent = NULL); - ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string, x_pos or y_pos = 0 will center window + /** + * advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string, x_pos or y_pos = 0 will center window + * @param[in] x_pos + * @li expects type const &int, defines x position on screen + * @param[in] y_pos + * @li expects type const &int, defines y position on screen + * @param[in] w + * @li expects type const &int, width of window, Note: value = 0 uses full screen + * @param[in] h + * @li expects type const &int, height of window, Note: value = 0 uses full screen + * @param[in] caption + * @li optional: expects type const std::string&, defines title of window header + * @param[in] iconname + * @li optional: expects type const std::string&, defines icon name of window header + * @param[in] parent + * @li optional: expects type CComponentsForm * as possible parent object, default = NULL + * @param[in] shadow_mode + * @li optional: expects type int as mode, default = CC_SHADOW_OFF \n + * possible values are \n + * CC_SHADOW_ON = (CC_SHADOW_RIGHT | CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_LEFT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT) \n + * Take a look into cc_types.h + * @param[in] color_frame + * @li optional: expects type fb_pixel_t, defines frame color, default = COL_FRAME_PLUS_0 + * @param[in] color_body + * @li optional: expects type fb_pixel_t, defines color color, default = COL_MENUCONTENT_PLUS_0 + * @param[in] color_shadow + * @li optional: expects type fb_pixel_t, defines shadow color, default = COL_SHADOW_PLUS_0 + * + * @note Discret dimensions parameters: values < 0 to -100 will be interpreted as percent values related to screen. + * For better readability please use placeholder 'CCW_PERCENT' as negative sign '-' \n + * Example: \n + * this inits a window with position x100 y100 on screen with dimensions 700px x 800px \n + * CComponentsWindow win(100, 100, 700, 800, "Test window");\n + * this inits a window with position x100 y100 on screen with 50% of screen size assigned with discret percental screen dimensions \n + * CComponentsWindow win(100, 100, CCW_PERCENT 50, CCW_PERCENT 50, "Test window"); + */ CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption = "", const std::string& iconname = "", @@ -141,7 +189,12 @@ class CComponentsWindow : public CComponentsForm fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); - ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales, x_pos or y_pos = 0 will center window + /** + * advanced constructor for CComponentsWindow, provides parameters for the most required properties + * @param[in] locale_text + * @li optional: expects type neutrino_locale_t, defines title of window header + * @see for other parameters take a look to CComponentsWindow base class above + */ CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, neutrino_locale_t locale_text = NONEXISTANT_LOCALE, const std::string& iconname = "", @@ -151,90 +204,249 @@ class CComponentsWindow : public CComponentsForm fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); - ///add item to body object, also usable is addCCItem() to add items to the windo object + /** + * Add an item to body object, also usable is addCCItem() to add items to the window object + * @param[in] cc_Item + * @li expects type CComponentsItem* , defines a cc item + * @return Returns item ID + * @see Take a look to cc_types.h for possible types. + */ int addWindowItem(CComponentsItem* cc_Item); - ///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader() - void showFooter(bool show = true){ccw_show_footer = show; initCCWItems();}; - ///allow/disallow paint a header, default true, see also ccw_show_header, showFooter() - void showHeader(bool show = true){ccw_show_header = show; initCCWItems();}; + /** + * enable/disable paint of footer, default true + * @param[in] show + * @li expects type bool, default = true + * @see ccw_show_footer, showHeader() + */ + void showFooter(bool show = true){ccw_show_footer = show; initCCWItems();} - enum - { - CC_WINDOW_LEFT_SIDEBAR = 1, - CC_WINDOW_RIGHT_SIDEBAR = 2 - }; - ///allow/disallow paint a sidebar, default are enabled + /** + * enable/disable paint of header, default true + * @param[in] show + * @li expects type bool, default = true + * @see ccw_show_header, showFooter() + */ + void showHeader(bool show = true){ccw_show_header = show; initCCWItems();} + + /** + * enable/disable paint of sidebar, + * @param[in] show + * @li optional: expects type const int&, default = enabled + */ void enableSidebar(const int& sidbar_type = CC_WINDOW_LEFT_SIDEBAR | CC_WINDOW_RIGHT_SIDEBAR); - ///set caption in header with string, see also getHeaderObject() - void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;} - ///set header text color - void setWindowHeaderTextColor(const fb_pixel_t& color){ccw_col_head_text = color;} - ///set background to header - void setWindowHeaderColor(const fb_pixel_t& color){ccw_col_head = color;} - ///set caption in header from locales, see also getHeaderObject() - void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); - ///set caption alignment, see CTextBox for possible modes - void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;}; + /** + * sets title text in header + * @param[in] text + * @li expects type const std::string&, defines title of window header + * @param[in] align_mode + * @li optional: expects type const cc_title_alignment_t&, defines allignment of title text + * @see CTextBox for alignment modes + */ + void setWindowCaption(const std::string& text, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN){ccw_caption = text; ccw_align_mode = align_mode;} - ///set icon name in header, see also getHeaderObject() + /** + * sets title text in header + * @param[in] text + * @li expects type neutrino_locale_t + * @param[in] align_mode + * @li optional: expects type const cc_title_alignment_t&, defines allignment of title text + * @see CTextBox for alignment modes + */ + void setWindowCaption(neutrino_locale_t locale_text, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN); + + /** + * Sets header text color + * @param[in] const fb_pixel_t& + * @li expects type const fb_pixel_t& + */ + void setWindowHeaderTextColor(const fb_pixel_t& color){ccw_col_head_text = color;} + + /** + * Sets header background color + * @param[in] const fb_pixel_t& + * @li expects type const fb_pixel_t& + */ + void setWindowHeaderColor(const fb_pixel_t& color){ccw_col_head = color;} + + /** + * sets title text alignment + * @param[in] align_mode + * @li expects type const cc_title_alignment_t& + * @see CTextBox for alignment modes + */ + void setWindowCaptionAlignment(const cc_title_alignment_t& align_mode){ccw_align_mode = align_mode;}; + + /** + * Sets icon name of window header. + * @param[in] iconname + * @li expects type const std::string& + */ void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname; initHeader();}; ///set default header icon buttons, see also getHeaderObject() - void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; + /** + * Sets context buttons in window header. + * @param[in] buttons + * @li expects type const int& + * @note possible types are: + * CC_BTN_HELP, + CC_BTN_INFO, + CC_BTN_MENU, + CC_BTN_EXIT, + CC_BTN_MUTE_ZAP_ACTIVE, + CC_BTN_MUTE_ZAP_INACTIVE, + CC_BTN_OKAY, + CC_BTN_MUTE, + CC_BTN_UP, + CC_BTN_DOWN, + CC_BTN_LEFT, + CC_BTN_RIGHT, + CC_BTN_FORWARD, + CC_BTN_BACKWARD, + CC_BTN_PAUSE, + CC_BTN_PLAY, + CC_BTN_RECORD_ACTIVE, + CC_BTN_RECORD_INACTIVE, + CC_BTN_RECORD_STOP, + * @see cc_frm_header.h for current types + */ + void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;} - ///returns a pointer to the internal header object, use this to get access to header properities - CComponentsHeader* getHeaderObject(){return ccw_head;}; + /** + * Gets a pointer to the internal header object, use this to get direct access to header properities + * @return CComponentsHeader* + */ + CComponentsHeader* getHeaderObject(){return ccw_head;} - ///returns a pointer to the internal body object, use this to get access to body properities - CComponentsForm* getBodyObject(){return ccw_body;}; - ///returns a pointer to the internal footer object, use this to get access to footer properities - CComponentsFooter* getFooterObject(){return ccw_footer;}; + /** + * Gets a pointer to the internal body object, use this to get access to body properities + * @return CComponentsForm* + */ + CComponentsForm* getBodyObject(){return ccw_body;} - ///set background to footer + /** + * Gets a pointer to the internal footer object, use this to get access to footer properities + * @return CComponentsFooter* + */ + CComponentsFooter* getFooterObject(){return ccw_footer;} + + /** + * Sets footer background color + * @param[in] color + * @li expects type const fb_pixel_t& + */ void setWindowFooterColor(const fb_pixel_t& color){ccw_col_footer = color;} - ///set font for footer buttons + + /** + * Sets font for footer buttons + * @param[in] font_type + * @li expects type Font* + */ void setWindowFooterFont(Font* font_type){ccw_button_font = font_type;} - ///returns a pointer to the internal left side bar object, use this to get access to left sidebar properities - CComponentsFrmChain* getLeftSidebarObject(){return ccw_left_sidebar;}; - ///returns a pointer to the internal right side bar object, use this to get access to right sidebar properities - CComponentsFrmChain* getRightSidebarObject(){return ccw_right_sidebar;}; - ///sets width of sidebars - void setWidthSidebar(const int& sidebar_width){ccw_w_sidebar = sidebar_width; initCCWItems();}; + /** + * Gets a pointer to the internal left side bar object, use this to get access to left sidebar properities + * @return CComponentsFrmChain* + */ + CComponentsFrmChain* getLeftSidebarObject(){return ccw_left_sidebar;} - ///sets current page, NOTE: this is simliar with setCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object + /** + * Gets a pointer to the internal right side bar object, use this to get access to right sidebar properities + * @return CComponentsFrmChain* + */ + CComponentsFrmChain* getRightSidebarObject(){return ccw_right_sidebar;} + + /** + * Sets width of sidebars + * @param[in] sidebar_width + * @li expects type const int& + */ + void setWidthSidebar(const int& sidebar_width){ccw_w_sidebar = sidebar_width; initCCWItems();} + + /** + * Sets current page number + * @param[in] sidebar_width + * @li expects type const int& + * @note This is simliar to setCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object. + */ void setCurrentPage(const u_int8_t& current_page); - ///get current page, NOTE: this is simliar with getCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object + + /** + * Gets current page number + * @return CComponentsFrmChain* + * @note This simliar to getCurrentPage() known from basic class CComponentsForm, but here it is related only for window body object + */ u_int8_t getCurrentPage(); - ///paint window body items, this paints only the current page, body = page, current page is definied in body object, see setCurrentPage() + /** + * Paints window body items, this paints only the current page, body = page, current page is definied in body object, see setCurrentPage() + * @param[in] do_save_bg + * @li optional: expects type bool, default = CC_SAVE_SCREEN_NO (false), sets background save mode + */ void paintCurPage(bool do_save_bg = CC_SAVE_SCREEN_NO); - ///paint defined page of body, parameter number 0...n + + /** + * Paints defined page of body, parameter number 0...n + * @param[in] page_number + * @li expects type const u_int8_t& as page number + * @param[in] do_save_bg + * @li optional: expects type bool, default = CC_SAVE_SCREEN_NO (false), sets background save mode + */ void paintPage(const u_int8_t& page_number, bool do_save_bg = CC_SAVE_SCREEN_NO); - ///enable/disable page scroll, parameter1 default enabled for up/down keys, only for body! + + /** + * enable/disable page scroll + * @param[in] mode + * @li optional: expects type const int&, default enabled for up/down keys, only for body! + */ void enablePageScroll(const int& mode = PG_SCROLL_M_UP_DOWN_KEY); - ///set width of body scrollbar + /** + * Sets width of body scrollbar + * @param[in] crollbar_width + * @li expects type const int& + */ void setScrollBarWidth(const int& scrollbar_width); - ///refresh position and dimension and reinitialize elemenatary properties + /** + * Reinit position and dimensions and reinitialize mostly elemenatary properties + */ void Refresh(){initCCWItems();}; - ///paint all window items, this overwriting paint() from CComponentsForm + /** + * Paint window + * @param[in] do_save_bg + * @li optional: expects type bool, sets background save mode + */ void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - ///adds additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup + /** + * Adds an additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup + * @param[in] key + * @li expects type const neutrino_msg_t& + * @see river/rcinput.h for possible keys + */ virtual void addExitKey(const neutrino_msg_t& key){getBodyObject()->addExitKey(key);} - ///remove all current exec keys from current collection, NOTE: use addExitKey() if new exec key is required + + /** + * Removes all current exec keys from current collection. + * @note use addExitKey() if new exec key is required + */ virtual void removeExitKeys(){getBodyObject()->removeExitKeys();} }; class CComponentsWindowMax : public CComponentsWindow { public: - ///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, this shows a centered window based up current screen settings + /** + * Simple constructor for CComponentsWindow, this shows only a centered window based up current screen settings + * @see for other parameters take a look to CComponentsWindow base class above + * @param[in] caption + * @li expects type const std::string&, defines title of window header + * @see for other parameters take a look to CComponentsWindow base class above + */ CComponentsWindowMax( const std::string& caption, const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, @@ -242,7 +454,13 @@ class CComponentsWindowMax : public CComponentsWindow fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); - ///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, this shows a centered window based up current screen settings + /** + * Simple constructor for CComponentsWindow, this shows only a centered window based up current screen settings + * @see for other parameters take a look to CComponentsWindow base class above + * @param[in] locale_text + * @li expects type neutrino_locale_t, defines title of window header + * @see for other parameters take a look to CComponentsWindow base class above + */ CComponentsWindowMax( neutrino_locale_t locale_caption, const std::string& iconname = "", CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index b783f82d8..be2e6678a 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -261,6 +261,20 @@ bool CComponentsItem::isAdded() return false; } +void CComponentsItem::setXPos(const int& xpos) +{ + CCDraw::setXPos(xpos); + if (cc_parent) + cc_xr = cc_parent->getRealXPos() + x; +} + +void CComponentsItem::setYPos(const int& ypos) +{ + CCDraw::setYPos(ypos); + if (cc_parent) + cc_yr = cc_parent->getRealYPos() + y; +} + void CComponentsItem::setXPosP(const uint8_t& xpos_percent) { int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth(); diff --git a/src/gui/components/cc_item.h b/src/gui/components/cc_item.h index 4f5f42da5..d76684020 100644 --- a/src/gui/components/cc_item.h +++ b/src/gui/components/cc_item.h @@ -100,7 +100,7 @@ class CComponentsItem : public CComponents * gui/color.h * driver/framebuffer.h */ - virtual void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, bool ignore_parent = false, const int& fblayer_type = CC_FBDATA_TYPES); + virtual void kill(const fb_pixel_t& bg_color = COL_BACKGROUND_PLUS_0, bool ignore_parent = false, const int& fblayer_type = ~CC_FBDATA_TYPES); ///get the current item type, see attribute cc_item_type above virtual int getItemType(); @@ -110,7 +110,7 @@ class CComponentsItem : public CComponents ///set select mode virtual void setSelected(bool selected, const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0, - const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0, + const fb_pixel_t& frame_col = COL_FRAME_PLUS_0, const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0, const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0, const int& frame_w = 3, @@ -134,6 +134,11 @@ class CComponentsItem : public CComponents ///returns current number of page location of current item, see: cc_page_number virtual u_int8_t getPageNumber(){return cc_page_number;}; + ///set screen x-position, parameter as int + virtual void setXPos(const int& xpos); + ///set screen y-position, parameter as int + virtual void setYPos(const int& ypos); + ///set screen x-position, parameter as uint8_t, percent x value related to current width of parent form or screen virtual void setXPosP(const uint8_t& xpos_percent); ///set screen y-position, parameter as uint8_t, percent y value related to current height of parent form or screen @@ -141,6 +146,17 @@ class CComponentsItem : public CComponents ///set x and y position as percent value related to current parent form or screen dimensions at once virtual void setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent); + ///sets real x position on screen. Use this, if item is added to a parent form + virtual void setRealXPos(const int& xr){cc_xr = xr;} + ///sets real y position on screen. Use this, if item is added to a parent form + virtual void setRealYPos(const int& yr){cc_yr = yr;} + ///sets real x and y position on screen at once. Use this, if item is added to a parent form + virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;} + ///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form + virtual int getRealXPos(){return cc_parent ? cc_xr : x;} + ///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form + virtual int getRealYPos(){return cc_parent ? cc_yr : y;} + ///do center item on screen or within a parent form, parameter along_mode assigns direction of centering virtual void setCenterPos(int along_mode = CC_ALONG_X | CC_ALONG_Y); diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp index bc41347b0..2dccb9820 100644 --- a/src/gui/components/cc_item_infobox.cpp +++ b/src/gui/components/cc_item_infobox.cpp @@ -51,10 +51,10 @@ CComponentsInfoBox::CComponentsInfoBox( const int& x_pos, { cc_item_type = CC_ITEMTYPE_TEXT_INFOBOX; - x = x_pos; - y = y_pos; - width = w; - height = h; + x = x_old = x_pos; + y = y_old = y_pos; + width = width_old = w; + height = height_old = h; shadow = shadow_mode; col_frame = color_frame; cc_enable_frame = true; @@ -124,7 +124,7 @@ void CComponentsInfoBox::paintPicture() pic->doPaintBg(false); //fit icon into frame - pic->setYPos(y_pic+(height/2-pic->getHeight()/2)); + pic->setYPos(y_pic+(height-2*fr_thickness)/2-pic->getHeight()/2); //paint, but set visibility mode pic->allowPaint(cc_allow_paint); diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 1870092af..c776dfcb6 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -74,8 +74,9 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, //CComponents x = x_old = x_pos; y = y_old = y_pos; - width = dx = dxc = w; - height = dy = dyc = h; + width = width_old = dx = dxc = w; + height = height_old = dy = dyc = h; + dx_orig = dy_orig = 0; pic_name = pic_name_old = image_name; shadow = shadow_mode; shadow_w = OFFSET_SHADOW; @@ -128,9 +129,9 @@ void CComponentsPicture::setPicture(const char* picture_name) void CComponentsPicture::setWidth(const int& w, bool keep_aspect) { - CComponentsItem::setWidth(w); if (w == width && keep_aspect == keep_dy_aspect) return; + CComponentsItem::setWidth(w); need_init = true; do_scale = true; keep_dy_aspect = keep_aspect; @@ -139,15 +140,33 @@ void CComponentsPicture::setWidth(const int& w, bool keep_aspect) void CComponentsPicture::setHeight(const int& h, bool keep_aspect) { - CComponentsItem::setHeight(h); if (h == height && keep_aspect == keep_dx_aspect) return; + CComponentsItem::setHeight(h); need_init = true; do_scale = true; keep_dx_aspect = keep_aspect; initCCItem(); } +void CComponentsPicture::setXPos(const int& xpos) +{ + CComponentsItem::setXPos(xpos); + if (xpos == x) + return; + need_init = true; + initCCItem(); +} + +void CComponentsPicture::setYPos(const int& ypos) +{ + CComponentsItem::setYPos(ypos); + if (ypos == y) + return; + need_init = true; + initCCItem(); +} + void CComponentsPicture::initCCItem() { if (pic_name.empty() || !need_init){ @@ -183,6 +202,9 @@ void CComponentsPicture::initCCItem() if (height == 0) height = dy_tmp; } + dx_orig = width; + dy_orig = height; + /* leave init methode here if we in no scale mode * otherwise goto next step! */ @@ -193,8 +215,12 @@ void CComponentsPicture::initCCItem() * check internal dimension values (dx/dy) and ensure that values are >0 * real image size */ - if ((dx != width || dy != height) || (dx == 0 || dy == 0)) - g_PicViewer->getSize(pic_name.c_str(), &dx, &dy); + g_PicViewer->getSize(pic_name.c_str(), &dx_orig, &dy_orig); + if ((dx != width || dy != height) || (dx == 0 || dy == 0)){ + dx = dx_orig; + dy = dy_orig; + //g_PicViewer->getSize(pic_name.c_str(), &dx, &dy); + } } /* on next step check item dimensions (width/height) for 0 values @@ -251,11 +277,11 @@ void CComponentsPicture::initPosition(int *x_position, int *y_position) } -// void CComponentsPicture::getSize(int* width_image, int *height_image) -// { -// *width_image = width; -// *height_image = height; -// } +void CComponentsPicture::getRealSize(int* dx_original, int *dy_original) +{ + *dx_original = dx_orig; + *dy_original = dy_orig; +} int CComponentsPicture::getWidth() { @@ -385,6 +411,7 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p void CComponentsChannelLogo::init(const uint64_t& channelId, const std::string& channelName, bool allow_scale) { + cc_item_type = CC_ITEMTYPE_CHANNEL_LOGO; channel_name = ""; channel_id = 0; alt_pic_name = ""; @@ -415,6 +442,8 @@ void CComponentsChannelLogo::setAltLogo(const char* picture_name) void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::string& channelName) { need_init = true; + string image = pic_name; + if (channelId || !channelName.empty()){ if ((channel_id == channelId) && (channel_name == channelName)) need_init = false; @@ -425,16 +454,16 @@ void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::st int dummy; - has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, pic_name, &dummy, &dummy); + has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, image, &dummy, &dummy); if (!has_logo)//no logo was found, use altrenate icon or logo - pic_name = alt_pic_name; + image = alt_pic_name; //if logo or alternate image still not available, set has logo to false - has_logo = !pic_name.empty(); + has_logo = !image.empty(); //refresh object - initCCItem(); + setPicture(image); //set has_logo to false if no dimensions were detected if (width && height) diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index 0781b446e..fe42604e7 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -54,9 +54,10 @@ class CComponentsPicture : public CComponentsItem ///screen cache content for painted image fb_pixel_t *image_cache; - ///current original image dimensions + ///current image dimensions int dx, dy; - + ///original image dimensions + int dx_orig, dy_orig; ///cached image dimensions int dxc, dyc; @@ -146,8 +147,8 @@ class CComponentsPicture : public CComponentsItem ///returns current assigned image name std::string getPictureName(){return pic_name;} -// ///handle image size -// void getSize(int* width_image, int *height_image); + ///get original image size + void getRealSize(int* dx_orig, int *dy_orig); ///return width of item int getWidth(); ///return height of item @@ -162,6 +163,11 @@ class CComponentsPicture : public CComponentsItem ///set height of object and image related to current screen size, see also CComponentsItem::setHeightP(), parameter as uint8_t virtual void setHeightP(const uint8_t& h_percent){CComponentsItem::setHeightP(h_percent), do_scale = true; need_init = hasChanges(); initCCItem();} + ///set screen x-position, parameter as int + virtual void setXPos(const int& xpos); + ///set screen y-position, parameter as int + virtual void setYPos(const int& ypos); + ///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself. virtual inline bool isPicPainted(){return is_image_painted;}; @@ -202,7 +208,8 @@ class CComponentsPictureScalable : public CComponentsPicture fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, int transparent = CFrameBuffer::TM_NONE) - : CComponentsPicture(x_pos, y_pos, 0, 0, image_name, parent, shadow_mode, color_frame, color_background, color_shadow, transparent){}; + : CComponentsPicture(x_pos, y_pos, 0, 0, image_name, parent, shadow_mode, color_frame, color_background, color_shadow, transparent) + {cc_item_type = CC_ITEMTYPE_PICTURE_SCALABLE;}; }; class CComponentsChannelLogo : public CComponentsPicture @@ -286,7 +293,8 @@ class CComponentsChannelLogoScalable : public CComponentsChannelLogo fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0, int transparent = CFrameBuffer::TM_BLACK) - : CComponentsChannelLogo(x_pos, y_pos, 0, 0, channelName, channelId, parent, shadow_mode, color_frame, color_background, color_shadow, transparent){}; + : CComponentsChannelLogo(x_pos, y_pos, 0, 0, channelName, channelId, parent, shadow_mode, color_frame, color_background, color_shadow, transparent) + {cc_item_type = CC_ITEMTYPE_CHANNEL_LOGO_SCALABLE;}; }; #endif diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 2a162998d..81f4b6277 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -57,10 +57,10 @@ CProgressBar::CProgressBar( const int x_pos, cc_item_type = CC_ITEMTYPE_PROGRESSBAR; //CComponents - x = x_pos; - y = y_pos; - width = w; - height = h; + x = x_old = x_pos; + y = y_old = y_pos; + width = width_old = w; + height = height_old = h; col_frame = color_frame; col_body = color_body; @@ -145,7 +145,7 @@ class CProgressBarCache static inline unsigned int make16color(__u32 rgb){return 0xFF000000 | rgb;}; - void pbcPaintBoxRel(int x, int y, int dx, int dy, fb_pixel_t *pixbuf, fb_pixel_t col); + void pbcPaintBoxRel(int x, int y, int dx, int dy, fb_pixel_t *pixbuf, fb_pixel_t col) const; void pbcApplyGradient(fb_pixel_t *pixbuf); void pbcCreateBitmaps(); @@ -177,7 +177,7 @@ class CProgressBarCache } void pbcClear(); public: - void pbcPaint(int x, int y, int pbc_active_width, int pbc_passive_width); + void pbcPaint(int x, int y, int pbc_active_width, int pbc_passive_width) const; static CProgressBarCache *pbcLookup( int dy, int dx, int active_col, @@ -198,6 +198,7 @@ void CProgressBarCache::pbcClear() if ((*it)->pbc_passive) free((*it)->pbc_passive); delete (*it); + (*it) = NULL; } pbCache.clear(); } @@ -222,7 +223,7 @@ CProgressBarCache *CProgressBarCache::pbcLookup(int dy, int dx, int active_col, return pbc; } -void CProgressBarCache::pbcPaint(int x, int y, int pbc_active_width, int pbc_passive_width) +void CProgressBarCache::pbcPaint(int x, int y, int pbc_active_width, int pbc_passive_width) const { y += yoff; static CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); @@ -250,7 +251,7 @@ void CProgressBarCache::pbcPaint(int x, int y, int pbc_active_width, int pbc_pas frameBuffer->mark(x, y, x + pbc_width, y + pbc_height); } -void CProgressBarCache::pbcPaintBoxRel(int x, int y, int dx, int dy, fb_pixel_t *pixbuf, fb_pixel_t col) +void CProgressBarCache::pbcPaintBoxRel(int x, int y, int dx, int dy, fb_pixel_t *pixbuf, fb_pixel_t col) const { if (x < 0) { dx -= x; diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 5e5d53d48..8f716dc0b 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -95,8 +95,6 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///destroy current CTextBox and CBox objects void clearCCText(); - ///initialize all required attributes for text and send to the CTextBox object - void initCCText(); ///init internal CBox object required by CTextBox object void initCBox(); @@ -164,6 +162,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///send option to CTextBox object to paint background box behind text or not virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; + ///initialize all required attributes for text and send to the CTextBox object + void initCCText(); + ///set text as string also possible with overloades members for loacales, const char and text file, returns true if text was changed virtual bool setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR); ///set text with const char*, returns true if text was changed diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index a7b7e13ca..5f32adf2d 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -64,7 +64,7 @@ void CComponentsTimer::runSharedTimerAction() tm_mutex.lock(); OnTimer(); if (!tm_enable_nano) - mySleep(tm_interval); + sleep(tm_interval); else usleep((useconds_t)tm_interval); tm_mutex.unlock(); @@ -144,8 +144,11 @@ bool CComponentsTimer::stopTimer() { tm_enable = false; stopThread(); - if(tm_thread == 0) + if(tm_thread == 0){ + if (!OnTimer.empty()) + OnTimer.clear(); return true; + } return false; } diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 83b22f8d3..3c32c0275 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -34,6 +34,7 @@ struct gradientData_t; class Font; class CComponentsForm; class CComponentsScrollBar; +class CCButtonSelect; ///cc item types typedef enum @@ -41,6 +42,9 @@ typedef enum CC_ITEMTYPE_GENERIC, CC_ITEMTYPE_ITEM, CC_ITEMTYPE_PICTURE, + CC_ITEMTYPE_PICTURE_SCALABLE, + CC_ITEMTYPE_CHANNEL_LOGO, + CC_ITEMTYPE_CHANNEL_LOGO_SCALABLE, CC_ITEMTYPE_TEXT, CC_ITEMTYPE_TEXT_INFOBOX, CC_ITEMTYPE_SHAPE_SQUARE, @@ -96,7 +100,7 @@ typedef enum CC_FBDATA_TYPE_FRAME = 8, CC_FBDATA_TYPE_BACKGROUND = 16, - CC_FBDATA_TYPES = 32 + CC_FBDATA_TYPES = CC_FBDATA_TYPE_BOX | CC_FBDATA_TYPE_SHADOW_BOX | CC_FBDATA_TYPE_FRAME }FBDATA_TYPES; //fb color gradient types @@ -194,15 +198,19 @@ typedef struct button_label_cc directKeys(1, CRCInput::RC_nokey){} } button_label_cc_struct; -#define CC_WIDTH_MIN 16 -#define CC_HEIGHT_MIN 16 +#define CC_WIDTH_MIN CFrameBuffer::getInstance()->scale2Res(16) +#define CC_HEIGHT_MIN CC_WIDTH_MIN +//shadow defines #define CC_SHADOW_OFF 0x0 #define CC_SHADOW_RIGHT 0x2 #define CC_SHADOW_BOTTOM 0x4 #define CC_SHADOW_CORNER_BOTTOM_LEFT 0x8 #define CC_SHADOW_CORNER_BOTTOM_RIGHT 0x10 #define CC_SHADOW_CORNER_TOP_RIGHT 0x20 +//prepared combined shadow defines +#define CC_SHADOW_RIGHT_CORNER_ALL CC_SHADOW_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT +#define CC_SHADOW_BOTTOM_CORNER_ALL CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_BOTTOM_LEFT #define CC_SHADOW_ON CC_SHADOW_RIGHT | CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_LEFT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT #define CC_SAVE_SCREEN_YES true diff --git a/src/gui/dmx_tspidbandwidth.c b/src/gui/dmx_tspidbandwidth.c deleted file mode 100644 index 07ced12f5..000000000 --- a/src/gui/dmx_tspidbandwidth.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * some definition - */ -#define TS_LEN 188 -#define TS_SYNC_BYTE 0x47 -#define TS_BUF_SIZE (TS_LEN * 2048) /* fix dmx buffer size */ - -static unsigned long timeval_to_ms(const struct timeval *tv) -{ - return (tv->tv_sec * 1000) + ((tv->tv_usec + 500) / 1000); -} - -long delta_time_ms (struct timeval *tv, struct timeval *last_tv) -{ - return timeval_to_ms(tv) - timeval_to_ms(last_tv); -} - -int ts_pidbandwidth (OPTION *opt) -{ - - u_char buf[TS_BUF_SIZE]; - struct pollfd pfd; - struct dmx_pes_filter_params flt; - int dmxfd; - struct timeval tv,last_tv, first_tv; - int pid; - uint64_t b_total; - long b; - long packets_bad; - long packets_total; - struct { // simple struct for storing last average bandwidth - unsigned long kb_sec; - unsigned long b_sec; - } last_avg; - - - - - if (opt->ts_raw_mode) { - pid = PID_FULL_TS; - } else { - pid = opt->pid; - } - - - - indent (0); - out_nl (2,""); - out_nl (2,"---------------------------------------------------------"); - out_nl (2,"PID bandwidth statistics..."); - if (opt->ts_raw_mode) { - out (2,"Full Transponder"); - } else { - out (2,"PID: %u (0x%04x)", pid, pid); - } - if (opt->rd_packet_count != 0) { - out (2," - max packet count: %ld ", opt->rd_packet_count); - } - out_nl (2,""); - out_nl (2,"---------------------------------------------------------"); - - - - // -- open DVR device for reading - pfd.events = POLLIN | POLLPRI; - if((pfd.fd = open(opt->devDvr,O_RDONLY|O_NONBLOCK)) < 0){ - IO_error(opt->devDvr); - return -1; - } - - - - if ((dmxfd=open(opt->devDemux,O_RDWR)) < 0) { - IO_error(opt->devDemux); - close(pfd.fd); - return -1; - } - ioctl (dmxfd,DMX_SET_BUFFER_SIZE, sizeof(buf)); - - flt.pid = pid; - flt.input = DMX_IN_FRONTEND; - flt.output = DMX_OUT_TS_TAP; - flt.pes_type = DMX_PES_OTHER; - flt.flags = DMX_IMMEDIATE_START; - if (ioctl(dmxfd, DMX_SET_PES_FILTER, &flt) < 0) { - IO_error("DMX_SET_PES_FILTER"); - close(pfd.fd); - close(dmxfd); - return -1; - } - - - - gettimeofday (&first_tv, NULL); - last_tv.tv_sec = first_tv.tv_sec; - last_tv.tv_usec = first_tv.tv_usec; - - b_total = 0; - packets_total = 0; - packets_bad = 0; - - while ( !isSigAbort() ) { - int b_len, b_start; - - // -- we will poll the PID in 2 secs intervall - int timeout = 2000; - - b_len = 0; - b_start = 0; - if (poll(&pfd, 1, timeout) > 0) { - if (pfd.revents & POLLIN) { - - b_len = read(pfd.fd, buf, sizeof(buf)); - gettimeofday (&tv, NULL); - - - if (b_len >= TS_LEN) { - b_start = sync_ts (buf, b_len); - } else { - b_len = 0; - } - - b = b_len - b_start; - if (b == 0) continue; - if (b < 0) { - IO_error("read"); - continue; - } - - b_total += b; - - - - // -- calc bandwidth - - { - uint64_t bit_s; - long d_tim_ms; - int packets; - - packets = b/TS_LEN; - packets_total += packets; - - - // output on different verbosity levels - // -- current bandwidth - d_tim_ms = delta_time_ms (&tv, &last_tv); - if (d_tim_ms <= 0) d_tim_ms = 1; // ignore usecs - - out (3, "packets read: %3d/(%ld) d_time: %2ld.%03ld s = ", - packets, packets_total, d_tim_ms / 1000UL, d_tim_ms % 1000UL); - - // -- current bandwidth in kbit/sec - // --- cast to uint64_t so it doesn't overflow as - // --- early, add time / 2 before division for correct rounding - bit_s = (((uint64_t)b * 8000ULL) + ((uint64_t)d_tim_ms / 2ULL)) - / (uint64_t)d_tim_ms; - - out (1, "%5llu.%03llu kbit/s", bit_s / 1000ULL, bit_s % 1000ULL); - - - // -- average bandwidth - d_tim_ms = delta_time_ms (&tv,&first_tv); - if (d_tim_ms <= 0) d_tim_ms = 1; // ignore usecs - - bit_s = ((b_total * 8000ULL) + ((uint64_t)d_tim_ms / 2ULL)) - / (uint64_t)d_tim_ms; - - last_avg.kb_sec = (unsigned long) (bit_s / 1000ULL); - last_avg.b_sec = (unsigned long) (bit_s % 1000ULL); - - out (2, " (Avrg: %5lu.%03lu kbit/s)", last_avg.kb_sec, last_avg.b_sec); - - - // -- bad packet(s) check in buffer - { - int bp; - - bp = ts_error_count (buf+b_start, b); - packets_bad += bp; - out (4, " [bad: %d]", bp); - } - - out_NL (1); - - } - - - last_tv.tv_sec = tv.tv_sec; - last_tv.tv_usec = tv.tv_usec; - - - - // count packets ? - if (opt->rd_packet_count > 0) { - opt->rd_packet_count -= b/TS_LEN; - if (opt->rd_packet_count <= 0) break; - } - - - } - } - - } - - - // -- packets stats - - out (4, "## "); - - if (opt->ts_raw_mode) { out (2,"PID: "); - } else { out (2,"PID: %u (0x%04x)", pid, pid); - } - - out (4, " bad/total packets: %ld/%ld (= %1.1Lf%%)", - packets_bad, packets_total, - (((long double) packets_bad)*100)/packets_total ); - out (4, " Avrg: %5lu.%03lu kbit/s", - last_avg.kb_sec, last_avg.b_sec); - out_NL(4); - - - - - if (ioctl(dmxfd, DMX_STOP) < 0) { - IO_error("DMX_STOP"); - } - close(dmxfd); - close(pfd.fd); - - - return 0; - -} - diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 9bf4a36f5..9bdc9c69b 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -19,8 +19,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -55,6 +54,7 @@ #include #include #include +#include #include #include @@ -68,6 +68,7 @@ time_t EpgPlus::duration = 0; int EpgPlus::sliderWidth = 0; int EpgPlus::channelsTableWidth = 0; int EpgPlus::entryFontSize = 0; +int EpgPlus::channelNumberOffset = 0; /* negative size means "screen width in percent" */ static EpgPlus::SizeSetting sizeSettingTable[] = @@ -109,18 +110,47 @@ void EpgPlus::Header::paint(const char * Name) std::string caption = Name ? Name : g_Locale->getText(LOCALE_EPGPLUS_HEAD); if (this->head == NULL) + { this->head = new CComponentsHeader(); + this->head->setContextButton(CComponentsHeader::CC_BTN_HELP); + this->head->enableClock(true, "%H:%M", "%H %M", true); + this->head->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); + + } if (this->head) { + if (g_settings.channellist_show_channellogo) + { + // ensure to have clean background + this->logo = this->head->getChannelLogoObject(); + this->logo->hide(); + this->logo->allowPaint(false); + } this->head->setDimensionsAll(this->x, this->y, this->width, this->font->getHeight()); - this->head->setCaption(caption, CTextBox::NO_AUTO_LINEBREAK); - this->head->setContextButton(CComponentsHeader::CC_BTN_HELP); - this->head->enableClock(true, "%H:%M", "%H %M", true); + this->head->setCaption(caption); this->head->paint(CC_SAVE_SCREEN_NO); } } +void EpgPlus::Header::paintChannelLogo(const CZapitChannel * Channel) +{ + if (!g_settings.channellist_show_channellogo) + return; + + if (this->head) + { + this->logo->hide(); + this->logo->clearSavedScreen(); + if (Channel) + { + this->head->setChannelLogo(Channel->getChannelID(), Channel->getName()); + } + this->logo->allowPaint(true); + this->logo->paint(); + } +} + int EpgPlus::Header::getUsedHeight() { return font->getHeight(); @@ -192,6 +222,9 @@ void EpgPlus::TimeLine::paint(time_t _startTime, int pduration) toggleColor = !toggleColor; } + + // shadow + this->frameBuffer->paintBoxRel(this->x + this->width, this->y + OFFSET_SHADOW, OFFSET_SHADOW, this->getUsedHeight(), COL_SHADOW_PLUS_0); } void EpgPlus::TimeLine::paintGrid() @@ -215,6 +248,7 @@ void EpgPlus::TimeLine::paintMark(time_t _startTime, int pduration, int px, int // paint new mark CProgressBar pbbar = CProgressBar(px, this->y + this->font->getHeight(), pwidth, this->font->getHeight()); pbbar.setActiveColor(COL_MENUCONTENTSELECTED_PLUS_0); + pbbar.setType(CProgressBar::PB_TIMESCALE); time_t currentTime; time(¤tTime); @@ -266,6 +300,13 @@ void EpgPlus::TimeLine::clearMark() { this->frameBuffer->paintBoxRel(this->x, this->y + this->font->getHeight(), this->width, this->font->getHeight() , COL_MENUCONTENT_PLUS_0); + + // paint the separation line + if (separationLineThickness > 0) + { + this->frameBuffer->paintBoxRel(this->x, this->y + this->font->getHeight() + this->font->getHeight(), + this->width, this->separationLineThickness, COL_MENUCONTENTDARK_PLUS_0); + } } int EpgPlus::TimeLine::getUsedHeight() @@ -307,13 +348,12 @@ bool EpgPlus::ChannelEventEntry::isSelected(time_t _selectedTime) const void EpgPlus::ChannelEventEntry::paint(bool pisSelected, bool toggleColor) { - if (this->channelEvent.description.empty()) - pisSelected = false; + bool selected = this->channelEvent.description.empty() ? false : pisSelected; fb_pixel_t color; fb_pixel_t bgcolor; - getItemColors(color, bgcolor, pisSelected, false, toggleColor); + getItemColors(color, bgcolor, selected, false, toggleColor, true /* toggle enlighten */); this->frameBuffer->paintBoxRel(this->x, this->y, this->width, this->font->getHeight(), bgcolor); @@ -332,7 +372,8 @@ void EpgPlus::ChannelEventEntry::paint(bool pisSelected, bool toggleColor) this->width, this->separationLineThickness, COL_MENUCONTENTDARK_PLUS_0); } - if (pisSelected) { + if (pisSelected) + { if (this->channelEvent.description.empty()) { // dummy channel event this->timeLine->clearMark(); @@ -359,25 +400,22 @@ int EpgPlus::ChannelEventEntry::getUsedHeight() Font *EpgPlus::ChannelEntry::font = NULL; int EpgPlus::ChannelEntry::separationLineThickness = 0; -EpgPlus::ChannelEntry::ChannelEntry(const CZapitChannel * pchannel, int pindex, CFrameBuffer * pframeBuffer, Footer * pfooter, CBouquetList * pbouquetList, int px, int py, int pwidth) +EpgPlus::ChannelEntry::ChannelEntry(const CZapitChannel * pchannel, int pindex, CFrameBuffer * pframeBuffer, Header * pheader, Footer * pfooter, CBouquetList * pbouquetList, int px, int py, int pwidth) { this->channel = pchannel; + this->displayNumber = ""; + this->displayName = ""; if (pchannel != NULL) { - std::stringstream pdisplayName; - //pdisplayName << pindex + 1 << " " << pchannel->getName(); - if (g_settings.channellist_show_numbers) - pdisplayName << pchannel->number << " " << pchannel->getName(); - else - pdisplayName << pchannel->getName(); - - this->displayName = pdisplayName.str(); + this->displayNumber = to_string(pchannel->number); + this->displayName = pchannel->getName(); } this->index = pindex; this->frameBuffer = pframeBuffer; + this->header = pheader; this->footer = pfooter; this->bouquetList = pbouquetList; @@ -423,8 +461,20 @@ void EpgPlus::ChannelEntry::paint(bool isSelected, time_t _selectedTime) this->frameBuffer->paintBoxRel(this->x, this->y, this->width, this->font->getHeight(), bgcolor, radius, CORNER_LEFT); - this->font->RenderString(this->x + OFFSET_INNER_MID, this->y + this->font->getHeight(), - this->width - 2*OFFSET_INNER_MID, this->displayName, color); + int xPos = this->x + OFFSET_INNER_MID; + int numberWidth = 0; + + if (g_settings.channellist_show_numbers) + { + // display channelnumber + int xOffset = EpgPlus::channelNumberOffset - this->font->getRenderWidth(this->displayNumber); + this->font->RenderString(xPos + xOffset, this->y + this->font->getHeight(), this->width - 2*OFFSET_INNER_MID, this->displayNumber, color); + numberWidth = EpgPlus::channelNumberOffset + OFFSET_INNER_SMALL; + xPos += numberWidth; + } + + // display channelname + this->font->RenderString(xPos, this->y + this->font->getHeight(), this->width - numberWidth - 2*OFFSET_INNER_MID, this->displayName, color); if (isSelected) { @@ -484,7 +534,7 @@ void EpgPlus::ChannelEntry::paint(bool isSelected, time_t _selectedTime) // paint detailsline if (isSelected) { - int xPos = this->x - DETAILSLINE_WIDTH; + xPos = this->x - DETAILSLINE_WIDTH; int yPosTop = this->y + this->font->getHeight()/2; int yPosBottom = this->footer->y + this->footer->getUsedHeight()/2; @@ -493,6 +543,8 @@ void EpgPlus::ChannelEntry::paint(bool isSelected, time_t _selectedTime) detailsLine->setDimensionsAll(xPos, yPosTop, yPosBottom, this->font->getHeight()/2, this->footer->getUsedHeight() - RADIUS_LARGE*2); detailsLine->paint(false); + + this->header->paintChannelLogo(this->channel); } } @@ -513,7 +565,7 @@ EpgPlus::Footer::Footer(CFrameBuffer * pframeBuffer, int px, int py, int pwidth, this->width = pwidth; this->buttonHeight = pbuttonHeight; - this->buttonY = this->y - OFFSET_INTER - this->buttonHeight; + this->buttonY = this->y - OFFSET_INTER - OFFSET_SHADOW - this->buttonHeight; } EpgPlus::Footer::~Footer() @@ -544,6 +596,7 @@ void EpgPlus::Footer::paintEventDetails(const std::string & description, const s int frame_thickness = 2; // clear the whole footer + this->frameBuffer->paintBoxRel(this->x + OFFSET_SHADOW, yPos + OFFSET_SHADOW, this->width, this->getUsedHeight(), COL_SHADOW_PLUS_0, RADIUS_LARGE); this->frameBuffer->paintBoxRel(this->x, yPos, this->width, this->getUsedHeight(), COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE); this->frameBuffer->paintBoxFrame(this->x, yPos, this->width, this->getUsedHeight(), frame_thickness, COL_FRAME_PLUS_0, RADIUS_LARGE); @@ -572,8 +625,9 @@ struct button_label buttonLabels[] = void EpgPlus::Footer::paintButtons(button_label * pbuttonLabels, int numberOfButtons) { int buttonWidth = (this->width); - CComponentsFooter _footer; - _footer.paintButtons(this->x, this->buttonY, buttonWidth, buttonHeight, numberOfButtons, pbuttonLabels, buttonWidth/numberOfButtons); + CComponentsFooter foot; + foot.enableShadow(CC_SHADOW_ON, -1, true); + foot.paintButtons(this->x, this->buttonY, buttonWidth, buttonHeight, numberOfButtons, pbuttonLabels, buttonWidth/numberOfButtons); } EpgPlus::EpgPlus() @@ -627,7 +681,7 @@ void EpgPlus::createChannelEntries(int selectedChannelEntryIndex) CZapitChannel * channel = (*this->channelList)[i]; - ChannelEntry *channelEntry = new ChannelEntry(channel, i, this->frameBuffer, this->footer, this->bouquetList, this->channelsTableX, yPosChannelEntry, this->channelsTableWidth); + ChannelEntry *channelEntry = new ChannelEntry(channel, i, this->frameBuffer, this->header, this->footer, this->bouquetList, this->channelsTableX, yPosChannelEntry, this->channelsTableWidth); //printf("Going to get getEventsServiceKey for %llx\n", (channel->getChannelID() & 0xFFFFFFFFFFFFULL)); CChannelEventList channelEventList; CEitManager::getInstance()->getEventsServiceKey(channel->getEpgID(), channelEventList); @@ -725,6 +779,16 @@ void EpgPlus::createChannelEntries(int selectedChannelEntryIndex) this->selectedChannelEntry = this->displayedChannelEntries[selectedChannelEntryIndex - this->channelListStartIndex]; } + + // get largest channelnumber + int n = 1; + for (TChannelEntries::iterator It = this->displayedChannelEntries.begin(); + It != this->displayedChannelEntries.end(); + ++It) + { + n = std::max(n, (*It)->channel->number); + } + channelNumberOffset = ChannelEntry::font->getRenderWidth(to_string(n)); } void EpgPlus::init() @@ -771,11 +835,13 @@ void EpgPlus::init() int footerHeight = Footer::getUsedHeight(); - this->maxNumberOfDisplayableEntries = (this->usableScreenHeight - headerHeight - timeLineHeight - buttonHeight - OFFSET_INTER - footerHeight) / this->entryHeight; + this->maxNumberOfDisplayableEntries = (this->usableScreenHeight - headerHeight - timeLineHeight - buttonHeight - OFFSET_SHADOW - OFFSET_INTER - footerHeight - OFFSET_SHADOW) / this->entryHeight; this->bodyHeight = this->maxNumberOfDisplayableEntries * entryHeight; - this->usableScreenHeight = headerHeight + timeLineHeight + this->bodyHeight + buttonHeight + OFFSET_INTER + footerHeight; // recalc deltaY + this->usableScreenHeight = headerHeight + timeLineHeight + this->bodyHeight + buttonHeight + OFFSET_SHADOW + OFFSET_INTER + footerHeight + OFFSET_SHADOW; // recalc deltaY this->usableScreenX = getScreenStartX(this->usableScreenWidth); + if (this->usableScreenX < DETAILSLINE_WIDTH) + this->usableScreenX = DETAILSLINE_WIDTH; this->usableScreenY = getScreenStartY(this->usableScreenHeight); this->headerX = this->usableScreenX; @@ -787,7 +853,7 @@ void EpgPlus::init() this->timeLineWidth = this->usableScreenWidth; this->footerX = usableScreenX; - this->footerY = this->usableScreenY + this->usableScreenHeight - footerHeight; + this->footerY = this->usableScreenY + this->usableScreenHeight - OFFSET_SHADOW - footerHeight; this->footerWidth = this->usableScreenWidth; this->channelsTableX = this->usableScreenX; @@ -1324,8 +1390,17 @@ void EpgPlus::hide() if (this->header->head) { this->header->head->kill(); + delete this->header->head; + this->header->head = NULL; } - this->frameBuffer->paintBackgroundBoxRel(this->usableScreenX - DETAILSLINE_WIDTH, this->usableScreenY, DETAILSLINE_WIDTH + this->usableScreenWidth, this->usableScreenHeight); + + if (this->selectedChannelEntry->detailsLine) { + this->selectedChannelEntry->detailsLine->kill(); + delete this->selectedChannelEntry->detailsLine; + this->selectedChannelEntry->detailsLine = NULL; + } + + this->frameBuffer->paintBackgroundBoxRel(this->usableScreenX, this->usableScreenY, this->usableScreenWidth + OFFSET_SHADOW, this->usableScreenHeight + OFFSET_SHADOW); } void EpgPlus::paintChannelEntry(int position) @@ -1368,10 +1443,14 @@ void EpgPlus::paint() this->timeLine->paintGrid(); // paint slider - int total_pages = ((this->channelList->getSize() - 1) / this->maxNumberOfDisplayableEntries) + 1; - int current_page = this->selectedChannelEntry == NULL ? 0 : (this->selectedChannelEntry->index / this->maxNumberOfDisplayableEntries); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, + this->channelList->getSize(), + this->maxNumberOfDisplayableEntries, + this->selectedChannelEntry == NULL ? 0 : this->selectedChannelEntry->index); - paintScrollBar(this->sliderX, this->sliderY, this->sliderWidth, this->sliderHeight, total_pages, current_page); + paintScrollBar(this->sliderX, this->sliderY, this->sliderWidth, this->sliderHeight, total_pages, current_page, CC_SHADOW_RIGHT_CORNER_ALL); } // -- EPG+ Menue Handler Class diff --git a/src/gui/epgplus.h b/src/gui/epgplus.h index 4cb72f51d..d0dc7286d 100644 --- a/src/gui/epgplus.h +++ b/src/gui/epgplus.h @@ -18,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef __epgplus__ @@ -69,6 +68,8 @@ class EpgPlus class Header { + private: + CComponentsChannelLogoScalable *logo; //// construction / destruction public: Header(CFrameBuffer* frameBuffer, @@ -84,6 +85,8 @@ class EpgPlus void paint(const char * Name = NULL); + void paintChannelLogo(const CZapitChannel * Channel = NULL); + static int getUsedHeight(); //// attributes @@ -192,6 +195,7 @@ class EpgPlus ChannelEntry(const CZapitChannel* channel, int index, CFrameBuffer* frameBuffer, + Header* header, Footer* footer, CBouquetList* bouquetList, int x, @@ -211,10 +215,12 @@ class EpgPlus //// attributes public: const CZapitChannel * channel; + std::string displayNumber; std::string displayName; int index; CFrameBuffer* frameBuffer; + Header* header; Footer* footer; CBouquetList* bouquetList; @@ -420,6 +426,7 @@ class EpgPlus int channelListStartIndex; int maxNumberOfDisplayableEntries; // maximal number of displayable entrys + static int channelNumberOffset; time_t startTime; time_t firstStartTime; diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index a53ac9b03..3bd6e1117 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -121,17 +121,19 @@ void reformatExtendedEvents(std::string strItem, std::string strLabel, bool bUse CEpgData::CEpgData() { - bigFonts = false; - frameBuffer = CFrameBuffer::getInstance(); - tmdb_active = false; - mp_movie_info = NULL; - header = NULL; + bigFonts = false; + frameBuffer = CFrameBuffer::getInstance(); + tmdb_active = false; + mp_movie_info = NULL; + header = NULL; + Bottombox = NULL; + pb = NULL; + font_title = NULL; } CEpgData::~CEpgData() { - delete header; - header = NULL; + ResetModules(); } void CEpgData::start() @@ -139,7 +141,8 @@ void CEpgData::start() ox = frameBuffer->getScreenWidthRel(bigFonts ? false /* big */ : true /* small */); oy = frameBuffer->getScreenHeightRel(bigFonts ? false /* big */ : true /* small */); - topheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getHeight(); + font_title = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]; + topheight = font_title->getHeight(); topboxheight = topheight + 6; botboxheight = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getHeight() + 6; buttonheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight() + 6; @@ -196,7 +199,7 @@ void CEpgData::processTextToArray(std::string text, int screening, bool has_cove // check the wordwidth - add to this line if size ok int aktWordWidth = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth(aktWord); - if ((aktWordWidth+aktWidth)<(ox - 2*OFFSET_INNER_MID - 15 - (has_cover ? ((ox/4)+OFFSET_INNER_MID) : 0))) + if ((aktWordWidth+aktWidth)<(ox - 2*OFFSET_INNER_MID - SCROLLBAR_WIDTH - (has_cover ? ((ox/4)+OFFSET_INNER_MID) : 0))) {//space ok, add aktWidth += aktWordWidth; aktLine += aktWord; @@ -267,12 +270,12 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) max_wday_w = std::max(max_wday_w, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth(std::string(g_Locale->getText(CLocaleManager::getWeekday(i))) + " ")); } int offs = fullClear ? 0 : cover_offset; - frameBuffer->paintBoxRel(sx+offs, y, ox-15-offs, sb, COL_MENUCONTENT_PLUS_0); // background of the text box + frameBuffer->paintBoxRel(sx+offs, y, ox-SCROLLBAR_WIDTH-offs, sb, COL_MENUCONTENT_PLUS_0); // background of the text box if (has_cover) { if (!g_PicViewer->DisplayImage(cover ,sx+OFFSET_INNER_MID ,y+OFFSET_INNER_MID+((sb-cover_height)/2), cover_width, cover_height, CFrameBuffer::TM_NONE)) { cover_offset = 0; - frameBuffer->paintBoxRel(sx, y, ox-15, sb, COL_MENUCONTENT_PLUS_0); // background of the text box + frameBuffer->paintBoxRel(sx, y, ox-SCROLLBAR_WIDTH, sb, COL_MENUCONTENT_PLUS_0); // background of the text box } } int logo_offset = 0; @@ -309,7 +312,7 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) offset += digi; break; } - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+OFFSET_INNER_MID+offset, y+medlineheight, ox- 15- 15, epgText[i].first.substr(pos1, pos2 - pos1), (epgText[i].second==2)? COL_MENUCONTENTINACTIVE_TEXT: COL_MENUCONTENT_TEXT); + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+OFFSET_INNER_MID+offset, y+medlineheight, ox - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - offset, epgText[i].first.substr(pos1, pos2 - pos1), (epgText[i].second==2)? COL_MENUCONTENTINACTIVE_TEXT: COL_MENUCONTENT_TEXT); count++; pos1 = epgText[i].first.find_first_not_of(tok, pos2); pos2 = epgText[i].first.find_first_of(tok, pos1); @@ -318,17 +321,14 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) count = 0; } else{ - g_Font[( i< info1_lines ) ?SNeutrinoSettings::FONT_TYPE_EPG_INFO1:SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+OFFSET_INNER_MID+cover_offset, y+medlineheight, ox-15-15-cover_offset, epgText[i].first, COL_MENUCONTENT_TEXT); + g_Font[( i< info1_lines ) ?SNeutrinoSettings::FONT_TYPE_EPG_INFO1:SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+OFFSET_INNER_MID+cover_offset, y+medlineheight, ox - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - cover_offset, epgText[i].first, COL_MENUCONTENT_TEXT); } } - - int sbc = ((textSize - 1)/ medlinecount) + 1; - int sbs= (startPos+ 1)/ medlinecount; - if (sbc < 1) - sbc = 1; - frameBuffer->paintBoxRel(sx+ ox- 15, ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); // scrollbar bg - frameBuffer->paintBoxRel(sx+ ox- 13, ypos+ 2+ sbs*(sb-4)/sbc , 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); // scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, textSize, medlinecount, startPos + 1); + paintScrollBar(sx + ox - SCROLLBAR_WIDTH, ypos, SCROLLBAR_WIDTH, sb, total_pages, current_page); } #define GENRE_MOVIE_COUNT 9 @@ -712,46 +712,16 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start const int pic_h = 39; toph = std::max(toph, pic_h); - // Calculate offset for the title when logo appears. - int pic_offx = 0; std::string lname; - int logo_w = 0; - int logo_h = 0; - int logo_w_max = ox / 4; - int logo_h_max = toph - 2*OFFSET_INNER_MIN; std::string channel_name; if (mp_info) channel_name = mp_movie_info->channelName; else channel_name = g_Zapit->getChannelName(channel_id); - if (g_settings.infobar_show_channellogo && g_PicViewer->GetLogoName(channel_id, channel_name, lname, &logo_w, &logo_h)) - { - if ((logo_h > logo_h_max) || (logo_w > logo_w_max)) - g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, logo_h_max); - pic_offx = logo_w + OFFSET_INNER_MID; - } - - int pos; - std::string text1 = epgData.title; - std::string text2 = ""; - if (g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getRenderWidth(text1) > ox - pic_offx - 2*OFFSET_INNER_MID) - { - do - { - pos = text1.find_last_of("[ .]+"); - if (pos != -1) - text1 = text1.substr(0, pos); - } while ((pos != -1) && (g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]->getRenderWidth(text1) > ox - pic_offx - 2*OFFSET_INNER_MID)); - if (epgData.title.length() > text1.length()) // shold never be false in this place - text2 = epgData.title.substr(text1.length()+ 1, uint(-1) ); - } if (!topboxheight) start(); - if (!text2.empty()) - toph = 2 * topboxheight; - sb = oy - toph - botboxheight; // 21.07.2005 - rainerk @@ -878,62 +848,48 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start COSDFader fader(g_settings.theme.menu_Content_alpha); fader.StartFadeIn(); - //show the epg + // show the epg // header + logo - int header_h = std::max(toph, logo_h); - if (!header){ - header = new CComponentsShapeSquare(sx, sy, ox, header_h); - header->setCorner(RADIUS_LARGE, CORNER_TOP); + if (!header) + { + header = new CComponentsHeader(); + header->setColorBody(COL_MENUHEAD_PLUS_0); + header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction); + header->enableClock(true, "%H:%M", "%H %M", true); } - header->setDimensionsAll(sx, sy, ox, header_h); - header->setColorBody(COL_MENUHEAD_PLUS_0); - header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction); - CComponentsPicture* headerPic = NULL; //NOTE: class CComponentsChannelLogo is preferred for channel logos - if (pic_offx > 0) { - headerPic = new CComponentsPicture(sx + OFFSET_INNER_MID, sy + (header_h-logo_h)/2, logo_w, logo_h, lname); - headerPic->doPaintBg(false); - } - std::string textAll = (!text2.empty()) ? text1 + "\n" + text2 : text1; - CComponentsText headerText(sx + OFFSET_INNER_MID + pic_offx, sy, ox - 2*OFFSET_INNER_MID - pic_offx, header_h, textAll, CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]); - headerText.doPaintBg(false); - headerText.setTextColor(COL_MENUHEAD_TEXT); + header->setDimensionsAll(sx, sy, ox, toph); + header->setCaptionFont(font_title); + header->setCaption(epgData.title); + + if (header->isPainted()) + header->hideCCItems(); + + // set channel logo + header->setChannelLogo(channel_id, channel_name); + + //paint head header->paint(CC_SAVE_SCREEN_NO); - headerText.paint(CC_SAVE_SCREEN_NO); - if (headerPic) - headerPic->paint(CC_SAVE_SCREEN_NO); int showPos = 0; textCount = epgText.size(); showText(showPos, sy + toph); - // small bottom box - frameBuffer->paintBoxRel(sx, sy+oy-botboxheight, ox, botboxheight, COL_MENUHEAD_PLUS_0); - if (!mp_info) - { - static int iw = 0, ih = 0, io = 0; - if (!iw && !ih) - frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_LEFT, &iw, &ih); - if (!io && iw) - io = iw + OFFSET_INNER_MID; + // small bottom box with left/right navigation + if (!Bottombox) + Bottombox = new CNaviBar(sx, sy+oy-botboxheight, ox, botboxheight); + if (!mp_info){ std::string fromto = epg_start + " - " + epg_end; - int widthl = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getRenderWidth(fromto); - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+OFFSET_INNER_MID+io, sy+oy-3, widthl, fromto, COL_MENUHEAD_TEXT); - int widthr = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getRenderWidth(epg_date); - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ox-OFFSET_INNER_MID-io-widthr, sy+oy-3, widthr, epg_date, COL_MENUHEAD_TEXT); - GetPrevNextEPGData(epgData.eventID, &epgData.epg_times.startzeit); - if (!call_fromfollowlist) - { - int iy = sy + oy - botboxheight + (botboxheight - iw)/2; - if (prev_id) - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_LEFT, sx + OFFSET_INNER_MID, iy); - if (next_id) - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_RIGHT, sx + ox - iw - OFFSET_INNER_MID, iy); - } + + Bottombox->enableArrows(prev_id && !call_fromfollowlist, next_id && !call_fromfollowlist); + Bottombox->setText(fromto, epg_date); } + + //paint bottombox contents + Bottombox->paint(false); showProgressBar(); // show Timer Event Buttons @@ -1246,6 +1202,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start } case CRCInput::RC_help: bigFonts = bigFonts ? false : true; + ResetModules(); frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy); showTimerEventBar (false); start(); @@ -1309,8 +1266,6 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if(epgTextSwitchClear) epgTextSwitch.clear(); } - if (headerPic) - delete headerPic; return res; } @@ -1323,6 +1278,8 @@ void CEpgData::hide() g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() / BIGFONT_FACTOR)); } + ResetModules(); + frameBuffer->paintBackgroundBoxRel(sx, sy, ox, oy); showTimerEventBar (false); } @@ -1465,18 +1422,21 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st void CEpgData::showProgressBar() { + int w = ox/10; + int x = sx + (ox - w)/2; + int h = botboxheight - 2*OFFSET_INNER_SMALL; + int y = sy + oy - botboxheight + (botboxheight - h)/2; + if (!pb){ + pb = new CProgressBar(x, y, w, h); + pb->setType(CProgressBar::PB_TIMESCALE); + } //show progressbar if (epg_done != -1) { - int w = 104; - int x = sx + (ox - w)/2; - int h = botboxheight - 12; - int y = sy + oy - botboxheight + (botboxheight - h)/2; - - CProgressBar pb(x, y, w, h); - pb.setType(CProgressBar::PB_TIMESCALE); - pb.setValues(epg_done, 100); - pb.paint(false); + pb->setValues(epg_done, 100); + pb->paint(true); + }else{ + pb->hide(); } } @@ -1551,6 +1511,19 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info) } } +void CEpgData::ResetModules() +{ + if (header){ + delete header; header = NULL; + } + if (Bottombox){ + delete Bottombox; Bottombox = NULL; + } + if (pb){ + delete pb; pb = NULL; + } +} + // -- EPG Data Viewer Menu Handler Class // -- to be used for calls from Menue // -- (2004-03-06 rasc) diff --git a/src/gui/epgview.h b/src/gui/epgview.h index c7ec15b80..617fff66f 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -38,7 +38,7 @@ #include #include "widget/menue.h" - +#include "widget/navibar.h" #include #include @@ -50,7 +50,10 @@ class CEpgData CChannelEventList evtlist; CChannelEventList followlist; CEPGData epgData; - CComponentsShapeSquare* header; + CComponentsHeader *header; + CNaviBar *Bottombox; + CProgressBar *pb; + Font *font_title; std::string epg_date; std::string epg_start; std::string epg_end; @@ -100,6 +103,7 @@ class CEpgData int show(const t_channel_id channel_id, uint64_t id = 0, time_t* startzeit = NULL, bool doLoop = true, bool callFromfollowlist = false, bool mp_info = false ); int show_mp(MI_MOVIE_INFO *mi, int mp_position = 0, int mp_duration = 0, bool doLoop = true); void hide(); + void ResetModules(); }; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 315acf576..7f17c199d 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -110,22 +110,35 @@ CEventList::CEventList() m_search_fsk = 1; full_width = width = 0; height = 0; - x = y = 0; - cc_infozone = NULL; + infozone = NULL; infozone_text = ""; item_event_ID = 0; oldIndex = -1; oldEventID = -1; - bgRightBoxPaint = false; + infozone_background = false; header = NULL; + pb = NULL; + navibar = NULL; } CEventList::~CEventList() { - delete header; - header = NULL; + ResetModules(); +} + +void CEventList::ResetModules() +{ + if (header){ + delete header; header = NULL; + } + if (navibar){ + delete navibar; navibar = NULL; + } + if (pb){ + delete pb; pb = NULL; + } } void CEventList::UpdateTimerList(void) @@ -249,6 +262,38 @@ void CEventList::readEvents(const t_channel_id channel_id) return; } +void CEventList::getChannelNames(t_channel_id &channel_id, std::string ¤t_channel_name, std::string &prev_channel_name, std::string &next_channel_name, neutrino_msg_t msg) +{ + t_bouquet_id current_bouquet_id = bouquetList->getActiveBouquetNumber(); + const unsigned int channel_nr = bouquetList->Bouquets[current_bouquet_id]->channelList->getSize(); + if(channel_nr < 2){ + channel_id = 0; + return; + } + unsigned int tmp_channel = 0; + for(unsigned int channel = 0; channel < channel_nr; channel++) + { + t_channel_id channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(channel)->getChannelID(); + if(channel_id_tmp == channel_id){ + if ( msg==CRCInput::RC_right || msg==CRCInput::RC_forward ) { + channel = (channel+1) %channel_nr; + }else if ( msg==CRCInput::RC_left || msg==CRCInput::RC_rewind ){ //RC_rewind + channel = (channel == 0) ? channel_nr -1 : channel - 1; + } + channel_id = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(channel)->getChannelID(); + current_channel_name = CServiceManager::getInstance()->GetServiceName(channel_id); + + tmp_channel = (channel == 0) ? channel_nr - 1 : channel - 1; + channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(tmp_channel)->getChannelID(); + prev_channel_name = CServiceManager::getInstance()->GetServiceName(channel_id_tmp); + + tmp_channel = (channel+1) %channel_nr; + channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(tmp_channel)->getChannelID(); + next_channel_name = CServiceManager::getInstance()->GetServiceName(channel_id_tmp); + break; + } + } +} int CEventList::exec(const t_channel_id channel_id, const std::string& channelname, const std::string& channelname_prev, const std::string& channelname_next,const CChannelEventList &followlist) // UTF-8 { @@ -271,36 +316,33 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna width = full_width; height = frameBuffer->getScreenHeightRel(); - // Calculate iheight (we assume the red button is the largest one?) - struct button_label tmp_button[1] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_EVENTLISTBAR_RECORDEVENT } }; - iheight = ::paintButtons(0, 0, 0, 1, tmp_button, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); - - // Calculate theight - theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight(); + // Calculate header_height + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + footer_height = header_height; const int pic_h = 39; - theight = std::max(theight, pic_h); + header_height = std::max(header_height, pic_h); - fheight1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight(); + largefont_height = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight(); { int h1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getHeight(); int h2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getHeight(); - fheight2 = std::max( h1, h2 ); + smallfont_height = std::max(h1, h2); } unit_short_minute = g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); - fheight = fheight1 + fheight2 + OFFSET_INNER_MIN; - fwidth1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth("DDD, :, ") + 4 * g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getMaxDigitWidth(); - //fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth("[ ] ") + 3 * g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getMaxDigitWidth() + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth(unit_short_minute); + item_height = smallfont_height + OFFSET_INNER_MIN + largefont_height; - listmaxshow = (height-theight-iheight-0)/fheight; - height = theight+iheight+0+listmaxshow*fheight; // recalc height + navibar_height = largefont_height+2*OFFSET_INNER_MIN; + + listmaxshow = (height - header_height - footer_height - OFFSET_SHADOW - navibar_height)/item_height; + height = header_height + footer_height + OFFSET_SHADOW + navibar_height + listmaxshow*item_height; // recalc height y = getScreenStartY(height); // calculate width of right info_zone infozone_width = full_width - width; // init right info_zone - if ((g_settings.eventlist_additional) && (cc_infozone == NULL)) - cc_infozone = new CComponentsText(x+width+10, y+theight, infozone_width-20, listmaxshow*fheight); + if ((g_settings.eventlist_additional) && (infozone == NULL)) + infozone = new CComponentsText(x+width+OFFSET_INNER_MID, y + header_height, infozone_width-2*OFFSET_INNER_MID, listmaxshow*item_height); int res = menu_return::RETURN_REPAINT; //printf("CEventList::exec: channel_id %llx\n", channel_id); @@ -332,7 +374,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna bool dont_hide = false; paintHead(channel_id, channelname, channelname_prev, channelname_next); paint(channel_id); - showFunctionBar(channel_id); + paintFoot(channel_id); int oldselected = selected; @@ -379,7 +421,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna else paintItem(selected - liststart, channel_id); - showFunctionBar(channel_id); + paintFoot(channel_id); } //sort else if (!showfollow && (msg == (neutrino_msg_t)g_settings.key_channelList_sort)) @@ -437,7 +479,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID); - showFunctionBar(evtlist[selected].channelID); + paintFoot(evtlist[selected].channelID); continue; } std::string recDir = g_settings.network_nfs_recordingdir; @@ -492,7 +534,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(used_id); - showFunctionBar(used_id); + paintFoot(used_id); } } else if ( msg == (neutrino_msg_t) g_settings.key_channelList_addremind )//add/remove zapto timer event @@ -504,7 +546,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID); - showFunctionBar(evtlist[selected].channelID); + paintFoot(evtlist[selected].channelID); continue; } @@ -516,7 +558,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID ); - showFunctionBar(evtlist[selected].channelID ); + paintFoot(evtlist[selected].channelID ); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } else if (msg == (neutrino_msg_t)g_settings.key_channelList_cancel) @@ -527,7 +569,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna paintHead(channel_id, channelname); readEvents(epg_id); paint(channel_id); - showFunctionBar(channel_id); + paintFoot(channel_id); } else { selected = oldselected; if(fader.StartFadeOut()) { @@ -542,39 +584,15 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna } else if ( msg==CRCInput::RC_left || msg==CRCInput::RC_right || msg==CRCInput::RC_rewind || msg==CRCInput::RC_forward ) { // maybe remove RC_rewind and RC_forward in the future? - bgRightBoxPaint = false; - t_bouquet_id current_bouquet_id= bouquetList->getActiveBouquetNumber(); - t_channel_id channel_id_tmp, _channel_id = channel_id; - const unsigned int channel_nr = bouquetList->Bouquets[current_bouquet_id]->channelList->getSize(); - std::string next_channel_name; - std::string prev_channel_name ; - std::string current_channel_name; - unsigned int tmp_channel = 0; - for(unsigned int channel = 0; channel < channel_nr; channel++) - { - channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(channel)->getChannelID(); - if(channel_id_tmp == channel_id){ - if ( msg==CRCInput::RC_right || msg==CRCInput::RC_forward ) { - channel = (channel+1) %channel_nr; - }else { //RC_rewind - channel = (channel == 0) ? channel_nr -1 : channel - 1; - } - _channel_id = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(channel)->getChannelID(); - current_channel_name = CServiceManager::getInstance()->GetServiceName(_channel_id); - - tmp_channel = (channel == 0) ? channel_nr - 1 : channel - 1; - channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(tmp_channel)->getChannelID(); - prev_channel_name = CServiceManager::getInstance()->GetServiceName(channel_id_tmp); - - tmp_channel = (channel+1) %channel_nr; - channel_id_tmp = bouquetList->Bouquets[current_bouquet_id]->channelList->getChannelFromIndex(tmp_channel)->getChannelID(); - next_channel_name = CServiceManager::getInstance()->GetServiceName(channel_id_tmp); - break; - } + std::string next_channel_name, prev_channel_name, current_channel_name; + t_channel_id _channel_id = channel_id; + getChannelNames(_channel_id, current_channel_name, prev_channel_name, next_channel_name, msg); + if(_channel_id){ + infozone_background = false; + loop = false; + dont_hide = true; + exec(_channel_id, current_channel_name, prev_channel_name, next_channel_name); } - loop = false; - dont_hide = true; - exec(_channel_id, current_channel_name, prev_channel_name, next_channel_name); } else if (msg == CRCInput::RC_0) { hide(); @@ -588,9 +606,9 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna paintHead(channel_id, channelname); oldIndex = -1; oldEventID = -1; - bgRightBoxPaint = false; + infozone_background = false; paint(channel_id); - showFunctionBar(channel_id); + paintFoot(channel_id); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } else if (msg == CRCInput::RC_epg) @@ -631,9 +649,9 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna paintHead(channel_id, in_search ? search_head_name : channelname); oldIndex = -1; oldEventID = -1; - bgRightBoxPaint = false; + infozone_background = false; paint(channel_id); - showFunctionBar(channel_id); + paintFoot(channel_id); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -642,7 +660,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna { oldIndex = -1; oldEventID = -1; - bgRightBoxPaint = false; + infozone_background = false; in_search = findEvents(channel_id, channelname); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } @@ -666,12 +684,12 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna } } - if (cc_infozone) - delete cc_infozone; - cc_infozone = NULL; + if (infozone) + delete infozone; + infozone = NULL; oldIndex = -1; oldEventID = -1; - bgRightBoxPaint = false; + infozone_background = false; if(!dont_hide){ hide(); @@ -682,7 +700,8 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna void CEventList::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, full_width,height); + ResetModules(); + frameBuffer->paintBackgroundBoxRel(x, y, full_width + OFFSET_SHADOW, height + OFFSET_SHADOW); } CTimerd::CTimerEventTypes CEventList::isScheduled(t_channel_id channel_id, CChannelEvent * event, int * tID) @@ -711,7 +730,7 @@ CTimerd::CTimerEventTypes CEventList::isScheduled(t_channel_id channel_id, CChan void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) { - int ypos = y+ theight + pos*fheight; + int ypos = y + header_height + pos*item_height; unsigned int currpos = liststart + pos; bool i_selected = currpos == selected; @@ -727,27 +746,27 @@ void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, width- 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius); if(currposgetText(CLocaleManager::getWeekday(tmStartZeit)); - datetime1_str += strftime(", %H:%M", tmStartZeit); - datetime1_str += strftime(", %d", tmStartZeit); - datetime1_str += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit)); + datetime_str = g_Locale->getText(CLocaleManager::getWeekday(tmStartZeit)); + datetime_str += strftime(", %H:%M", tmStartZeit); + datetime_str += strftime(", %d", tmStartZeit); + datetime_str += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit)); if ( m_showChannel ) // show the channel if we made a event search only (which could be made through all channels ). { t_channel_id channel = evtlist[currpos].channelID; - datetime1_str += " "; - datetime1_str += CServiceManager::getInstance()->GetServiceName(channel); + datetime_str += " "; + datetime_str += CServiceManager::getInstance()->GetServiceName(channel); } snprintf(tmpstr,sizeof(tmpstr), "[%d %s]", evtlist[currpos].duration / 60, unit_short_minute); @@ -755,10 +774,10 @@ void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) } // 1st line - int fwidth1a=g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth(datetime1_str); - fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth(duration_str); + int datetime_width = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth(datetime_str); + int duration_width = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth(duration_str); - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->RenderString(x + OFFSET_INNER_SMALL, ypos + OFFSET_INNER_MIN + fheight2, fwidth1a, datetime1_str, color); + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->RenderString(x + OFFSET_INNER_SMALL, ypos + OFFSET_INNER_MIN + smallfont_height, datetime_width, datetime_str, color); int seit = ( evtlist[currpos].startTime - time(NULL) ) / 60; if ( (seit> 0) && (seit<100) && (!duration_str.empty()) ) @@ -766,9 +785,9 @@ void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) char beginnt[100]; snprintf(beginnt, sizeof(beginnt), "%s %d %s", g_Locale->getText(LOCALE_WORD_IN), seit, unit_short_minute); int w = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth(beginnt); - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x + width - 15 - 2*OFFSET_INNER_MID - fwidth2 - w, ypos + OFFSET_INNER_MIN + fheight2, w, beginnt, color); + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x + width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - duration_width - w, ypos + OFFSET_INNER_MIN + smallfont_height, w, beginnt, color); } - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x + width - 15 - OFFSET_INNER_MID - fwidth2, ypos + OFFSET_INNER_MIN + fheight2, fwidth2, duration_str, color); + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - duration_width, ypos + OFFSET_INNER_MIN + smallfont_height, duration_width, duration_str, color); // 2nd line // set status icons @@ -785,7 +804,7 @@ void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) int iw = 0, ih = 0; if(icontype != 0) { frameBuffer->getIconSize(icontype, &iw, &ih); - frameBuffer->paintIcon(icontype, x + OFFSET_INNER_MID, ypos + OFFSET_INNER_MIN + fheight2, fheight1); + frameBuffer->paintIcon(icontype, x + OFFSET_INNER_MID, ypos + OFFSET_INNER_MIN + smallfont_height, largefont_height); iw += OFFSET_INNER_MID; } @@ -798,12 +817,14 @@ void CEventList::paintItem(unsigned int pos, t_channel_id channel_idI) { //paint_warning = true; frameBuffer->getIconSize(NEUTRINO_ICON_IMPORTANT, &i2w, &i2h); - frameBuffer->paintIcon(NEUTRINO_ICON_IMPORTANT, x + iw + OFFSET_INNER_MID, ypos + OFFSET_INNER_MIN + fheight2, fheight1); + frameBuffer->paintIcon(NEUTRINO_ICON_IMPORTANT, x + iw + OFFSET_INNER_MID, ypos + OFFSET_INNER_MIN + smallfont_height, largefont_height); iw += i2w + OFFSET_INNER_MID; } // paint 2nd line text - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->RenderString(x + iw + OFFSET_INNER_MID, ypos + fheight, width - iw - 2*OFFSET_INNER_MID, evtlist[currpos].description, color); + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->RenderString(x + iw + OFFSET_INNER_MID, ypos + item_height, width - iw - 2*OFFSET_INNER_MID, evtlist[currpos].description, color); + + showProgressBar(currpos); } } @@ -829,6 +850,13 @@ void CEventList::paintDescription(int index) else CEitManager::getInstance()->getActualEPGServiceKey(evtlist[index].channelID, &epgData ); + infozone_text = ""; + if (!epgData.info1.empty() && !epgData.info2.empty() && (epgData.info2.find(epgData.info1) != 0)) { + infozone_text += epgData.info1; + infozone_text += "\n"; + infozone_text += epgData.info2; + } + else if(!epgData.info2.empty()){ infozone_text = epgData.info2; } @@ -838,66 +866,94 @@ void CEventList::paintDescription(int index) else infozone_text = g_Locale->getText(LOCALE_EPGLIST_NOEVENTS); - cc_infozone->setText(infozone_text, CTextBox::TOP, g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_EVENT]); - cc_infozone->doPaintBg(false); - cc_infozone->doPaintTextBoxBg(true); - cc_infozone->forceTextPaint(); - cc_infozone->paint(CC_SAVE_SCREEN_NO); + infozone->setText(infozone_text, CTextBox::TOP, g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_EVENT]); + infozone->doPaintBg(false); + infozone->doPaintTextBoxBg(true); + //FIXME infozone->enableShadow(CC_SHADOW_RIGHT, -1, true); + infozone->forceTextPaint(); + infozone->paint(CC_SAVE_SCREEN_NO); } void CEventList::paintHead(t_channel_id _channel_id, std::string _channelname, std::string _channelname_prev, std::string _channelname_next) { - int font_mid = SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE; - int font_lr = SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE; - - if (!header) - header = new CComponentsFrmChain(); - - header->setDimensionsAll(x, y, full_width, theight); - header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction); - header->setCorner(RADIUS_LARGE, CORNER_TOP); - header->clear(); - - int x_off = OFFSET_INNER_MID; - int mid_width = full_width * 40 / 100; // 40% - int max_height = theight - 2*OFFSET_INNER_MIN; - int side_width = ((full_width - mid_width) / 2) - (2 * x_off); - - //create an logo object - CComponentsChannelLogoScalable* midLogo = new CComponentsChannelLogoScalable(0, 0, _channelname, _channel_id, header); - if (midLogo->hasLogo()) - { - midLogo->setWidth(min(midLogo->getWidth(), mid_width), true); - if (midLogo->getHeight() > max_height) - midLogo->setHeight(max_height, true); - - midLogo->setPos(CC_CENTERED, CC_CENTERED); - - // recalc widths - side_width = ((full_width - midLogo->getWidth()) / 2) - (4 * x_off); - } - else { - header->removeCCItem(midLogo); //remove/destroy logo object, if it is not available - int w_midText = g_Font[font_mid]->getRenderWidth(_channelname); - CComponentsText *midText = new CComponentsText(0, CC_CENTERED, w_midText, theight, _channelname, CTextBox::CENTER, g_Font[font_mid], CComponentsText::FONT_STYLE_REGULAR, header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - midText->setXPos(full_width/2 - midText->getWidth()/2); - midText->doPaintBg(false); + if (header == NULL){ + header = new CComponentsHeader(); + header->getTextObject()->enableTboxSaveScreen(g_settings.theme.menu_Head_gradient);//enable screen save for title text if color gradient is in use + header->enableClock(true, "%H:%M", "%H %M", true); + header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0, g_settings.theme.menu_Head_gradient_direction); + header->setDimensionsAll(x, y, full_width, header_height); + header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); } + //header->getClockObject()->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT); - if (!_channelname_prev.empty()) { - CComponentsText *lText = new CComponentsText(x_off, CC_CENTERED, side_width, theight, _channelname_prev, CTextBox::NO_AUTO_LINEBREAK, g_Font[font_lr], CComponentsText::FONT_STYLE_REGULAR, header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - lText->doPaintBg(false); - } + if (header->isPainted()) + header->getChannelLogoObject()->hide(); + if (g_settings.channellist_show_channellogo) + header->setChannelLogo(_channel_id,_channelname); + header->setCaption(_channelname, CCHeaderTypes::CC_TITLE_LEFT); - if (!_channelname_next.empty()) { - int x_pos = full_width - side_width - x_off; - CComponentsText *rText = new CComponentsText(x_pos, CC_CENTERED, side_width, theight, _channelname_next, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[font_lr], CComponentsText::FONT_STYLE_REGULAR, header, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); - rText->doPaintBg(false); - } - - if (header->isPainted()) //clean up background of header for new captions - header->kill(header->getColorBody()); header->paint(CC_SAVE_SCREEN_NO); + + if(_channelname_prev.empty() && _channelname_next.empty()){ + getChannelNames(_channel_id, _channelname, _channelname_prev, _channelname_next, 0); + } + + paintNaviBar(_channelname_prev, _channelname_next); +} + +void CEventList::paintNaviBar(std::string _channelname_prev, std::string _channelname_next) +{ + int navibar_y = y + height - OFFSET_SHADOW - footer_height - navibar_height; + + if (!navibar) + { + navibar = new CNaviBar(x, navibar_y, full_width, navibar_height); + navibar->setFont(g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]); + //FIXME navibar->enableShadow(CC_SHADOW_RIGHT, -1, true); + } + + navibar->enableArrows(!_channelname_prev.empty(), !_channelname_next.empty()); + navibar->setText(_channelname_prev, _channelname_next); + + navibar->paint(false); + + // shadow + frameBuffer->paintBoxRel(x + full_width, navibar_y + OFFSET_SHADOW, OFFSET_SHADOW, navibar_height, COL_SHADOW_PLUS_0); +} + +void CEventList::showProgressBar(int pos) +{ + int epg_done= -1; + if ((( time(NULL)- evtlist[pos].startTime )>= 0 ) && (evtlist[pos].duration > 0)) + { + unsigned nProcentagePassed = ((time(NULL) - evtlist[pos].startTime) * 100 / evtlist[pos].duration); + if (nProcentagePassed<= 100) + epg_done= nProcentagePassed; + } + + if (!pb) + { + int pbw = full_width/10; + int pbx = x + (full_width - pbw)/2; + int pbh = navibar_height - 2*OFFSET_INNER_SMALL; + int pby = y + height - OFFSET_SHADOW - footer_height - navibar_height + (navibar_height - pbh)/2; + + pb = new CProgressBar(pbx, pby, pbw, pbh); + pb->setType(CProgressBar::PB_TIMESCALE); + pb->doPaintBg(false); + } + + //show progressbar + if (epg_done > 0) + { + pb->setValues(epg_done, 100); + pb->paint(true); + } + else + { + pb->hide(); + } + } void CEventList::paint(t_channel_id channel_id) @@ -905,12 +961,13 @@ void CEventList::paint(t_channel_id channel_id) liststart = (selected/listmaxshow)*listmaxshow; // paint background for right box - if (g_settings.eventlist_additional && !bgRightBoxPaint) { - frameBuffer->paintBoxRel(x+width,y+theight,infozone_width,listmaxshow*fheight,COL_MENUCONTENT_PLUS_0); - bgRightBoxPaint = true; + if (g_settings.eventlist_additional && !infozone_background) + { + frameBuffer->paintBoxRel(x + width,y + header_height, infozone_width, item_height*listmaxshow, COL_MENUCONTENT_PLUS_0); + infozone_background = true; } - for(unsigned int count=0;countpaintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - int sbc= ((evtlist.size()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); - if (sbc < 1) - sbc = 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, evtlist.size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page); + //FIXME shadow + frameBuffer->paintBoxRel(x + full_width, y + header_height + OFFSET_SHADOW, OFFSET_SHADOW, item_height*listmaxshow, COL_SHADOW_PLUS_0); } -void CEventList::showFunctionBar(t_channel_id channel_id) +void CEventList::paintFoot(t_channel_id channel_id) { - int bx = x; - int bw = full_width; - int bh = iheight; - int by = y + height - bh; - CColorKeyHelper keyhelper; //user_menue.h neutrino_msg_t dummy = CRCInput::RC_nokey; const char * icon = NULL; - struct button_label buttons[5]; + struct button_label buttons[5]; //TODO dbt: add directly into footer object with setButtonLabels() int btn_cnt = 0; int tID = -1; //any value, not NULL @@ -999,26 +1047,37 @@ void CEventList::showFunctionBar(t_channel_id channel_id) btn_cnt++; } - ::paintButtons(bx, by, bw, btn_cnt, buttons, bw, bh); +#if 0 + buttons[btn_cnt].button = NEUTRINO_ICON_BUTTON_INFO_SMALL; + buttons[btn_cnt].locale = LOCALE_EPGPLUS_HEAD; + btn_cnt++; + + buttons[btn_cnt].button = NEUTRINO_ICON_BUTTON_0; + buttons[btn_cnt].locale = LOCALE_TIMERLIST_NAME; + btn_cnt++; +#endif + + CComponentsFooter footer; + footer.enableShadow(CC_SHADOW_ON, -1, true); + footer.paintButtons(x, y + height - OFFSET_SHADOW - footer_height, full_width, footer_height, btn_cnt, buttons); } int CEventListHandler::exec(CMenuTarget* parent, const std::string &/*actionkey*/) { - int res = menu_return::RETURN_EXIT_ALL; - if (parent) { + int res = menu_return::RETURN_EXIT_ALL; + + if (parent) parent->hide(); - } + CEventList *e = new CEventList; CChannelList *channelList = CNeutrinoApp::getInstance()->channelList; - e->exec(CZapit::getInstance()->GetCurrentChannelID(), channelList->getActiveChannelName()); // UTF-8 + e->exec(CZapit::getInstance()->GetCurrentChannelID(), channelList->getActiveChannelName()); delete e; return res; } -/************************************************************************************************/ bool CEventList::findEvents(t_channel_id channel_id, std::string channelname) -/************************************************************************************************/ { bool res = false; int event = 0; @@ -1029,19 +1088,19 @@ bool CEventList::findEvents(t_channel_id channel_id, std::string channelname) m_search_autokeyword = m_search_keyword; } - CEventFinderMenu menu( &event, - &m_search_epg_item, - &m_search_keyword, - &m_search_list, - &m_search_channel_id, - &m_search_bouquet_id, - &m_search_genre, - &m_search_fsk - ); + CEventFinderMenu menu(&event, + &m_search_epg_item, + &m_search_keyword, + &m_search_list, + &m_search_channel_id, + &m_search_bouquet_id, + &m_search_genre, + &m_search_fsk); + hide(); menu.exec(NULL,""); search_head_name = g_Locale->getText(LOCALE_EVENTFINDER_SEARCH); - if(event == 1) + if (event == 1) { res = true; m_showChannel = true; // force the event list to paint the channel name @@ -1142,16 +1201,15 @@ bool CEventList::findEvents(t_channel_id channel_id, std::string channelname) } } - if(event) + if (event) paintHead(0, search_head_name); else paintHead(channel_id, channelname); paint(); - showFunctionBar(channel_id); + paintFoot(channel_id); return(res); } -/************************************************************************************************/ /* class CSearchNotifier : public CChangeObserver { @@ -1167,7 +1225,7 @@ class CSearchNotifier : public CChangeObserver } }; */ -/************************************************************************************************ +/* bool CEventFinderMenuHandler::changeNotify(const neutrino_locale_t OptionName, void *Data) { if(OptionName == ) @@ -1225,36 +1283,29 @@ const CMenuOptionChooser::keyval SEARCH_EPG_OPTIONS[SEARCH_EPG_OPTION_COUNT] = { CEventList::SEARCH_EPG_ALL, LOCALE_EVENTFINDER_SEARCH_ALL_EPG } }; - - -/************************************************************************************************/ -CEventFinderMenu::CEventFinderMenu( int* event, - int* search_epg_item, - std::string* search_keyword, - int* search_list, - t_channel_id* search_channel_id, - t_bouquet_id* search_bouquet_id, - int* search_genre, - int* search_fsk - ) -/************************************************************************************************/ +CEventFinderMenu::CEventFinderMenu(int* event, + int* search_epg_item, + std::string* search_keyword, + int* search_list, + t_channel_id* search_channel_id, + t_bouquet_id* search_bouquet_id, + int* search_genre, + int* search_fsk) { - m_event = event; - m_search_epg_item = search_epg_item; + m_event = event; + m_search_epg_item = search_epg_item; m_search_keyword = search_keyword; - m_search_list = search_list; - m_search_channel_id = search_channel_id; - m_search_bouquet_id = search_bouquet_id; - m_search_genre = search_genre; - m_search_fsk = search_fsk; + m_search_list = search_list; + m_search_channel_id = search_channel_id; + m_search_bouquet_id = search_bouquet_id; + m_search_genre = search_genre; + m_search_fsk = search_fsk; + width = 40; selected = -1; } - -/************************************************************************************************/ int CEventFinderMenu::exec(CMenuTarget* parent, const std::string &actionkey) -/************************************************************************************************/ { int res = menu_return::RETURN_REPAINT; @@ -1342,9 +1393,7 @@ int CEventFinderMenu::exec(CMenuTarget* parent, const std::string &actionkey) return res; } -/************************************************************************************************/ int CEventFinderMenu::showMenu(void) -/************************************************************************************************/ { int res = menu_return::RETURN_REPAINT; m_search_channelname_mf = NULL; @@ -1408,12 +1457,8 @@ int CEventFinderMenu::showMenu(void) return(res); } - -/************************************************************************************************/ bool CEventFinderMenu::changeNotify(const neutrino_locale_t OptionName, void *) -/************************************************************************************************/ { - if (ARE_LOCALES_EQUAL(OptionName, LOCALE_EVENTFINDER_SEARCH_WITHIN_LIST)) { if (*m_search_list == CEventList::SEARCH_LIST_CHANNEL) diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 90542ba26..e6df12580 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -23,7 +23,6 @@ Boston, MA 02110-1301, USA. */ - #ifndef __EVENTLIST_HPP__ #define __EVENTLIST_HPP__ @@ -32,7 +31,7 @@ #include #include #include - +#include #include "infoviewer.h" #include "widget/menue.h" @@ -43,7 +42,6 @@ class CFramebuffer; class CEventList : public CListHelpers { - // Eventfinder start public: typedef enum { @@ -53,14 +51,16 @@ class CEventList : public CListHelpers SEARCH_EPG_INFO2, SEARCH_EPG_GENRE, SEARCH_EPG_ALL - }SEARCH_EPG; + } SEARCH_EPG; + typedef enum { SEARCH_LIST_NONE, SEARCH_LIST_CHANNEL, SEARCH_LIST_BOUQUET, SEARCH_LIST_ALL - }SEARCH_LIST; + } SEARCH_LIST; + private: int m_search_epg_item; std::string m_search_keyword; @@ -73,10 +73,8 @@ class CEventList : public CListHelpers bool m_showChannel; int oldIndex; event_id_t oldEventID; - bool bgRightBoxPaint; bool findEvents(t_channel_id channel_id, std::string channelname); - // Eventfinder end CFrameBuffer *frameBuffer; CChannelEventList evtlist; @@ -86,32 +84,38 @@ class CEventList : public CListHelpers unsigned int current_event; unsigned int liststart; unsigned int listmaxshow; - int fheight; // Fonthoehe Channellist-Inhalt - int fheight1,fheight2; - int fwidth1,fwidth2; - int theight; // Fonthoehe Channellist-Titel - int iheight; // Height info bar + int item_height; + int largefont_height, smallfont_height; + int header_height; + int footer_height; std::string search_head_name; int full_width, width, infozone_width; + int navibar_height; int height; int x; int y; std::string infozone_text; + bool infozone_background; int sort_mode; event_id_t item_event_ID; - CComponentsText *cc_infozone; - CComponentsFrmChain *header; + CComponentsText *infozone; + CComponentsHeader *header; + CProgressBar *pb; + CNaviBar *navibar; const char * unit_short_minute; void paintItem(unsigned pos, t_channel_id channel_id = 0); void paintDescription(int index); void paint(t_channel_id channel_id = 0); void paintHead(t_channel_id _channel_id, std::string _channelname, std::string _channelname_prev = "", std::string _channelname_next = ""); + void paintNaviBar(std::string _channelname_prev, std::string _channelname_next); + void showProgressBar(int pos); void hide(); - void showFunctionBar(t_channel_id channel_id); - + void paintFoot(t_channel_id channel_id); + void getChannelNames(t_channel_id &channel_id, std::string ¤t_channel_name, std::string &prev_channel_name, std::string &next_channel_name, neutrino_msg_t msg); + int timerPre; int timerPost; void UpdateTimerList(void); @@ -123,13 +127,13 @@ class CEventList : public CListHelpers CEventList(); ~CEventList(); int exec(const t_channel_id channel_id, const std::string& channelname, const std::string& prev = "", const std::string& next = "", const CChannelEventList &followlist = CChannelEventList ()); // UTF-8 + void ResetModules(); }; class CEventListHandler : public CMenuTarget { public: int exec( CMenuTarget* parent, const std::string &actionkey); - }; class CEventFinderMenu : public CMenuTarget, CChangeObserver @@ -149,16 +153,16 @@ class CEventFinderMenu : public CMenuTarget, CChangeObserver int selected; int showMenu(void); public: - CEventFinderMenu( int* event, - int* search_epg_item, - std::string* search_keyword, - int* search_list, - t_channel_id* search_channel_id, - t_bouquet_id* search_bouquet_id, - int* search_genre, - int* search_fsk - ); - int exec( CMenuTarget* parent, const std::string &actionkey); + CEventFinderMenu(int* event, + int* search_epg_item, + std::string* search_keyword, + int* search_list, + t_channel_id* search_channel_id, + t_bouquet_id* search_bouquet_id, + int* search_genre, + int* search_fsk); + + int exec( CMenuTarget* parent, const std::string &actionkey); bool changeNotify(const neutrino_locale_t OptionName, void *); }; diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 823562a27..676247dcd 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -269,19 +270,18 @@ void CFileBrowser::fontInit() height = frameBuffer->getScreenHeightRel(); x = getScreenStartX(width); - theight = fnt_title->getHeight(); - fheight = fnt_item->getHeight(); - if (fheight == 0) - fheight = 1; /* avoid div by zero on invalid font */ - //foheight = fnt_foot->getHeight()+6; //initial height value for buttonbar; TODO get value from buttonbar - foheight = paintFoot(false); - skwidth = 26; + header_height = fnt_title->getHeight(); + item_height = fnt_item->getHeight(); + if (item_height == 0) + item_height = 1; /* avoid div by zero on invalid font */ + footer_height = paintFoot(false); + smskey_width = fnt_foot->getRenderWidth("M") + OFFSET_INNER_MID; liststart = 0; - listmaxshow = std::max(1,(int)(height - theight - foheight)/fheight); + listmaxshow = std::max(1,(int)(height - header_height - footer_height - OFFSET_SHADOW)/item_height); //recalc height - height = theight + listmaxshow * fheight + foheight; + height = header_height + listmaxshow*item_height + footer_height + OFFSET_SHADOW; y = getScreenStartY(height); } @@ -557,19 +557,29 @@ bool CFileBrowser::readDir_std(const std::string & dirname, CFileList* flist) struct stat64 statbuf; dirent64 **namelist; int n; + std::string to_scan_dir = dirname; - n = scandir64(dirname.c_str(), &namelist, 0, alphasort64); + n = scandir64(to_scan_dir.c_str(), &namelist, 0, alphasort64); if (n < 0) { - perror(("Filebrowser scandir: "+dirname).c_str()); + std::string scn_err = "Filebrowser scandir: " + to_scan_dir + " "; + to_scan_dir = "/media/"; + dprintf(DEBUG_NORMAL, "\033[33m[CFileBrowser]\[%s - %d], %s failed, %s, try fallback to [%s]\033[0m\n", __func__, __LINE__, scn_err.c_str(), strerror(errno), to_scan_dir.c_str()); + n = scandir64(to_scan_dir.c_str(), &namelist, 0, alphasort64); + name = to_scan_dir; + } + + if (n < 0){ //fallback failed + perror(("Filebrowser scandir: "+to_scan_dir).c_str()); return false; } + for (int i = 0; i < n; i++) { CFile file; if(strcmp(namelist[i]->d_name,".") != 0) { - file.Name = dirname + namelist[i]->d_name; + file.Name = to_scan_dir + namelist[i]->d_name; // printf("file.Name: '%s', getFileName: '%s' getPath: '%s'\n",file.Name.c_str(),file.getFileName().c_str(),file.getPath().c_str()); if(stat64((file.Name).c_str(),&statbuf) != 0) @@ -1163,13 +1173,13 @@ void CFileBrowser::addRecursiveDir(CFileList * re_filelist, std::string rpath, b void CFileBrowser::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height); + frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW); } void CFileBrowser::paintItem(unsigned int pos) { - int colwidth1, colwidth2, colwidth3; - int ypos = y+ theight+0 + pos*fheight; + int col1_width, col2_width, col3_width; + int ypos = y + header_height + pos*item_height; CFile * actual_file = NULL; std::string fileicon; unsigned int currpos = liststart + pos; @@ -1177,7 +1187,7 @@ void CFileBrowser::paintItem(unsigned int pos) if (currpos >= filelist.size()) { // just paint an empty line - frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); return; } @@ -1197,15 +1207,15 @@ void CFileBrowser::paintItem(unsigned int pos) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x,ypos, width- 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius); if (g_settings.filebrowser_showrights == 0 && S_ISREG(actual_file->Mode)) - colwidth2 = 0; + col2_width = 0; else - colwidth2 = fnt_item->getRenderWidth("rwxrwxrwx"); - colwidth3 = fnt_item->getRenderWidth("222.222G"); - colwidth1 = width - 35 - colwidth2 - colwidth3 - 10; + col2_width = fnt_item->getRenderWidth("rwxrwxrwx"); + col3_width = fnt_item->getRenderWidth("222.222G"); + col1_width = width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - col3_width - OFFSET_INNER_MID - col2_width - OFFSET_INNER_MID; if ( !actual_file->Name.empty() ) { @@ -1220,6 +1230,7 @@ void CFileBrowser::paintItem(unsigned int pos) case CFile::FILE_WAV: case CFile::FILE_FLAC: case CFile::FILE_AAC: + case CFile::FILE_PLAYLIST: fileicon = NEUTRINO_ICON_MP3; break; @@ -1228,13 +1239,31 @@ void CFileBrowser::paintItem(unsigned int pos) break; case CFile::FILE_PICTURE: + fileicon = NEUTRINO_ICON_PICTURE; + break; + + case CFile::FILE_AVI: + case CFile::FILE_ASF: + case CFile::FILE_MKV: + case CFile::FILE_VOB: + case CFile::FILE_MPG: + case CFile::FILE_TS: + fileicon = NEUTRINO_ICON_MOVIE; + break; + case CFile::FILE_TEXT: default: fileicon = NEUTRINO_ICON_FILE; } - frameBuffer->paintIcon(fileicon, x+5 , ypos + (fheight-16) / 2 ); - fnt_item->RenderString(x + 35, ypos + fheight, colwidth1 - 10 , FILESYSTEM_ENCODING_TO_UTF8_STRING(actual_file->getFileName()), color); + int icon_w = 0; + int icon_h = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_FILE, &icon_w, &icon_h); + + frameBuffer->paintIcon(fileicon, x + OFFSET_INNER_MID, ypos, item_height); + + int col1_offset = OFFSET_INNER_MID + icon_w + OFFSET_INNER_MID; + fnt_item->RenderString(x + col1_offset, ypos + item_height, col1_width - col1_offset, FILESYSTEM_ENCODING_TO_UTF8_STRING(actual_file->getFileName()), color); if( S_ISREG(actual_file->Mode) ) { @@ -1247,13 +1276,13 @@ void CFileBrowser::paintItem(unsigned int pos) modestring[9] = 0; - fnt_item->RenderString(x + width - 25 - colwidth3 - colwidth2 , ypos+ fheight, colwidth2, modestring, color); + fnt_item->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - col3_width - OFFSET_INNER_MID - col2_width , ypos + item_height, col2_width, modestring, color); } #define GIGABYTE 1073741824LL #define MEGABYTE 1048576LL #define KILOBYTE 1024LL - char tmpstr[256]; + char sizestring[256]; const char *unit = ""; int64_t factor = 0; if (actual_file->Size >= GIGABYTE) @@ -1275,14 +1304,14 @@ void CFileBrowser::paintItem(unsigned int pos) { int a = actual_file->Size / factor; int b = (actual_file->Size - a * factor) * 1000 / factor; - snprintf(tmpstr, sizeof(tmpstr), "%d.%03d%s", a, b, unit); + snprintf(sizestring, sizeof(sizestring), "%d.%03d%s", a, b, unit); } else - snprintf(tmpstr,sizeof(tmpstr),"%d", (int)actual_file->Size); + snprintf(sizestring,sizeof(sizestring),"%d", (int)actual_file->Size); /* right align file size */ - int sz_w = fnt_item->getRenderWidth(tmpstr); - fnt_item->RenderString(x + width - sz_w - 25, ypos+ fheight, sz_w, tmpstr, color); + int sz_w = fnt_item->getRenderWidth(sizestring); + fnt_item->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - sz_w, ypos + item_height, sz_w, sizestring, color); } if(actual_file->isDir()) @@ -1293,7 +1322,7 @@ void CFileBrowser::paintItem(unsigned int pos) strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&rawtime)); /* right align directory time */ int time_w = fnt_item->getRenderWidth(timestring); - fnt_item->RenderString(x + width - time_w - 25, ypos+ fheight, time_w, timestring, color); + fnt_item->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - time_w, ypos + item_height, time_w, timestring, color); } } } @@ -1318,16 +1347,17 @@ void CFileBrowser::paintHead() /* too long? Leave out the "Filebrowser" or "Shoutcast" prefix * the allocated space is sufficient since it is surely shorter than before */ - if (fnt_title->getRenderWidth(l_name) > width - 11) + if (fnt_title->getRenderWidth(l_name) > width - 2*OFFSET_INNER_MID) l = sprintf(l_name, "%s", FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str()); if (l_name[l - 1] == '/') l_name[--l] = '\0'; /* still too long? the last part is probably more interesting than the first part... */ - while ((fnt_title->getRenderWidth(&l_name[i]) > width - 20) && (i < l)) + while ((fnt_title->getRenderWidth(&l_name[i]) > width - 2*OFFSET_INNER_MID) && (i < l)) i++; - CComponentsHeader header(x, y, width, theight, &l_name[i]); + CComponentsHeader header(x, y, width, header_height, &l_name[i]); + header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); header.paint(CC_SAVE_SCREEN_NO); free(l_name); @@ -1361,17 +1391,12 @@ bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str, return false; } -const struct button_label FileBrowserFilterButton[2] = -{ - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_FILEBROWSER_FILTER_INACTIVE }, - { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_FILEBROWSER_FILTER_ACTIVE }, -}; - int CFileBrowser::paintFoot(bool show) { - int cnt,res; + int cnt, res; std::string sort_text = g_Locale->getText(LOCALE_MOVIEBROWSER_FOOT_SORT); + sort_text += " "; sort_text += g_Locale->getText(sortByNames[g_settings.filebrowser_sortmethod]); int sort_text_len = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(g_Locale->getText(LOCALE_MOVIEBROWSER_FOOT_SORT)); @@ -1381,65 +1406,77 @@ int CFileBrowser::paintFoot(bool show) sort_text_len += len; - neutrino_locale_t f_loc = LOCALE_FILEBROWSER_FILTER_INACTIVE; + neutrino_locale_t locale_filebrowser_filter = LOCALE_FILEBROWSER_FILTER_INACTIVE; if (Filter != NULL && use_filter) - f_loc = LOCALE_FILEBROWSER_FILTER_ACTIVE; + locale_filebrowser_filter = LOCALE_FILEBROWSER_FILTER_ACTIVE; - button_label_ext footerButtons_pm[] = { + button_label_ext buttons_playlistmode[] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_FILEBROWSER_DELETE, NULL, 0, false }, - { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_FILEBROWSER_ADD, NULL, 0, false }, + { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_FILEBROWSER_ADD, NULL, 0, false }, { NEUTRINO_ICON_BUTTON_YELLOW, NONEXISTANT_LOCALE, sort_text.c_str(), sort_text_len, false }, - { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_AUDIOPLAYER_SHUFFLE, NULL, 0, false }, + { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_AUDIOPLAYER_SHUFFLE, NULL, 0, false }, { NEUTRINO_ICON_BUTTON_OKAY, LOCALE_FILEBROWSER_SELECT, NULL, 0, false }, { NEUTRINO_ICON_BUTTON_PLAY, LOCALE_FILEBROWSER_MARK, NULL, 0, false }, }; - button_label_ext footerButtons[] = { + button_label_ext buttons_filelistmode[] = { { NEUTRINO_ICON_BUTTON_RED, NONEXISTANT_LOCALE, sort_text.c_str(), sort_text_len, false }, { NEUTRINO_ICON_BUTTON_OKAY, LOCALE_FILEBROWSER_SELECT, NULL, 0, false }, { NEUTRINO_ICON_BUTTON_MUTE_SMALL, LOCALE_FILEBROWSER_DELETE, NULL, 0, false }, { NEUTRINO_ICON_BUTTON_PLAY, LOCALE_FILEBROWSER_MARK, NULL, 0, false }, - { NEUTRINO_ICON_BUTTON_BLUE, f_loc, NULL, 0, false }, + { NEUTRINO_ICON_BUTTON_BLUE, locale_filebrowser_filter, NULL, 0, false }, }; if (playlistmode) { - cnt = sizeof(footerButtons_pm) / sizeof(button_label_ext); + cnt = sizeof(buttons_playlistmode)/sizeof(button_label_ext); if (!show) - return paintButtons(footerButtons_pm, cnt, 0, 0, 0, 0, 0, false, NULL, NULL); + return paintButtons(buttons_playlistmode, cnt, 0, 0, 0, 0, 0, false, NULL, NULL); } else { - cnt = sizeof(footerButtons) / sizeof(button_label_ext); + cnt = sizeof(buttons_filelistmode)/sizeof(button_label_ext); if (!show) - return paintButtons(footerButtons, cnt, 0, 0, 0, 0, 0, false, NULL, NULL); + return paintButtons(buttons_filelistmode, cnt, 0, 0, 0, 0, 0, false, NULL, NULL); } - int fowidth = width - skwidth; + int footer_y = y + height - OFFSET_SHADOW - footer_height; + int footer_width = width - smskey_width; + // shadow + frameBuffer->paintBoxRel(x + OFFSET_SHADOW, footer_y + OFFSET_SHADOW, width, footer_height, COL_SHADOW_PLUS_0, RADIUS_MID, CORNER_BOTTOM); - if (filelist.empty()) { - frameBuffer->paintBoxRel(x, y + height - foheight, width, foheight, COL_MENUFOOT_PLUS_0, RADIUS_MID, CORNER_BOTTOM); - return foheight; + if (filelist.empty()) + { + // show an empty footer + frameBuffer->paintBoxRel(x, footer_y, width, footer_height, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + return footer_height; } + + /* + We can't use CComponentsFooter because + CComponentsFooter can't handle button_label_ext + */ if (playlistmode) - res = paintButtons(footerButtons_pm, Filter ? cnt : cnt - 1, x, y + height - foheight, width, foheight, fowidth); + res = paintButtons(buttons_playlistmode, cnt, x, footer_y, width, footer_height, footer_width); else - res = paintButtons(footerButtons, Filter ? cnt : cnt - 1, x, y + height - foheight, width, foheight, fowidth); + res = paintButtons(buttons_filelistmode, cnt, x, footer_y, width, footer_height, footer_width); + paintSMSKey(); return res; } void CFileBrowser::paintSMSKey() { - int skheight = fnt_foot->getHeight(); + int smskey_height = fnt_foot->getHeight(); + int smskey_y = y + height - OFFSET_SHADOW - footer_height; //background - frameBuffer->paintBoxRel(x + width - skwidth, y + height - foheight, skwidth, foheight, COL_MENUFOOT_PLUS_0, RADIUS_MID, CORNER_BOTTOM_RIGHT); + frameBuffer->paintBoxRel(x + width - smskey_width, smskey_y, smskey_width, footer_height, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM_RIGHT); if(m_SMSKeyInput.getOldKey()!=0) { char cKey[2] = {m_SMSKeyInput.getOldKey(), 0}; cKey[0] = toupper(cKey[0]); int len = fnt_foot->getRenderWidth(cKey); - fnt_foot->RenderString(x + width - skwidth, y + height - foheight + foheight/2 + skheight/2, len, cKey, COL_MENUHEAD_TEXT); + fnt_foot->RenderString(x + width - smskey_width, smskey_y + footer_height/2 + smskey_height/2, len, cKey, COL_MENUHEAD_TEXT); } } @@ -1453,16 +1490,10 @@ void CFileBrowser::paint() paintItem(count); //scrollbar - int ypos = y+ theight; - int sb = fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - int sbc= ((filelist.size()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); - if (sbc < 1) - sbc = 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0, RADIUS_SMALL); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, filelist.size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page, CC_SHADOW_ON); } void CFileBrowser::SMSInput(const neutrino_msg_t msg) diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index 3d458125d..4de5981c2 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -162,10 +162,10 @@ class CFileBrowser unsigned int listmaxshow; std::vector selections; - int fheight; // Fonthoehe Filelist-Inhalt - int theight; // Fonthoehe Filelist-Titel - int foheight; // Hoehe der button leiste - int skwidth; // width SMSKey field + int item_height; + int header_height; + int footer_height; + int smskey_width; std::string name; std::string base; std::string m_baseurl; diff --git a/src/gui/followscreenings.cpp b/src/gui/followscreenings.cpp index 2ee471fd6..9f33be0a7 100644 --- a/src/gui/followscreenings.cpp +++ b/src/gui/followscreenings.cpp @@ -67,7 +67,7 @@ CChannelEventList *CFollowScreenings::getFollowScreenings(void) continue; followlist.push_back(*e); - if (followlist.size() == 1 && !g_settings.timer_followscreenings) + if (followlist.size() == 1 && g_settings.timer_followscreenings == FOLLOWSCREENINGS_OFF) break; } } diff --git a/src/gui/followscreenings.h b/src/gui/followscreenings.h index 53e362e3e..d24d39171 100644 --- a/src/gui/followscreenings.h +++ b/src/gui/followscreenings.h @@ -59,6 +59,12 @@ class CFollowScreenings : public CMenuTarget std::vector forwarders; void updateRightIcon(int i, time_t start, unsigned int duration); public: + enum + { + FOLLOWSCREENINGS_OFF = 0, + FOLLOWSCREENINGS_ON = 1, + }; + CFollowScreenings(const t_channel_id Channel_id, time_t Starttime, time_t Stoptime, const std::string &Title, uint64_t EpgID=0, unsigned char Apids=TIMERD_APIDS_STD, bool Safety=false, std::string RecDir="", CChannelEventList *Evtlist=NULL) : CMenuTarget () { this->channel_id = Channel_id; diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 48884f300..9f6a4ed64 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -89,12 +89,12 @@ const CMenuOptionChooser::keyval HDD_SLEEP_OPTIONS[HDD_SLEEP_OPTION_COUNT] = }; devtool_s CHDDMenuHandler::devtools[] = { - { "ext4", "/sbin/fsck.ext4", "-C 1 -f -y", "/sbin/mkfs.ext4", "-T largefile -m0", false, false }, - { "ext3", "/sbin/fsck.ext3", "-C 1 -f -y", "/sbin/mkfs.ext3", "-T largefile -m0", false, false }, - { "ext2", "/sbin/fsck.ext2", "-C 1 -f -y", "/sbin/mkfs.ext2", "-T largefile -m0", false, false }, - { "vfat", "/sbin/fsck.vfat", "-a", "/sbin/mkfs.vfat", "", false, false }, - { "exfat", "/sbin/fsck.exfat", "", "/sbin/mkfs.exfat", "", false, false }, - { "xfs", "/sbin/xfs_repair", "", "/sbin/mkfs.xfs", "-f", false, false }, + { "ext4", "/sbin/fsck.ext4", "-C 1 -f -y", "/sbin/mkfs.ext4", "-m 0", false, false }, + { "ext3", "/sbin/fsck.ext3", "-C 1 -f -y", "/sbin/mkfs.ext3", "-m 0", false, false }, + { "ext2", "/sbin/fsck.ext2", "-C 1 -f -y", "/sbin/mkfs.ext2", "-m 0", false, false }, + { "vfat", "/sbin/fsck.vfat", "-a", "/sbin/mkfs.vfat", "", false, false }, + { "exfat", "/sbin/fsck.exfat", "", "/sbin/mkfs.exfat", "", false, false }, + { "xfs", "/sbin/xfs_repair", "", "/sbin/mkfs.xfs", "-f", false, false }, }; #define FS_MAX (sizeof(CHDDMenuHandler::devtools)/sizeof(devtool_s)) diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 8dd342ed8..d62fa7487 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -69,7 +69,7 @@ void CImageInfo::Init(void) cc_sub_caption = NULL; b_info = NULL; btn_red = NULL; - item_offset = 10; + item_offset = OFFSET_INNER_MID; item_font = NULL; item_height = 0; y_tmp = 0; @@ -355,7 +355,7 @@ void CImageInfo::InitInfos() y_tmp = 0; for (size_t i=0; igetWidth(), 0, g_Locale->getText(v_info[i].caption), v_info[i].info_text); - item->setLabelWidthPercent(20); + item->setLabelWidthPercent(15); if (!item_font){ item_font = item->getFont(); diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 54b485b09..5e770faac 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -75,7 +75,7 @@ void CInfoClock::initCCLockItems() setClockFormat("%H:%M", "%H %M"); //set height, NOTE: height is strictly bound to settings - height = g_settings.infoClockFontSize; + height = CFrameBuffer::getInstance()->scale2Res(g_settings.infoClockFontSize); initClockFont(0, height); // set corner radius depending on clock height diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index c590b849c..c9d76dbda 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -695,15 +695,15 @@ void CInfoViewer::check_channellogo_ca_SettingsChange() } } -void CInfoViewer::showTitle(t_channel_id chid, const bool calledFromNumZap, int epgpos) +void CInfoViewer::showTitle(t_channel_id chid, const bool calledFromNumZap, int epgpos, bool forcePaintButtonBar/*=false*/) { CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(chid); if(channel) - showTitle(channel, calledFromNumZap, epgpos); + showTitle(channel, calledFromNumZap, epgpos, forcePaintButtonBar); } -void CInfoViewer::showTitle(CZapitChannel * channel, const bool calledFromNumZap, int epgpos) +void CInfoViewer::showTitle(CZapitChannel * channel, const bool calledFromNumZap, int epgpos, bool forcePaintButtonBar/*=false*/) { if(!calledFromNumZap && !(zap_mode & IV_MODE_DEFAULT)) resetSwitchMode(); @@ -727,7 +727,8 @@ void CInfoViewer::showTitle(CZapitChannel * channel, const bool calledFromNumZap check_channellogo_ca_SettingsChange(); aspectRatio = 0; last_curr_id = last_next_id = 0; - showButtonBar = !calledFromNumZap; + showButtonBar = (!calledFromNumZap || forcePaintButtonBar); + bool noTimer = (calledFromNumZap && forcePaintButtonBar); fileplay = (ChanNum == 0); newfreq = true; @@ -777,7 +778,7 @@ void CInfoViewer::showTitle(CZapitChannel * channel, const bool calledFromNumZap show_dot = !show_dot; if (showButtonBar) { - infoViewerBB->paintshowButtonBar(); + infoViewerBB->paintshowButtonBar(noTimer); } int ChanNumWidth = 0; @@ -947,7 +948,7 @@ bool CInfoViewer::showLivestreamInfo() CMoviePlayerGui::getInstance().getLivestreamInfo(&livestreamInfo1, &tmp1); if (!(videoDecoder->getBlank())) { - int xres, yres, framerate; + int xres = 0, yres = 0, framerate = 0; std::string tmp2; videoDecoder->getPictureInfo(xres, yres, framerate); switch (framerate) { @@ -976,6 +977,7 @@ bool CInfoViewer::showLivestreamInfo() tmp2 = "60fps"; break; default: + framerate = 0; tmp2 = g_Locale->getText(LOCALE_STREAMINFO_FRAMERATE_UNKNOWN); break; } @@ -1068,7 +1070,6 @@ void CInfoViewer::loop(bool show_dot) //printf("%s:%d: imitate VZAP; RC_left/right\n", __func__, __LINE__); CMoviePlayerGui::getInstance().setFromInfoviewer(true); g_RCInput->postMsg (msg, data); - hideIt = true; } else setSwitchMode(IV_MODE_VIRTUAL_ZAP); diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 415f84f8c..c8df0a74a 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -173,8 +173,8 @@ class CInfoViewer void start(); void showEpgInfo(); - void showTitle(CZapitChannel * channel, const bool calledFromNumZap = false, int epgpos = 0); - void showTitle(t_channel_id channel_id, const bool calledFromNumZap = false, int epgpos = 0); + void showTitle(CZapitChannel * channel, const bool calledFromNumZap = false, int epgpos = 0, bool forcePaintButtonBar = false); + void showTitle(t_channel_id channel_id, const bool calledFromNumZap = false, int epgpos = 0, bool forcePaintButtonBar = false); void lookAheadEPG(const int ChanNum, const std::string & Channel, const t_channel_id new_channel_id = 0, const bool calledFromNumZap = false); //alpha: fix for nvod subchannel update void killTitle(); void getEPG(const t_channel_id for_channel_id, CSectionsdClient::CurrentNextInfo &info); diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index d82f08267..5118bc3f9 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -458,7 +458,7 @@ void CInfoViewerBB::showBBIcons(const int modus, const std::string & icon) } } -void CInfoViewerBB::paintshowButtonBar() +void CInfoViewerBB::paintshowButtonBar(bool noTimer/*=false*/) { if (!is_visible) return; @@ -466,7 +466,9 @@ void CInfoViewerBB::paintshowButtonBar() for (int i = 0; i < CInfoViewerBB::BUTTON_MAX; i++) { tmp_bbButtonInfoText[i] = ""; } - g_InfoViewer->sec_timer_id = g_RCInput->addTimer(1*1000*1000, false); + + if (!noTimer) + g_InfoViewer->sec_timer_id = g_RCInput->addTimer(1*1000*1000, false); if (g_settings.infobar_casystem_display < 2) paint_ca_bar(); diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index 753e32a2e..765ddc20a 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -141,7 +141,7 @@ class CInfoViewerBB void showIcon_Tuner(void); void showIcon_DD(void); void showBBButtons(bool paintFooter = false); - void paintshowButtonBar(); + void paintshowButtonBar(bool noTimer = false); void getBBButtonInfo(void); void reset_allScala(void); void initBBOffset(void); diff --git a/src/gui/lua/lua_api_version.h b/src/gui/lua/lua_api_version.h index 9e8343ca1..6f932f261 100644 --- a/src/gui/lua/lua_api_version.h +++ b/src/gui/lua/lua_api_version.h @@ -4,4 +4,4 @@ * to luainstance.h changes */ #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 72 +#define LUA_API_VERSION_MINOR 76 diff --git a/src/gui/lua/lua_cc_text.cpp b/src/gui/lua/lua_cc_text.cpp index 461164e1a..3e2158e52 100644 --- a/src/gui/lua/lua_cc_text.cpp +++ b/src/gui/lua/lua_cc_text.cpp @@ -208,10 +208,11 @@ int CLuaInstCCText::CCTextSetText(lua_State *L) std::string text = ""; lua_Integer mode = D->mode; lua_Integer font_text = D->font_text; - tableLookup(L, "text", text); - tableLookup(L, "mode", mode); - tableLookup(L, "font_text", font_text); - + if (lua_istable(L, -1)){ + tableLookup(L, "text", text); + tableLookup(L, "mode", mode); + tableLookup(L, "font_text", font_text); + } D->ct->setText(text, mode, g_Font[font_text]); return 0; } @@ -228,6 +229,7 @@ int CLuaInstCCText::CCTextGetLines(lua_State *L) } else { CTextBox* ctb = D->ct->getCTextBoxObject(); + D->ct->initCCText(); if (ctb) lines = (lua_Integer)ctb->getLines(); } diff --git a/src/gui/lua/lua_cc_window.cpp b/src/gui/lua/lua_cc_window.cpp index 819fe18d2..0d4c9d412 100644 --- a/src/gui/lua/lua_cc_window.cpp +++ b/src/gui/lua/lua_cc_window.cpp @@ -89,12 +89,13 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L) tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); tableLookup(L, "icon", icon); - bool has_shadow = false; + lua_Integer has_shadow = CC_SHADOW_OFF; if (!tableLookup(L, "has_shadow", has_shadow)) { tmp1 = "false"; if (tableLookup(L, "has_shadow", tmp1)) paramBoolDeprecated(L, tmp1.c_str()); - has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes"); + if ((tmp1 == "true" || tmp1 == "1" || tmp1 == "yes")) + has_shadow = CC_SHADOW_ON; } tableLookup(L, "color_frame" , color_frame); @@ -126,7 +127,7 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L) CLuaCCWindow **udata = (CLuaCCWindow **) lua_newuserdata(L, sizeof(CLuaCCWindow *)); *udata = new CLuaCCWindow(); - (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str(), 0, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow); + (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str(), NULL, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow); /* Ignore percent conversion of width and height to remain compatible with the Lua API */ (*udata)->w->setWidth(dx); @@ -220,10 +221,10 @@ int CLuaInstCCWindow::CCWindowSetCaption(lua_State *L) std::string name = ""; tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); - lua_Integer alignment = (lua_Integer)CTextBox::NO_AUTO_LINEBREAK; + lua_Integer alignment = (lua_Integer)DEFAULT_TITLE_ALIGN; tableLookup(L, "alignment", alignment); - D->w->setWindowCaption(name, alignment | (lua_Integer)CTextBox::NO_AUTO_LINEBREAK); + D->w->setWindowCaption(name, (cc_title_alignment_t)alignment); return 0; } diff --git a/src/gui/lua/lua_cc_window.h b/src/gui/lua/lua_cc_window.h index 98cd9ac86..2c5c961f3 100644 --- a/src/gui/lua/lua_cc_window.h +++ b/src/gui/lua/lua_cc_window.h @@ -29,7 +29,7 @@ class CLuaCCWindow ~CLuaCCWindow() { delete w; } }; -class CLuaInstCCWindow +class CLuaInstCCWindow : CCHeaderTypes { public: CLuaInstCCWindow() {}; diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp index ee304db0a..c031083ce 100644 --- a/src/gui/lua/luainstance.cpp +++ b/src/gui/lua/luainstance.cpp @@ -175,6 +175,7 @@ static void set_lua_variables(lua_State *L) { "MENUCONTENTINACTIVE", MAGIC_COLOR | (COL_MENUCONTENTINACTIVE) }, { "MENUFOOT", MAGIC_COLOR | (COL_MENUFOOT) }, { "FRAME", MAGIC_COLOR | (COL_FRAME) }, + { "SCROLLBAR", MAGIC_COLOR | (COL_SCROLLBAR) }, { "SCROLLBAR_ACTIVE", MAGIC_COLOR | (COL_SCROLLBAR_ACTIVE) }, { "SCROLLBAR_PASSIVE", MAGIC_COLOR | (COL_SCROLLBAR_PASSIVE) }, { "PROGRESSBAR_ACTIVE", MAGIC_COLOR | (COL_PROGRESSBAR_ACTIVE) }, @@ -226,6 +227,7 @@ static void set_lua_variables(lua_State *L) { "MENUCONTENTINACTIVE_PLUS_0", (lua_Unsigned) (COL_MENUCONTENTINACTIVE_PLUS_0) }, { "MENUFOOT_PLUS_0", (lua_Unsigned) (COL_MENUFOOT_PLUS_0) }, { "FRAME_PLUS_0", (lua_Unsigned) (COL_FRAME_PLUS_0) }, + { "SCROLLBAR_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_PLUS_0) }, { "SCROLLBAR_ACTIVE_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_ACTIVE_PLUS_0) }, { "SCROLLBAR_PASSIVE_PLUS_0", (lua_Unsigned) (COL_SCROLLBAR_PASSIVE_PLUS_0) }, { "PROGRESSBAR_ACTIVE_PLUS_0", (lua_Unsigned) (COL_PROGRESSBAR_ACTIVE_PLUS_0) }, diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 67adbf805..1b9e38e36 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -455,7 +455,7 @@ void CMotorControl::paintStatus() void CMotorControl::paintHead() { - CComponentsHeaderLocalized header(x, y, width, hheight, LOCALE_MOTORCONTROL_HEAD); + CComponentsHeader header(x, y, width, hheight, LOCALE_MOTORCONTROL_HEAD); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 5ae6dc094..4d0cc6e45 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -1252,8 +1252,8 @@ bool CMovieBrowser::getSelectedFiles(CFileList &flist, P_MI_MOVIE_LIST &mlist) { flist.clear(); mlist.clear(); - P_MI_MOVIE_LIST *handle_list = &m_vHandleBrowserList; + P_MI_MOVIE_LIST *handle_list = &m_vHandleBrowserList; if (m_windowFocus == MB_FOCUS_LAST_PLAY) handle_list = &m_vHandlePlayList; if (m_windowFocus == MB_FOCUS_LAST_RECORD) @@ -2095,6 +2095,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) { if (m_movieSelectionHandler != NULL) { + m_header->kill(); framebuffer->paintBackground(); //clear whole screen g_EpgData->show_mp(m_movieSelectionHandler); refresh(); @@ -2478,12 +2479,27 @@ bool CMovieBrowser::onDelete(bool cursor_only) MI_MOVIE_INFO *movieinfo; movieinfo = NULL; - filelist_it = filelist.end(); - if (!cursor_only && getSelectedFiles(filelist, movielist)) - filelist_it = filelist.begin(); - if (filelist.empty()) { //just add the m_movieSelectionHandler + + getSelectedFiles(filelist, movielist); + + printf("CMovieBrowser::onDelete(%s) filelist size: %d\n", cursor_only ? "true" : "false", filelist.size()); + printf("CMovieBrowser::onDelete(%s) movielist size: %d\n", cursor_only ? "true" : "false", movielist.size()); + + if (cursor_only || (filelist.empty() || movielist.empty())) + { + printf("CMovieBrowser::onDelete(%s) clearing the lists\n", cursor_only ? "true" : "false"); + + filelist.clear(); + movielist.clear(); + + printf("CMovieBrowser::onDelete(%s) add the m_movieSelectionHandler\n", cursor_only ? "true" : "false"); + + // just add the m_movieSelectionHandler filelist.push_back(m_movieSelectionHandler->file); movielist.push_back(m_movieSelectionHandler); + + printf("CMovieBrowser::onDelete(%s) filelist size: %d\n", cursor_only ? "true" : "false", filelist.size()); + printf("CMovieBrowser::onDelete(%s) movielist size: %d\n", cursor_only ? "true" : "false", movielist.size()); } MI_MOVIE_LIST dellist; @@ -2754,7 +2770,7 @@ void CMovieBrowser::updateDir(void) void CMovieBrowser::loadAllTsFileNamesFromStorage(void) { //TRACE("[mb]->loadAllTsFileNamesFromStorage \n"); - int i,size; + size_t i,size; m_movieSelectionHandler = NULL; m_dirNames.clear(); @@ -2765,8 +2781,10 @@ void CMovieBrowser::loadAllTsFileNamesFromStorage(void) size = m_dir.size(); for (i=0; i < size;i++) { - if (*m_dir[i].used == true) + if (*m_dir[i].used == true){ + OnGlobalProgress(i, size, m_dir[i].name); loadTsFileNamesFromDir(m_dir[i].name); + } } TRACE("[mb] Dir%d, Files:%d\n", (int)m_dirNames.size(), (int)m_vMovieInfo.size()); @@ -2874,7 +2892,8 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) CFileList flist; if (readDir(dirname, &flist) == true) { - for (size_t i = 0; i < flist.size(); i++) + size_t count = flist.size(); + for (size_t i = 0; i < count; i++) { if (S_ISDIR(flist[i].Mode)) { if (m_settings.ts_only || !CFileBrowser::checkBD(flist[i])) { @@ -2885,7 +2904,8 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) } else { result |= addFile(flist[i], dirItNr); } - OnLoadFile(i, flist.size(), g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); + if (result) + OnLocalProgress(i, count, dirname ); } //result = true; } @@ -3124,7 +3144,10 @@ void CMovieBrowser::loadMovies(bool doRefresh) { TRACE("[mb] loadMovies: \n"); - CProgressWindow loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_HEAD, 500, 150, show_mode == MB_SHOW_YT ? &ytparser.OnLoadVideoInfo : &OnLoadFile); + struct timeval t1, t2; + gettimeofday(&t1, NULL); + + CProgressWindow loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES, CCW_PERCENT 50, CCW_PERCENT 10, NULL, show_mode == MB_SHOW_YT ? &ytparser.OnProgress : &OnLocalProgress, &OnGlobalProgress); loadBox.enableShadow(); loadBox.paint(); @@ -3139,6 +3162,11 @@ void CMovieBrowser::loadMovies(bool doRefresh) } m_file_info_stale = false; + gettimeofday(&t2, NULL); + uint64_t duration = ((t2.tv_sec * 1000000ULL + t2.tv_usec) - (t1.tv_sec * 1000000ULL + t1.tv_usec)) / 1000ULL; + if (duration) + fprintf(stderr, "\033[33m[CMovieBrowser] %s: %" PRIu64 " ms to scan movies \033[0m\n",__func__, duration); + loadBox.hide(); if (doRefresh) @@ -3299,12 +3327,10 @@ int CMovieBrowser::showMovieCutMenu() movieCutMenu.addIntroItems(LOCALE_MOVIEBROWSER_MENU_CUT_HEAD); CMenuForwarder *mf; -#if 0 mf = new CMenuForwarder(m_movieSelectionHandler->epgTitle, false); mf->setHint(NEUTRINO_ICON_HINT_MOVIE, NONEXISTANT_LOCALE); movieCutMenu.addItem(mf); movieCutMenu.addItem(GenericMenuSeparator); -#endif mf = new CMenuForwarder(LOCALE_MOVIEBROWSER_MENU_COPY_ONEFILE, true, NULL, this, "copy_onefile", CRCInput::RC_red); mf->setHint(NEUTRINO_ICON_HINT_MOVIE, LOCALE_MOVIEBROWSER_HINT_COPY_ONEFILE); @@ -3431,9 +3457,13 @@ bool CMovieBrowser::showMenu(bool calledExternally) if (!calledExternally) { CMenuWidget mainMenu(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER); mainMenu.addIntroItems(LOCALE_MOVIEBROWSER_MENU_MAIN_HEAD); + if (m_movieSelectionHandler){ + mainMenu.addItem(new CMenuForwarder(m_movieSelectionHandler->epgTitle, false)); + } + mainMenu.addItem(GenericMenuSeparator); mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_INFO_HEAD, (m_movieSelectionHandler != NULL), NULL, this, "show_movie_info_menu", CRCInput::RC_red)); mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_MENU_CUT_HEAD, (m_movieSelectionHandler != NULL), NULL, this, "show_movie_cut_menu", CRCInput::RC_green)); - mainMenu.addItem(new CMenuForwarder(LOCALE_FILEBROWSER_DELETE, (m_movieSelectionHandler != NULL), NULL, this, "delete_movie", CRCInput::RC_yellow)); + mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DELETE_MOVIE, (m_movieSelectionHandler != NULL), NULL, this, "delete_movie", CRCInput::RC_yellow)); mainMenu.addItem(GenericMenuSeparatorLine); mainMenu.addItem(new CMenuForwarder(LOCALE_EPGPLUS_OPTIONS, true, NULL, &optionsMenu,NULL, CRCInput::RC_1)); mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_MENU_DIRECTORIES_HEAD, true, NULL, &dirMenu, NULL, CRCInput::RC_2)); diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 607528821..bbaecf735 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -57,6 +57,7 @@ #include #include #include +#include #define MAX_NUMBER_OF_BOOKMARK_ITEMS MI_MOVIE_BOOK_USER_MAX // we just use the same size as used in Movie info (MAX_NUMBER_OF_BOOKMARK_ITEMS is used for the number of menu items) #define MOVIEBROWSER_SETTINGS_FILE CONFIGDIR "/moviebrowser.conf" @@ -133,7 +134,7 @@ class CYTCacheSelectorTarget : public CMenuTarget }; // Priorities for Developmemt: P1: critical feature, P2: important feature, P3: for next release, P4: looks nice, lets see -class CMovieBrowser : public CMenuTarget +class CMovieBrowser : public CMenuTarget, public CProgressSignals { friend class CYTCacheSelectorTarget; @@ -362,7 +363,6 @@ class CMovieBrowser : public CMenuTarget void clearSelection(); bool supportedExtension(CFile &file); bool addFile(CFile &file, int dirItNr); - sigc::signal OnLoadFile; }; // I tried a lot to use the menu.cpp as ListBox selection, and I got three solution which are all garbage. diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 29e927f48..9ec28dc32 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -28,7 +28,10 @@ #include #endif +#ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#endif + #include #include #include @@ -38,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +158,8 @@ void CMoviePlayerGui::Init(void) { playing = false; stopped = true; + currentVideoSystem = -1; + currentOsdResolution = 0; frameBuffer = CFrameBuffer::getInstance(); @@ -239,6 +245,12 @@ void CMoviePlayerGui::cutNeutrino() if (playing) return; +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + COsdHelpers *coh = COsdHelpers::getInstance(); + currentVideoSystem = coh->getVideoSystem(); + currentOsdResolution = coh->getOsdResolution(); +#endif + playing = true; /* set g_InfoViewer update timer to 1 sec, should be reset to default from restoreNeutrino->set neutrino mode */ if (!isWebTV) @@ -271,6 +283,19 @@ void CMoviePlayerGui::restoreNeutrino() if (!playing) return; +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + if ((currentVideoSystem > -1) && + (g_settings.video_Mode == VIDEO_STD_AUTO) && + (g_settings.enabled_auto_modes[currentVideoSystem] == 1)) { + COsdHelpers *coh = COsdHelpers::getInstance(); + if (currentVideoSystem != coh->getVideoSystem()) { + coh->setVideoSystem(currentVideoSystem, false); + coh->changeOsdResolution(currentOsdResolution, false, true); + } + currentVideoSystem = -1; + } +#endif + playing = false; #ifdef HAVE_AZBOX_HARDWARE g_Zapit->setStandby(false); @@ -926,7 +951,7 @@ bool CMoviePlayerGui::selectLivestream(std::vector &streamLis #endif bool resIO = false; - while (1) { + while (!streamList.empty()) { size_t i; for (i = 0; i < streamList.size(); ++i) { _info = &(streamList[i]); @@ -1256,6 +1281,11 @@ bool CMoviePlayerGui::SetPosition(int pos, bool absolute) { clearSubtitle(); bool res = playback->SetPosition(pos, absolute); + if(is_file_player && res && speed == 0 && playstate == CMoviePlayerGui::PAUSE){ + playstate = CMoviePlayerGui::PLAY; + speed = 1; + playback->SetSpeed(speed); + } return res; } @@ -1355,7 +1385,7 @@ void CMoviePlayerGui::PlayFileLoop(void) } #endif /* in case ffmpeg report incorrect values */ - if(file_prozent > 96 && (playstate == CMoviePlayerGui::PLAY) && (speed == 1)){ + if(file_prozent > 89 && (playstate == CMoviePlayerGui::PLAY) && (speed == 1)){ if(position_tmp != position){ position_tmp = position ; eof2 = 0; @@ -1474,7 +1504,6 @@ void CMoviePlayerGui::PlayFileLoop(void) disableOsdElements(MUTE); CFileBrowser *playlist = new CFileBrowser(); CFile *pfile = NULL; - pfile = &(*filelist_it); int selected = std::distance( filelist.begin(), filelist_it ); filelist_it = filelist.end(); if (playlist->playlist_manager(filelist, selected)) @@ -1541,7 +1570,8 @@ void CMoviePlayerGui::PlayFileLoop(void) makeScreenShot(); } else if ((msg == (neutrino_msg_t) g_settings.mpkey_rewind) || (msg == (neutrino_msg_t) g_settings.mpkey_forward)) { - int newspeed; + int newspeed = 0; + bool setSpeed = false; if (msg == (neutrino_msg_t) g_settings.mpkey_rewind) { newspeed = (speed >= 0) ? -1 : speed - 1; } else { @@ -1554,9 +1584,10 @@ void CMoviePlayerGui::PlayFileLoop(void) if (playstate != CMoviePlayerGui::PAUSE) playstate = msg == (neutrino_msg_t) g_settings.mpkey_rewind ? CMoviePlayerGui::REW : CMoviePlayerGui::FF; updateLcd(); + setSpeed = true; } - if (!FileTimeOSD->IsVisible() && !time_forced) { + if (!FileTimeOSD->IsVisible() && !time_forced && setSpeed) { FileTimeOSD->switchMode(position, duration); time_forced = true; } @@ -2299,7 +2330,7 @@ void CMoviePlayerGui::selectChapter() playback->GetChapters(positions, titles); std::vector playlists; std::vector ptitles; - int current; + int current = 0; playback->GetTitles(playlists, ptitles, current); if (positions.empty() && playlists.empty()) @@ -2452,7 +2483,6 @@ bool CMoviePlayerGui::convertSubtitle(std::string &text) else { memset(buf + (len - olen), 0, olen); text = buf; - ret = true; } free(buf); diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 1e15997d7..0b6cd507d 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -118,6 +118,8 @@ class CMoviePlayerGui : public CMenuTarget int startposition; int position; int duration; + int currentVideoSystem; + uint32_t currentOsdResolution; unsigned short numpida; unsigned short vpid; diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index be24d6a45..14a8c433d 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -679,12 +679,14 @@ string COPKGManager::getPkgDescription(std::string pkgName, std::string pkgDesc) return pkgDesc; fpos_t fz; + fz.__pos = 0; fseek(fd, 0, SEEK_END); fgetpos(fd, &fz); fseek(fd, 0, SEEK_SET); - if (fz.__pos == 0) + if (fz.__pos == 0){ + fclose(fd); return pkgDesc; - + } char buf[512]; string package, version, description; while (fgets(buf, sizeof(buf), fd)) { diff --git a/src/gui/osd_helpers.cpp b/src/gui/osd_helpers.cpp new file mode 100644 index 000000000..b5bb20127 --- /dev/null +++ b/src/gui/osd_helpers.cpp @@ -0,0 +1,217 @@ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +extern CInfoClock *InfoClock; +extern CTimeOSD *FileTimeOSD; +extern cVideo *videoDecoder; + +COsdHelpers::COsdHelpers() +{ + g_settings_osd_resolution_save = 0; +} + +COsdHelpers::~COsdHelpers() +{ +} + +COsdHelpers* COsdHelpers::getInstance() +{ + static COsdHelpers* osdh = NULL; + if(!osdh) + osdh = new COsdHelpers(); + + return osdh; +} + +#ifdef ENABLE_CHANGE_OSD_RESOLUTION +void COsdHelpers::changeOsdResolution(uint32_t mode, bool automode/*=false*/, bool forceOsdReset/*=false*/) +{ + size_t idx = 0; + bool resetOsd = false; + uint32_t modeNew; + + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + + if (automode) { + if (g_settings.video_Mode == VIDEO_STD_AUTO) + modeNew = OSDMODE_1080; + else + modeNew = g_settings_osd_resolution_save; + } + else { + modeNew = mode; + } + + int videoSystem = getVideoSystem(); + + if ((g_settings.video_Mode == VIDEO_STD_AUTO) && + (g_settings.enabled_auto_modes[videoSystem] == 1) && + (!isVideoSystem1080(videoSystem))) + modeNew = OSDMODE_720; + +// if (!isVideoSystem1080(videoSystem)) +// modeNew = OSDMODE_720; + + idx = frameBuffer->getIndexOsdResolution(modeNew); + resetOsd = (modeNew != getOsdResolution()) ? true : false; +#if 1 + printf(">>>>>[%s:%d] osd mode: %s => %s, automode: %s, forceOsdReset: %s\n", __func__, __LINE__, + (g_settings.osd_resolution == OSDMODE_720)?"OSDMODE_720":"OSDMODE_1080", + (modeNew == OSDMODE_720)?"OSDMODE_720":"OSDMODE_1080", + (automode)?"true":"false", + (forceOsdReset)?"true":"false"); +#endif + if (forceOsdReset) + resetOsd = true; + + if (frameBuffer->fullHdAvailable()) { + if (frameBuffer->osd_resolutions.empty()) + return; + + bool ivVisible = false; + if (g_InfoViewer && g_InfoViewer->is_visible) { + g_InfoViewer->killTitle(); + ivVisible = true; + } + + int switchFB = frameBuffer->setMode(frameBuffer->osd_resolutions[idx].xRes, + frameBuffer->osd_resolutions[idx].yRes, + frameBuffer->osd_resolutions[idx].bpp); + + if (switchFB == 0) { +//printf("\n>>>>>[%s:%d] New res: %dx%dx%d\n \n", __func__, __LINE__, resW, resH, bpp); + g_settings.osd_resolution = modeNew; + if (InfoClock) + InfoClock->enableInfoClock(false); + frameBuffer->Clear(); + if (resetOsd) { + CNeutrinoApp::getInstance()->setScreenSettings(); + CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT); + CVolumeHelper::getInstance()->refresh(); + if (InfoClock) + CInfoClock::getInstance()->ClearDisplay(); + if (FileTimeOSD) + FileTimeOSD->Init(); + if (CNeutrinoApp::getInstance()->channelList) + CNeutrinoApp::getInstance()->channelList->ResetModules(); + } + if (InfoClock) + InfoClock->enableInfoClock(true); + } + if (g_InfoViewer) { + g_InfoViewer->ResetModules(); + g_InfoViewer->start(); + } + if (ivVisible) { + CNeutrinoApp::getInstance()->StopSubtitles(); + g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannel(), true, 0, true); + CNeutrinoApp::getInstance()->StartSubtitles(); + } + } +} +#else +void COsdHelpers::changeOsdResolution(uint32_t, bool, bool) +{ +} +#endif + +int COsdHelpers::isVideoSystem1080(int res) +{ + if ((res == VIDEO_STD_1080I60) || + (res == VIDEO_STD_1080I50) || + (res == VIDEO_STD_1080P30) || + (res == VIDEO_STD_1080P24) || + (res == VIDEO_STD_1080P25)) + return true; + +#ifdef BOXMODEL_CS_HD2 + if ((res == VIDEO_STD_1080P50) || + (res == VIDEO_STD_1080P60) || + (res == VIDEO_STD_1080P2397) || + (res == VIDEO_STD_1080P2997)) + return true; +#endif + +#if 0 + /* for testing only */ + if (res == VIDEO_STD_720P50) + return true; +#endif + + return false; +} + +int COsdHelpers::getVideoSystem() +{ + return videoDecoder->GetVideoSystem(); +} + +uint32_t COsdHelpers::getOsdResolution() +{ + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + if (frameBuffer->osd_resolutions.size() == 1) + return 0; + + uint32_t yRes = frameBuffer->getScreenHeight(true); + for (size_t i = 0; i < frameBuffer->osd_resolutions.size(); i++) { + if (frameBuffer->osd_resolutions[i].yRes == yRes) + return frameBuffer->osd_resolutions[i].mode; + } + return 0; +} + +#define DEBUGINFO_SETVIDEOSYSTEM + +int COsdHelpers::setVideoSystem(int newSystem, bool remember/* = true*/) +{ + if ((newSystem < 0) || (newSystem > VIDEO_STD_MAX)) + return -1; + + if (newSystem == getVideoSystem()) + return 0; + +#ifdef DEBUGINFO_SETVIDEOSYSTEM + int fd = CFrameBuffer::getInstance()->getFileHandle(); + fb_var_screeninfo var; + fb_fix_screeninfo fix; + + ioctl(fd, FBIOGET_VSCREENINFO, &var); + ioctl(fd, FBIOGET_FSCREENINFO, &fix); + printf(">>>>>[%s - %s:%d] before SetVideoSystem:\n" + " var.xres : %4d, var.yres : %4d, var.yres_virtual: %4d\n" + " fix.line_length : %4d, fix.smem_len: %d Byte\n", + __path_file__, __func__, __LINE__, + var.xres, var.yres, var.yres_virtual, + fix.line_length, fix.smem_len); +#endif + + int ret = videoDecoder->SetVideoSystem(newSystem, remember); + +#ifdef DEBUGINFO_SETVIDEOSYSTEM + ioctl(fd, FBIOGET_VSCREENINFO, &var); + ioctl(fd, FBIOGET_FSCREENINFO, &fix); + printf(">>>>>[%s - %s:%d] after SetVideoSystem:\n" + " var.xres : %4d, var.yres : %4d, var.yres_virtual: %4d\n" + " fix.line_length : %4d, fix.smem_len: %d Byte\n", + __path_file__, __func__, __LINE__, + var.xres, var.yres, var.yres_virtual, + fix.line_length, fix.smem_len); +#endif + + return ret; +} diff --git a/src/gui/osd_helpers.h b/src/gui/osd_helpers.h new file mode 100644 index 000000000..9c78886f0 --- /dev/null +++ b/src/gui/osd_helpers.h @@ -0,0 +1,29 @@ + +#ifndef __osd_helpers__ +#define __osd_helpers__ + +enum { + OSDMODE_720 = 0, + OSDMODE_1080 = 1 +}; + +class COsdHelpers +{ + private: + + public: + COsdHelpers(); + ~COsdHelpers(); + static COsdHelpers* getInstance(); + + int g_settings_osd_resolution_save; + + void changeOsdResolution(uint32_t mode, bool automode=false, bool forceOsdReset=false); + int isVideoSystem1080(int res); + int getVideoSystem(); + uint32_t getOsdResolution(); + int setVideoSystem(int newSystem, bool remember = true); +}; + + +#endif //__osd_helpers__ diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 1daba9223..94e864f7b 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -40,6 +40,7 @@ #include #include "osd_setup.h" +#include "osd_helpers.h" #include "themes.h" #include "screensetup.h" #include "osdlang_setup.h" @@ -200,7 +201,7 @@ font_sizes_struct neutrino_font[SNeutrinoSettings::FONT_TYPE_COUNT] = {LOCALE_FONTSIZE_EPG_INFO1 , 17, CNeutrinoFonts::FONT_STYLE_ITALIC , 2}, {LOCALE_FONTSIZE_EPG_INFO2 , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_EPG_DATE , 15, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, - {LOCALE_FONTSIZE_EPGPLUS_ITEM , 18, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, + {LOCALE_FONTSIZE_EPGPLUS_ITEM , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_EVENTLIST_TITLE , 30, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}, {LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, @@ -215,7 +216,7 @@ font_sizes_struct neutrino_font[SNeutrinoSettings::FONT_TYPE_COUNT] = {LOCALE_FONTSIZE_INFOBAR_CHANNAME , 30, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_INFOBAR_INFO , 20, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_FILEBROWSER_ITEM , 16, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, + {LOCALE_FONTSIZE_FILEBROWSER_ITEM , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_MENU_HINT , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}, {LOCALE_FONTSIZE_MOVIEBROWSER_HEAD , 15, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_MOVIEBROWSER_LIST , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}, @@ -316,6 +317,7 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) memset(window_size_value, 0, sizeof(window_size_value)); snprintf(window_size_value, sizeof(window_size_value), "%d / %d", g_settings.window_width, g_settings.window_height); mfWindowSize->setOption(window_size_value); + CNeutrinoApp::getInstance()->channelList->ResetModules(); break; } else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) { g_settings.window_width = old_window_width; @@ -393,12 +395,11 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) return res; } - #define OSD_PRESET_OPTIONS_COUNT 2 -const CMenuOptionChooser::keyval OSD_PRESET_OPTIONS[OSD_PRESET_OPTIONS_COUNT] = +const CMenuOptionChooser::keyval_ext OSD_PRESET_OPTIONS[] = { - { 0, LOCALE_COLORMENU_SD_PRESET }, - { 1, LOCALE_COLORMENU_HD_PRESET } + { COsdSetup::PRESET_CRT, NONEXISTANT_LOCALE, "CRT" }, + { COsdSetup::PRESET_LCD, NONEXISTANT_LOCALE, "LCD" } }; #define INFOBAR_CASYSTEM_MODE_OPTION_COUNT 4 @@ -647,6 +648,35 @@ int COsdSetup::showOsdSetup() osd_menu->addItem(GenericMenuSeparatorLine); +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + // osd resolution + size_t resCount = frameBuffer->osd_resolutions.size(); + struct CMenuOptionChooser::keyval_ext kext[resCount]; + char valname[resCount][255]; + if (resCount > 0) { + for (size_t i = 0; i < resCount; i++) { + kext[i].key = i; + kext[i].value = NONEXISTANT_LOCALE; + snprintf(valname[i], sizeof(valname[resCount]), "%dx%d", frameBuffer->osd_resolutions[i].xRes, frameBuffer->osd_resolutions[i].yRes); + kext[i].valname = valname[i]; + } + } + else { + kext[0].key = 0; + kext[0].value = NONEXISTANT_LOCALE; + kext[0].valname = "-"; + resCount = 1; + } + int videoSystem = COsdHelpers::getInstance()->getVideoSystem(); + bool enable = ((resCount > 1) && + COsdHelpers::getInstance()->isVideoSystem1080(videoSystem) && + (g_settings.video_Mode != VIDEO_STD_AUTO)); + CMenuOptionChooser * osd_res = new CMenuOptionChooser(LOCALE_COLORMENU_OSD_RESOLUTION, &g_settings.osd_resolution, kext, resCount, enable, this); + osd_res->OnAfterChangeOption.connect(sigc::mem_fun(frameBuffer->getInstance(), &CFrameBuffer::clearIconCache)); + osd_res->setHint("", LOCALE_MENU_HINT_OSD_RESOLUTION); + osd_menu->addItem(osd_res); +#endif + //monitor CMenuOptionChooser *mc; if (cs_get_revision() != 1) { /* 1 == Tripledragon */ @@ -655,6 +685,8 @@ int COsdSetup::showOsdSetup() osd_menu->addItem(mc); } + osd_menu->addItem(GenericMenuSeparatorLine); + // round corners mc = new CMenuOptionChooser(LOCALE_EXTRA_ROUNDED_CORNERS, &g_settings.rounded_corners, MENU_CORNERSETTINGS_TYPE_OPTIONS, MENU_CORNERSETTINGS_TYPE_OPTION_COUNT, true, this); mc->setHint("", LOCALE_MENU_HINT_ROUNDED_CORNERS); @@ -741,6 +773,8 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors) &t.menu_Foot_alpha, colorSetupNotifier); CColorChooser* chFootTextcolor = new CColorChooser(LOCALE_COLORMENU_TEXTCOLOR, &t.menu_Foot_Text_red, &t.menu_Foot_Text_green, &t.menu_Foot_Text_blue, NULL, colorSetupNotifier); + CColorChooser* chShadowColor = new CColorChooser(LOCALE_COLORMENU_SHADOW_COLOR, &t.shadow_red, &t.shadow_green, &t.shadow_blue, + &t.menu_Head_alpha, colorSetupNotifier); menu_colors->addItem( new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_COLORMENUSETUP_MENUHEAD)); @@ -906,6 +940,13 @@ void COsdSetup::showOsdMenueColorSetup(CMenuWidget *menu_colors) oj = new CMenuOptionChooser(LOCALE_MISCSETTINGS_COLORED_EVENTS_INFOBAR, &t.colored_events_infobar, OPTIONS_COLORED_EVENTS_OPTIONS, OPTIONS_COLORED_EVENTS_OPTION_COUNT, true); oj->setHint("", LOCALE_MENU_HINT_COLORED_EVENTS); menu_colors->addItem(oj); + + // shadow + menu_colors->addItem( new CMenuSeparator(CMenuSeparator::LINE)); + + mf = new CMenuDForwarder(LOCALE_COLORMENU_SHADOW_COLOR, true, NULL, chShadowColor ); + mf->setHint("", LOCALE_MENU_HINT_COLORS_SHADOW); + menu_colors->addItem(mf); } /* for font size setup */ @@ -1371,16 +1412,56 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) int preset = * (int *) data; printf("preset %d (setting %d)\n", preset, g_settings.screen_preset); - g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd : g_settings.screen_StartX_crt; - g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd : g_settings.screen_StartY_crt; - g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt; - g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt; + CNeutrinoApp::getInstance()->setScreenSettings(); osd_menu->hide(); if (g_InfoViewer == NULL) g_InfoViewer = new CInfoViewer; g_InfoViewer->changePB(); return true; } +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_OSD_RESOLUTION)) + { + if (frameBuffer->osd_resolutions.empty()) + return true; + osd_menu->hide(); + uint32_t osd_mode = (uint32_t)*(int*)data; + COsdHelpers::getInstance()->g_settings_osd_resolution_save = osd_mode; + COsdHelpers::getInstance()->changeOsdResolution(osd_mode); +#if 0 + if (frameBuffer->fullHdAvailable()) { + if (frameBuffer->osd_resolutions.empty()) + return true; + + size_t index = (size_t)*(int*)data; + size_t resCount = frameBuffer->osd_resolutions.size(); + if (index >= resCount) + index = 0; + + uint32_t resW = frameBuffer->osd_resolutions[index].xRes; + uint32_t resH = frameBuffer->osd_resolutions[index].yRes; + uint32_t bpp = frameBuffer->osd_resolutions[index].bpp; + int switchFB = frameBuffer->setMode(resW, resH, bpp); + + if (switchFB == 0) { +//printf("\n>>>>>[%s:%d] New res: %dx%dx%d\n \n", __func__, __LINE__, resW, resH, bpp); + osd_menu->hide(); + frameBuffer->Clear(); + CNeutrinoApp::getInstance()->setScreenSettings(); + CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT); + CVolumeHelper::getInstance()->refresh(); + CInfoClock::getInstance()->ClearDisplay(); + FileTimeOSD->Init(); + if (CNeutrinoApp::getInstance()->channelList) + CNeutrinoApp::getInstance()->channelList->ResetModules(); + if (g_InfoViewer) + g_InfoViewer->ResetModules(); + } + } +#endif + return true; + } +#endif else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_EXTRA_ROUNDED_CORNERS)) { osd_menu->hide(); g_settings.rounded_corners = * (int*) data; diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index 18adc6311..cdea56535 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -96,6 +96,12 @@ class COsdSetup : public CMenuTarget, public CChangeObserver INFOBAR_LOGO_FRAMED, INFOBAR_LOGO_SHADED }; + + enum + { + PRESET_CRT, + PRESET_LCD + }; COsdSetup(int wizard_mode = SNeutrinoSettings::WIZARD_OFF); ~COsdSetup(); diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index dc70d7e11..e1e330b00 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -163,19 +163,19 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) width = frameBuffer->getScreenWidthRel(); height = frameBuffer->getScreenHeightRel(); - theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + item_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - //get footerHeight from paintButtons - buttons1Height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); - buttons2Height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); - footerHeight = buttons1Height + buttons2Height; + //get footer_height from paintButtons + buttons1_height = ::paintButtons(0, 0, 0, PictureViewerButtons1Count, PictureViewerButtons1, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); + buttons2_height = ::paintButtons(0, 0, 0, PictureViewerButtons2Count, PictureViewerButtons2, 0, 0, "", false, COL_MENUFOOT_TEXT, NULL, 0, false); + footer_height = buttons1_height + buttons2_height; - listmaxshow = (height-theight-footerHeight)/(fheight); - height = theight+listmaxshow*fheight+footerHeight; // recalc height + listmaxshow = (height - header_height - footer_height - OFFSET_SHADOW)/item_height; + height = header_height + listmaxshow*item_height + footer_height + OFFSET_SHADOW; // recalc height - x=getScreenStartX( width ); - y=getScreenStartY( height ); + x=getScreenStartX(width); + y=getScreenStartY(height); m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling); m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY); @@ -661,7 +661,7 @@ void CPictureViewerGui::hide() void CPictureViewerGui::paintItem(int pos) { // printf("paintItem{\n"); - int ypos = y+ theight + 0 + pos*fheight; + int ypos = y + header_height + pos*item_height; unsigned int currpos = liststart + pos; @@ -679,8 +679,8 @@ void CPictureViewerGui::paintItem(int pos) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x, ypos, width - 15, fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, width - 15, fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, item_height, bgcolor, i_radius); if (currpos < playlist.size()) { @@ -691,8 +691,8 @@ void CPictureViewerGui::paintItem(int pos) char timestring[18]; strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&playlist[currpos].Date)); int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(timestring); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10,ypos+fheight, width-30 - w, tmp, color, fheight); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+width-20-w,ypos+fheight, w, timestring, color, fheight); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID, ypos + item_height, width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID - w, tmp, color, item_height); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, ypos + item_height, w, timestring, color, item_height); } // printf("paintItem}\n"); @@ -702,7 +702,8 @@ void CPictureViewerGui::paintItem(int pos) void CPictureViewerGui::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_MP3, CComponentsHeaderLocalized::CC_BTN_HELP); + CComponentsHeader header(x, y, width, header_height, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_PICTUREVIEWER, CComponentsHeader::CC_BTN_HELP); + header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); #ifdef ENABLE_GUI_MOUNT header.setContextButton(NEUTRINO_ICON_BUTTON_MENU); @@ -720,15 +721,20 @@ void CPictureViewerGui::paintFoot() else PictureViewerButtons2[0].locale = LOCALE_PICTUREVIEWER_SORTORDER_DATE; - frameBuffer->paintBoxRel(x, y + (height - footerHeight), width, footerHeight, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + int footer_y = y + (height - footer_height - OFFSET_SHADOW); + + // shadow + frameBuffer->paintBoxRel(x + OFFSET_SHADOW, footer_y + OFFSET_SHADOW, width, footer_height, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + + frameBuffer->paintBoxRel(x, footer_y, width, footer_height, COL_MENUFOOT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); if (!playlist.empty()) { - ::paintButtons(x, y + (height - footerHeight), 0, PictureViewerButtons1Count, PictureViewerButtons1, width); - ::paintButtons(x, y + (height - buttons2Height), 0, PictureViewerButtons2Count, PictureViewerButtons2, width); + ::paintButtons(x, footer_y, width, PictureViewerButtons1Count, PictureViewerButtons1, width, buttons1_height); + ::paintButtons(x, footer_y + buttons1_height, width, PictureViewerButtons2Count, PictureViewerButtons2, width, buttons2_height); } else - ::paintButtons(x, y + (height - footerHeight), 0, 1, &(PictureViewerButtons1[1]), width); + ::paintButtons(x, footer_y, width, 1, &(PictureViewerButtons1[1]), width, buttons1_height); } //------------------------------------------------------------------------ @@ -749,19 +755,11 @@ void CPictureViewerGui::paint() paintItem(count); } - int ypos = y+ theight; - int sb = fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - unsigned int tmp_max = listmaxshow; - if(!tmp_max) - tmp_max = 1; - int sbc= ((playlist.size()- 1)/ tmp_max)+ 1; - int sbs= (selected/tmp_max); - if (sbc < 1) - sbc = 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + //scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, playlist.size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page, CC_SHADOW_ON); paintFoot(); paintInfo(); diff --git a/src/gui/pictureviewer.h b/src/gui/pictureviewer.h index 6e89ccbcd..70b38fd16 100644 --- a/src/gui/pictureviewer.h +++ b/src/gui/pictureviewer.h @@ -74,11 +74,11 @@ class CPictureViewerGui : public CMenuTarget unsigned int selected; unsigned int liststart; unsigned int listmaxshow; - int fheight; // Fonthoehe Playlist-Inhalt - int theight; // Fonthoehe Playlist-Titel - int footerHeight; - int buttons1Height; - int buttons2Height; + int item_height; + int header_height; + int footer_height; + int buttons1_height; + int buttons2_height; bool visible; State m_state; SortOrder m_sort; diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 00cd52f39..fae191c0e 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -41,6 +41,7 @@ #include "record_setup.h" #include +#include #include #include @@ -173,6 +174,13 @@ const CMenuOptionChooser::keyval END_OF_RECORDING[END_OF_RECORDING_COUNT] = {1, LOCALE_RECORDINGMENU_END_OF_RECORDING_EPG} }; +const CMenuOptionChooser::keyval timer_followscreenings_options[] = +{ + {CFollowScreenings::FOLLOWSCREENINGS_OFF ,LOCALE_OPTIONS_OFF }, + {CFollowScreenings::FOLLOWSCREENINGS_ON ,LOCALE_OPTIONS_ON } +}; +size_t timer_followscreenings_options_count = sizeof(timer_followscreenings_options)/sizeof(CMenuOptionChooser::keyval); + int CRecordSetup::showRecordSetup() { CMenuForwarder * mf; @@ -302,7 +310,7 @@ int CRecordSetup::showRecordSetup() void CRecordSetup::showRecordTimerSetup(CMenuWidget *menu_timersettings) { //recording start/end correcture - int pre,post; + int pre = 0,post = 0; g_Timerd->getRecordingSafety(pre,post); g_settings.record_safety_time_before = pre/60; g_settings.record_safety_time_after = post/60; @@ -342,7 +350,7 @@ void CRecordSetup::showRecordTimerSetup(CMenuWidget *menu_timersettings) menu_timersettings->addItem(GenericMenuSeparatorLine); //allow followscreenings - CMenuOptionChooser* followscreenings = new CMenuOptionChooser(LOCALE_TIMERSETTINGS_FOLLOWSCREENINGS, &g_settings.timer_followscreenings, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + CMenuOptionChooser* followscreenings = new CMenuOptionChooser(LOCALE_TIMERSETTINGS_FOLLOWSCREENINGS, &g_settings.timer_followscreenings, timer_followscreenings_options, timer_followscreenings_options_count, true); followscreenings->setHint("", LOCALE_MENU_HINT_TIMER_FOLLOWSCREENINGS); menu_timersettings->addItem(followscreenings); } diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 034b70b36..e679b4ba0 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -357,7 +357,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) perror(NEUTRINO_SCAN_STOP_SCRIPT " failed"); } if(!test) { - CComponentsHeaderLocalized header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : LOCALE_SCANTS_FAILED); + CComponentsHeader header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : LOCALE_SCANTS_FAILED); header.paint(CC_SAVE_SCREEN_NO); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(0xFFFF); do { @@ -521,8 +521,8 @@ void CScanTs::paintLine(int px, int py, int w, const char * const txt) void CScanTs::paint(bool fortest) { - CComponentsHeaderLocalized header(x, y, width, hheight, fortest ? LOCALE_SCANTS_TEST : LOCALE_SCANTS_HEAD); - header.setCaptionAlignment(CTextBox::CENTER); + CComponentsHeader header(x, y, width, hheight, fortest ? LOCALE_SCANTS_TEST : LOCALE_SCANTS_HEAD); + header.setCaptionAlignment(CCHeaderTypes::CC_TITLE_CENTER); header.paint(CC_SAVE_SCREEN_NO); frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 3bf274b39..d3d61e7bb 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -164,7 +164,7 @@ void* CScreenSaver::ScreenSaverPrg(void* arg) if (g_settings.screensaver_timeout) { - while(1) + while(PScreenSaver) { PScreenSaver->paint(); sleep(g_settings.screensaver_timeout); diff --git a/src/gui/screensetup.cpp b/src/gui/screensetup.cpp index b1327fed2..207020eab 100644 --- a/src/gui/screensetup.cpp +++ b/src/gui/screensetup.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -109,27 +110,61 @@ int CScreenSetup::exec(CMenuTarget* parent, const std::string &) switch ( msg ) { - case CRCInput::RC_ok: + case CRCInput::RC_ok: { // abspeichern g_settings.screen_StartX = x_coord[0]; g_settings.screen_EndX = x_coord[1]; g_settings.screen_StartY = y_coord[0]; g_settings.screen_EndY = y_coord[1]; - if(g_settings.screen_preset) { - g_settings.screen_StartX_lcd = g_settings.screen_StartX; - g_settings.screen_StartY_lcd = g_settings.screen_StartY; - g_settings.screen_EndX_lcd = g_settings.screen_EndX; - g_settings.screen_EndY_lcd = g_settings.screen_EndY; - } else { - g_settings.screen_StartX_crt = g_settings.screen_StartX; - g_settings.screen_StartY_crt = g_settings.screen_StartY; - g_settings.screen_EndX_crt = g_settings.screen_EndX; - g_settings.screen_EndY_crt = g_settings.screen_EndY; + switch (g_settings.osd_resolution) { +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + case 1: + { + switch (g_settings.screen_preset) { + case COsdSetup::PRESET_CRT: + g_settings.screen_StartX_crt_1 = g_settings.screen_StartX; + g_settings.screen_StartY_crt_1 = g_settings.screen_StartY; + g_settings.screen_EndX_crt_1 = g_settings.screen_EndX; + g_settings.screen_EndY_crt_1 = g_settings.screen_EndY; + break; + case COsdSetup::PRESET_LCD: + default: + g_settings.screen_StartX_lcd_1 = g_settings.screen_StartX; + g_settings.screen_StartY_lcd_1 = g_settings.screen_StartY; + g_settings.screen_EndX_lcd_1 = g_settings.screen_EndX; + g_settings.screen_EndY_lcd_1 = g_settings.screen_EndY; + break; + } + } + break; +#endif + case 0: + default: + { + switch (g_settings.screen_preset) { + case COsdSetup::PRESET_CRT: + g_settings.screen_StartX_crt_0 = g_settings.screen_StartX; + g_settings.screen_StartY_crt_0 = g_settings.screen_StartY; + g_settings.screen_EndX_crt_0 = g_settings.screen_EndX; + g_settings.screen_EndY_crt_0 = g_settings.screen_EndY; + break; + case COsdSetup::PRESET_LCD: + default: + g_settings.screen_StartX_lcd_0 = g_settings.screen_StartX; + g_settings.screen_StartY_lcd_0 = g_settings.screen_StartY; + g_settings.screen_EndX_lcd_0 = g_settings.screen_EndX; + g_settings.screen_EndY_lcd_0 = g_settings.screen_EndY; + break; + } + } + break; } + if (g_InfoViewer) /* recalc infobar position */ g_InfoViewer->start(); loop = false; break; + } case CRCInput::RC_home: if ( ( ( g_settings.screen_StartX != x_coord[0] ) || diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index a3a32cc45..e1f560813 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -522,18 +522,20 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) if(!channel) return; - int array[6]={g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_RESOLUTION)), + int array[]= {g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_RESOLUTION)), + g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_VIDEOSYSTEM)), + g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_OSD_RESOLUTION)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_ARATIO)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_BITRATE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_SCANTS_FREQDATA))}; - for(i=0 ; i<6; i++) { + for(i=0 ; i<(int)(sizeof(array)/sizeof(array[0])); i++) { if(spaceoffset < array[i]) spaceoffset = array[i]; } - spaceoffset += g_Font[font_info]->getRenderWidth(" "); + spaceoffset += g_Font[font_info]->getRenderWidth(" "); average_bitrate_offset = spaceoffset; int box_width2 = box_width-(spaceoffset+xpos); @@ -552,7 +554,30 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) snprintf(buf, sizeof(buf), "%dx%d", xres, yres); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width2, buf, COL_MENUCONTENT_TEXT); - //audio rate +#if HAVE_COOL_HARDWARE + //Video SYSTEM + ypos += iheight; + snprintf(buf, sizeof(buf), "%s:", g_Locale->getText (LOCALE_STREAMINFO_VIDEOSYSTEM)); + g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_MENUCONTENT_TEXT); + cs_vs_format_t vsfn; + videoDecoder->GetVideoSystemFormatName(&vsfn); +#ifdef BOXMODEL_CS_HD1 + snprintf(buf, sizeof(buf), "HDMI: %s%s", vsfn.format, +#else + snprintf(buf, sizeof(buf), "HDMI: %s, Scart/Cinch: %s%s", vsfn.formatHD, vsfn.formatSD, +#endif + (g_settings.video_Mode == VIDEO_STD_AUTO)?" (AUTO)":""); + g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width2, buf, COL_MENUCONTENT_TEXT); +#endif + + //OSD RESOLUTION + ypos += iheight; + snprintf(buf, sizeof(buf), "%s:",g_Locale->getText (LOCALE_STREAMINFO_OSD_RESOLUTION)); + g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_MENUCONTENT_TEXT); + snprintf(buf, sizeof(buf), "%dx%d", frameBuffer->getScreenWidth(true), frameBuffer->getScreenHeight(true)); + g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width2, buf, COL_MENUCONTENT_TEXT); + + //Aspect Ratio ypos += iheight; snprintf(buf, sizeof(buf), "%s:",g_Locale->getText (LOCALE_STREAMINFO_ARATIO)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_MENUCONTENT_TEXT); @@ -619,7 +644,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) snprintf(buf, sizeof(buf), "%s:", g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_MENUCONTENT_TEXT); - int type, layer, freq, mode, lbitrate; + int type = 0, layer = 0, freq = 0, mode = 0, lbitrate = 0; /* audioDecoder->getAudioInfo() seems broken in libcoolstream2. ddmode is always 1 ("CH1/CH2"). diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index cee1d8f62..b155106fd 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -748,11 +749,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) else if (actionKey == "window"){ if (window == NULL){ window = new CComponentsWindow(); - window->setWindowCaption("|........HEADER........|", CTextBox::CENTER); + window->setWindowCaption("|........HEADER........|", CCHeaderTypes::CC_TITLE_CENTER); window->setDimensionsAll(50, 50, 500, 500); window->setWindowIcon(NEUTRINO_ICON_INFO); window->enableShadow(); - window->getFooterObject()->setCaption("|........FOOTER........|", CTextBox::CENTER); + window->getFooterObject()->setCaption("|........FOOTER........|", CCHeaderTypes::CC_TITLE_CENTER); CComponentsShapeCircle *c10 = new CComponentsShapeCircle(0, 0, 28); CComponentsShapeCircle *c11 = new CComponentsShapeCircle(0, CC_APPEND, 28); @@ -841,6 +842,55 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) } return res; } + else if (actionKey == "progress_window"){ + //classical + CProgressWindow pw0("Progress Single Test"); + pw0.paint(); + size_t max = 3; + for(size_t i = 0; i< max; i++){ + pw0.showStatus(i, max, to_string(i)); + sleep(1); + } + pw0.hide(); + + CProgressWindow pw1("Progress Local/Global Test"); + pw1.paint(); + for(size_t i = 0; i< max; i++){ + pw1.showGlobalStatus(i, max, to_string(i)); + for(size_t j = 0; j< max; j++){ + pw1.showLocalStatus(j, max, to_string(j)); + sleep(1); + } + } + pw1.hide(); + + //with signals + sigc::signal OnProgress0, OnProgress1; + CProgressWindow pw2("Progress Single Test -> single Signal", CCW_PERCENT 50, CCW_PERCENT 30, &OnProgress0); + pw2.paint(); + + for(size_t i = 0; i< max; i++){ + OnProgress0(i, max, to_string(i)); + sleep(1); + } + pw2.hide(); + + OnProgress0.clear(); + OnProgress1.clear(); + CProgressWindow pw3("Progress Single Test -> dub Signal", CCW_PERCENT 50, CCW_PERCENT 20, NULL, &OnProgress0, &OnProgress1); + pw3.paint(); + + for(size_t i = 0; i< max; i++){ + OnProgress1(i, max, to_string(i)); + for(size_t j = 0; j< max; j++){ + OnProgress0(j, max, to_string(j)); + sleep(1); + } + } + pw3.hide(); + + return menu_return::RETURN_REPAINT; + } else if (actionKey == "hintbox_test") { ShowHint("Testmenu: Hintbox popup test", "Test for HintBox,\nPlease press any key or wait some seconds! ...", 700, 10, NULL, NEUTRINO_ICON_HINT_IMAGEINFO, CComponentsHeader::CC_BTN_EXIT); @@ -986,7 +1036,7 @@ void CTestMenu::showRecords() recline->doPaintBg(true); recline->setColorBody(COL_INFOBAR_PLUS_0); recline->enableShadow(CC_SHADOW_ON, w_shadow); - recline->setCorner(CORNER_RADIUS_MID); + recline->setCorner(RADIUS_MID); recordsbox->addCCItem(recline); CComponentsPicture *iconf = new CComponentsPicture(OFFSET_INNER_MID, CC_CENTERED, NEUTRINO_ICON_REC, recline, CC_SHADOW_OFF, COL_RED, COL_INFOBAR_PLUS_0); @@ -1085,6 +1135,7 @@ int CTestMenu::showTestMenu() void CTestMenu::showCCTests(CMenuWidget *widget) { widget->addIntroItems(); + widget->addItem(new CMenuForwarder("Progress Window", true, NULL, this, "progress_window")); widget->addItem(new CMenuForwarder("Running Clock", true, NULL, this, "running_clock")); widget->addItem(new CMenuForwarder("Clock", true, NULL, this, "clock")); widget->addItem(new CMenuForwarder("Button", true, NULL, this, "button")); diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 05794c4fd..7ad470d1b 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -329,6 +329,11 @@ void CThemes::setTheme(CConfigFile &configfile) configfile.setInt32( "progressbar_timescale_green", t.progressbar_timescale_green); configfile.setInt32( "progressbar_timescale_yellow", t.progressbar_timescale_yellow); configfile.setInt32( "progressbar_timescale_invert", t.progressbar_timescale_invert); + + configfile.setInt32( "shadow_alpha", t.shadow_alpha ); + configfile.setInt32( "shadow_red", t.shadow_red ); + configfile.setInt32( "shadow_green", t.shadow_green ); + configfile.setInt32( "shadow_blue", t.shadow_blue ); } void CThemes::getTheme(CConfigFile &configfile) @@ -428,6 +433,11 @@ void CThemes::getTheme(CConfigFile &configfile) t.progressbar_timescale_green = configfile.getInt32("progressbar_timescale_green", 100); t.progressbar_timescale_yellow = configfile.getInt32("progressbar_timescale_yellow", 70); t.progressbar_timescale_invert = configfile.getInt32("progressbar_timescale_invert", 0); + + t.shadow_alpha = configfile.getInt32( "shadow_alpha", 0 ); + t.shadow_red = configfile.getInt32( "shadow_red", 8 ); + t.shadow_green = configfile.getInt32( "shadow_green", 8); + t.shadow_blue = configfile.getInt32( "shadow_blue", 8 ); } void CThemes::move_userDir() diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 13caaf993..9b6a2f7c9 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -272,11 +272,14 @@ CTimerList::CTimerList() visible = false; x = y = 0; width = height = 0; - fheight = theight = 0; - footerHeight = 0; + header_height = 0; + font_height = 0; + item_height = 0; + footer_height = 0; selected = 0; liststart = 0; listmaxshow = 0; + header = NULL; Timer = new CTimerdClient(); timerNew_message = ""; timerNew_pluginName = ""; @@ -439,7 +442,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "send_remotetimer") == 0) && RemoteBoxChanExists(timerlist[selected].channel_id)) { - int pre,post; + int pre = 0,post = 0; Timer->getRecordingSafety(pre,post); CHTTPTool httpTool; std::string r_url; @@ -673,27 +676,23 @@ void CTimerList::updateEvents(void) RemoteBoxTimerList (timerlist); sort(timerlist.begin(), timerlist.end()); - theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - //get footerHeight from paintButtons - footerHeight = ::paintButtons(TimerListButtons, TimerListButtonsCount, 0, 0, 0, 0, 0, false); + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + font_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + item_height = 2*font_height + 1; // + 1 for separationline + footer_height = header_height; - //width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20); - width = frameBuffer->getScreenWidth()*0.9; - height = frameBuffer->getScreenHeight() - (2*theight); // max height - - listmaxshow = (height-theight)/(fheight*2); - height = theight+listmaxshow*fheight*2+footerHeight; // recalc height + width = frameBuffer->getScreenWidth()/100 * 90; + height = frameBuffer->getScreenHeight(); + listmaxshow = (height - header_height - footer_height - OFFSET_SHADOW) / item_height; if (timerlist.size() < listmaxshow) - { - listmaxshow=timerlist.size(); - height = theight+listmaxshow*fheight*2+footerHeight; // recalc height - } + listmaxshow = timerlist.size(); + + height = header_height + item_height*listmaxshow + footer_height + OFFSET_SHADOW; // recalc height if (!timerlist.empty() && selected == (int)timerlist.size()) { - selected=timerlist.size()-1; + selected = timerlist.size() - 1; liststart = (selected/listmaxshow)*listmaxshow; } @@ -842,7 +841,8 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) rtimer.stopTime = (time_t) atoll(remotetimers[i]["stop"][0].get("digits","").asString().c_str()); rtimer.epgID = (event_id_t) atoi(remotetimers[i].get("epg_id","").asString()); sscanf(remotetimers[i].get("channel_id","").asString().c_str(), SCANF_CHANNEL_ID_TYPE, &rtimer.channel_id); - strncpy(rtimer.epgTitle,remotetimers[i].get("title","").asString().c_str(),51); + strncpy(rtimer.epgTitle,remotetimers[i].get("title","").asString().c_str(),sizeof(rtimer.epgTitle)); + rtimer.epgTitle[sizeof(rtimer.epgTitle) - 1] = 0; if (remotetimers[i]["audio"].get("apids_conf","").asString() == "true") rtimer.apids = TIMERD_APIDS_CONF; //printf("[remotetimer] r-timer:%s - %s\n", remotetimers[i].get("channel_id","").asString().c_str(), remotetimers[i].get("title","").asString().c_str()); @@ -1085,6 +1085,12 @@ void CTimerList::hide() { if (visible) { + if (header) + { + header->kill(); + delete header; + header = NULL; + } frameBuffer->paintBackgroundBoxRel(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW); visible = false; } @@ -1130,12 +1136,12 @@ bool CTimerList::RemoteBoxSetup() void CTimerList::paintItem(int pos) { - int ypos = y+ theight+ pos*fheight*2; + int ypos = y + header_height + pos*item_height; - int real_width=width; + int real_width = width; if (timerlist.size() > listmaxshow) { - real_width-=15; //scrollbar + real_width -= SCROLLBAR_WIDTH; } unsigned int currpos = liststart + pos; @@ -1154,43 +1160,52 @@ void CTimerList::paintItem(int pos) i_radius = RADIUS_LARGE; if (i_radius) - frameBuffer->paintBoxRel(x, ypos, real_width, 2*fheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintBoxRel(x, ypos, real_width, 2*fheight, bgcolor, i_radius); + frameBuffer->paintBoxRel(x, ypos, real_width, item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, ypos, real_width, item_height, bgcolor, i_radius); + // separationline + frameBuffer->paintHLineRel(x, real_width, ypos + item_height - 1, (pos + 1 == (int) listmaxshow) ? bgcolor : COL_MENUCONTENTDARK_PLUS_0); //shadow - frameBuffer->paintBoxRel(x + width, ypos, OFFSET_SHADOW, 2*fheight, COL_SHADOW_PLUS_0); + frameBuffer->paintBoxRel(x + width, ypos + OFFSET_SHADOW, OFFSET_SHADOW, item_height, COL_SHADOW_PLUS_0); + + int line1_y = ypos + 1*font_height; + int line2_y = ypos + 2*font_height; + + int digit_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth(); + int time_width = 8*digit_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(".. :"); // keep in sync with strftime-lines below if (currpos < timerlist.size()) { CTimerd::responseGetTimer & timer = timerlist[currpos]; char zAlarmTime[25] = {0}; struct tm *alarmTime = localtime(&(timer.alarmTime)); - strftime(zAlarmTime,20,"%d.%m. %H:%M",alarmTime); + strftime(zAlarmTime, 20, "%d.%m. %H:%M", alarmTime); char zStopTime[25] = {0}; struct tm *stopTime = localtime(&(timer.stopTime)); - strftime(zStopTime,20,"%d.%m. %H:%M",stopTime); - int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth(); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10,ypos+fheight, fw*12, zAlarmTime, color, fheight); - if (timer.stopTime != 0) - { - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10,ypos+2*fheight, fw*12, zStopTime, color, fheight); - } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13,ypos+fheight, (real_width-fw*13)/2-5, convertTimerRepeat2String(timer.eventRepeat), color, fheight); + strftime(zStopTime, 20, "%d.%m. %H:%M", stopTime); + // paint start/stop times + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID, line1_y, time_width, zAlarmTime, color, font_height); + if (timer.stopTime != 0) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID, line2_y, time_width, zStopTime, color, font_height); + + // paint timer-type + std::string t_type = (timer.eventType == CTimerd::TIMER_REMOTEBOX) ? std::string(convertTimerType2String(timer.eventType)) + " (" + std::string(timer.remotebox_name) + ")" : convertTimerType2String(timer.eventType); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID + time_width + OFFSET_INNER_MID, line1_y, real_width - time_width - 3*OFFSET_INNER_MID, t_type, color, font_height); + + // paint repeat-type/count + std::string t_repeat = convertTimerRepeat2String(timer.eventRepeat); if (timer.eventRepeat != CTimerd::TIMERREPEAT_ONCE) { - char srepeatcount[25] = {0}; if (timer.repeatCount == 0) - { - // Unicode 8734 (hex: 221E) not available in all fonts - //sprintf(srepeatcount,"∞"); - sprintf(srepeatcount,"00"); - } + t_repeat += ", oo"; // Unicode 8734 (hex: 221E) not available in all fonts else - sprintf(srepeatcount,"%ux",timer.repeatCount); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*23)/2,ypos+fheight, (real_width-fw*13)/2-5, srepeatcount, color, fheight); + t_repeat += ", " + to_string(timer.repeatCount) + "x"; } - std::string t_type = (timer.eventType == CTimerd::TIMER_REMOTEBOX) ? std::string(convertTimerType2String(timer.eventType)) + " (" + std::string(timer.remotebox_name) + ")" : convertTimerType2String(timer.eventType); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*13)/2,ypos+fheight, (real_width-fw*13)/2-5, t_type, color, fheight); + int t_repeat_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(t_repeat); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + real_width - OFFSET_INNER_MID - t_repeat_width, line1_y, t_repeat_width, t_repeat, color, font_height); + + int icon_w, icon_h; + frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); // paint rec icon when recording in progress if ((timer.eventType == CTimerd::TIMER_RECORD) && (CRecordManager::getInstance()->RecordingStatus(timer.channel_id))) @@ -1200,23 +1215,14 @@ void CTimerList::paintItem(int pos) recinfo.eventID = timer.eventID; if (CRecordManager::getInstance()->IsRecording(&recinfo)) { - int icol_w, icol_h; - frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icol_w, &icol_h); - if ((icol_w > 0) && (icol_h > 0)) - { - frameBuffer->paintIcon(NEUTRINO_ICON_REC, (x + real_width) - (icol_w + 8), ypos, 2*fheight); - } + if (icon_w && icon_h) + frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + real_width - OFFSET_INNER_MID - icon_w, line1_y, font_height); } } - - if ((timer.eventType == CTimerd::TIMER_REMOTEBOX) && timer.eventState == CTimerd::TIMERSTATE_ISRUNNING) + else if ((timer.eventType == CTimerd::TIMER_REMOTEBOX) && timer.eventState == CTimerd::TIMERSTATE_ISRUNNING) { - int icol_w, icol_h; - frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icol_w, &icol_h); - if ((icol_w > 0) && (icol_h > 0)) - { - frameBuffer->paintIcon(NEUTRINO_ICON_REC, (x + real_width) - (icol_w + 8), ypos, 2*fheight); - } + if (icon_w && icon_h) + frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + real_width - OFFSET_INNER_MID - icon_w, line1_y, font_height); } std::string zAddData(""); @@ -1341,46 +1347,47 @@ void CTimerList::paintItem(int pos) default: {} } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13,ypos+2*fheight, real_width-(fw*13+5), zAddData, color, fheight); + + // paint timer-name + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + OFFSET_INNER_MID + time_width + OFFSET_INNER_MID, line2_y, real_width - time_width - 3*OFFSET_INNER_MID, zAddData, color, font_height); + // LCD Display if (currpos == (unsigned) selected) { - std::string line1 = convertTimerType2String(timer.eventType); // UTF-8 - //std::string line2 = zAlarmTime; + std::string line1 = convertTimerType2String(timer.eventType); switch (timer.eventType) { - case CTimerd::TIMER_RECORD : - // line2+= " -"; - // line2+= zStopTime+6; - //case CTimerd::TIMER_NEXTPROGRAM : - case CTimerd::TIMER_ZAPTO : - { - line1 += ' '; - line1 += convertChannelId2String(timer.channel_id); // UTF-8 + case CTimerd::TIMER_RECORD : + case CTimerd::TIMER_ZAPTO : + { + line1 += ' '; + line1 += convertChannelId2String(timer.channel_id); + break; + } + case CTimerd::TIMER_STANDBY : + { + if (timer.standby_on) + line1 += " ON"; + else + line1 += " OFF"; + break; + } + default: + ; } - break; - case CTimerd::TIMER_STANDBY : - { - if (timer.standby_on) - line1+=" ON"; - else - line1+=" OFF"; - } - break; - default: - ; - } - CVFD::getInstance()->showMenuText(0, line1.c_str(), -1, true); // UTF-8 - //CVFD::getInstance()->showMenuText(1, line2.c_str(), -1, true); // UTF-8 + CVFD::getInstance()->showMenuText(0, line1.c_str(), -1, true); } } } void CTimerList::paintHead() { - CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER, CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT, NULL, CC_SHADOW_ON); - header.enableClock(true, "%d.%m.%Y %H:%M"); - header.paint(CC_SAVE_SCREEN_NO); + if (header == NULL) + { + header = new CComponentsHeader(x, y, width, header_height, LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER, CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT, NULL, CC_SHADOW_ON); + header->enableClock(true, " %d.%m.%Y - %H:%M ", NULL, false); + } + header->paint(CC_SAVE_SCREEN_NO); } void CTimerList::paintFoot() @@ -1390,24 +1397,25 @@ void CTimerList::paintFoot() CTimerd::responseGetTimer* timer=&timerlist[selected]; if (timer != NULL) { - //replace info button with dummy if timer is not type REC or ZAP + //replace info button with dummy if timer is not type REC or ZAP if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_REMOTEBOX || timer->eventType == CTimerd::TIMER_ZAPTO) TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_INFO_SMALL; else TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; } } - //shadow - frameBuffer->paintBoxRel(x + OFFSET_SHADOW, y + height - footerHeight, width, footerHeight + OFFSET_SHADOW, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); int c = TimerListButtonsCount; if (g_settings.timer_remotebox_ip.size() == 0) c--; // reduce play button + CComponentsFooter footer; + footer.enableShadow(CC_SHADOW_ON, -1, true); + if (timerlist.empty()) - ::paintButtons(x, y + height - footerHeight, width, 2, &(TimerListButtons[1]), width); + footer.paintButtons(x, y + height - OFFSET_SHADOW - footer_height, width, footer_height, 2, &(TimerListButtons[1])); else - ::paintButtons(x, y + height - footerHeight, width, c, TimerListButtons, width); + footer.paintButtons(x, y + height - OFFSET_SHADOW - footer_height, width, footer_height, c, TimerListButtons); } void CTimerList::paint() @@ -1426,15 +1434,10 @@ void CTimerList::paint() if (timerlist.size()>listmaxshow) { - int ypos = y+ theight; - int sb = 2*fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - unsigned int tmp_max = listmaxshow; - if (!tmp_max) - tmp_max = 1; - int sbc = ((timerlist.size()- 1)/ tmp_max)+ 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ page_nr * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0, RADIUS_SMALL); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, timerlist.size(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + header_height, SCROLLBAR_WIDTH, item_height*listmaxshow, total_pages, current_page); } paintFoot(); @@ -1816,7 +1819,7 @@ int CTimerList::newTimer() bool CTimerList::askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTime, char * remotebox_name) { CTimerd::TimerList overlappingTimers; - int pre,post; + int pre = 0,post = 0; Timer->getRecordingSafety(pre,post); for (CTimerd::TimerList::iterator it = timerlist.begin(); it != timerlist.end();++it) diff --git a/src/gui/timerlist.h b/src/gui/timerlist.h index d58b0a8a9..e8a30af1f 100644 --- a/src/gui/timerlist.h +++ b/src/gui/timerlist.h @@ -51,13 +51,15 @@ class CTimerList : public CMenuTarget, public CListHelpers int y; int width; int height; - int fheight; // fontheight content - int theight; // fontheight titel - int footerHeight; + int font_height; + int item_height; + int header_height; + int footer_height; int selected; int liststart; unsigned int listmaxshow; bool visible; + CComponentsHeader *header; int httpConnectTimeout; CTimerdClient *Timer; diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 5871a3ea2..1f4c67b17 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -93,7 +93,7 @@ void CUpnpBrowserGui::Init() topbox.setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0, COL_MENUHEAD_TEXT); topbox.setTextFont(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]); topbox.enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_SHADOW_PLUS_0, g_settings.theme.menu_Head_gradient_direction); - topbox.enableShadow(CC_SHADOW_ON, -1, true); + topbox.enableShadow(CC_SHADOW_ON); infobox.enableFrame(true, 2); infobox.setCorner(RADIUS_LARGE); @@ -101,7 +101,7 @@ void CUpnpBrowserGui::Init() infobox.setTextColor(COL_MENUCONTENTDARK_TEXT); infobox.setTextFont(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]); infobox.enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_SHADOW_PLUS_0, g_settings.theme.menu_Hint_gradient_direction); - infobox.enableShadow(CC_SHADOW_ON, -1, true); + infobox.enableShadow(CC_SHADOW_ON); timebox.enableFrame(true, 2); timebox.setCorner(RADIUS_LARGE); @@ -109,7 +109,7 @@ void CUpnpBrowserGui::Init() timebox.setTextColor(infobox.getTextColor()); timebox.setTextFont(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]); timebox.enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_SHADOW_PLUS_0, g_settings.theme.menu_Hint_gradient_direction); - timebox.enableShadow(CC_SHADOW_ON, -1, true); + timebox.enableShadow(CC_SHADOW_ON); m_width = m_frameBuffer->getScreenWidthRel(); m_height = m_frameBuffer->getScreenHeightRel(); @@ -193,7 +193,7 @@ int CUpnpBrowserGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/ stopAudio(); m_frameBuffer->stopFrame(); - m_frameBuffer->Clear(); + topbox.kill(); CZapit::getInstance()->EnablePlayback(true); CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE , m_LastMode); @@ -731,7 +731,7 @@ bool CUpnpBrowserGui::selectItem(std::string id) if (!getItems(id, liststart, entries, total)) return endall; - while (loop) { + while (loop && entries!=NULL) { updateTimes(); updateMode(); @@ -916,7 +916,6 @@ bool CUpnpBrowserGui::selectItem(std::string id) delete entries; timeout = 0; - m_frameBuffer->Clear(); return endall; } @@ -941,8 +940,9 @@ void CUpnpBrowserGui::paintDeviceInfo() tmp += m_devices[m_selecteddevice].modelurl; topbox.setDimensionsAll(m_x, m_y, m_width, m_topbox_height); - topbox.setText(tmp, CTextBox::AUTO_WIDTH); - topbox.paint0(); + topbox.setCorner(RADIUS_LARGE); + if (topbox.setText(tmp, CTextBox::AUTO_WIDTH | CTextBox::CENTER)) + topbox.paint0(); } void CUpnpBrowserGui::paintDevice(unsigned int _pos) @@ -965,8 +965,8 @@ void CUpnpBrowserGui::paintDevice(unsigned int _pos) } if (i_radius) - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_item_height, COL_MENUCONTENT_PLUS_0); - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_item_height, bgcolor, i_radius); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, COL_MENUCONTENT_PLUS_0); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, bgcolor, i_radius); if (pos >= m_devices.size()) return; @@ -975,8 +975,8 @@ void CUpnpBrowserGui::paintDevice(unsigned int _pos) std::string name = m_devices[pos].friendlyname; int w = g_Font[font_item]->getRenderWidth(name); - g_Font[font_item]->RenderString(m_x + OFFSET_INNER_MID, ypos + m_item_height, m_width - 15 - OFFSET_INNER_MID - w, num, color, m_item_height); - g_Font[font_item]->RenderString(m_x + m_width - 15 - OFFSET_INNER_MID - w, ypos + m_item_height, w, name, color, m_item_height); + g_Font[font_item]->RenderString(m_x + OFFSET_INNER_MID, ypos + m_item_height, m_width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, num, color, m_item_height); + g_Font[font_item]->RenderString(m_x + m_width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, ypos + m_item_height, w, name, color, m_item_height); } void CUpnpBrowserGui::paintDevices() @@ -985,33 +985,27 @@ void CUpnpBrowserGui::paintDevices() CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "Select UPnP Device"); // Head - CComponentsHeaderLocalized header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP); + CComponentsHeader header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP); header.enableShadow( CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true); if (CNeutrinoApp::getInstance()->isMuted()) //TODO: consider mute mode on runtime header.addContextButton(NEUTRINO_ICON_BUTTON_MUTE_SMALL); else header.removeContextButtons(); - //header.enableShadow(); + header.setCorner(RADIUS_LARGE, CORNER_TOP); header.paint(CC_SAVE_SCREEN_NO); // Items for (unsigned int count=0; countpaintBoxRel(m_x + m_width - 15, m_item_y, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - unsigned int tmp_max = m_listmaxshow; - if(!tmp_max) - tmp_max = 1; - int sbc = ((m_devices.size() - 1) / tmp_max) + 1; - int sbs = ((m_selecteddevice) / tmp_max); - - m_frameBuffer->paintBoxRel(m_x + m_width - 13, m_item_y + 2 + sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); - - //shadow - m_frameBuffer->paintBoxRel(m_x + m_width, m_item_y + OFFSET_SHADOW, OFFSET_SHADOW, sb, COL_SHADOW_PLUS_0); + // scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, m_devices.size(), m_listmaxshow, m_selecteddevice); + paintScrollBar(m_x + m_width - SCROLLBAR_WIDTH, m_item_y, SCROLLBAR_WIDTH, m_item_height*m_listmaxshow, total_pages, current_page, CC_SHADOW_ON); // Foot + footer.setCorner(RADIUS_LARGE, CORNER_BOTTOM); footer.paintButtons(m_x, m_footer_y, m_width, m_footer_height, 1, &RescanButton, m_width/2); paintItem2DetailsLine(-1); // clear it @@ -1033,8 +1027,8 @@ void CUpnpBrowserGui::paintItem(std::vector *entries, unsigned int po i_radius = RADIUS_LARGE; if (i_radius) - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_item_height, COL_MENUCONTENT_PLUS_0); - m_frameBuffer->paintBoxRel(m_x, ypos, m_width - 15, m_item_height, bgcolor, i_radius); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, COL_MENUCONTENT_PLUS_0); + m_frameBuffer->paintBoxRel(m_x, ypos, m_width - SCROLLBAR_WIDTH, m_item_height, bgcolor, i_radius); if (pos >= (*entries).size()) return; @@ -1086,8 +1080,8 @@ void CUpnpBrowserGui::paintItem(std::vector *entries, unsigned int po icon_o = icon_w + OFFSET_INNER_MID; m_frameBuffer->paintIcon(fileicon, m_x + OFFSET_INNER_MID, ypos + (m_item_height - icon_h)/2); } - g_Font[font_item]->RenderString(m_x + OFFSET_INNER_MID + icon_o, ypos + m_item_height, m_width - 15 - OFFSET_INNER_MID - w, name, color, m_item_height); - g_Font[font_item]->RenderString(m_x + m_width - 15 - OFFSET_INNER_MID - w, ypos + m_item_height, w, info, color, m_item_height); + g_Font[font_item]->RenderString(m_x + OFFSET_INNER_MID + icon_o, ypos + m_item_height, m_width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, name, color, m_item_height); + g_Font[font_item]->RenderString(m_x + m_width - SCROLLBAR_WIDTH - OFFSET_INNER_MID - w, ypos + m_item_height, w, info, color, m_item_height); } void CUpnpBrowserGui::paintItemInfo(UPnPEntry *entry) @@ -1148,8 +1142,9 @@ void CUpnpBrowserGui::paintItemInfo(UPnPEntry *entry) } } - topbox.setText(tmp, CTextBox::AUTO_WIDTH); - topbox.paint0(); + topbox.setCorner(RADIUS_LARGE); + if (topbox.setText(tmp, CTextBox::AUTO_WIDTH | CTextBox::CENTER)) + topbox.paint0(); } void CUpnpBrowserGui::paintItems(std::vector *entry, unsigned int selected, unsigned int max, unsigned int offset) @@ -1175,16 +1170,11 @@ void CUpnpBrowserGui::paintItems(std::vector *entry, unsigned int sel for (unsigned int count=0; countpaintBoxRel(m_x + m_width - 15, m_item_y, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - unsigned int tmp = m_listmaxshow ? m_listmaxshow : 1;//avoid division by zero - int sbc = ((max + offset - 1) / tmp) + 1; - int sbs = ((selected + offset) / tmp); - - int sbh = 0; - if ((sbc > 0) && (sbc > sb-4)) - sbh = 2; - m_frameBuffer->paintBoxRel(m_x + m_width - 13, m_item_y + 2 + sbs*((sb-4)/sbc+sbh), 11, (sb-4)/sbc + sbh, COL_SCROLLBAR_ACTIVE_PLUS_0); + //scrollbar + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, max + offset, m_listmaxshow, selected + offset); + paintScrollBar(m_x + m_width - SCROLLBAR_WIDTH, m_item_y, SCROLLBAR_WIDTH, m_item_height*m_listmaxshow, total_pages, current_page, CC_SHADOW_ON); // Foot buttons size_t numbuttons = sizeof(BrowseButtons)/sizeof(BrowseButtons[0]); @@ -1197,7 +1187,9 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing) char tmp_time[] = "000:00"; int timebox_width = timebox.getFont()->getRenderWidth(tmp_time) + OFFSET_INNER_MID*2; infobox.setDimensionsAll(m_x, m_infobox_y, m_width - OFFSET_SHADOW - OFFSET_INTER - timebox_width, m_infobox_height); + infobox.setCorner(RADIUS_LARGE); timebox.setDimensionsAll(m_x + m_width - timebox_width, infobox.getYPos(), timebox_width, m_infobox_height); + timebox.setCorner(RADIUS_LARGE); printf("paintDetails: use_playing %d shown %d\n", use_playing, m_playing_entry_is_shown); if ((!use_playing) && entry->isdir){ @@ -1212,8 +1204,8 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing) text = m_playing_entry.title; text += !m_playing_entry.artist.empty() ? " - " + m_playing_entry.artist : ""; text += "\n" + m_playing_entry.album; - infobox.setText(text, CTextBox::AUTO_WIDTH); - infobox.paint0(); + if (infobox.setText(text, CTextBox::AUTO_WIDTH)) + infobox.paint0(); } }else{ if (!entry) @@ -1222,8 +1214,8 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing) text = entry->title; text += !entry->artist.empty() ? " - " + entry->artist : ""; text += "\n" + entry->album; - infobox.setText(text, CTextBox::AUTO_WIDTH); - infobox.paint0(); + if (infobox.setText(text, CTextBox::AUTO_WIDTH)) + infobox.paint0(); } if (image) image->paint0(); @@ -1233,8 +1225,11 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing) void CUpnpBrowserGui::paintItem2DetailsLine(int pos) { - if (pos < 0) + if (pos < 0){ + if (dline) + dline->kill(); return; + } int xpos = m_x - DETAILSLINE_WIDTH; int ypos1 = m_item_y + pos*m_item_height; @@ -1316,10 +1311,10 @@ void CUpnpBrowserGui::showPicture(std::string name) void CUpnpBrowserGui::playVideo(std::string name, std::string url) { - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoMessages::mode_ts); - stopAudio(); + CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoMessages::mode_ts); + m_frameBuffer->stopFrame(); CMoviePlayerGui::getInstance().SetFile(name, url); CMoviePlayerGui::getInstance().exec(NULL, "upnp"); diff --git a/src/gui/vfd_setup.cpp b/src/gui/vfd_setup.cpp index d1ef2d2f0..782f054eb 100644 --- a/src/gui/vfd_setup.cpp +++ b/src/gui/vfd_setup.cpp @@ -127,12 +127,16 @@ int CVfdSetup::showSetup() vfds->addItem(mf); } - if (CVFD::getInstance()->has_lcd) { + if (g_info.hw_caps->can_set_display_brightness) + { //vfd brightness menu mf = new CMenuForwarder(LOCALE_LCDMENU_LCDCONTROLER, vfd_enabled, NULL, this, "brightness", CRCInput::RC_green); mf->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS_SETUP); vfds->addItem(mf); + } + if (CVFD::getInstance()->has_lcd) + { if (cs_get_revision() == 9) // Tank only { //backlight menu diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 06c27be48..6c9726e0d 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -517,7 +518,8 @@ void CVideoSettings::setVideoSettings() void CVideoSettings::setupVideoSystem(bool do_ask) { printf("[neutrino VideoSettings] %s setup videosystem...\n", __FUNCTION__); - videoDecoder->SetVideoSystem(g_settings.video_Mode); //FIXME + COsdHelpers::getInstance()->setVideoSystem(g_settings.video_Mode); //FIXME + COsdHelpers::getInstance()->changeOsdResolution(0, true, false); if (do_ask) { @@ -527,7 +529,8 @@ void CVideoSettings::setupVideoSystem(bool do_ask) if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_INFO) != CMsgBox::mbrYes) { g_settings.video_Mode = prev_video_mode; - videoDecoder->SetVideoSystem(g_settings.video_Mode); + COsdHelpers::getInstance()->setVideoSystem(g_settings.video_Mode); + COsdHelpers::getInstance()->changeOsdResolution(0, true, false); } else prev_video_mode = g_settings.video_Mode; @@ -714,7 +717,8 @@ void CVideoSettings::nextMode(void) else if(res == messages_return::cancel_info) { g_settings.video_Mode = VIDEOMENU_VIDEOMODE_OPTIONS[curmode].key; //CVFD::getInstance()->ShowText(text); - videoDecoder->SetVideoSystem(g_settings.video_Mode); + COsdHelpers::getInstance()->setVideoSystem(g_settings.video_Mode); + COsdHelpers::getInstance()->changeOsdResolution(0, true, false); //return; disp_cur = 1; } diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 9f9921ad6..6205ee322 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -53,7 +53,7 @@ void CVolumeBar::initVarVolumeBar() col_body = COL_MENUCONTENT_PLUS_0; corner_rad = CORNER_RADIUS_MID; vb_item_offset = OFFSET_INNER_SMALL; - height = g_settings.volume_size; //default height + height = CFrameBuffer::getInstance()->scale2Res(g_settings.volume_size); //assume volume value as pointer to global setting vb_vol = &g_settings.current_volume; @@ -91,8 +91,8 @@ void CVolumeBar::initVolumeBarSize() //vb_digit_w += corner_rad/2; //scale - vb_pbw = 200; - vb_pbh = height-4*vb_item_offset; + vb_pbw = CFrameBuffer::getInstance()->scale2Res(200); + vb_pbh = height-2*vb_item_offset; //result for width width = (vb_icon_w + vb_pbw + vb_digit_w) + 4*vb_item_offset + corner_rad/2; @@ -112,8 +112,6 @@ void CVolumeBar::initVolumeBarSize() mute_corrY = (height - mute_dy) / 2; cvh->setMuteIconCorrY(mute_corrY); - vb_pbh = height-8; - vb_pby = height/2-vb_pbh/2; } @@ -267,8 +265,8 @@ void CVolumeBar::paint(bool do_save_bg) CVolumeHelper::CVolumeHelper() { - h_spacer = 11; - v_spacer = 6; + h_spacer = OFFSET_INNER_MID; + v_spacer = OFFSET_INNER_SMALL; vb_font = NULL; clock_font = NULL; @@ -359,10 +357,10 @@ void CVolumeHelper::initVolBarSize() digit_width = 0; frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &icon_width, &icon_height); icon_height = max(icon_height, 16); // if no icon available - icon_height += 2; - icon_width += 8; + icon_height += OFFSET_INNER_MIN; + icon_width += OFFSET_INNER_MID; g_settings.volume_size = max(g_settings.volume_size, icon_height); - vol_height = g_settings.volume_size; + vol_height = CFrameBuffer::getInstance()->scale2Res(g_settings.volume_size); if (g_settings.volume_digits) { CNeutrinoFonts *cnf = CNeutrinoFonts::getInstance(); @@ -370,7 +368,7 @@ void CVolumeHelper::initVolBarSize() int tmp_h = vol_height; digit_width = 0; vb_font = cnf->getDynFont(digit_width, tmp_h, "100", CNeutrinoFonts::FONT_STYLE_REGULAR, CNeutrinoFonts::FONT_ID_VOLBAR); - digit_width += 6; + digit_width += OFFSET_INNER_SMALL; vol_height = max(vol_height, tmp_h); } } diff --git a/src/gui/widget/Makefile.am b/src/gui/widget/Makefile.am index 5da8d7ebe..838ba162f 100644 --- a/src/gui/widget/Makefile.am +++ b/src/gui/widget/Makefile.am @@ -27,6 +27,7 @@ libneutrino_gui_widget_a_SOURCES = \ menue.cpp \ mountchooser.cpp \ msgbox.cpp \ + navibar.cpp \ shellwindow.cpp \ stringinput.cpp \ stringinput_ext.cpp \ diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index 1c5049e6a..62e34b06c 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -103,8 +103,8 @@ int paintButtons( const button_label_ext * const content, int w_footer = footerwidth; int h_footer = 0; - int w_space = 10; //minimal space between buttons - int h_space = 4; //minimal space between caption and/or icon and border + int w_space = OFFSET_INNER_MID; //minimal space between buttons + int h_space = OFFSET_INNER_SMALL; //minimal space between caption and/or icon and border int x_icon = x_footer + w_space; int x_caption = 0; @@ -205,7 +205,7 @@ int paintButtons( const button_label_ext * const content, fprintf(stderr, "PB: sp %d mw %d w_t %d w_i %d w_s %d c_i %d\n", spacing, maxwidth, w_text, w_icons, w_space, count_items); #endif - if (fwidth[cnt - 1] == 0) /* divisor needs to be labels+1 unless rightmost icon has a label */ + if (cnt > 0 && fwidth[cnt - 1] == 0) /* divisor needs to be labels+1 unless rightmost icon has a label */ count_labels++; /* side effect: we don't try to divide by 0 :-) */ if (maximize) { @@ -312,8 +312,8 @@ int paintButtons( const int &x, int w_footer = footerwidth; int h_footer = 0; - int w_space = 10; //minimal space between buttons - int h_space = 4; //minimal space between caption and/or icon and border + int w_space = OFFSET_INNER_MID; //minimal space between buttons + int h_space = OFFSET_INNER_SMALL; //minimal space between caption and/or icon and border int x_icon = x_footer + w_space; int x_caption = 0; diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index fc8989efc..d4fd87b76 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -99,16 +99,18 @@ void Helpbox::addLine(const std::string& icon, const std::string& text, const in if (!text.empty()){ int x_text = w_picon + (picon ? OFFSET_INNER_MID : 0); CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, 0, text, text_mode, font); - txt->doPaintBg(false); - txt->forceTextPaint(); + if(txt){ + txt->doPaintBg(false); + txt->forceTextPaint(); #if 0 //"contrast agent", if you want to see where the text items are drawn. txt->setColorBody(COL_RED); #endif - int lines = txt->getCTextBoxObject()->getLines(); - txt_height = std::max(lines*font->getHeight(), h_line); - txt->setHeight(txt_height); + int lines = txt->getCTextBoxObject()->getLines(); + txt_height = std::max(lines*font->getHeight(), h_line); + txt->setHeight(txt_height); - line->addCCItem(txt); + line->addCCItem(txt); + } } if (txt_height > line->getHeight()) diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 45ef2b6ed..e0b6bfd4c 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -67,7 +67,7 @@ CHintBox::CHintBox( const neutrino_locale_t Caption, const char * const Picon, const int& header_buttons, const int& text_mode, - const int& indent): CComponentsWindow( 0, 0, width, + const int& indent): CComponentsWindow( 0, 0, Width, HINTBOX_MIN_HEIGHT, Caption, string(Icon == NULL ? "" : Icon), @@ -84,7 +84,7 @@ CHintBox::CHintBox( const char * const Caption, const char * const Picon, const int& header_buttons, const int& text_mode, - const int& indent):CComponentsWindow( 0, 0, width, + const int& indent):CComponentsWindow( 0, 0, Width, HINTBOX_MIN_HEIGHT, Caption, string(Icon == NULL ? "" : Icon), @@ -101,7 +101,7 @@ CHintBox::CHintBox( const neutrino_locale_t Caption, const char * const Picon, const int& header_buttons, const int& text_mode, - const int& indent):CComponentsWindow( 0, 0, width, + const int& indent):CComponentsWindow( 0, 0, Width, HINTBOX_MIN_HEIGHT, Caption, string(Icon == NULL ? "" : Icon), @@ -118,7 +118,7 @@ CHintBox::CHintBox( const char * const Caption, const char * const Picon, const int& header_buttons, const int& text_mode, - const int& indent):CComponentsWindow( 0, 0, width, + const int& indent):CComponentsWindow( 0, 0, Width, HINTBOX_MIN_HEIGHT, Caption, string(Icon == NULL ? "" : Icon), @@ -162,6 +162,8 @@ void CHintBox::init(const std::string& Text, const int& Width, const std::string if (!Text.empty()) addHintItem(Text, text_mode, Picon, COL_MENUCONTENT_TEXT, hb_font); + else + ReSize(); } CHintBox::~CHintBox() @@ -186,6 +188,7 @@ void CHintBox::enableTimeOutBar(bool enable) timeout_pb->setValues(timeout_pb->getValue()+1, 100*timeout); }else{ timeout_pb = new CProgressBar(); + timeout_pb->setType(CProgressBar::PB_TIMESCALE); timeout_pb->setDimensionsAll(ccw_body->getRealXPos(), ccw_body->getRealYPos(), ccw_body->getWidth(), TIMEOUT_BAR_HEIGHT); timeout_pb->setValues(0, 100*timeout); if (!timeout_pb_timer) { @@ -312,13 +315,8 @@ void CHintBox::addHintItem(const std::string& Text, const int& text_mode, const info_box->setPicture(Picon); info_box->doPaintBg(false); - /* recalculate new hintbox height */ + /* recalculate new hintbox dimensions and position*/ ReSize(); - - /* set hint box position general to center and refresh window */ - setCenterPos(CC_ALONG_X); - y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >> 2), - Refresh(); } void CHintBox::setMsgText(const std::string& Text, const uint& hint_id, const int& mode, Font* font_text, const fb_pixel_t& color_text, const int& style) @@ -350,6 +348,10 @@ void CHintBox::ReSize() h += item->getHeight(); } height = min(HINTBOX_MAX_HEIGHT, max(HINTBOX_MIN_HEIGHT, max(height,h))); + + /* set hint box position general to center and refresh window */ + setCenterPos(CC_ALONG_X); + y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >> 2), Refresh(); } diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index 187752286..9019228a6 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -32,14 +32,15 @@ #include -#define HINTBOX_MIN_WIDTH 320 -#define HINTBOX_MIN_HEIGHT 125 -#define HINTBOX_MAX_HEIGHT 520 +#define HINTBOX_MIN_WIDTH CFrameBuffer::getInstance()->scale2Res(320) +#define HINTBOX_MIN_HEIGHT CFrameBuffer::getInstance()->scale2Res(125) +#define HINTBOX_MAX_HEIGHT CFrameBuffer::getInstance()->scale2Res(520) + #define HINTBOX_DEFAULT_TIMEOUT g_settings.timing[SNeutrinoSettings::TIMING_POPUP_MESSAGES] #define NO_TIMEOUT 0 #define DEFAULT_TIMEOUT -1 //frame around hint container as indent -#define W_FRAME std::max(HINTBOX_MIN_WIDTH, HINTBOX_MIN_HEIGHT) * 2/100 +#define W_FRAME OFFSET_INNER_MID //frame color around hint/message box #define HINTBOX_DEFAULT_FRAME_COLOR COL_FRAME #define TIMEOUT_BAR_HEIGHT OFFSET_SHADOW/2 diff --git a/src/gui/widget/icons.h b/src/gui/widget/icons.h index cafb9b343..830ceb22b 100644 --- a/src/gui/widget/icons.h +++ b/src/gui/widget/icons.h @@ -91,8 +91,6 @@ #define NEUTRINO_ICON_EPGINFO "epginfo" #define NEUTRINO_ICON_ERROR "error" #define NEUTRINO_ICON_FEATURES "features" -#define NEUTRINO_ICON_FILE "file" -#define NEUTRINO_ICON_FOLDER "folder" #define NEUTRINO_ICON_GAMES "games" #define NEUTRINO_ICON_INFO "information" #define NEUTRINO_ICON_IMPORTANT "important" @@ -101,7 +99,6 @@ #define NEUTRINO_ICON_LOCK_PASSIVE "lock_passive" #define NEUTRINO_ICON_HIDDEN "hidden" #define NEUTRINO_ICON_MOUNTED "mounted" -#define NEUTRINO_ICON_MP3 "mp3" #define NEUTRINO_ICON_MULTIMEDIA "multimedia" #define NEUTRINO_ICON_MOVIEPLAYER "icon_movieplayer" #define NEUTRINO_ICON_NKPLAY "icon_nkplay" @@ -182,6 +179,7 @@ #define NEUTRINO_ICON_STAR_ON "star-on" #define NEUTRINO_ICON_STAR_OFF "star-off" #define NEUTRINO_ICON_TMDB "tmdb" +#define NEUTRINO_ICON_PICTUREVIEWER "pictureviewer" #define DUMMY_ICON "dummy" @@ -259,6 +257,13 @@ #define NEUTRINO_ICON_HINT_RESTORE "hint_restore" #define NEUTRINO_ICON_HINT_FACTORY "hint_factory" +/* filetypes */ +#define NEUTRINO_ICON_FILE "file" +#define NEUTRINO_ICON_FOLDER "folder" +#define NEUTRINO_ICON_MOVIE "movie" +#define NEUTRINO_ICON_MP3 "mp3" +#define NEUTRINO_ICON_PICTURE "picture" + /* plugins */ #define NEUTRINO_ICON_HINT_PLUGIN "hint_plugin" diff --git a/src/gui/widget/listbox.cpp b/src/gui/widget/listbox.cpp index e836412fc..ad7c26fb9 100644 --- a/src/gui/widget/listbox.cpp +++ b/src/gui/widget/listbox.cpp @@ -67,16 +67,10 @@ void CListBox::paint() paintItem(count); } - int ypos = y+ theight; - int sb = fheight* listmaxshow; - frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_SCROLLBAR_PASSIVE_PLUS_0); - - int sbc= ((getItemCount()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); - if (sbc < 1) - sbc = 1; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs * (sb-4)/sbc, 11, (sb-4)/sbc, COL_SCROLLBAR_ACTIVE_PLUS_0); + int total_pages; + int current_page; + getScrollBarData(&total_pages, ¤t_page, getItemCount(), listmaxshow, selected); + paintScrollBar(x + width - SCROLLBAR_WIDTH, y + theight, SCROLLBAR_WIDTH, fheight*listmaxshow, total_pages, current_page); } void CListBox::paintHead() @@ -109,8 +103,9 @@ void CListBox::hide() frameBuffer->paintBackgroundBoxRel(x,y, width,height+ButtonHeight); } -unsigned int CListBox::getItemCount() +unsigned int CListBox::getItemCount() { + // WTF? Why a fixed value? return 10; } @@ -128,8 +123,8 @@ void CListBox::paintItem(unsigned int /*itemNr*/, int paintNr, bool pselected) getItemColors(color, bgcolor, pselected); - frameBuffer->paintBoxRel(x,ypos, width- 15, getItemHeight(), bgcolor); - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 10, ypos+ fheight, width-20, "demo", color); + frameBuffer->paintBoxRel(x,ypos, width - SCROLLBAR_WIDTH, getItemHeight(), bgcolor); + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_MID, ypos + fheight, width - SCROLLBAR_WIDTH - 2*OFFSET_INNER_MID, "demo", color); } void CListBox::updateSelection(unsigned int newpos) diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 3d17d46fb..de9a1bf1b 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -54,15 +54,14 @@ #include #include #include "listframe.h" +#include #include #include -#define SCROLL_FRAME_WIDTH 10 +#define MAX_WINDOW_WIDTH (frameBuffer ? frameBuffer->getScreenWidth() - 40:0) +#define MAX_WINDOW_HEIGHT (frameBuffer ? frameBuffer->getScreenHeight() - 40:0) -#define MAX_WINDOW_WIDTH (frameBuffer->getScreenWidth() - 40) -#define MAX_WINDOW_HEIGHT (frameBuffer->getScreenHeight() - 40) - -#define MIN_WINDOW_WIDTH (frameBuffer->getScreenWidth() >> 1) +#define MIN_WINDOW_WIDTH (frameBuffer ? frameBuffer->getScreenWidth() >> 1:0) #define MIN_WINDOW_HEIGHT 40 #define TITLE_BACKGROUND_COLOR COL_MENUHEAD_PLUS_0 @@ -207,7 +206,7 @@ void CListFrame::reSizeMainFrameWidth(int textWidth) int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*OFFSET_INNER_MID; - if( iNewWindowWidth > m_nMaxWidth) iNewWindowWidth = m_nMaxWidth; + if(iNewWindowWidth > m_nMaxWidth) iNewWindowWidth = m_nMaxWidth; if((unsigned int) iNewWindowWidth < MIN_WINDOW_WIDTH) iNewWindowWidth = MIN_WINDOW_WIDTH; m_cFrame.iWidth = iNewWindowWidth; @@ -270,9 +269,9 @@ void CListFrame::initFramesRel(void) if(m_nMode & SCROLL) { - m_cFrameScrollRel.iX = m_cFrame.iWidth - SCROLL_FRAME_WIDTH; + m_cFrameScrollRel.iX = m_cFrame.iWidth - SCROLLBAR_WIDTH; m_cFrameScrollRel.iY = m_cFrameTitleRel.iHeight; - m_cFrameScrollRel.iWidth = SCROLL_FRAME_WIDTH; + m_cFrameScrollRel.iWidth = SCROLLBAR_WIDTH; m_cFrameScrollRel.iHeight = m_cFrameHeaderListRel.iHeight + m_cFrameListRel.iHeight - m_nBgRadius; } else @@ -384,13 +383,9 @@ void CListFrame::refreshScroll(void) if (m_nNrOfPages > 1) { - frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, - m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, COL_SCROLLBAR_PASSIVE_PLUS_0, RADIUS_MIN); - unsigned int marker_size = (m_cFrameScrollRel.iHeight - 2*OFFSET_INNER_MIN) / m_nNrOfPages; - frameBuffer->paintBoxRel(m_cFrameScrollRel.iX + OFFSET_INNER_MIN+m_cFrame.iX, - m_cFrameScrollRel.iY + OFFSET_INNER_MIN + m_nCurrentPage * marker_size +m_cFrame.iY, - m_cFrameScrollRel.iWidth - (2*OFFSET_INNER_MIN), - marker_size, COL_SCROLLBAR_ACTIVE_PLUS_0, RADIUS_MIN); + paintScrollBar(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, + m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, + m_nNrOfPages, m_nCurrentPage); } } diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 7b2178e5f..123d506aa 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -51,7 +51,7 @@ CMenuSeparator CGenericMenuSeparator(0, NONEXISTANT_LOCALE, true); CMenuSeparator CGenericMenuSeparatorLine(CMenuSeparator::LINE, NONEXISTANT_LOCALE, true); CMenuForwarder CGenericMenuBack(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT, NULL, true); CMenuForwarder CGenericMenuCancel(LOCALE_MENU_CANCEL, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true); -CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true); +CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_RIGHT, NULL, true); CMenuSeparator * const GenericMenuSeparator = &CGenericMenuSeparator; CMenuSeparator * const GenericMenuSeparatorLine = &CGenericMenuSeparatorLine; CMenuForwarder * const GenericMenuBack = &CGenericMenuBack; @@ -78,7 +78,7 @@ CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const I x = -1; used = false; - icon_frame_w = 10; + icon_frame_w = OFFSET_INNER_MID; hint = NONEXISTANT_LOCALE; name = NONEXISTANT_LOCALE; nameString = ""; @@ -249,7 +249,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text stringstartposOption = name_start_x; if (right_bgcol) { if (!*right_text) - stringstartposOption -= 60; + stringstartposOption -= CFrameBuffer::getInstance()->scale2Res(60); fb_pixel_t right_frame_col, right_bg_col; if (active) { right_bg_col = right_bgcol; @@ -270,7 +270,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text } } if (desc_text && *desc_text) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->RenderString(name_start_x + 10, y+ item_height, _dx- 10 - (name_start_x - x), desc_text, item_color); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->RenderString(name_start_x + OFFSET_INNER_MID, y+ item_height, _dx- OFFSET_INNER_MID - (name_start_x - x), desc_text, item_color); } void CMenuItem::prepareItem(const bool select_mode, const int &item_height) @@ -296,7 +296,7 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, } int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); - int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - 10; + int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - OFFSET_INNER_MID; if(maxspace < slider_lenght) return ; @@ -379,7 +379,7 @@ void CMenuItem::paintItemButton(const bool select_mode, int item_height, const c if (icon_w>0 && icon_h>0) { - frameBuffer->paintIcon(iconName_Info_right, dx + icon_start_x - (icon_w + 20), y+ ((item_height/2- icon_h/2)) ); + frameBuffer->paintIcon(iconName_Info_right, dx + icon_start_x - (icon_w + 2*OFFSET_INNER_MID), y+ ((item_height/2- icon_h/2)) ); } } } @@ -600,6 +600,7 @@ void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, c selected = (widget_index == NO_WIDGET_ID ? preselected : mglobal->v_selected[widget_index]); //dimension + mwidth_save = mwidth; min_width = 0; width = 0; /* is set in paint() */ if (mwidth > 100){ @@ -1095,6 +1096,13 @@ void CMenuWidget::checkHints() void CMenuWidget::calcSize() { + // recalc min_width + min_width = 0; + int mwidth = std::min(mwidth_save, 100); + min_width = frameBuffer->getScreenWidth(true) * mwidth / 100; + if (min_width > (int)frameBuffer->getScreenWidth()) + min_width = frameBuffer->getScreenWidth(); + width = min_width; int wi, hi; @@ -1103,35 +1111,34 @@ void CMenuWidget::calcSize() if (items[i]->iconName_Info_right) { frameBuffer->getIconSize(items[i]->iconName_Info_right, &wi, &hi); if ((wi > 0) && (hi > 0)) - wi += 10; + wi += OFFSET_INNER_MID; else wi = 0; } - int tmpw = items[i]->getWidth() + 10 + 10 + wi; /* 10 pixels to the left and right of the text */ + int tmpw = items[i]->getWidth() + 2*OFFSET_INNER_MID + wi; /* 10 pixels to the left and right of the text */ if (tmpw > width) width = tmpw; } hint_height = 0; if(g_settings.show_menu_hints && has_hints) { - hint_height = 60; //TODO: rework calculation of hint_height - int fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - int h_tmp = 16 + 2*fheight; + int lines = 2; + int text_height = 2*OFFSET_INNER_MID + lines*g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); /* assuming all hint icons has the same size ! */ - int iw, ih; - frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &iw, &ih); - h_tmp = std::max(h_tmp, ih+10); - hint_height = std::max(h_tmp, hint_height); + int icon_width, icon_height; + frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &icon_width, &icon_height); + icon_height += 2*OFFSET_INNER_MID; + hint_height = std::max(icon_height, text_height); } /* set the max height to 9/10 of usable screen height debatable, if the callers need a possibility to set this */ height = (frameBuffer->getScreenHeight() - fbutton_height - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ - if(height > ((int)frameBuffer->getScreenHeight() - 10)) - height = frameBuffer->getScreenHeight() - 10; + if(height > ((int)frameBuffer->getScreenHeight() - OFFSET_INNER_MID)) + height = frameBuffer->getScreenHeight() - OFFSET_INNER_MID; int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(getName()); - if (neededWidth > width-48) { - width= neededWidth+ 49; + if (neededWidth > width - frameBuffer->scale2Res(48)) { + width = neededWidth + frameBuffer->scale2Res(48)+1; } hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); @@ -1165,7 +1172,7 @@ void CMenuWidget::calcSize() iconOffset = w; } - iconOffset += 10; + iconOffset += OFFSET_INNER_MID; width += iconOffset; if (fbutton_count) @@ -1188,7 +1195,7 @@ void CMenuWidget::calcSize() * + center_offset for symmetry * + 20 for setMenuPos calculates 10 pixels border left and right */ int center_offset = (g_settings.menu_pos == MENU_POS_CENTER) ? DETAILSLINE_WIDTH : 0; - int max_possible = (int)frameBuffer->getScreenWidth() - DETAILSLINE_WIDTH - center_offset - 20; + int max_possible = (int)frameBuffer->getScreenWidth() - DETAILSLINE_WIDTH - center_offset - 2*OFFSET_INNER_MID; if (full_width > max_possible) { width = max_possible - sb_width - OFFSET_SHADOW; @@ -1232,7 +1239,7 @@ void CMenuWidget::paint() if (header == NULL){ header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile); header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT); - header->setOffset(10); + header->setOffset(OFFSET_INNER_MID); } header->setCaption(getName()); header->setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0); @@ -1272,25 +1279,25 @@ void CMenuWidget::setMenuPos(const int& menu_width) break; case MENU_POS_TOP_LEFT: - y = offy + scr_y + 10; - x = offx + scr_x + 10; + y = offy + scr_y + OFFSET_INNER_MID; + x = offx + scr_x + OFFSET_INNER_MID; x += DETAILSLINE_WIDTH; break; case MENU_POS_TOP_RIGHT: - y = offy + scr_y + 10; - x = /*offx +*/ scr_x + scr_w - menu_width - 10; + y = offy + scr_y + OFFSET_INNER_MID; + x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; break; case MENU_POS_BOTTOM_LEFT: - y = /*offy +*/ scr_y + scr_h - real_h - 10; - x = offx + scr_x + 10; + y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; + x = offx + scr_x + OFFSET_INNER_MID; x += DETAILSLINE_WIDTH; break; case MENU_POS_BOTTOM_RIGHT: - y = /*offy +*/ scr_y + scr_h - real_h - 10; - x = /*offx +*/ scr_x + scr_w - menu_width - 10; + y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; + x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; break; } if (x_old != x || y_old != y) @@ -1517,61 +1524,50 @@ void CMenuWidget::setFooter(const struct button_label *_fbutton_labels, const in //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t Name, int * const OptionValue, const bool Active, - const int min_value, const int max_value, - CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, - const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionNumberChooser::CMenuOptionNumberChooser( const neutrino_locale_t Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - name = Name; - optionValue = OptionValue; - - lower_bound = min_value; - upper_bound = max_value; - - display_offset = print_offset; - - localized_value = special_value; - localized_value_name = special_value_name; - - display_offset = print_offset; - nameString = ""; - numberFormat = "%d"; - numberFormatFunction = NULL; - observ = Observ; - slider_on = sliderOn; - - numeric_input = false; - - directKeyOK = false; + init(Name, "", OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); } -CMenuOptionNumberChooser::CMenuOptionNumberChooser(const std::string &Name, int * const OptionValue, const bool Active, - const int min_value, const int max_value, - CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, - const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionNumberChooser::CMenuOptionNumberChooser( const std::string &Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - name = NONEXISTANT_LOCALE; - optionValue = OptionValue; + init(NONEXISTANT_LOCALE, Name, OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); +} - lower_bound = min_value; - upper_bound = max_value; +void CMenuOptionNumberChooser::init( const neutrino_locale_t& lName, + const std::string &sName, + int* const Option_Value, + const int& min_value, + const int& max_value, + const int& print_offset, + const int& special_value, + const neutrino_locale_t& special_value_name, + CChangeObserver * const Observ, + bool sliderOn) +{ + name = lName; + nameString = sName; + optionValue = Option_Value; + lower_bound = min_value; + upper_bound = max_value; + display_offset = print_offset; + localized_value = special_value; + localized_value_name = special_value_name; + observ = Observ; + slider_on = sliderOn; - display_offset = print_offset; - - localized_value = special_value; - localized_value_name = special_value_name; - - nameString = Name; - numberFormat = "%d"; - numberFormatFunction = NULL; - observ = Observ; - slider_on = sliderOn; - - numeric_input = false; - - directKeyOK = false; + numberFormat = "%d"; + numberFormatFunction = NULL; + directKeyOK = false; + numeric_input = false; } int CMenuOptionNumberChooser::exec(CMenuTarget*) @@ -1687,112 +1683,60 @@ int CMenuOptionNumberChooser::getWidth(void) width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); } - width += 10; /* min 10 pixels between option name and value. enough? */ + width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ const char *desc_text = getDescription(); if (*desc_text) - width = std::max(width, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); return width; } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, - const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = ""; - name = OptionName; - optionValue = OptionValue; - number_of_options = Number_Of_Options; - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; - for (unsigned int i = 0; i < number_of_options; i++) - { - struct keyval_ext opt; - opt = Options[i]; - options.push_back(opt); - } + init("", OptionName, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); } -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, - const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = OptionName; - name = NONEXISTANT_LOCALE; - optionValue = OptionValue; - number_of_options = Number_Of_Options; - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; - for (unsigned int i = 0; i < number_of_options; i++) - { - struct keyval_ext opt; - opt = Options[i]; - options.push_back(opt); - } + init(OptionName, NONEXISTANT_LOCALE, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, - const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = ""; - name = OptionName; - optionValue = OptionValue; - number_of_options = Number_Of_Options; - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; - for (unsigned int i = 0; i < number_of_options; i++) - options.push_back(Options[i]); + init("", OptionName, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); } -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, - const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = OptionName; - name = NONEXISTANT_LOCALE; - optionValue = OptionValue; - number_of_options = Number_Of_Options; - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; - for (unsigned int i = 0; i < number_of_options; i++) - options.push_back(Options[i]); + init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); } -CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = ""; - name = OptionName; - optionValue = OptionValue; - options = Options; - number_of_options = options.size(); - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; + init("", OptionName, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); } CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) { - nameString = OptionName; - name = NONEXISTANT_LOCALE; - optionValue = OptionValue; - options = Options; - number_of_options = options.size(); - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; + init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); } CMenuOptionChooser::~CMenuOptionChooser() @@ -1800,26 +1744,48 @@ CMenuOptionChooser::~CMenuOptionChooser() clearChooserOptions(); } -void CMenuOptionChooser::initVarOptionChooser( const std::string &OptionName, - const neutrino_locale_t Name, - int * const OptionValue, - const bool Active, - CChangeObserver * const Observ, - neutrino_msg_t DirectKey, - const char * IconName, - bool Pulldown, - bool OptionsSort) +void CMenuOptionChooser::init( const std::string &OptionName, + const neutrino_locale_t Name, + int * const OptionValue, + const struct keyval * const Options, + const struct keyval_ext * const OptionsExt, + std::vector * v_Options, + const size_t Number_Of_Options, + CChangeObserver * const Observ, + bool Pulldown, + bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); nameString = OptionName; name = Name; optionValue = OptionValue; - active = Active; + number_of_options = Number_Of_Options; observ = Observ; - directKey = DirectKey; - iconName = IconName; pulldown = Pulldown; optionsSort = OptionsSort; + + if (Options || OptionsExt) + { + if (Options) + { + for (unsigned int i = 0; i < number_of_options; i++) + { + struct keyval_ext opt; + opt = Options[i]; + options.push_back(opt); + } + } + + if (OptionsExt) + { + for (unsigned int i = 0; i < number_of_options; i++) + options.push_back(OptionsExt[i]); + } + } + else{ + if (v_Options) + options = *v_Options; + } } void CMenuOptionChooser::clearChooserOptions() @@ -2013,33 +1979,38 @@ int CMenuOptionChooser::getWidth(void) width = tw + ow; } - width += 10; /* min 10 pixels between option name and value. enough? */ + width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ const char *desc_text = getDescription(); if (*desc_text) - width = std::max(width, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); return width; } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) - : CMenuItem(Active, DirectKey, IconName) +CMenuOptionStringChooser::CMenuOptionStringChooser( const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) { - nameString = ""; - name = OptionName; - optionValuePtr = OptionValue ? OptionValue : &optionValue; - observ = Observ; - pulldown = Pulldown; + init("", OptionName, OptionValue, Observ, Pulldown); } -CMenuOptionStringChooser::CMenuOptionStringChooser(const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) - : CMenuItem(Active, DirectKey, IconName) +CMenuOptionStringChooser::CMenuOptionStringChooser( const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) +{ + init(OptionName, NONEXISTANT_LOCALE, OptionValue, Observ, Pulldown); +} + +void CMenuOptionStringChooser::init( const std::string &OptionName, + const neutrino_locale_t Name, + std::string* pOptionValue, + CChangeObserver * const Observ, + bool Pulldown) { nameString = OptionName; - name = NONEXISTANT_LOCALE; - optionValuePtr = OptionValue ? OptionValue : &optionValue; + name = Name; + optionValuePtr = pOptionValue ? pOptionValue : &optionValue; observ = Observ; pulldown = Pulldown; } @@ -2144,48 +2115,52 @@ int CMenuOptionStringChooser::paint( bool selected ) } //------------------------------------------------------------------------------------------------------------------------------- -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) { - option_string_ptr = &Option; - name = Text; - nameString = ""; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; + init("", Text, Option, NULL, Target, ActionKey); } -CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init(Text, NONEXISTANT_LOCALE, Option, NULL, Target, ActionKey); +} + +CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init("", Text, "", Option, Target, ActionKey); +} + +CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init(Text, NONEXISTANT_LOCALE, "", Option, Target, ActionKey); +} + +void CMenuForwarder::init( const std::string &Text, + const neutrino_locale_t Name, + const std::string &sOption, + const char * const cOption, + CMenuTarget* Target, + const char * const ActionKey) { - option_string_ptr = &Option; - name = NONEXISTANT_LOCALE; nameString = Text; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; -} + name = Name; -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - option_string = Option ? Option : ""; - option_string_ptr = &option_string; - name = Text; - nameString = ""; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; -} + if (sOption.empty()) + { + option_string = cOption ? cOption : ""; + option_string_ptr = &option_string; + } + else + option_string_ptr = &sOption; -CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - option_string = Option ? Option : ""; - option_string_ptr = &option_string; - name = NONEXISTANT_LOCALE; - nameString = Text; jumpTarget = Target; actionKey = ActionKey ? ActionKey : ""; } @@ -2206,13 +2181,13 @@ int CMenuForwarder::getWidth(void) bgcol = jumpTarget->getColor(); if (!option_name.empty()) - tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name); + tw += OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name); else if (bgcol) - tw += 10 + 60; + tw += OFFSET_INNER_MID + CFrameBuffer::getInstance()->scale2Res(60); const char *desc_text = getDescription(); if (*desc_text) - tw = std::max(tw, 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + tw = std::max(tw, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); return tw; } @@ -2255,23 +2230,25 @@ int CMenuForwarder::paint(bool selected) //------------------------------------------------------------------------------------------------------------------------------- CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) { - type = Type; - name = Text; - nameString = ""; + init(Type, Text, ""); } CMenuSeparator::CMenuSeparator(const int Type, const std::string &Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) { - type = Type; - name = NONEXISTANT_LOCALE; - nameString = Text; + init(Type, NONEXISTANT_LOCALE, Text); } +void CMenuSeparator::init(const int& Type, const neutrino_locale_t& lText, const std::string &sText) +{ + type = Type; + name = lText; + nameString = sText; +} int CMenuSeparator::getHeight(void) { if (nameString.empty() && name == NONEXISTANT_LOCALE) - return 10; + return OFFSET_INNER_MID; return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } @@ -2279,7 +2256,7 @@ int CMenuSeparator::getWidth(void) { int w = 0; if (type & LINE) - w = 30; /* 15 pixel left and right */ + w = 2*OFFSET_INNER_MID; /* offset left and right */ const char *l_name = getName(); if ((type & STRING) && *l_name) w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); @@ -2306,7 +2283,7 @@ int CMenuSeparator::paint(bool selected) if ((type & LINE)) { int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; - paintBoxRel(x+10, y+(height>>1), dx-20, 2, COL_MENUCONTENT_PLUS_3, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); + paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); } if ((type & STRING)) { @@ -2314,17 +2291,19 @@ int CMenuSeparator::paint(bool selected) if (*l_name) { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); // UTF-8 + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); + int iconwidth, iconheight; + CFrameBuffer::getInstance()->getIconSize(NEUTRINO_ICON_BUTTON_HOME, &iconwidth, &iconheight); /* if no alignment is specified, align centered */ if (type & ALIGN_LEFT) - name_start_x = x + (!(type & SUB_HEAD) ? name_start_x : 20 + 24 /*std icon_width is 24px - this should be determinated from NEUTRINO_ICON_BUTTON_HOME or so*/); + name_start_x = x + (!(type & SUB_HEAD) ? name_start_x : 2*OFFSET_INNER_MID + iconwidth); else if (type & ALIGN_RIGHT) - name_start_x = x + dx - stringwidth - 20; + name_start_x = x + dx - stringwidth - 2*OFFSET_INNER_MID; else /* ALIGN_CENTER */ name_start_x = x + (dx >> 1) - (stringwidth >> 1); - frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor); + frameBuffer->paintBoxRel(name_start_x-OFFSET_INNER_SMALL, y, stringwidth+2*OFFSET_INNER_SMALL, height, item_bgcolor); paintItemCaption(selected); } @@ -2451,7 +2430,7 @@ int CMenuProgressbar::getWidth(void) { int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); if (width) - width += 10; + width += OFFSET_INNER_MID; return width + scale.getWidth(); } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index de1d58744..3b47f51de 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -202,6 +202,9 @@ class CMenuItem : public CComponentsSignals class CMenuSeparator : public CMenuItem { int type; + void init( const int& Type, + const neutrino_locale_t& lText, + const std::string& sText); public: @@ -231,6 +234,12 @@ class CMenuSeparator : public CMenuItem class CMenuForwarder : public CMenuItem { std::string actionKey; + void init( const std::string &OptionName, + const neutrino_locale_t Name, + const std::string &sOption, + const char * const cOption, + CMenuTarget* Target, + const char * const ActionKey); protected: std::string option_string; @@ -319,6 +328,17 @@ private: std::string numberFormat; std::string (*numberFormatFunction)(int num); + void init( const neutrino_locale_t& lName, + const std::string &sName, + int* const Option_Value, + const int& min_value, + const int& max_value, + const int& print_offset, + const int& special_value, + const neutrino_locale_t& special_value_name, + CChangeObserver * const Observ, + bool sliderOn); + public: CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, @@ -386,39 +406,40 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser private: std::vector options; std::vector option_chooser_options_v; - unsigned number_of_options; + size_t number_of_options; CChangeObserver * observ; bool pulldown; bool optionsSort; void clearChooserOptions(); - void initVarOptionChooser( const std::string &OptionName, + void init( const std::string &OptionName, const neutrino_locale_t Name, int * const OptionValue, - const bool Active, + const struct keyval * const Options, + const struct keyval_ext * const OptionsExt, + std::vector * v_Options, + const size_t Number_Of_Options, CChangeObserver * const Observ, - neutrino_msg_t DirectKey, - const char * IconName, bool Pulldown, bool OptionsSort - ); + ); public: CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options, - const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options, - const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options, - const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, - bool Pulldown = false, bool OptionsSort = false); + bool size_t = false, bool OptionsSort = false); CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options, - const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, + const size_t Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, bool Pulldown = false, bool OptionsSort = false); CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector &Options, @@ -429,6 +450,7 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, bool Pulldown = false, bool OptionsSort = false); + ~CMenuOptionChooser(); void setOption(const int newvalue); @@ -451,6 +473,11 @@ class CMenuOptionStringChooser : public CMenuItem std::vector options; CChangeObserver * observ; bool pulldown; + void init( const std::string &OptionName, + const neutrino_locale_t Name, + std::string* pOptionValue, + CChangeObserver * const Observ, + bool Pulldown ); public: CMenuOptionStringChooser(const neutrino_locale_t Name, std::string* OptionValue, bool Active = false, @@ -513,6 +540,7 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals std::string iconfile; int min_width; + int mwidth_save; int width; int height; int hheight; // header diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index eb40539cb..c1cdbfe30 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -335,7 +335,7 @@ int CMsgBox::exec() void CMsgBox::refreshFoot(void) { - ccw_footer->paint(false); + ccw_footer->getButtonChainObject()->paint(); } diff --git a/src/gui/widget/navibar.cpp b/src/gui/widget/navibar.cpp new file mode 100644 index 000000000..6afb1d46e --- /dev/null +++ b/src/gui/widget/navibar.cpp @@ -0,0 +1,116 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for epg window navigation bar. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "navibar.h" + + +using namespace std; + + +CNaviBar::CNaviBar( const int& x_pos, + const int& y_pos, + const int& dx, + const int& dy, + CComponentsForm* parent, + int shadow_mode, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) + : CComponentsFrmChain( x_pos, y_pos, dx, dy, + NULL, + CC_DIR_X, + parent, + shadow_mode, + color_frame, + color_body, + color_shadow) +{ + setCornerType(CORNER_NONE); + enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction); + set2ndColor(COL_MENUCONTENT_PLUS_0); + + nb_lpic = nb_rpic = NULL; + nb_lText = nb_rText = NULL; + nb_font = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE];; + nb_lpic_enable = nb_rpic_enable = false; + nb_l_text = nb_r_text = string(); + + initCCItems(); +} + +void CNaviBar::initCCItems() +{ + int x_off = OFFSET_INNER_MID; + int mid_width = width * 40 / 100; // 40% + int side_width = ((width - mid_width) / 2) - (2 * x_off); + int h_text = height; + + // init left arrow + if (!nb_lpic){ + nb_lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT); + nb_lpic->doPaintBg(false); + this->addCCItem(nb_lpic); + nb_lpic->enableSaveBg(); + } + nb_lpic->allowPaint(nb_lpic_enable); + + // init right arrow + if (!nb_rpic){ + nb_rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT); + + nb_rpic->doPaintBg(false); + this->addCCItem(nb_rpic); + nb_rpic->enableSaveBg(); + int x_pos = width - nb_rpic->getWidth() - x_off; + nb_rpic->setXPos(x_pos); + } + nb_rpic->allowPaint(nb_rpic_enable); + + // init text left + if (!nb_lText){ + nb_lText = new CComponentsText(x_off + nb_lpic->getWidth() + x_off, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); + nb_lText->doPaintBg(false); + nb_lText->enableSaveBg(); + } + nb_lText->setText(nb_l_text, CTextBox::NO_AUTO_LINEBREAK, nb_font, COL_MENUHEAD_TEXT, CComponentsText::FONT_STYLE_REGULAR); + + // init text right + if (!nb_rText){ + nb_rText = new CComponentsText(0, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT); + nb_rText->doPaintBg(false); + nb_rText->enableSaveBg(); + } + nb_rText->setText(nb_r_text, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, nb_font); + nb_rText->setXPos(nb_rpic->getXPos() - x_off - nb_rText->getWidth()); +} + + +void CNaviBar::paint(bool do_save_bg) +{ + hideCCItems(); + CComponentsFrmChain::paint(do_save_bg); +} diff --git a/src/gui/widget/navibar.h b/src/gui/widget/navibar.h new file mode 100644 index 000000000..cb3cbe08f --- /dev/null +++ b/src/gui/widget/navibar.h @@ -0,0 +1,169 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Class for epg window navigation bar. + Copyright (C) 2017, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + + +#ifndef __C_NAVIBAR__ +#define __C_NAVIBAR__ + +#include +#include + + +/** + CNaviBar is sub class of CComponentsFrmChain. + Shows a navigation bar with text and navigation icons. + You can enable/disable predefined icons and texts + on the left and/or right side of bar. +*/ +class CNaviBar : public CComponentsFrmChain +{ + private: + CComponentsPictureScalable *nb_lpic, *nb_rpic; + CComponentsText *nb_lText, *nb_rText; + + Font *nb_font; + + bool nb_lpic_enable; + bool nb_rpic_enable; + + std::string nb_l_text; + std::string nb_r_text; + + void initCCItems(); + + public: + /**CNaviBar Constructor + * @param[in] x_pos + * @li expects type int, x position + * @param[in] y_ypos + * @li expects type int, y position + * @param[in] dx + * @li expects type int, width + * @param[in] dy + * @li expects type int, height + * @param[in] parent + * @li optional: expects type CComponentsForm or derivates, allows usage as item inside CComponentsForm container, default = NULL + * @param[in] shadow_mode + * @li optional: expects type fb_pixel_t, defines shadow mode, default CC_SHADOW_OFF + * @param[in] color_frame + * @li optional: expects type fb_pixel_t, defines frame color, default value = COL_FRAME_PLUS_0 + * @param[in] color_body + * @li optional: expects type fb_pixel_t, defines body color, default value = COL_MENUFOOT_PLUS_0 + * @param[in] color_shadow + * @li optional: expects type fb_pixel_t, defines shadow color, default value = COL_SHADOW_PLUS_0 + * + * @see class CComponentsFrmChain() + */ + CNaviBar( const int& x_pos, + const int& y_pos, + const int& dx, + const int& dy, + CComponentsForm* parent = NULL, + int shadow_mode = CC_SHADOW_OFF, + fb_pixel_t& color_frame = COL_FRAME_PLUS_0, + fb_pixel_t& color_body = COL_MENUFOOT_PLUS_0, + fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0); + + //~CNaviBar(); //is inherited + + /** + * Enable or disable left icon + * @param[in] enable + * @li exepts type bool, default = true + */ + void enableLeftArrow(bool enable = true){nb_lpic_enable = enable; initCCItems();} + + /** + * Enable or disable right icon + * @param[in] enable + * @li exepts type bool, default = true + */ + void enableRightArrow(bool enable = true){nb_rpic_enable = enable; initCCItems();} + + /** + * disable left icon + * no parameter + */ + void disableLeftArrow(){enableLeftArrow(false);} + + /** + * disable right icon + * no parameter + */ + void disableRightArrow(){enableRightArrow(false);} + + /** + * Enable or disable both icons at once. + * @param[in] enable_left + * @li exepts type bool, default = true + * @param[in] enable_right + * @li exepts type bool, default = true + */ + void enableArrows(bool enable_left = true, bool enable_right = true){enableLeftArrow(enable_left); enableRightArrow(enable_right);} + + /** + * Disable all icons. + * no parameter + */ + void disableArrows(){disableLeftArrow(); disableRightArrow();} + + /** + * Sets font type for texts. + * @param[in] font + * @li exepts type Font* + */ + void setFont(Font *font) {nb_font = font; initCCItems();} + + /** + * Sets left text. + * @param[in] text + * @li exepts type std::string + */ + void setLeftText(const std::string& text) {nb_l_text = text; initCCItems();} + + /** + * Sets right text + * @param[in] text + * @li exepts type std::string + */ + void setRightText(const std::string& text) {nb_r_text = text; initCCItems();} + + /** + * Sets left and right text at once. + * @param[in] left + * @li exepts type std::string + * @param[in] right + * @li exepts type std::string + */ + void setText(const std::string& left, const std::string& right) {setLeftText(left); setRightText(right);} + + /** + * Paint bar on screen. + * @param[in] do_save_bg + * @li optional: exepts type bool, default = CC_SAVE_SCREEN_YES. + */ + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +#endif + diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index 0fed059cd..ee2985c04 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -59,8 +59,19 @@ CProgressWindow::CProgressWindow(const neutrino_locale_t title, Init(statusSignal, localSignal, globalSignal); } +CProgressWindow::CProgressWindow(const std::string &title, + const int &dx, + const int &dy, + signal *statusSignal, + signal *localSignal, + signal *globalSignal) + : CComponentsWindow(0, 0, dx, dy, title, NEUTRINO_ICON_INFO, NULL, CC_SHADOW_ON) +{ + Init(statusSignal, localSignal, globalSignal); +} + void CProgressWindow::Init( signal *statusSignal, - signal *localSignal, + signal *localSignal, signal *globalSignal) { if (statusSignal) @@ -70,112 +81,80 @@ void CProgressWindow::Init( signal *statusSignal, if (globalSignal) *globalSignal->connect(mem_fun(*this, &CProgressWindow::showGlobalStatus)); - global_progress = local_progress = 100; + global_progress = local_progress = 0; showFooter(false); - shadow = true; - - int x_item = 10; - int y_item = 10; - - int w_item = width-2*x_item; - int h_item = 14; - int h_pbar = 20; - w_bar_frame = 0; //create status text object status_txt = new CComponentsLabel(); - int h_txt = max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), h_item); - status_txt->setDimensionsAll(x_item, y_item, w_item, h_txt); + status_txt->setDimensionsAll(OFFSET_INNER_MID, OFFSET_INNER_MID, width-2*OFFSET_INNER_MID, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()); status_txt->setColorBody(col_body); status_txt->doPaintTextBoxBg(true); status_txt->doPaintBg(false); addWindowItem(status_txt); - y_item += h_txt + 10; + + cur_statusText = string(); //create local_bar object - local_bar = new CProgressBar(); - local_bar->allowPaint(false); - local_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); - local_bar->setColorBody(col_body); - local_bar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0); - local_bar->setFrameThickness(w_bar_frame); - local_bar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0); - addWindowItem(local_bar); - y_item += 2*h_pbar; + local_bar = getProgressItem(); //create global_bar object - global_bar = new CProgressBar(); - global_bar->allowPaint(false); - global_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); - global_bar->setColorBody(col_body); - global_bar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0); - global_bar->setFrameThickness(w_bar_frame); - global_bar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0); - addWindowItem(global_bar); - y_item += 2*h_pbar; + global_bar = getProgressItem(); + //set window height h_height = ccw_head->getHeight(); - height = max(height, y_item + h_height); + ccw_body->setHeight(ccw_body->back()->getYPos()+ ccw_body->back()->getHeight()+ OFFSET_INNER_MID); + height = max(height, ccw_body->getHeight() + h_height); + //set position on screen setCenterPos(); } -void CProgressWindow::setTitle(const neutrino_locale_t title) +CProgressBar* CProgressWindow::getProgressItem() { - setWindowCaption(title); - -#ifdef VFD_UPDATE - CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(ccw_caption)); // set global text in VFD -#endif // VFD_UPDATE -} - -void CProgressWindow::setTitle(const string & title) -{ - setWindowCaption(title); - -#ifdef VFD_UPDATE - CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(ccw_caption)); // set global text in VFD -#endif // VFD_UPDATE -} - -//if header is disabled we need new position for body items -void CProgressWindow::fitItems() -{ - if (ccw_show_header) - return; - - for(size_t i=0; isize() ;i++){ - int y_item = ccw_body->getCCItem(i)->getYPos() + h_height - 10; - ccw_body->getCCItem(i)->setYPos(y_item); + CProgressBar *pBar = new CProgressBar(); + pBar->allowPaint(false); + int y_tmp = 0; + for(size_t i = ccw_body->size()-1; i< ccw_body->size(); i++){ + y_tmp += ccw_body->getCCItem(i)->getYPos() + ccw_body->getCCItem(i)->getHeight(); + y_tmp += OFFSET_INNER_MID; } + pBar->setDimensionsAll(OFFSET_INNER_MID, y_tmp, width-2*OFFSET_INNER_MID, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()); + pBar->setColorBody(col_body); + pBar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0); + pBar->setFrameThickness(1); + pBar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0); + pBar->setType(CProgressBar::PB_TIMESCALE); + addWindowItem(pBar); + + return pBar; +} + +void CProgressWindow::initStatus(const unsigned int prog, const unsigned int max, const string &statusText, CProgressBar *pBar) +{ + pBar->allowPaint(true); + pBar->setValues(prog, (int)max); + if (!statusText.empty() && (cur_statusText != statusText)){ + showStatusMessageUTF(statusText); + cur_statusText = statusText; + } + pBar->paint(false); + frameBuffer->blit(); } void CProgressWindow::showStatus(const unsigned int prog, const unsigned int max, const string &statusText) { - if (global_progress == prog) - return; - - if (!global_bar->isPainted()){ - int g_height = global_bar->getHeight(); - global_bar->setYPos(local_bar->getYPos() + g_height/2); - global_bar->setHeight(g_height + g_height/2); - } - - showGlobalStatus(prog, max, statusText); + showLocalStatus(prog, max, statusText); } void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned int max, const string &statusText) { - if (global_progress == prog) + if (!local_bar->isPainted()) + showLocalStatus(0, 0, statusText); // ensure first paint of local bar on painted global bar at same time + if (global_progress == prog && global_bar->isPainted()) return; - - global_bar->allowPaint(true); global_progress = prog; - global_bar->setValues(prog, (int)max); - if (!statusText.empty()) - showStatusMessageUTF(statusText); - global_bar->paint(false); + initStatus(prog, max, statusText, global_bar); #ifdef VFD_UPDATE CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress); @@ -184,15 +163,10 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned i void CProgressWindow::showLocalStatus(const unsigned int prog, const unsigned int max, const string &statusText) { - if (local_progress == prog) + if (local_progress == prog && local_bar->isPainted()) return; - - local_bar->allowPaint(true); local_progress = prog; - local_bar->setValues(prog, (int)max); - if (!statusText.empty()) - showStatusMessageUTF(statusText); - local_bar->paint(false); + initStatus(prog, max, statusText, local_bar); #ifdef VFD_UPDATE CVFD::getInstance()->showProgressBar2(local_progress); @@ -242,3 +216,33 @@ void CProgressWindow::paint(bool do_save_bg) fitItems(); CComponentsWindow::paint(do_save_bg); } + +void CProgressWindow::setTitle(const neutrino_locale_t title) +{ + setWindowCaption(title); + +#ifdef VFD_UPDATE + CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(ccw_caption)); // set global text in VFD +#endif // VFD_UPDATE +} + +void CProgressWindow::setTitle(const string & title) +{ + setWindowCaption(title); + +#ifdef VFD_UPDATE + CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(ccw_caption)); // set global text in VFD +#endif // VFD_UPDATE +} + +//if header is disabled we need new position for body items +void CProgressWindow::fitItems() +{ + if (ccw_show_header) + return; + + for(size_t i=0; isize() ;i++){ + int y_item = ccw_body->getCCItem(i)->getYPos() + h_height - OFFSET_INNER_MID; + ccw_body->getCCItem(i)->setYPos(y_item); + } +} \ No newline at end of file diff --git a/src/gui/widget/progresswindow.h b/src/gui/widget/progresswindow.h index 811b5714a..da88911f3 100644 --- a/src/gui/widget/progresswindow.h +++ b/src/gui/widget/progresswindow.h @@ -28,6 +28,9 @@ #include #include "menue.h" +#define PW_MIN_WIDTH CCW_PERCENT 50 +#define PW_MIN_HEIGHT CCW_PERCENT 20 + class CProgressWindow : public CComponentsWindow, public CMenuTarget { private: @@ -36,11 +39,14 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget unsigned int global_progress; unsigned int local_progress; - int w_bar_frame; + std::string cur_statusText; int h_height; void Init( sigc::signal *statusSignal, sigc::signal *localSignal, sigc::signal *globalSignal); + + CProgressBar* getProgressItem(); + void initStatus(const unsigned int prog, const unsigned int max, const std::string &statusText, CProgressBar *pBar); void fitItems(); public: @@ -84,10 +90,10 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget * status.hide(); * } * - * //That's it. Until now these steps are a classical way inside neutrino, but you can use proress window with signals too. - * //Working with signals have the advantage that the implementation could be more compactly, because - * //complex constructions within the classes are usually unnecessary, - * //beacuse of the signals can be installed where they directly take the required values. See next example: + * //That's it. Until now these steps are a classical way inside neutrino, but you can use proress window with signals too. + * //Working with signals have the advantage that the implementation could be more compactly, because + * //complex constructions within the classes are usually unnecessary, + * //beacuse of the signals can be installed where they directly catching the required values. See next example: * * class CFooClass * { @@ -96,6 +102,7 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget * private: * //other members... * sigc::signal OnProgress; + * void DoCount(); * //other members... * public: * //other members... @@ -127,12 +134,57 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget * //finally remove window from screen * progress.hide(); * } + * + * //Another and a recommended way to implement signals is to inherit prepared signals with + * //class CProgressSignals. This class contains prepared signals for implemantation and disconnetion of slots + * //is performed automatically. + * //See next example: + * class CFooClass : public CProgressSignals + * { + * private: + * //other members... + * void DoCount(); + * //other members... + * public: + * //other members... + * void DoAnything(); + * //other members... + * }; + * + * //add the OnGlobalProgress and OnLocalProgress signals into a counter methode + * void CFooClass::DoCount();{ + * size_t max = 10; + * for (size_t i = 0; i < max; i++){ + * OnGlobalProgress(i, max, "Test"); //visualize global progress + * for (size_t j = 0; j < max; j++){ + * OnLocalProgress(ij, max, "Test"); // visualize local progress + * } + * } + * } + * + * void CFooClass::DoAnything{ + * //inside of methode which calls the progress define a CProgressWindow object and the counter method: + * //...any code + * CProgressWindow progress(NULL, 500, 150, NULL, &OnLocalProgress, &OnGlobalProgress); + * progress.paint(); // paint window + * + * //... + * + * void DoCount(); + * + * //... + * + * //finally remove window from screen + * progress.hide(); + * } + * * @note - * Don't use status_Signal at same time with localSignal and globalSignal. In This case please set status_Signal = NULL + * Don't use status_Signal at same time with localSignal and globalSignal. \n + * In This case please set prameter 'status_Signal' = NULL */ CProgressWindow(CComponentsForm *parent = NULL, - const int &dx = 700, - const int &dy = 200, + const int &dx = PW_MIN_WIDTH, + const int &dy = PW_MIN_HEIGHT, sigc::signal *status_Signal = NULL, sigc::signal *localSignal = NULL, sigc::signal *globalSignal = NULL); @@ -144,8 +196,21 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget * @see For other arguments and examples, see related constructor(s) */ CProgressWindow(const neutrino_locale_t title, - const int &dx = 700, - const int &dy = 200, + const int &dx = PW_MIN_WIDTH, + const int &dy = PW_MIN_HEIGHT, + sigc::signal *status_Signal = NULL, + sigc::signal *localSignal = NULL, + sigc::signal *globalSignal = NULL); + + /**CProgressWindow Constructor + * @param[in] title + * @li expects type std::string as window title + * + * @see For other arguments and examples, see related constructor(s) + */ + CProgressWindow(const std::string &title, + const int &dx = PW_MIN_WIDTH, + const int &dy = PW_MIN_HEIGHT, sigc::signal *status_Signal = NULL, sigc::signal *localSignal = NULL, sigc::signal *globalSignal = NULL); @@ -223,5 +288,25 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget void paint(bool do_save_bg = true); }; +class CProgressSignals : public sigc::trackable +{ + public: + /**CProgressSignals Constructor: + * Additional class for inherited signal implemantations into classes with used CProgressWindow instances. + */ + CProgressSignals() + { + //obligatory init of signals. Not really required but just to be safe. + OnProgress.clear(); + OnLocalProgress.clear(); + OnGlobalProgress.clear(); + }; + + /** + * For general usage for implementations of signals for classes which are using CProgressBar() window instances based on inheritance. + * @see Take a look into examples to find in progressbar.h + */ + sigc::signal OnProgress, OnLocalProgress, OnGlobalProgress; +}; #endif diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index f325cedb1..a0c789a86 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -278,12 +278,17 @@ void CStringInput::keyDownPressed() { int npos = 0; std::string tmp_value = *valueString; - for(int count=0;count<(int)strlen(validchars);count++) + const int validchar_len = (int)strlen(validchars); + for(int count=0;countat(selected)==validchars[count]) npos = count; npos--; - if(npos<0) - npos = strlen(validchars)-1; + if(npos<0){ + if(validchar_len > 0) + npos = validchar_len-1; + else + npos = 0; + } valueString->at(selected)=validchars[npos]; int current_value = atoi(*valueString); diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 82195ae5a..587c237d6 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -61,6 +61,7 @@ #include #include #include "textbox.h" +#include #include #include #ifdef VISUAL_DEBUG @@ -68,14 +69,14 @@ #endif #include -#define SCROLL_FRAME_WIDTH 10 -#define SCROLL_MARKER_BORDER 2 +#define SCROLL_FRAME_WIDTH SCROLLBAR_WIDTH +#define SCROLL_MARKER_BORDER OFFSET_INNER_MIN -#define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX - 40) -#define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - 40) +#define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX - CFrameBuffer::getInstance()->scale2Res(40)) +#define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - CFrameBuffer::getInstance()->scale2Res(40)) #define MIN_WINDOW_WIDTH ((g_settings.screen_EndX - g_settings.screen_StartX)>>1) -#define MIN_WINDOW_HEIGHT 40 +#define MIN_WINDOW_HEIGHT CFrameBuffer::getInstance()->scale2Res(40) CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, const CBox* position, CFBWindow::color_t textBackgroundColor) @@ -525,14 +526,9 @@ void CTextBox::refreshScroll(void) if (m_nNrOfPages > 1) { - frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, + paintScrollBar(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, - COL_SCROLLBAR_PASSIVE_PLUS_0, RADIUS_MIN); - unsigned int marker_size = (m_cFrameScrollRel.iHeight - 2*SCROLL_MARKER_BORDER) / m_nNrOfPages; - frameBuffer->paintBoxRel(m_cFrameScrollRel.iX + SCROLL_MARKER_BORDER + m_cFrame.iX, - m_cFrameScrollRel.iY + SCROLL_MARKER_BORDER + m_nCurrentPage * marker_size + m_cFrame.iY, - m_cFrameScrollRel.iWidth - 2*SCROLL_MARKER_BORDER, - marker_size, COL_SCROLLBAR_ACTIVE_PLUS_0, RADIUS_MIN); + m_nNrOfPages, m_nCurrentPage); m_has_scrolled = true; } else @@ -900,6 +896,16 @@ int CTextBox::getLines(const std::string& text) return count; } +int CTextBox::getLines() +{ + if (m_cText.empty()) + return 0; + + refreshTextLineArray(); + + return m_nNrOfLines; +} + int CTextBox::getMaxLineWidth(const std::string& text, Font* font) { std::string txt = text; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 0c182eaa8..5980985e5 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -164,7 +164,7 @@ class CTextBox : public sigc::trackable int text_Hborder_width; int text_Vborder_width; bool m_FontUseDigitHeight; - + public: /* Constructor */ CTextBox(); @@ -199,28 +199,30 @@ class CTextBox : public sigc::trackable void enableUTF8(bool enable = true){m_utf8_encoded = enable;} void disableUTF8(bool enable = false){enableUTF8(enable);} - inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; - inline CBox getWindowsPos(void) {return(m_cFrame);}; + bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; + CBox getWindowsPos(void) {return(m_cFrame);}; - inline int getLinesPerPage(void) {return m_nLinesPerPage;}; - inline int getPages(void) {return(m_nNrOfPages);}; - inline int getBackGroundRadius(void) {return(m_nBgRadius);}; + int getLinesPerPage(void) {return m_nLinesPerPage;}; + int getPages(void) {return(m_nNrOfPages);}; + int getBackGroundRadius(void) {return(m_nBgRadius);}; /** * Returns count of lines of a passed text. * @param[in] text - * @li exepts type std::string + * @li expects type std::string * @return count of lines as int * @see getLines() */ - static int getLines(const std::string& text); + static int getLines(const std::string& text); /** - * Returns count of evaluated lines from an existent CTextBox instance. + * Returns count of calculated lines from an existing CTextBox instance. * @return count of lines as int * @see static version getLines() + * @note Real count of lines will be only returned if CTextBox object is initialized with a valid CBox instance, \n + * otherwise count of 0 lines will be returned! */ - int getLines(){return(m_nNrOfLines);} + int getLines(); /** * Returns width of largest line from passed text diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c74e9fee8..065038159 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -76,10 +76,12 @@ #include "gui/eventlist.h" #include "gui/favorites.h" #include "gui/filebrowser.h" +#include "gui/followscreenings.h" #include "gui/hdd_menu.h" #include "gui/infoviewer.h" #include "gui/mediaplayer.h" #include "gui/movieplayer.h" +#include "gui/osd_helpers.h" #include "gui/osd_setup.h" #include "gui/osdlang_setup.h" #include "gui/pictureviewer.h" @@ -234,6 +236,8 @@ CNeutrinoApp::CNeutrinoApp() init_td_api(); // shutdown_td_api(); #endif + osd_resolution_tmp = -1; + frameBufferInitialized = false; frameBuffer = CFrameBuffer::getInstance(); frameBuffer->setIconBasePath(ICONSDIR); @@ -314,22 +318,6 @@ static SNeutrinoSettings::usermenu_t usermenu_default[] = { /************************************************************************************** * CNeutrinoApp - loadSetup, load the application-settings * **************************************************************************************/ -#if HAVE_TRIPLEDRAGON || HAVE_SPARK_HARDWARE || HAVE_GENERIC_HARDWARE -#define DEFAULT_X_START_SD 32 -#define DEFAULT_Y_START_SD 26 -#define DEFAULT_X_END_SD 694 -#define DEFAULT_Y_END_SD 570 -#else -#define DEFAULT_X_START_SD 60 -#define DEFAULT_Y_START_SD 20 -#define DEFAULT_X_END_SD 1220 -#define DEFAULT_Y_END_SD 560 -#endif - -#define DEFAULT_X_START_HD 40 //5 -#define DEFAULT_Y_START_HD 25 //5 -#define DEFAULT_X_END_HD 1235 //1275 -#define DEFAULT_Y_END_HD 690 //715 std::string ttx_font_file = ""; @@ -339,22 +327,27 @@ int CNeutrinoApp::loadSetup(const char * fname) int erg = 0; configfile.clear(); - //settings laden - und dabei Defaults setzen! - if(!configfile.loadConfig(fname)) { - //file existiert nicht + // load settings; setup defaults + if (!configfile.loadConfig(fname)) + { + // file doesn't exist erg = 1; - } else { + } + else + { +#if 0 /* try to detect bad / broken config file */ - if (!configfile.getInt32("screen_EndX_crt", 0) || - !configfile.getInt32("screen_EndY_crt", 0) || - !configfile.getInt32("screen_EndX_lcd", 0) || - !configfile.getInt32("screen_EndY_lcd", 0)) { + if (!configfile.getInt32("screen_EndX_crt_0", 0) || + !configfile.getInt32("screen_EndY_crt_0", 0) || + !configfile.getInt32("screen_EndX_lcd_0", 0) || + !configfile.getInt32("screen_EndY_lcd_0", 0)) { printf("[neutrino] config file %s is broken, using defaults\n", fname); configfile.clear(); - } else { + } else +#endif migrateConfig(fname); - } } + parentallocked = !access(NEUTRINO_PARENTALLOCKED_FILE, R_OK); //theme/color options @@ -515,7 +508,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.timer_remotebox_ip.push_back(timer_rb); } } - g_settings.timer_followscreenings = configfile.getInt32( "timer_followscreenings", 1 ); + g_settings.timer_followscreenings = configfile.getInt32( "timer_followscreenings", CFollowScreenings::FOLLOWSCREENINGS_ON ); g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); g_settings.infobar_show_channeldesc = configfile.getBool("infobar_show_channeldesc" , false ); @@ -594,6 +587,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.epg_scan = CEpgScan::SCAN_CURRENT; g_settings.epg_scan_mode = CEpgScan::MODE_OFF; } + g_settings.epg_scan_rescan = configfile.getInt32("epg_scan_rescan", 24); g_settings.epg_save_mode = configfile.getInt32("epg_save_mode", 0); //widget settings g_settings.widget_fade = false; @@ -750,34 +744,37 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.channellist_show_numbers = configfile.getInt32("channellist_show_numbers", 1); //screen configuration - g_settings.screen_StartX_crt = configfile.getInt32( "screen_StartX_crt", DEFAULT_X_START_SD); - g_settings.screen_StartY_crt = configfile.getInt32( "screen_StartY_crt", DEFAULT_Y_START_SD ); - g_settings.screen_EndX_crt = configfile.getInt32( "screen_EndX_crt", DEFAULT_X_END_SD); - g_settings.screen_EndY_crt = configfile.getInt32( "screen_EndY_crt", DEFAULT_Y_END_SD); - g_settings.screen_StartX_lcd = configfile.getInt32( "screen_StartX_lcd", DEFAULT_X_START_HD); - g_settings.screen_StartY_lcd = configfile.getInt32( "screen_StartY_lcd", DEFAULT_Y_START_HD ); - g_settings.screen_EndX_lcd = configfile.getInt32( "screen_EndX_lcd", DEFAULT_X_END_HD); - g_settings.screen_EndY_lcd = configfile.getInt32( "screen_EndY_lcd", DEFAULT_Y_END_HD); - g_settings.screen_preset = configfile.getInt32( "screen_preset", 1); - + g_settings.osd_resolution = (osd_resolution_tmp == -1) ? configfile.getInt32("osd_resolution", 0) : osd_resolution_tmp; + COsdHelpers::getInstance()->g_settings_osd_resolution_save = g_settings.osd_resolution; + g_settings.screen_StartX_crt_0 = configfile.getInt32("screen_StartX_crt_0", 80); + g_settings.screen_StartY_crt_0 = configfile.getInt32("screen_StartY_crt_0", 45); + g_settings.screen_EndX_crt_0 = configfile.getInt32("screen_EndX_crt_0" , 1280 - g_settings.screen_StartX_crt_0 - 1); + g_settings.screen_EndY_crt_0 = configfile.getInt32("screen_EndY_crt_0" , 580 - g_settings.screen_StartY_crt_0 - 1); + g_settings.screen_StartX_lcd_0 = configfile.getInt32("screen_StartX_lcd_0", 40); + g_settings.screen_StartY_lcd_0 = configfile.getInt32("screen_StartY_lcd_0", 25); + g_settings.screen_EndX_lcd_0 = configfile.getInt32("screen_EndX_lcd_0" , 1280 - g_settings.screen_StartX_lcd_0 - 1); + g_settings.screen_EndY_lcd_0 = configfile.getInt32("screen_EndY_lcd_0" , 720 - g_settings.screen_StartY_lcd_0 - 1); + g_settings.screen_StartX_crt_1 = configfile.getInt32("screen_StartX_crt_1", 80); + g_settings.screen_StartY_crt_1 = configfile.getInt32("screen_StartY_crt_1", 45); + g_settings.screen_EndX_crt_1 = configfile.getInt32("screen_EndX_crt_1" , 1920 - g_settings.screen_StartX_crt_1 - 1); + g_settings.screen_EndY_crt_1 = configfile.getInt32("screen_EndY_crt_1" , 870 - g_settings.screen_StartY_crt_1 - 1); + g_settings.screen_StartX_lcd_1 = configfile.getInt32("screen_StartX_lcd_1", 40); + g_settings.screen_StartY_lcd_1 = configfile.getInt32("screen_StartY_lcd_1", 25); + g_settings.screen_EndX_lcd_1 = configfile.getInt32("screen_EndX_lcd_1" , 1920 - g_settings.screen_StartX_lcd_1 - 1); + g_settings.screen_EndY_lcd_1 = configfile.getInt32("screen_EndY_lcd_1" , 1080 - g_settings.screen_StartY_lcd_1 - 1); + g_settings.screen_preset = configfile.getInt32("screen_preset", COsdSetup::PRESET_LCD); #if HAVE_TRIPLEDRAGON g_settings.screen_preset = 0; /* does not make sense to have two configurations for that... */ #elif ! HAVE_COOLSTREAM g_settings.screen_preset = 1; /* spark is now always using 1280x720 framebuffer */ #endif - g_settings.screen_StartX = g_settings.screen_preset ? g_settings.screen_StartX_lcd : g_settings.screen_StartX_crt; - g_settings.screen_StartY = g_settings.screen_preset ? g_settings.screen_StartY_lcd : g_settings.screen_StartY_crt; - g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt; - g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt; - - g_settings.screen_width = frameBuffer->getScreenWidth(true); - g_settings.screen_height = frameBuffer->getScreenHeight(true); + setScreenSettings(); // avoid configuration mismatch - if (g_settings.screen_EndX > g_settings.screen_width) - g_settings.screen_EndX = g_settings.screen_width; - if (g_settings.screen_EndY > g_settings.screen_height) - g_settings.screen_EndY = g_settings.screen_height; + if (g_settings.screen_EndX >= g_settings.screen_width) + g_settings.screen_EndX = g_settings.screen_width - 1; + if (g_settings.screen_EndY >= g_settings.screen_height) + g_settings.screen_EndY = g_settings.screen_height - 1; g_settings.bigFonts = configfile.getInt32("bigFonts", 1); g_settings.window_size = configfile.getInt32("window_size", 100); @@ -880,7 +877,7 @@ int CNeutrinoApp::loadSetup(const char * fname) //Filebrowser g_settings.filebrowser_showrights = configfile.getInt32("filebrowser_showrights", 1); - g_settings.filebrowser_sortmethod = configfile.getInt32("filebrowser_sortmethod", 0); + g_settings.filebrowser_sortmethod = configfile.getInt32("filebrowser_sortmethod", 1); if ((g_settings.filebrowser_sortmethod < 0) || (g_settings.filebrowser_sortmethod >= FILEBROWSER_NUMBER_OF_SORT_VARIANTS)) g_settings.filebrowser_sortmethod = 0; g_settings.filebrowser_denydirectoryleave = configfile.getBool("filebrowser_denydirectoryleave", false); @@ -989,6 +986,56 @@ int CNeutrinoApp::loadSetup(const char * fname) return erg; } +void CNeutrinoApp::setScreenSettings() +{ + g_settings.screen_width = frameBuffer->getScreenWidth(true); + g_settings.screen_height = frameBuffer->getScreenHeight(true); + + switch (g_settings.osd_resolution) { +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + case 1: + { + switch (g_settings.screen_preset) { + case COsdSetup::PRESET_CRT: + g_settings.screen_StartX = g_settings.screen_StartX_crt_1; + g_settings.screen_StartY = g_settings.screen_StartY_crt_1; + g_settings.screen_EndX = g_settings.screen_EndX_crt_1; + g_settings.screen_EndY = g_settings.screen_EndY_crt_1; + break; + case COsdSetup::PRESET_LCD: + default: + g_settings.screen_StartX = g_settings.screen_StartX_lcd_1; + g_settings.screen_StartY = g_settings.screen_StartY_lcd_1; + g_settings.screen_EndX = g_settings.screen_EndX_lcd_1; + g_settings.screen_EndY = g_settings.screen_EndY_lcd_1; + break; + } + } + break; +#endif + case 0: + default: + { + switch (g_settings.screen_preset) { + case COsdSetup::PRESET_CRT: + g_settings.screen_StartX = g_settings.screen_StartX_crt_0; + g_settings.screen_StartY = g_settings.screen_StartY_crt_0; + g_settings.screen_EndX = g_settings.screen_EndX_crt_0; + g_settings.screen_EndY = g_settings.screen_EndY_crt_0; + break; + case COsdSetup::PRESET_LCD: + default: + g_settings.screen_StartX = g_settings.screen_StartX_lcd_0; + g_settings.screen_StartY = g_settings.screen_StartY_lcd_0; + g_settings.screen_EndX = g_settings.screen_EndX_lcd_0; + g_settings.screen_EndY = g_settings.screen_EndY_lcd_0; + break; + } + } + break; + } +} + void CNeutrinoApp::upgradeSetup(const char * fname) { dprintf(DEBUG_NORMAL, "upgrade/cleanup %s\n", fname); @@ -1218,6 +1265,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("epg_read_frequently", g_settings.epg_read_frequently); configfile.setInt32("epg_scan", g_settings.epg_scan); configfile.setInt32("epg_scan_mode", g_settings.epg_scan_mode); + configfile.setInt32("epg_scan_rescan", g_settings.epg_scan_rescan); configfile.setInt32("epg_save_mode", g_settings.epg_save_mode); configfile.setInt32("epg_cache_time" ,g_settings.epg_cache ); configfile.setInt32("epg_extendedcache_time" ,g_settings.epg_extendedcache); @@ -1352,15 +1400,24 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("channellist_show_numbers", g_settings.channellist_show_numbers); //screen configuration - configfile.setInt32( "screen_StartX_lcd", g_settings.screen_StartX_lcd ); - configfile.setInt32( "screen_StartY_lcd", g_settings.screen_StartY_lcd ); - configfile.setInt32( "screen_EndX_lcd", g_settings.screen_EndX_lcd ); - configfile.setInt32( "screen_EndY_lcd", g_settings.screen_EndY_lcd ); - configfile.setInt32( "screen_StartX_crt", g_settings.screen_StartX_crt ); - configfile.setInt32( "screen_StartY_crt", g_settings.screen_StartY_crt ); - configfile.setInt32( "screen_EndX_crt", g_settings.screen_EndX_crt ); - configfile.setInt32( "screen_EndY_crt", g_settings.screen_EndY_crt ); - configfile.setInt32( "screen_preset", g_settings.screen_preset ); + configfile.setInt32("osd_resolution" , COsdHelpers::getInstance()->g_settings_osd_resolution_save); + configfile.setInt32("screen_StartX_lcd_0", g_settings.screen_StartX_lcd_0); + configfile.setInt32("screen_StartY_lcd_0", g_settings.screen_StartY_lcd_0); + configfile.setInt32("screen_EndX_lcd_0" , g_settings.screen_EndX_lcd_0); + configfile.setInt32("screen_EndY_lcd_0" , g_settings.screen_EndY_lcd_0); + configfile.setInt32("screen_StartX_crt_0", g_settings.screen_StartX_crt_0); + configfile.setInt32("screen_StartY_crt_0", g_settings.screen_StartY_crt_0); + configfile.setInt32("screen_EndX_crt_0" , g_settings.screen_EndX_crt_0); + configfile.setInt32("screen_EndY_crt_0" , g_settings.screen_EndY_crt_0); + configfile.setInt32("screen_StartX_lcd_1", g_settings.screen_StartX_lcd_1); + configfile.setInt32("screen_StartY_lcd_1", g_settings.screen_StartY_lcd_1); + configfile.setInt32("screen_EndX_lcd_1" , g_settings.screen_EndX_lcd_1); + configfile.setInt32("screen_EndY_lcd_1" , g_settings.screen_EndY_lcd_1); + configfile.setInt32("screen_StartX_crt_1", g_settings.screen_StartX_crt_1); + configfile.setInt32("screen_StartY_crt_1", g_settings.screen_StartY_crt_1); + configfile.setInt32("screen_EndX_crt_1" , g_settings.screen_EndX_crt_1); + configfile.setInt32("screen_EndY_crt_1" , g_settings.screen_EndY_crt_1); + configfile.setInt32("screen_preset" , g_settings.screen_preset); //Software-update configfile.setInt32 ("softupdate_mode" , g_settings.softupdate_mode ); @@ -1854,14 +1911,50 @@ void CNeutrinoApp::CmdParser(int argc, char **argv) /************************************************************************************** * CNeutrinoApp - setup the framebuffer * **************************************************************************************/ + void CNeutrinoApp::SetupFrameBuffer() { frameBuffer->init(); - if(frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t))) { + int setFbMode = 0; + osd_resolution_tmp = -1; +#ifdef ENABLE_CHANGE_OSD_RESOLUTION + frameBuffer->setOsdResolutions(); + if (frameBuffer->osd_resolutions.empty()) { + dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n"); + exit(-1); + } + + uint32_t ort; + configfile.loadConfig(NEUTRINO_SETTINGS_FILE); + ort = configfile.getInt32("osd_resolution", 0); + + size_t resCount = frameBuffer->osd_resolutions.size(); + + if (ort > (resCount - 1)) + osd_resolution_tmp = ort = 0; + + if (resCount == 1) + ort = 0; + + setFbMode = frameBuffer->setMode(frameBuffer->osd_resolutions[ort].xRes, + frameBuffer->osd_resolutions[ort].yRes, + frameBuffer->osd_resolutions[ort].bpp); + +/* + setFbMode = 0; + COsdHelpers::getInstance()->changeOsdResolution(0, true); +*/ +#else + /* all other hardware ignores setMode parameters */ + setFbMode = frameBuffer->setMode(0, 0, 0); +#endif + + if (setFbMode == -1) { dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n"); exit(-1); } frameBuffer->Clear(); + frameBufferInitialized = true; } /************************************************************************************** @@ -2083,11 +2176,18 @@ void wake_up(bool &wakeup) int CNeutrinoApp::run(int argc, char **argv) { + puts("[neutrino] executing " NEUTRINO_APP_START_SCRIPT "."); + if (my_system(NEUTRINO_APP_START_SCRIPT) != 0) + perror(NEUTRINO_APP_START_SCRIPT " failed"); + CmdParser(argc, argv); TIMER_START(); cs_api_init(); cs_register_messenger(CSSendMessage); +#if defined(HAVE_COOL_HARDWARE) && defined(ENABLE_CHANGE_OSD_RESOLUTION) + cs_new_auto_videosystem(); +#endif g_info.hw_caps = get_hwcaps(); can_deepstandby = g_info.hw_caps->can_shutdown; @@ -2149,6 +2249,8 @@ TIMER_START(); ZapStart_arg.volume = g_settings.current_volume; ZapStart_arg.webtv_xml = &g_settings.webtv_xml; + ZapStart_arg.osd_resolution = g_settings.osd_resolution; + CCamManager::getInstance()->SetCITuner(g_settings.ci_tuner); /* create decoders, read channels */ bool zapit_init = CZapit::getInstance()->Start(&ZapStart_arg); @@ -2177,6 +2279,20 @@ TIMER_START(); CheckFastScan(); + // dirty part of hw_caps - specify some details after zapit start + if (strcmp(g_info.hw_caps->boxname, "HD1") == 0) + { + // only SAT-HD1 has fan + if (!CFEManager::getInstance()->getFE(0)->hasSat()) + g_info.hw_caps->has_fan = 0; + } + if (strcmp(g_info.hw_caps->boxname, "Neo") == 0) + { + // detecting Neo Twin by counting frontends + if (CFEManager::getInstance()->getFrontendCount() > 1) + strcpy(g_info.hw_caps->boxname, "Neo Twin"); + } + //timer start long timerd_signal = 0; timer_wakeup = false;//init @@ -2948,6 +3064,18 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) CMoviePlayerGui::getInstance(true).showSubtitle(data); return messages_return::handled; } + if (msg == NeutrinoMessages::EVT_AUTO_SET_VIDEOSYSTEM) { + printf(">>>>>[CNeutrinoApp::%s:%d] Receive EVT_AUTO_SET_VIDEOSYSTEM message\n", __func__, __LINE__); + COsdHelpers *coh = COsdHelpers::getInstance(); + int videoSystem = (int)data; + if ((videoSystem != -1) /* -1 => not enabled for automode */ && + (coh->getVideoSystem() != videoSystem)) { + coh->setVideoSystem(videoSystem, false); + if (frameBufferInitialized) + coh->changeOsdResolution(0, true, false); + } + return messages_return::handled; + } if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { CZapit::getInstance()->GetAudioMode(g_settings.audio_AnalogMode); if(g_settings.audio_AnalogMode < 0 || g_settings.audio_AnalogMode > 2) @@ -3430,6 +3558,8 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, 5) == CMsgBox::mbrYes); } else if( msg == NeutrinoMessages::SHUTDOWN ) { + if(CStreamManager::getInstance()->StreamStatus()) + skipShutdownTimer = true; if(!skipShutdownTimer) { ExitRun(g_info.hw_caps->can_shutdown); } @@ -4121,7 +4251,7 @@ void CNeutrinoApp::radioMode( bool rezap) CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); videoDecoder->Standby(false); } - mode = mode_radio; + #ifdef ENABLE_PIP pipDecoder->Pig(g_settings.pip_radio_x, g_settings.pip_radio_y, g_settings.pip_radio_width, g_settings.pip_radio_height, @@ -4129,6 +4259,12 @@ void CNeutrinoApp::radioMode( bool rezap) #endif CRecordManager::getInstance()->StopAutoRecord(); + if (mode != mode_webtv) { + frameBuffer->useBackground(false); + frameBuffer->paintBackground(); + } + mode = mode_radio; + g_RemoteControl->radioMode(); SetChannelMode(g_settings.channel_mode_radio); @@ -4995,11 +5131,7 @@ bool CNeutrinoApp::adjustToChannelID(const t_channel_id channel_id) } /* - * commit 523b273a changed the names of config file entries: - * casystem_display => infobar_casystem_display - * casystem_dotmatrix => infobar_casystem_dotmatrix - * casystem_frame => infobar_casystem_frame - * convert these, so that users do not need to set up their system again + * convert config keys, so that users do not need to set up their system again */ struct __key_rename { const char *from; @@ -5010,6 +5142,14 @@ static struct __key_rename key_rename[] = { { "casystem_display", "infobar_casystem_display" }, { "casystem_dotmatrix", "infobar_casystem_dotmatrix"}, { "casystem_frame", "infobar_casystem_frame" }, + { "screen_StartX_crt", "screen_StartX_crt_0" }, + { "screen_StartY_crt", "screen_StartY_crt_0" }, + { "screen_EndX_crt", "screen_EndX_crt_0" }, + { "screen_EndY_crt", "screen_EndY_crt_0" }, + { "screen_StartX_lcd", "screen_StartX_lcd_0" }, + { "screen_StartY_lcd", "screen_StartY_lcd_0" }, + { "screen_EndX_lcd", "screen_EndX_lcd_0" }, + { "screen_EndY_lcd", "screen_EndY_lcd_0" }, { NULL, NULL } }; @@ -5032,9 +5172,8 @@ void CNeutrinoApp::migrateConfig(const char *fname) /* only set new key to old value if the new key does not yet exist */ if (configfile.getInt32(to, magic) == magic) configfile.setInt32(to, tmp); - /* always remove old key*/ + /* always remove old key */ configfile.deleteKey(from); } /* more complex migration, including converting values etc. could be done here */ } - diff --git a/src/neutrino.h b/src/neutrino.h index 406a934b7..b70f5586f 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -108,6 +108,8 @@ private: bool channelList_allowed; bool channelList_painted; int first_mode_found; + int osd_resolution_tmp; + bool frameBufferInitialized; void SDT_ReloadChannels(); void setupNetwork( bool force= false ); @@ -162,6 +164,7 @@ public: void saveSetup(const char * fname); int loadSetup(const char * fname); + void setScreenSettings(); void upgradeSetup(const char * fname); void loadKeys(const char * fname = NULL); void saveKeys(const char * fname = NULL); diff --git a/src/neutrinoMessages.h b/src/neutrinoMessages.h index fe89d019a..81f77fa6c 100644 --- a/src/neutrinoMessages.h +++ b/src/neutrinoMessages.h @@ -123,6 +123,7 @@ struct NeutrinoMessages { /* NEVER CHANGE THIS */ EVT_CA_MESSAGE = CRCInput::RC_Events + 60, /* data = CA_MESSAGE pointer */ EVT_SUBT_MESSAGE = CRCInput::RC_Events + 61, /* data = subtitles pointer */ + EVT_AUTO_SET_VIDEOSYSTEM = CRCInput::RC_Events + 62, /* data = new video system */ /* END */ EVT_CURRENTEPG = CRCInput::RC_WithData + 1, diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index edff6f910..3f0098aad 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -211,6 +211,7 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]= {"crypt", &CControlAPI::CryptCGI, "text/plain"}, // timer {"timer", &CControlAPI::TimerCGI, "text/plain"}, + {"sendalltimers", &CControlAPI::TimerSendCGI, "text/plain"}, // bouquet editing {"setbouquet", &CControlAPI::setBouquetCGI, "text/plain"}, {"savebouquet", &CControlAPI::saveBouquetCGI, "text/plain"}, @@ -337,7 +338,34 @@ void CControlAPI::TimerCGI(CyhookHandler *hh) hh->SendError(); } +void CControlAPI::TimerSendCGI(CyhookHandler *hh) +{ + hh->outStart(); + + if (NeutrinoAPI->Timerd->isTimerdAvailable()) + { + if (!hh->ParamList.empty()) + { + bool force = (hh->ParamList["force"] == "1") || (hh->ParamList["force"] == "true"); + if(!hh->ParamList["ip"].empty()) + { + NeutrinoAPI->SendAllTimers(hh->ParamList["ip"],force); + hh->SendOk(); + } + else if(!hh->ParamList["name"].empty()) + { + NeutrinoAPI->SendAllTimers(NeutrinoAPI->GetRemoteBoxIP(decodeString(hh->ParamList["name"])),force); + hh->SendOk(); + } + else + hh->SendError(); + } + } + else + hh->SendError(); +} //----------------------------------------------------------------------------- + void CControlAPI::SetModeCGI(CyhookHandler *hh) { if (!(hh->ParamList.empty())) diff --git a/src/nhttpd/tuxboxapi/controlapi.h b/src/nhttpd/tuxboxapi/controlapi.h index 36873b8fc..b266e85d4 100644 --- a/src/nhttpd/tuxboxapi/controlapi.h +++ b/src/nhttpd/tuxboxapi/controlapi.h @@ -73,6 +73,7 @@ private: // CGI functions for ExecuteCGI void TimerCGI(CyhookHandler *hh); + void TimerSendCGI(CyhookHandler *hh); void SetModeCGI(CyhookHandler *hh); void GetModeCGI(CyhookHandler *hh); void ExecCGI(CyhookHandler *hh); diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp index 4ec8ca05b..68c92c5e3 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoapi.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -464,7 +466,7 @@ int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString) //------------------------------------------------------------------------- std::string CNeutrinoAPI::getVideoResolutionAsString(void) { - int xres, yres, framerate; + int xres = 0, yres = 0, framerate = 0; videoDecoder->getPictureInfo(xres, yres, framerate); std::stringstream out; out << xres << "x" << yres; @@ -474,7 +476,7 @@ std::string CNeutrinoAPI::getVideoResolutionAsString(void) //------------------------------------------------------------------------- std::string CNeutrinoAPI::getVideoFramerateAsString(void) { - int xres, yres, framerate; + int xres = 0, yres = 0, framerate = 0; std::string sframerate = "{=L:unknown=}"; videoDecoder->getPictureInfo(xres, yres, framerate); switch(framerate){ @@ -489,7 +491,7 @@ std::string CNeutrinoAPI::getVideoFramerateAsString(void) //------------------------------------------------------------------------- std::string CNeutrinoAPI::getAudioInfoAsString(void) { - int type, layer, freq, mode, lbitrate; + int type = 0, layer = 0, freq = 0, mode = 0, lbitrate = 0; audioDecoder->getAudioInfo(type, layer, freq, lbitrate, mode); std::stringstream out; if(type == 0) @@ -530,3 +532,53 @@ std::string CNeutrinoAPI::getLogoFile(t_channel_id channelId) return logoString; return ""; } + +std::string CNeutrinoAPI::GetRemoteBoxIP(std::string _rbname) +{ + std::string c_url = ""; + for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) + { + if (it->rbname == _rbname) + { + if (!it->user.empty() && !it->pass.empty()) + c_url += it->user + ":" + it->pass +"@"; + c_url += it->rbaddress; + c_url += ":" + to_string(it->port); + break; + } + } + return c_url; +} + +void CNeutrinoAPI::SendAllTimers(std::string url, bool force) +{ + CTimerd::TimerList timerlist; + timerlist.clear(); + Timerd->getTimerList(timerlist); + sort(timerlist.begin(), timerlist.end()); + + int pre = 0,post = 0; + Timerd->getRecordingSafety(pre,post); + CHTTPTool httpTool; + std::string r_url; + + for(CTimerd::TimerList::iterator timer = timerlist.begin(); timer != timerlist.end(); ++timer) + { + if (timer->eventType == CTimerd::TIMER_RECORD) { + r_url = "http://"; + r_url += url; + r_url += "/control/timer?action=new"; + r_url += "&alarm=" + to_string((int)timer->alarmTime + pre); + r_url += "&stop=" + to_string((int)timer->stopTime - post); + r_url += "&announce=" + to_string((int)timer->announceTime + pre); + r_url += "&channel_id=" + string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer->channel_id); + r_url += "&aj=on"; + r_url += "&rs=on"; + + r_url = httpTool.downloadString(r_url, -1, 300); + + if ((r_url=="ok") || force) + Timerd->removeTimerEvent(timer->eventID); + } + } +} diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.h b/src/nhttpd/tuxboxapi/neutrinoapi.h index 5936e194b..77e51baa0 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.h +++ b/src/nhttpd/tuxboxapi/neutrinoapi.h @@ -84,6 +84,8 @@ public: std::string getAudioInfoAsString(void); std::string getCryptInfoAsString(void); std::string getLogoFile(t_channel_id channelId); + std::string GetRemoteBoxIP(std::string _rbname); + void SendAllTimers(std::string url, bool force = false); public: CNeutrinoAPI(); ~CNeutrinoAPI(void); diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 4b8f8ce7d..e5b2178c7 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -1023,6 +1023,10 @@ std::string CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::strin unsigned timerId=0; std::string cmd, stimerid; CTimerd::responseGetTimer timer; // Timer + timer.alarmTime = 0; + timer.stopTime = 0; + timer.apids = 0; + timer.eventType = CTimerd::__TIMER_NEXTPROGRAM;//nothing time_t now_t = time(NULL); ySplitString(para, " ", cmd, stimerid); if(cmd != "new") diff --git a/src/system/localize.h b/src/system/localize.h index b12b430fd..0794ff499 100644 --- a/src/system/localize.h +++ b/src/system/localize.h @@ -69,6 +69,7 @@ class CLocaleManager loadLocale_ret_t loadLocale(const char * const locale, bool asdefault = false); const char * getText(const neutrino_locale_t keyName) const; + std::string getTextAsString(const neutrino_locale_t keyName) const {return (static_cast(getText(keyName)));} static neutrino_locale_t getMonth (const struct tm * struct_tm_p); static neutrino_locale_t getMonth (const int mon); diff --git a/src/system/locals.h b/src/system/locals.h index 965508c82..9aee9e30b 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -349,10 +349,10 @@ typedef enum LOCALE_COLORMENU_FADE, LOCALE_COLORMENU_FONT, LOCALE_COLORMENU_FONT_TTX, - LOCALE_COLORMENU_HD_PRESET, LOCALE_COLORMENU_MENUCOLORS, LOCALE_COLORMENU_OSD_PRESET, - LOCALE_COLORMENU_SD_PRESET, + LOCALE_COLORMENU_OSD_RESOLUTION, + LOCALE_COLORMENU_SHADOW_COLOR, LOCALE_COLORMENU_TEXTCOLOR, LOCALE_COLORMENU_THEMESELECT, LOCALE_COLORMENU_TIMING, @@ -1064,6 +1064,7 @@ typedef enum LOCALE_MENU_HINT_COLORED_EVENTS, LOCALE_MENU_HINT_COLORED_EVENTS_TEXTCOLOR, LOCALE_MENU_HINT_COLORS, + LOCALE_MENU_HINT_COLORS_SHADOW, LOCALE_MENU_HINT_CONTENT_BACK, LOCALE_MENU_HINT_CONTENT_TEXTCOLOR, LOCALE_MENU_HINT_DBOXINFO, @@ -1281,6 +1282,7 @@ typedef enum LOCALE_MENU_HINT_OSD, LOCALE_MENU_HINT_OSD_LANGUAGE, LOCALE_MENU_HINT_OSD_PRESET, + LOCALE_MENU_HINT_OSD_RESOLUTION, LOCALE_MENU_HINT_OSD_TIMING, LOCALE_MENU_HINT_OTHER_FONTS, LOCALE_MENU_HINT_PARENTALLOCK_CHANGEPIN, @@ -1696,6 +1698,7 @@ typedef enum LOCALE_MOVIEBROWSER_CUTTING, LOCALE_MOVIEBROWSER_DELETE_ALL, LOCALE_MOVIEBROWSER_DELETE_INFO, + LOCALE_MOVIEBROWSER_DELETE_MOVIE, LOCALE_MOVIEBROWSER_DELETE_SCREENSHOT, LOCALE_MOVIEBROWSER_DIR, LOCALE_MOVIEBROWSER_DIRECTORIES, @@ -2347,8 +2350,10 @@ typedef enum LOCALE_STREAMINFO_FRAMERATE_UNKNOWN, LOCALE_STREAMINFO_HEAD, LOCALE_STREAMINFO_NOT_AVAILABLE, + LOCALE_STREAMINFO_OSD_RESOLUTION, LOCALE_STREAMINFO_RESOLUTION, LOCALE_STREAMINFO_SIGNAL, + LOCALE_STREAMINFO_VIDEOSYSTEM, LOCALE_STREAMING_BUSY, LOCALE_STREAMING_DIR_NOT_WRITABLE, LOCALE_STREAMING_OVERFLOW, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 0a256f41c..bdd72cbfd 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -349,10 +349,10 @@ const char * locale_real_names[] = "colormenu.fade", "colormenu.font", "colormenu.font_ttx", - "colormenu.hd_preset", "colormenu.menucolors", "colormenu.osd_preset", - "colormenu.sd_preset", + "colormenu.osd_resolution", + "colormenu.shadow_color", "colormenu.textcolor", "colormenu.themeselect", "colormenu.timing", @@ -1064,6 +1064,7 @@ const char * locale_real_names[] = "menu.hint_colored_events", "menu.hint_colored_events_textcolor", "menu.hint_colors", + "menu.hint_colors_shadow", "menu.hint_content_back", "menu.hint_content_textcolor", "menu.hint_dboxinfo", @@ -1281,6 +1282,7 @@ const char * locale_real_names[] = "menu.hint_osd", "menu.hint_osd_language", "menu.hint_osd_preset", + "menu.hint_osd_resolution", "menu.hint_osd_timing", "menu.hint_other_fonts", "menu.hint_parentallock_changepin", @@ -1696,6 +1698,7 @@ const char * locale_real_names[] = "moviebrowser.cutting", "moviebrowser.delete_all", "moviebrowser.delete_info", + "moviebrowser.delete_movie", "moviebrowser.delete_screenshot", "moviebrowser.dir", "moviebrowser.directories", @@ -2347,8 +2350,10 @@ const char * locale_real_names[] = "streaminfo.framerate_unknown", "streaminfo.head", "streaminfo.not_available", + "streaminfo.osd_resolution", "streaminfo.resolution", "streaminfo.signal", + "streaminfo.videosystem", "streaming.busy", "streaming.dir_not_writable", "streaming.overflow", diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index dac8b81c4..9c09bc2ad 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -179,9 +179,9 @@ void CColorSetupNotifier::setPalette() 8, convertSetupAlpha2Alpha(t.infobar_alpha) ); frameBuffer->paletteGenFade(COL_SHADOW, - convertSetupColor2RGB(int(t.infobar_red*0.4), int(t.infobar_green*0.4), int(t.infobar_blue*0.4)), - convertSetupColor2RGB(t.infobar_Text_red, t.infobar_Text_green, t.infobar_Text_blue), - 8, convertSetupAlpha2Alpha(t.infobar_alpha) ); + convertSetupColor2RGB(int(t.shadow_red), int(t.shadow_green), int(t.shadow_blue)), + convertSetupColor2RGB(t.shadow_red, t.shadow_green, t.shadow_blue), + 8, convertSetupAlpha2Alpha(t.shadow_alpha) ); frameBuffer->paletteGenFade(COL_INFOBAR_CASYSTEM, convertSetupColor2RGB(t.infobar_casystem_red, t.infobar_casystem_green, t.infobar_casystem_blue), diff --git a/src/system/settings.h b/src/system/settings.h index 7bb105560..40a8cfd69 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -155,6 +155,11 @@ struct SNeutrinoTheme int progressbar_timescale_green; int progressbar_timescale_yellow; int progressbar_timescale_invert; + + unsigned char shadow_alpha; + unsigned char shadow_red; + unsigned char shadow_green; + unsigned char shadow_blue; }; struct timer_remotebox_item @@ -295,6 +300,7 @@ struct SNeutrinoSettings std::string epg_dir; int epg_scan; int epg_scan_mode; + int epg_scan_rescan; int epg_save_mode; int epg_search_history_size; @@ -590,6 +596,13 @@ struct SNeutrinoSettings int window_height; int eventlist_additional; int eventlist_epgplus; + + enum CHANNELLIST_ADDITIONAL_MODES + { + CHANNELLIST_ADDITIONAL_MODE_OFF = 0, + CHANNELLIST_ADDITIONAL_MODE_EPG = 1, + CHANNELLIST_ADDITIONAL_MODE_MINITV = 2 + }; int channellist_additional; int channellist_epgtext_align_right; int channellist_foot; @@ -611,14 +624,23 @@ struct SNeutrinoSettings int screen_StartY; int screen_EndX; int screen_EndY; - int screen_StartX_crt; - int screen_StartY_crt; - int screen_EndX_crt; - int screen_EndY_crt; - int screen_StartX_lcd; - int screen_StartY_lcd; - int screen_EndX_lcd; - int screen_EndY_lcd; + int screen_StartX_crt_0; + int screen_StartY_crt_0; + int screen_EndX_crt_0; + int screen_EndY_crt_0; + int screen_StartX_lcd_0; + int screen_StartY_lcd_0; + int screen_EndX_lcd_0; + int screen_EndY_lcd_0; + int screen_StartX_crt_1; + int screen_StartY_crt_1; + int screen_EndX_crt_1; + int screen_EndY_crt_1; + int screen_StartX_lcd_1; + int screen_StartY_lcd_1; + int screen_EndX_lcd_1; + int screen_EndY_lcd_1; + int osd_resolution; int screen_preset; int screen_width; int screen_height; @@ -901,30 +923,34 @@ const time_settings_struct_t timing_setting[SNeutrinoSettings::TIMING_SETTING_CO #define DEFAULT_LCD_AUTODIMM 0x00 #define DEFAULT_LCD_SHOW_VOLUME 0x01 -#define CORNER_RADIUS_LARGE 11 -#define CORNER_RADIUS_MID 7 -#define CORNER_RADIUS_SMALL 5 -#define CORNER_RADIUS_MIN 3 +#define CORNER_RADIUS_LARGE CFrameBuffer::getInstance()->scale2Res(11) +#define CORNER_RADIUS_MID CFrameBuffer::getInstance()->scale2Res(7) +#define CORNER_RADIUS_SMALL CFrameBuffer::getInstance()->scale2Res(5) +#define CORNER_RADIUS_MIN CFrameBuffer::getInstance()->scale2Res(3) #define CORNER_RADIUS_NONE 0 -#define RADIUS_LARGE (g_settings.rounded_corners ? CORNER_RADIUS_LARGE : 0) -#define RADIUS_MID (g_settings.rounded_corners ? CORNER_RADIUS_MID : 0) -#define RADIUS_SMALL (g_settings.rounded_corners ? CORNER_RADIUS_SMALL : 0) -#define RADIUS_MIN (g_settings.rounded_corners ? CORNER_RADIUS_MIN : 0) +#define RADIUS_LARGE (g_settings.rounded_corners ? CORNER_RADIUS_LARGE : CORNER_RADIUS_NONE) +#define RADIUS_MID (g_settings.rounded_corners ? CORNER_RADIUS_MID : CORNER_RADIUS_NONE) +#define RADIUS_SMALL (g_settings.rounded_corners ? CORNER_RADIUS_SMALL : CORNER_RADIUS_NONE) +#define RADIUS_MIN (g_settings.rounded_corners ? CORNER_RADIUS_MIN : CORNER_RADIUS_NONE) #define RADIUS_NONE 0 // offsets -#define OFFSET_SHADOW 6 -#define OFFSET_INTER 6 -#define OFFSET_INNER_LARGE 20 -#define OFFSET_INNER_MID 10 -#define OFFSET_INNER_SMALL 5 -#define OFFSET_INNER_MIN 2 +#define OFFSET_SHADOW CFrameBuffer::getInstance()->scale2Res(6) +#define OFFSET_INTER CFrameBuffer::getInstance()->scale2Res(6) +#define OFFSET_INNER_LARGE CFrameBuffer::getInstance()->scale2Res(20) +#define OFFSET_INNER_MID CFrameBuffer::getInstance()->scale2Res(10) +#define OFFSET_INNER_SMALL CFrameBuffer::getInstance()->scale2Res(5) +#define OFFSET_INNER_MIN CFrameBuffer::getInstance()->scale2Res(2) #define OFFSET_INNER_NONE 0 -#define SCROLLBAR_WIDTH OFFSET_INNER_MID + 2*OFFSET_INNER_MIN +#define SCROLLBAR_WIDTH (OFFSET_INNER_MID + 2*OFFSET_INNER_MIN) -#define DETAILSLINE_WIDTH 16 // TODO: scale2Res() ? +#define FRAME_WIDTH_MIN CFrameBuffer::getInstance()->scale2Res(2) + +#define DETAILSLINE_WIDTH CFrameBuffer::getInstance()->scale2Res(16) + +#define SIDEBAR_WIDTH CFrameBuffer::getInstance()->scale2Res(40) #define BIGFONT_FACTOR 1.5 diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 3c558ee1b..407d452a4 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -323,7 +323,7 @@ bool cYTFeedParser::parseFeedJSON(std::string &answer) Json::Value elements = root["items"]; for(unsigned int i=0; igetText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); + OnProgress(i, elements.size(), g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); #ifdef DEBUG_PARSER printf("=========================================================\n"); printf("Element %d in elements\n", i); diff --git a/src/system/ytparser.h b/src/system/ytparser.h index c54c2239b..dcc8f1322 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -30,6 +30,7 @@ #include #include #include +#include class cYTVideoUrl { @@ -68,7 +69,7 @@ class cYTVideoInfo typedef std::vector yt_video_list_t; -class cYTFeedParser +class cYTFeedParser : public CProgressSignals { private: std::string error; @@ -155,8 +156,6 @@ class cYTFeedParser void SetMaxResults(int count) { max_results = count; } void SetConcurrentDownloads(int count) { concurrent_downloads = count; } void SetThumbnailDir(std::string &_thumbnail_dir); - - sigc::signal OnLoadVideoInfo; }; #endif diff --git a/src/timerd/timerd.cpp b/src/timerd/timerd.cpp index 7b98bfd43..3585a3b94 100644 --- a/src/timerd/timerd.cpp +++ b/src/timerd/timerd.cpp @@ -306,7 +306,7 @@ bool timerd_parse_command(CBasicMessage::Header &rmsg, int connfd) CBasicServer::receive_data(connfd, &recInfo, sizeof(CTimerd::TransferRecordingInfo)); if(recInfo.recordingSafety) { - int pre,post; + int pre = 0,post = 0; CTimerManager::getInstance()->getRecordingSafety(pre,post); msgAddTimer.announceTime -= pre; msgAddTimer.alarmTime -= pre; diff --git a/src/timerd/timermanager.cpp b/src/timerd/timermanager.cpp index 8998ea2d2..3903a4b0f 100644 --- a/src/timerd/timermanager.cpp +++ b/src/timerd/timermanager.cpp @@ -332,7 +332,7 @@ int CTimerManager::modifyEvent(int peventID, time_t announceTime, time_t alarmTi CTimerEvent *event = events[peventID]; event->announceTime = announceTime; event->alarmTime = alarmTime; - event->stopTime = stopTime; + event->stopTime = (event->eventType == CTimerd::TIMER_RECORD) ? stopTime : 0; if(event->eventState==CTimerd::TIMERSTATE_PREANNOUNCE) event->eventState = CTimerd::TIMERSTATE_SCHEDULED; event->eventRepeat = evrepeat; @@ -1347,7 +1347,7 @@ bool CTimerEvent_Record::adjustToCurrentEPG() CChannelEventList evtlist; CEitManager::getInstance()->getEventsServiceKey(eventInfo.channel_id, evtlist); - int pre, post; + int pre = 0, post = 0; CTimerManager::getInstance()->getRecordingSafety(pre, post); time_t _announceTime = announceTime; diff --git a/src/zapit/include/zapit/zapit.h b/src/zapit/include/zapit/zapit.h index e774cf9c4..2d34ea1a3 100644 --- a/src/zapit/include/zapit/zapit.h +++ b/src/zapit/include/zapit/zapit.h @@ -42,6 +42,7 @@ typedef struct ZAPIT_start_arg t_channel_id startchannelradio_id; int uselastchannel; int video_mode; + uint32_t osd_resolution; int volume; int ci_clock; std::list *webtv_xml; diff --git a/src/zapit/src/femanager.cpp b/src/zapit/src/femanager.cpp index 4d9c19205..5fd546b58 100644 --- a/src/zapit/src/femanager.cpp +++ b/src/zapit/src/femanager.cpp @@ -381,7 +381,9 @@ void CFEManager::saveSettings(bool write) void CFEManager::copySettings(CFrontend * from, CFrontend * to) { INFO("Copy settings fe %d -> fe %d", from->fenumber, to->fenumber); - if (to->config.diseqcType != DISEQC_UNICABLE || to->config.diseqcType != DISEQC_UNICABLE2 || to->getMode() == CFrontend::FE_MODE_LINK_LOOP) + if ((to->config.diseqcType != DISEQC_UNICABLE && + to->config.diseqcType != DISEQC_UNICABLE2) || + to->getMode() == CFrontend::FE_MODE_LINK_LOOP) to->config.diseqcType = from->config.diseqcType; to->config.diseqcRepeats = from->config.diseqcRepeats; diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index 113f2e1e9..a31a2eca4 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -626,6 +626,7 @@ uint32_t CFrontend::getRate() const fe_status_t CFrontend::getStatus(void) const { struct dvb_frontend_event event; + event.status = FE_REINIT; fop(ioctl, FE_READ_STATUS, &event.status); return (fe_status_t) (event.status & FE_HAS_LOCK); } diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 9db9ea289..0c790ce10 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -78,6 +78,7 @@ #include #include +#include #ifdef PEDANTIC_VALGRIND_SETUP #define VALGRIND_PARANOIA(x) memset(&x, 0, sizeof(x)) @@ -1723,7 +1724,8 @@ bool CZapit::ParseCommand(CBasicMessage::Header &rmsg, int connfd) case CZapitMessages::CMD_SET_VIDEO_SYSTEM: { CZapitMessages::commandInt msg; CBasicServer::receive_data(connfd, &msg, sizeof(msg)); - videoDecoder->SetVideoSystem(msg.val); + COsdHelpers::getInstance()->setVideoSystem(msg.val); + COsdHelpers::getInstance()->changeOsdResolution(0, true); CNeutrinoApp::getInstance()->g_settings_video_Mode(msg.val); break; } @@ -2482,7 +2484,9 @@ bool CZapit::Start(Z_start_arg *ZapStart_arg) audioDecoder = cAudio::GetDecoder(0); videoDecoder->SetDemux(videoDemux); - videoDecoder->SetVideoSystem(video_mode); + COsdHelpers::getInstance()->setVideoSystem(video_mode); + uint32_t osd_resolution = ZapStart_arg->osd_resolution; + COsdHelpers::getInstance()->changeOsdResolution(osd_resolution); videoDecoder->Standby(false); audioDecoder->SetDemux(audioDemux);