diff --git a/configure.in b/configure.in index 43137ac..3173b12 100644 --- a/configure.in +++ b/configure.in @@ -21,19 +21,33 @@ AC_ARG_WITH(sdl-gfx-prefix, AC_CHECK_LIB(SDL_gfx, rotozoomSurfaceXY,,check_sdl_gfx="no") +AC_CHECK_LIB(SDL_ttf, TTF_OpenFont) + # Check for libpng AC_CHECK_LIB(png, png_read_image,,check_png="no") +# Check for libopk +AC_CHECK_LIB(opk, opk_open,,INOTIFY=no) + +# Check for libxdgmime +AC_CHECK_LIB(xdgmime, xdg_mime_get_extensions_from_mime_type) + AC_ARG_ENABLE(platform, [ --enable-platform=X specify the targeted platform], [GMENU2X_PLATFORM="$enableval"], [GMENU2X_PLATFORM="default"]) case "$GMENU2X_PLATFORM" in - dingux) - AC_DEFINE(PLATFORM_DINGUX) - PLATFORM="dingux" + a320) + AC_DEFINE(PLATFORM_A320) + PLATFORM="a320" SCREEN_RES="320x240" ;; + gcw0) + AC_DEFINE(PLATFORM_GCW0) + PLATFORM="gcw0" + SCREEN_RES="320x240" + CPUFREQ=no + ;; nanonote) AC_DEFINE(PLATFORM_NANONOTE) PLATFORM="nanonote" @@ -60,8 +74,25 @@ case "$GMENU2X_PLATFORM" in ;; esac +AC_ARG_ENABLE(cpufreq, + [ --disable-cpufreq disable support for CPU frequency scaling], + [CPUFREQ=no],,) + +AC_ARG_ENABLE(inotify, + [ --disable-inotify disable file monitoring], + [INOTIFY=no],,) + AC_SUBST(PLATFORM) AC_SUBST(SCREEN_RES) +AC_DEFINE_UNQUOTED(PLATFORM, "${PLATFORM}") + +if test "x$CPUFREQ" != xno ; then + AC_DEFINE(ENABLE_CPUFREQ) +fi + +if test "x$INOTIFY" != xno ; then + AC_DEFINE(ENABLE_INOTIFY) +fi AC_OUTPUT(Makefile src/Makefile data/Makefile) diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..b336cc7 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/data/platform/dingux/about.txt b/data/platform/a320/about.txt similarity index 100% rename from data/platform/dingux/about.txt rename to data/platform/a320/about.txt diff --git a/data/platform/dingux/gmenu2x.conf b/data/platform/a320/gmenu2x.conf similarity index 100% rename from data/platform/dingux/gmenu2x.conf rename to data/platform/a320/gmenu2x.conf diff --git a/data/platform/dingux/input.conf b/data/platform/a320/input.conf similarity index 100% rename from data/platform/dingux/input.conf rename to data/platform/a320/input.conf diff --git a/data/platform/dingux/sections/applications/.empty b/data/platform/a320/sections/applications/.empty similarity index 100% rename from data/platform/dingux/sections/applications/.empty rename to data/platform/a320/sections/applications/.empty diff --git a/data/platform/dingux/sections/applications/30_terminal b/data/platform/a320/sections/applications/30_terminal similarity index 100% rename from data/platform/dingux/sections/applications/30_terminal rename to data/platform/a320/sections/applications/30_terminal diff --git a/data/platform/dingux/sections/emulators/.empty b/data/platform/a320/sections/settings/.empty similarity index 100% rename from data/platform/dingux/sections/emulators/.empty rename to data/platform/a320/sections/settings/.empty diff --git a/data/platform/dingux/sections/settings/10_poweroff b/data/platform/a320/sections/settings/10_poweroff similarity index 86% rename from data/platform/dingux/sections/settings/10_poweroff rename to data/platform/a320/sections/settings/10_poweroff index 9246193..057151c 100644 --- a/data/platform/dingux/sections/settings/10_poweroff +++ b/data/platform/a320/sections/settings/10_poweroff @@ -2,3 +2,4 @@ title=Power Off description=Shut down the system icon=skin:icons/poweroff.png exec=/sbin/poweroff +editable=false diff --git a/data/platform/dingux/sections/settings/20_reboot b/data/platform/a320/sections/settings/20_reboot similarity index 85% rename from data/platform/dingux/sections/settings/20_reboot rename to data/platform/a320/sections/settings/20_reboot index 1dc642c..33d041f 100644 --- a/data/platform/dingux/sections/settings/20_reboot +++ b/data/platform/a320/sections/settings/20_reboot @@ -2,3 +2,4 @@ title=Reboot description=Reboot the dingoo icon=skin:icons/reboot.png exec=/sbin/reboot +editable=false diff --git a/data/platform/dingux/sections/settings/30_suspend b/data/platform/a320/sections/settings/30_suspend similarity index 88% rename from data/platform/dingux/sections/settings/30_suspend rename to data/platform/a320/sections/settings/30_suspend index 3413e6a..d3e2399 100644 --- a/data/platform/dingux/sections/settings/30_suspend +++ b/data/platform/a320/sections/settings/30_suspend @@ -3,3 +3,4 @@ description=Suspend the dingoo icon=skin:icons/suspend.png exec=/usr/sbin/suspend dontleave=true +editable=false diff --git a/data/platform/dingux/sections/settings/40_alsamixer b/data/platform/a320/sections/settings/40_alsamixer similarity index 89% rename from data/platform/dingux/sections/settings/40_alsamixer rename to data/platform/a320/sections/settings/40_alsamixer index 6dc4964..215b6b8 100644 --- a/data/platform/dingux/sections/settings/40_alsamixer +++ b/data/platform/a320/sections/settings/40_alsamixer @@ -3,3 +3,4 @@ description=Configure sound settings icon=skin:icons/alsamixer.png exec=/usr/bin/alsamixer consoleapp=true +editable=false diff --git a/data/platform/dingux/sections/settings/50_system_info b/data/platform/a320/sections/settings/50_system_info similarity index 93% rename from data/platform/dingux/sections/settings/50_system_info rename to data/platform/a320/sections/settings/50_system_info index 773a8e2..0ae9eec 100644 --- a/data/platform/dingux/sections/settings/50_system_info +++ b/data/platform/a320/sections/settings/50_system_info @@ -4,3 +4,4 @@ icon=skin:icons/about.png exec=/usr/bin/dialog params=--ok-label "Press START to exit" --no-shadow --msgbox "`/usr/bin/system_info`" 240 320 consoleapp=true +editable=false diff --git a/data/platform/dingux/sections/settings/60_tv_out b/data/platform/a320/sections/settings/60_tv_out similarity index 88% rename from data/platform/dingux/sections/settings/60_tv_out rename to data/platform/a320/sections/settings/60_tv_out index 4f1bbc3..756981f 100644 --- a/data/platform/dingux/sections/settings/60_tv_out +++ b/data/platform/a320/sections/settings/60_tv_out @@ -3,3 +3,4 @@ description=Enable/Disable TV output icon=skin:icons/tv.png exec=/usr/sbin/tvout_config consoleapp=true +editable=false diff --git a/data/platform/dingux/skins/Default/imgs/buttons/accept.png b/data/platform/a320/skins/Default/imgs/buttons/accept.png similarity index 100% rename from data/platform/dingux/skins/Default/imgs/buttons/accept.png rename to data/platform/a320/skins/Default/imgs/buttons/accept.png diff --git a/data/platform/dingux/skins/Default/imgs/buttons/cancel.png b/data/platform/a320/skins/Default/imgs/buttons/cancel.png similarity index 100% rename from data/platform/dingux/skins/Default/imgs/buttons/cancel.png rename to data/platform/a320/skins/Default/imgs/buttons/cancel.png diff --git a/data/platform/gcw0/about.txt b/data/platform/gcw0/about.txt new file mode 100644 index 0000000..ddeeedb --- /dev/null +++ b/data/platform/gcw0/about.txt @@ -0,0 +1,19 @@ +GMenu2X has been created by Massimiliano "Ryo" Torromeo, and is released under the GPL-v2 license. + +This version is maintained by the Qi-Hardware and OpenDingux crew. The credits, as well as the latest source code can be found here: +http://projects.qi-hardware.com/index.php/p/gmenu2x + +Credits for the translations: +----- +English & Italian by Massimiliano Torromeo +French by Yodaz +Danish by claus +Dutch by superfly +Spanish by pedator +Portuguese (Portugal) by NightShadow +Slovak by Jozef +Swedish by Esslan and Micket +German by fusion_power, johnnysnet and Waldteufel +Finnish by Jontte and Atte +Norwegian by cowai +Russian by XaMMaX90 diff --git a/data/platform/gcw0/gmenu2x.conf b/data/platform/gcw0/gmenu2x.conf new file mode 100644 index 0000000..4d21f4b --- /dev/null +++ b/data/platform/gcw0/gmenu2x.conf @@ -0,0 +1,4 @@ +videoBpp=32 +menuClock=192 +maxClock=1020 +backlightTimeout=60 diff --git a/data/platform/gcw0/input.conf b/data/platform/gcw0/input.conf new file mode 100644 index 0000000..db4d9bc --- /dev/null +++ b/data/platform/gcw0/input.conf @@ -0,0 +1,10 @@ +accept=keyboard,306 +cancel=keyboard,308 +altleft=keyboard,9 +altright=keyboard,8 +menu=keyboard,27 +settings=keyboard,13 +up=keyboard,273 +down=keyboard,274 +left=keyboard,276 +right=keyboard,275 diff --git a/data/platform/dingux/sections/games/.empty b/data/platform/gcw0/sections/applications/.empty similarity index 100% rename from data/platform/dingux/sections/games/.empty rename to data/platform/gcw0/sections/applications/.empty diff --git a/data/platform/gcw0/sections/applications/30_terminal b/data/platform/gcw0/sections/applications/30_terminal new file mode 100644 index 0000000..6a02151 --- /dev/null +++ b/data/platform/gcw0/sections/applications/30_terminal @@ -0,0 +1,6 @@ +title=Terminal +description=Disable graphic mode +icon=skin:icons/utilities-terminal.png +exec=/bin/busybox +params=sh -c 'clear; echo "The graphic mode is now disabled."; echo ""; echo "This is only useful for developers who want to test their graphical apps from telnet."; echo ""; echo "(Press START to exit to the launcher)"; read' +consoleapp=true diff --git a/data/platform/dingux/sections/settings/.empty b/data/platform/gcw0/sections/settings/.empty similarity index 100% rename from data/platform/dingux/sections/settings/.empty rename to data/platform/gcw0/sections/settings/.empty diff --git a/data/platform/gcw0/sections/settings/10_poweroff b/data/platform/gcw0/sections/settings/10_poweroff new file mode 100644 index 0000000..057151c --- /dev/null +++ b/data/platform/gcw0/sections/settings/10_poweroff @@ -0,0 +1,5 @@ +title=Power Off +description=Shut down the system +icon=skin:icons/poweroff.png +exec=/sbin/poweroff +editable=false diff --git a/data/platform/gcw0/sections/settings/20_reboot b/data/platform/gcw0/sections/settings/20_reboot new file mode 100644 index 0000000..4806411 --- /dev/null +++ b/data/platform/gcw0/sections/settings/20_reboot @@ -0,0 +1,5 @@ +title=Reboot +description=Reboot the system +icon=skin:icons/reboot.png +exec=/sbin/reboot +editable=false diff --git a/data/platform/gcw0/sections/settings/40_alsamixer b/data/platform/gcw0/sections/settings/40_alsamixer new file mode 100644 index 0000000..215b6b8 --- /dev/null +++ b/data/platform/gcw0/sections/settings/40_alsamixer @@ -0,0 +1,6 @@ +title=Sound Mixer +description=Configure sound settings +icon=skin:icons/alsamixer.png +exec=/usr/bin/alsamixer +consoleapp=true +editable=false diff --git a/data/platform/gcw0/sections/settings/50_system_info b/data/platform/gcw0/sections/settings/50_system_info new file mode 100644 index 0000000..0ae9eec --- /dev/null +++ b/data/platform/gcw0/sections/settings/50_system_info @@ -0,0 +1,7 @@ +title=System Info +description=Info about the system +icon=skin:icons/about.png +exec=/usr/bin/dialog +params=--ok-label "Press START to exit" --no-shadow --msgbox "`/usr/bin/system_info`" 240 320 +consoleapp=true +editable=false diff --git a/data/platform/gcw0/skins/Default/imgs/buttons/accept.png b/data/platform/gcw0/skins/Default/imgs/buttons/accept.png new file mode 100644 index 0000000..e3400f9 Binary files /dev/null and b/data/platform/gcw0/skins/Default/imgs/buttons/accept.png differ diff --git a/data/platform/gcw0/skins/Default/imgs/buttons/cancel.png b/data/platform/gcw0/skins/Default/imgs/buttons/cancel.png new file mode 100644 index 0000000..16de5be Binary files /dev/null and b/data/platform/gcw0/skins/Default/imgs/buttons/cancel.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_BLUE.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_BLUE.png new file mode 100644 index 0000000..60c7a59 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_BLUE.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_GREEN.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_GREEN.png new file mode 100644 index 0000000..2010a6b Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_GREEN.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_GREY.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_GREY.png new file mode 100644 index 0000000..98d0b3c Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_GREY.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_LIGHTBLUE.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_LIGHTBLUE.png new file mode 100644 index 0000000..b9785d4 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_LIGHTBLUE.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_ORANGE.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_ORANGE.png new file mode 100644 index 0000000..f740515 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_ORANGE.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_A_RED.png b/data/platform/gcw0/skins/Default/wallpapers/320_A_RED.png new file mode 100644 index 0000000..a80059f Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_A_RED.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_DARK.png b/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_DARK.png new file mode 100644 index 0000000..22b4101 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_DARK.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_LIGHT.png b/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_LIGHT.png new file mode 100644 index 0000000..1c127d4 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_CONSOLE_LIGHT.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BLUE.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BLUE.png new file mode 100644 index 0000000..bf0d733 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BLUE.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BUBBLEGUM.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BUBBLEGUM.png new file mode 100644 index 0000000..aac7568 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_BUBBLEGUM.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_DARK.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_DARK.png new file mode 100644 index 0000000..b394df7 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_DARK.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_GREY.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_GREY.png new file mode 100644 index 0000000..5b5342c Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_GREY.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_LEMON.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_LEMON.png new file mode 100644 index 0000000..e8a236d Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_LEMON.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_MINT.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_MINT.png new file mode 100644 index 0000000..353b642 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_MINT.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_ORANGE.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_ORANGE.png new file mode 100644 index 0000000..51173ea Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_ORANGE.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_STRAWBERRY.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_STRAWBERRY.png new file mode 100644 index 0000000..3ee9ea7 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_STRAWBERRY.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_TOMATO.png b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_TOMATO.png new file mode 100644 index 0000000..5f64eef Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_DIAGONAL_TEXT_TOMATO.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_GCW_DARK.png b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_DARK.png new file mode 100644 index 0000000..ab36fef Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_DARK.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_GCW_LIGHT.png b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_LIGHT.png new file mode 100644 index 0000000..9ab9be3 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_LIGHT.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/320_GCW_WAVE2.png b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_WAVE2.png new file mode 100644 index 0000000..fe1735c Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/320_GCW_WAVE2.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/COPYING b/data/platform/gcw0/skins/Default/wallpapers/COPYING new file mode 100644 index 0000000..e67240e --- /dev/null +++ b/data/platform/gcw0/skins/Default/wallpapers/COPYING @@ -0,0 +1,7 @@ +320_* images: + Copyright 2013 Ivan Díaz Bardeci + Licensed under Attribution-ShareAlike CC BY-SA. + +blue-zero.png: + Copyright 2013 Maarten ter Huurne + Licensed under Attribution-ShareAlike CC BY-SA. diff --git a/data/platform/gcw0/skins/Default/wallpapers/blue-zero.png b/data/platform/gcw0/skins/Default/wallpapers/blue-zero.png new file mode 100644 index 0000000..716c179 Binary files /dev/null and b/data/platform/gcw0/skins/Default/wallpapers/blue-zero.png differ diff --git a/data/platform/gcw0/skins/Default/wallpapers/default.png b/data/platform/gcw0/skins/Default/wallpapers/default.png new file mode 120000 index 0000000..f5809e0 --- /dev/null +++ b/data/platform/gcw0/skins/Default/wallpapers/default.png @@ -0,0 +1 @@ +320_GCW_DARK.png \ No newline at end of file diff --git a/data/platform/gcw0/skins/OD/skin.conf b/data/platform/gcw0/skins/OD/skin.conf new file mode 100644 index 0000000..a30fe83 --- /dev/null +++ b/data/platform/gcw0/skins/OD/skin.conf @@ -0,0 +1,11 @@ +wallpaper="blue-zero.png" +linkHeight=50 +topBarHeight=50 +bottomBarHeight=21 +linkWidth=80 +topBarBg=#ffffff00 +bottomBarBg=#ffffff00 +selectionBg=#9b9bff80 +messageBoxBg=#000014bc +messageBoxBorder=#9b9bff80 +messageBoxSelection=#9b9bff80 diff --git a/data/skins/320x240/Default/wallpapers/Qiwallpaper1.png b/data/platform/nanonote/skins/Default/wallpapers/Qiwallpaper1.png similarity index 100% rename from data/skins/320x240/Default/wallpapers/Qiwallpaper1.png rename to data/platform/nanonote/skins/Default/wallpapers/Qiwallpaper1.png diff --git a/data/skins/320x240/Default/wallpapers/Qiwallpaper2.png b/data/platform/nanonote/skins/Default/wallpapers/Qiwallpaper2.png similarity index 100% rename from data/skins/320x240/Default/wallpapers/Qiwallpaper2.png rename to data/platform/nanonote/skins/Default/wallpapers/Qiwallpaper2.png diff --git a/data/skins/320x240/Default/wallpapers/hicksonst.png b/data/platform/nanonote/skins/Default/wallpapers/hicksonst.png similarity index 100% rename from data/skins/320x240/Default/wallpapers/hicksonst.png rename to data/platform/nanonote/skins/Default/wallpapers/hicksonst.png diff --git a/data/skins/320x240/Default/wallpapers/open.png b/data/platform/nanonote/skins/Default/wallpapers/open.png similarity index 100% rename from data/skins/320x240/Default/wallpapers/open.png rename to data/platform/nanonote/skins/Default/wallpapers/open.png diff --git a/data/skins/320x240/Default/wallpapers/qi.png b/data/platform/nanonote/skins/Default/wallpapers/qi.png similarity index 100% rename from data/skins/320x240/Default/wallpapers/qi.png rename to data/platform/nanonote/skins/Default/wallpapers/qi.png diff --git a/data/skins/320x240/Default/imgs/bottombar.png b/data/skins/320x240/Default/imgs/bottombar.png index f7ec0b4..4c5c2fe 100644 Binary files a/data/skins/320x240/Default/imgs/bottombar.png and b/data/skins/320x240/Default/imgs/bottombar.png differ diff --git a/data/skins/320x240/Default/imgs/font.png b/data/skins/320x240/Default/imgs/font.png deleted file mode 100644 index cdccf51..0000000 Binary files a/data/skins/320x240/Default/imgs/font.png and /dev/null differ diff --git a/data/skins/320x240/Default/imgs/l_disabled.png b/data/skins/320x240/Default/imgs/l_disabled.png deleted file mode 100644 index d9a7dbd..0000000 Binary files a/data/skins/320x240/Default/imgs/l_disabled.png and /dev/null differ diff --git a/data/skins/320x240/Default/imgs/r_disabled.png b/data/skins/320x240/Default/imgs/r_disabled.png deleted file mode 100644 index 702ed6a..0000000 Binary files a/data/skins/320x240/Default/imgs/r_disabled.png and /dev/null differ diff --git a/data/skins/320x240/Default/imgs/section-l.png b/data/skins/320x240/Default/imgs/section-l.png new file mode 100644 index 0000000..ca6f426 Binary files /dev/null and b/data/skins/320x240/Default/imgs/section-l.png differ diff --git a/data/skins/320x240/Default/imgs/section-r.png b/data/skins/320x240/Default/imgs/section-r.png new file mode 100644 index 0000000..0fd1852 Binary files /dev/null and b/data/skins/320x240/Default/imgs/section-r.png differ diff --git a/data/skins/320x240/Default/imgs/topbar.png b/data/skins/320x240/Default/imgs/topbar.png index ccd9ea4..7fe0df7 100644 Binary files a/data/skins/320x240/Default/imgs/topbar.png and b/data/skins/320x240/Default/imgs/topbar.png differ diff --git a/data/skins/320x240/Default/skin.conf b/data/skins/320x240/Default/skin.conf index c98f25d..71fa2cd 100644 --- a/data/skins/320x240/Default/skin.conf +++ b/data/skins/320x240/Default/skin.conf @@ -5,5 +5,6 @@ messageBoxBg=#00000080 messageBoxSelection=#fffffff80 bottomBarBg=#ffffff80 topBarHeight=50 +bottomBarHeight=21 linkHeight=50 linkWidth=80 \ No newline at end of file diff --git a/data/skins/800x480/Default/imgs/font.png b/data/skins/800x480/Default/imgs/font.png deleted file mode 100644 index cdccf51..0000000 Binary files a/data/skins/800x480/Default/imgs/font.png and /dev/null differ diff --git a/data/skins/800x480/Default/imgs/l_disabled.png b/data/skins/800x480/Default/imgs/l_disabled.png deleted file mode 100644 index d9a7dbd..0000000 Binary files a/data/skins/800x480/Default/imgs/l_disabled.png and /dev/null differ diff --git a/data/skins/800x480/Default/imgs/l_enabled.png b/data/skins/800x480/Default/imgs/l_enabled.png deleted file mode 100644 index f300d91..0000000 Binary files a/data/skins/800x480/Default/imgs/l_enabled.png and /dev/null differ diff --git a/data/skins/800x480/Default/imgs/r_disabled.png b/data/skins/800x480/Default/imgs/r_disabled.png deleted file mode 100644 index 702ed6a..0000000 Binary files a/data/skins/800x480/Default/imgs/r_disabled.png and /dev/null differ diff --git a/data/skins/800x480/Default/imgs/r_enabled.png b/data/skins/800x480/Default/imgs/r_enabled.png deleted file mode 100644 index 239a856..0000000 Binary files a/data/skins/800x480/Default/imgs/r_enabled.png and /dev/null differ diff --git a/data/skins/320x240/Default/imgs/l_enabled.png b/data/skins/800x480/Default/imgs/section-l.png similarity index 100% rename from data/skins/320x240/Default/imgs/l_enabled.png rename to data/skins/800x480/Default/imgs/section-l.png diff --git a/data/skins/320x240/Default/imgs/r_enabled.png b/data/skins/800x480/Default/imgs/section-r.png similarity index 100% rename from data/skins/320x240/Default/imgs/r_enabled.png rename to data/skins/800x480/Default/imgs/section-r.png diff --git a/data/skins/800x480/Default/skin.conf b/data/skins/800x480/Default/skin.conf index c98f25d..71fa2cd 100644 --- a/data/skins/800x480/Default/skin.conf +++ b/data/skins/800x480/Default/skin.conf @@ -5,5 +5,6 @@ messageBoxBg=#00000080 messageBoxSelection=#fffffff80 bottomBarBg=#ffffff80 topBarHeight=50 +bottomBarHeight=21 linkHeight=50 linkWidth=80 \ No newline at end of file diff --git a/data/translations/Basque b/data/translations/Basque index 1895e61..235981f 100644 --- a/data/translations/Basque +++ b/data/translations/Basque @@ -1,3 +1,4 @@ +Lng=eu Settings=Aukerak Configure GMenu2X's options=GMenu2X aukerak konfiguratu Activate Usb on SD=Sd-aren usb-a aktibatu @@ -50,11 +51,11 @@ Number of columns=Zutabe zenbakia Set the number of columns of links to display on a page=Orri bakoitzeko erakutsiko diren zutabeak Number of rows=Ilara zenbakia Set the number of rows of links to display on a page=Orri bakoitzeko erakutsiko diren ilarak -Top Bar Color=Goiko barraren kolorea +Top Bar=Goiko barraren Color of the top bar=Goian dagoen barraren kolorea -Bottom Bar Color=Beheko barraren kolorea +Bottom Bar=Beheko barraren Color of the bottom bar=Behean dagoen barraren kolorea -Selection Color=aukeratutakoaren kolorea +Selection=Aukeratutakoaren Color of the selection and other interface details=Aukeratutako testuaren kolorea eta interfacearen beste aukera batzuk You should disable Usb Networking to do this.=Usb sarea desaktibatu beharko zenuke. Operation not permitted.=Baimendu gabeko operazioa. diff --git a/data/translations/Catalan b/data/translations/Catalan index 94a53db..9fdc913 100644 --- a/data/translations/Catalan +++ b/data/translations/Catalan @@ -1,137 +1,138 @@ -Settings=Preferències -Configure GMenu2X's options=Configura les opcions del GMenu2X -Activate Usb on SD=Activa USB per la SD -Activate Usb on Nand=Activa USB per la Nand -Info about GMenu2X=Informació del GMenu2X -About=Informació -Add section=Afegir secció -Rename section=Re anomenar secció -Delete section=Eliminar secció -Scan for applications and games=Buscar aplicacions i jocs -applications=Aplicacions -Edit link=Editar enllaç -Title=Títol -Link title=Títol de l'enllaç -Description=Descripció -Link description=Descripció de l'enllaç -Section=Secció -The section this link belongs to=Secció a la que pertany l'enllaç -Icon=Icona -Select an icon for the link: $1=Selecciona una icona per l'enllaç: $1 -Manual=Manual -Select a graphic/textual manual or a readme=Selecciona un manual gràfic/text o un "readme" -Cpu clock frequency to set when launching this link=Ajust del rellotge de la cpu per aquest enllaç -Volume to set for this link=Ajust del volum de l'enllaç -Parameters=Paràmetres -Parameters to pass to the application=Paràmetres que s'envien a l'aplicació -Selector Directory=Directori del Selector -Directory to scan for the selector=Directori a explorar amb el selector -Selector Browser=Explorador del selector -Allow the selector to change directory=Permetre al selector canviar de directori -Selector Filter=Filtre del selector -Filter for the selector (Separate values with a comma)=Filtre per el selector (Separar valors amb comes) -Selector Screenshots=Captures de pantalla del selector -Directory of the screenshots for the selector=Directori de captures de pantalla per el selector -Selector Aliases=Alias del selector -File containing a list of aliases for the selector=Fitxer que conté la llista d'alias per el selector -Explicitly relaunch GMenu2X after this link's execution ends=Força recarregar el GMenu2X a l'acabar l'execució de l'enllaç -Don't Leave=No sortir -Don't quit GMenu2X when launching this link=No tancar GMenu2X al carregar aquest enllaç -Save last selection=Recordar l'última selecció -Save the last selected link and section on exit=Recordar l'última secció i enllaç seleccionat al sortir -Clock for GMenu2X=Rellotge per al GMenu2X -Set the cpu working frequency when running GMenu2X=Ajustar la freqüència de treball de la cpu a l'executar GMenu2X -Maximum overclock=Overclock màxim -Set the maximum overclock for launching links=Ajustar al màxim overclock per a carregar enllaços -Global Volume=Volum global -Set the default volume for the gp2x soundcard=Ajusta el volum per defecte del so a la gp2x -Output logs=Fitxers de Log -Logs the output of the links. Use the Log Viewer to read them.=Enregistra els Logs dels enllaços. Usa el lector de registres per llegir-los. -Number of columns=Número de columnes -Set the number of columns of links to display on a page=Ajusta el número de columnes d'enllaços a mostrar per pàgina -Number of rows=Número de línies -Set the number of rows of links to display on a page=Ajusta el número de línies d'enllaços a mostrar per pàgina -Top Bar Color=Color de barra superior -Color of the top bar=Color de la barra superior -Bottom Bar Color=Color de barra inferior -Color of the bottom bar=Color de la barra inferior -Selection Color=Color selecció -Color of the selection and other interface details=Color de la selecció i altres detalls de la interfície -You should disable Usb Networking to do this.=Ha de desactivar la Xarxa per USB per fer això. -Operation not permitted.=Operació no permesa. -Language=Idioma -Set the language used by GMenu2X=Ajusta l'idioma utilitzat al GMenu2X -Increase=Augmentar -Decrease=Reduïr -Change color component=Canviar component cromàtic -Increase value=Incrementar valor -Decrease value=Reduir valor -Switch=Canviar -Change value=Canviar valor -Edit=Modificar -Clear=Netejar -Select a directory=Selecciona un directori -Select a file=Selecciona un fitxer -Clock (default: 200)=Freqüència (predeterminada: 200) -Volume (default: -1)=Volum (predeterminat: -1) -Enter folder=Entrar a la carpeta -Wrapper=Retornar -Confirm=Confirmar -Enter folder/Confirm=Entrar a la carpeta/Confirmar -Up one folder=Pujar una carpeta -Select an application=Selecciona un programa -Space=Espai -Shift=Majúscules -Cancel=Cancel·lar -OK=Acceptar -Backspace=Retrocés -Skin=Tema -Set the skin used by GMenu2X=Selecciona el tema a utilitzar al GMenu2X -Add link in $1=Afegir enllaç a $1 -Edit $1=Modificar $1 -Delete $1 link=Eliminar l'enllaç de $1 -Deleting $1=Eliminant $1 -Are you sure?=Estàs segur? -Insert a name for the new section=Introduir nom per a la nova secció -Insert a new name for this section=Introduir nou nom per a la secció -Yes=Si -No=No -You will lose all the links in this section.=Es perdran tots els enllaços d'aquesta secció. -Exit=Sortir -Link Scanner=Buscador d'enllaços -Scanning SD filesystem...=Explorant el sistema de fitxers de la SD... -Scanning NAND filesystem...=Explorant el sistema de fitxers de la NAND... -$1 files found.=$1 Fitxer(s) trobat(s). -Creating links...=Creant enllaços... -$1 links created.=$1 enllaç(os) creat(s). -Version $1 (Build date: $2)=Versió $1 (Compilació: $2) -Log Viewer=Visor de Logs -Displays last launched program's output=Mostra la sortida de l'últim programa executat -Do you want to delete the log file?=¿Desitja eliminar el fitxer de registre de successos? -USB Enabled (SD)=USB Activat (SD) -USB Enabled (Nand)=USB Activat (Nand) -Turn off=Desactivar -Launching $1=Executant $1 -Change page=Canviar pàgina -Page=Pàgina -Scroll=Desplaçament -Untitled=Sense títol -Change GMenu2X wallpaper=Canvia el fons del GMenu2X -Activate/deactivate tv-out=Activa/desactiva la sortida de TV -Select wallpaper=Selecciona la imatge de fons -Gamma=Gamma -Set gp2x gamma value (default: 10)=Ajustar el valor gama de la gp2x (predeterminat: 10) -Tv-Out encoding=Codificació de sortida de TV -Encoding of the tv-out signal=Codificació de la senyal de sortida de TV -Tweak RAM Timings=Modifica la sincronització de RAM -This usually speeds up the application at the cost of stability=Normalment accelera l'aplicació a costa de l'estabilitat -Gamma (default: 0)=Gamma (predeterminat: 0) -Gamma value to set when launching this link=Valor de gamma que utilitzarà a l'executar aquest enllaç -Wallpaper=Fons d'escriptori -Configure skin=Configura el Tema -Message Box Color=Color de caixa de text -Message Box Border Color=Color de la vora de la caixa de text -Message Box Selection Color=Color de la selecció de la caixa de text -Background color of the message box=Color de fons de la caixa de text -Border color of the message box=Color de la vora de la caixa de text -Color of the selection of the message box=Color de la selecció de la caixa de text +Lng=ca +Settings=Preferències +Configure GMenu2X's options=Configura les opcions del GMenu2X +Activate Usb on SD=Activa USB per la SD +Activate Usb on Nand=Activa USB per la Nand +Info about GMenu2X=Informació del GMenu2X +About=Informació +Add section=Afegir secció +Rename section=Re anomenar secció +Delete section=Eliminar secció +Scan for applications and games=Buscar aplicacions i jocs +applications=Aplicacions +Edit link=Editar enllaç +Title=Títol +Link title=Títol de l'enllaç +Description=Descripció +Link description=Descripció de l'enllaç +Section=Secció +The section this link belongs to=Secció a la que pertany l'enllaç +Icon=Icona +Select an icon for the link: $1=Selecciona una icona per l'enllaç: $1 +Manual=Manual +Select a graphic/textual manual or a readme=Selecciona un manual gràfic/text o un "readme" +Cpu clock frequency to set when launching this link=Ajust del rellotge de la cpu per aquest enllaç +Volume to set for this link=Ajust del volum de l'enllaç +Parameters=Paràmetres +Parameters to pass to the application=Paràmetres que s'envien a l'aplicació +Selector Directory=Directori del Selector +Directory to scan for the selector=Directori a explorar amb el selector +Selector Browser=Explorador del selector +Allow the selector to change directory=Permetre al selector canviar de directori +Selector Filter=Filtre del selector +Filter for the selector (Separate values with a comma)=Filtre per el selector (Separar valors amb comes) +Selector Screenshots=Captures de pantalla del selector +Directory of the screenshots for the selector=Directori de captures de pantalla per el selector +Selector Aliases=Alias del selector +File containing a list of aliases for the selector=Fitxer que conté la llista d'alias per el selector +Explicitly relaunch GMenu2X after this link's execution ends=Força recarregar el GMenu2X a l'acabar l'execució de l'enllaç +Don't Leave=No sortir +Don't quit GMenu2X when launching this link=No tancar GMenu2X al carregar aquest enllaç +Save last selection=Recordar l'última selecció +Save the last selected link and section on exit=Recordar l'última secció i enllaç seleccionat al sortir +Clock for GMenu2X=Rellotge per al GMenu2X +Set the cpu working frequency when running GMenu2X=Ajustar la freqüència de treball de la cpu a l'executar GMenu2X +Maximum overclock=Overclock màxim +Set the maximum overclock for launching links=Ajustar al màxim overclock per a carregar enllaços +Global Volume=Volum global +Set the default volume for the gp2x soundcard=Ajusta el volum per defecte del so a la gp2x +Output logs=Fitxers de Log +Logs the output of the links. Use the Log Viewer to read them.=Enregistra els Logs dels enllaços. Usa el lector de registres per llegir-los. +Number of columns=Número de columnes +Set the number of columns of links to display on a page=Ajusta el número de columnes d'enllaços a mostrar per pàgina +Number of rows=Número de línies +Set the number of rows of links to display on a page=Ajusta el número de línies d'enllaços a mostrar per pàgina +Top Bar=Barra superior +Color of the top bar=Color de la barra superior +Bottom Bar=Barra inferior +Color of the bottom bar=Color de la barra inferior +Selection=Selecció +Color of the selection and other interface details=Color de la selecció i altres detalls de la interfície +You should disable Usb Networking to do this.=Ha de desactivar la Xarxa per USB per fer això. +Operation not permitted.=Operació no permesa. +Language=Idioma +Set the language used by GMenu2X=Ajusta l'idioma utilitzat al GMenu2X +Increase=Augmentar +Decrease=Reduïr +Change color component=Canviar component cromàtic +Increase value=Incrementar valor +Decrease value=Reduir valor +Switch=Canviar +Change value=Canviar valor +Edit=Modificar +Clear=Netejar +Select a directory=Selecciona un directori +Select a file=Selecciona un fitxer +Clock (default: 200)=Freqüència (predeterminada: 200) +Volume (default: -1)=Volum (predeterminat: -1) +Enter folder=Entrar a la carpeta +Wrapper=Retornar +Confirm=Confirmar +Enter folder/Confirm=Entrar a la carpeta/Confirmar +Up one folder=Pujar una carpeta +Select an application=Selecciona un programa +Space=Espai +Shift=Majúscules +Cancel=Cancel·lar +OK=Acceptar +Backspace=Retrocés +Skin=Tema +Set the skin used by GMenu2X=Selecciona el tema a utilitzar al GMenu2X +Add link in $1=Afegir enllaç a $1 +Edit $1=Modificar $1 +Delete $1 link=Eliminar l'enllaç de $1 +Deleting $1=Eliminant $1 +Are you sure?=Estàs segur? +Insert a name for the new section=Introduir nom per a la nova secció +Insert a new name for this section=Introduir nou nom per a la secció +Yes=Si +No=No +You will lose all the links in this section.=Es perdran tots els enllaços d'aquesta secció. +Exit=Sortir +Link Scanner=Buscador d'enllaços +Scanning SD filesystem...=Explorant el sistema de fitxers de la SD... +Scanning NAND filesystem...=Explorant el sistema de fitxers de la NAND... +$1 files found.=$1 Fitxer(s) trobat(s). +Creating links...=Creant enllaços... +$1 links created.=$1 enllaç(os) creat(s). +Version $1 (Build date: $2)=Versió $1 (Compilació: $2) +Log Viewer=Visor de Logs +Displays last launched program's output=Mostra la sortida de l'últim programa executat +Do you want to delete the log file?=¿Desitja eliminar el fitxer de registre de successos? +USB Enabled (SD)=USB Activat (SD) +USB Enabled (Nand)=USB Activat (Nand) +Turn off=Desactivar +Launching $1=Executant $1 +Change page=Canviar pàgina +Page=Pàgina +Scroll=Desplaçament +Untitled=Sense títol +Change GMenu2X wallpaper=Canvia el fons del GMenu2X +Activate/deactivate tv-out=Activa/desactiva la sortida de TV +Select wallpaper=Selecciona la imatge de fons +Gamma=Gamma +Set gp2x gamma value (default: 10)=Ajustar el valor gama de la gp2x (predeterminat: 10) +Tv-Out encoding=Codificació de sortida de TV +Encoding of the tv-out signal=Codificació de la senyal de sortida de TV +Tweak RAM Timings=Modifica la sincronització de RAM +This usually speeds up the application at the cost of stability=Normalment accelera l'aplicació a costa de l'estabilitat +Gamma (default: 0)=Gamma (predeterminat: 0) +Gamma value to set when launching this link=Valor de gamma que utilitzarà a l'executar aquest enllaç +Wallpaper=Fons d'escriptori +Configure skin=Configura el Tema +Message Box=Caixa de text +Message Box Border=Vora de la caixa de text +Message Box Selection=Selecció de la caixa de text +Background color of the message box=Color de fons de la caixa de text +Border color of the message box=Color de la vora de la caixa de text +Color of the selection of the message box=Color de la selecció de la caixa de text diff --git a/data/translations/Danish b/data/translations/Danish index ecd2099..6ab9d6c 100644 --- a/data/translations/Danish +++ b/data/translations/Danish @@ -1,129 +1,130 @@ -settings=Indstillinger -Configure GMenu2X's options=Konfigurer GMenu2X's Indstillinger -Activate Usb on SD=Aktiver Usb på SD -Activate Usb on Nand=Aktiver Usb på Nand -Info about GMenu2X=Information om GMenu2X -Activate/deactivate tv-out=Aktiver/deaktiver tv-udgang -Exit GMenu2X to the official frontend=Lukker GMenu2X -Change GMenu2X wallpaper=Skift baggrund -About=Om -Add section=Tilføj sektion -Rename section=Ændre navn på sektion -Delete section=Slet sektion -Scan for applications and games=Skan hukommelsen for applikationer og spil -applications=applikationer -Edit link=Rediger genveje -Title=Titel -Link title=Genvejs titel -Description=Beskrivelse -Link description=Genvejs beskrivelse -Section=Seektion -The section this link belongs to=Sektionen for denne genvej -Icon=Ikon -Select an icon for the link=Vælg et ikon til denne genvej -Manual=Manual -Select a graphic/textual manual or a readme=Vælg en grafisk/tekstbaseret manual eller en readme fil -Cpu clock frequency to set when launching this link=Cpu-clockfrekvens indstilling for denne genvej -Volume to set for this link=Lydstyrke indstilling for denne genvej -Parameters=Parametre -Parameters to pass to the application=Angiv parametre for applikationen -Selector Directory=Selector oversigt -Directory to scan for the selector=Angiv Mappe som selector skal skanne -Selector Browser=Selector Browser -Allow the selector to change directory=Tillad selector at ændre mappe -Selector Filter=Selector filter -Filter for the selector (Separate values with a comma)=Filter til selector (separer værdier med komma) -Selector Screenshots= Selector Screenshots -Directory of the screenshots for the selector=Mappe med Screenshots af selector -Selector Aliases=Selector alias -File containing a list of aliases for the selector=Fil som indeholder en liste over alias for selector -Explicitly relaunch GMenu2X after this link's execution ends=Tving GMenu2X til at genstarte når denne genvej køres -Don't Leave=Forlad ikke -Don't quit GMenu2X when launching this link=Afslut ikke GMenu2X når denne genvej startes -Save last selection=Gem sidste ændring -Save the last selected link and section on exit= Gem sidst valgte genvej og sektion ved afslutning -Clock for GMenu2X=Clockfrekvens for GMenu2X -Set the cpu working frequency when running GMenu2X=Indstil cpu-clockfrekvens for GMenu2X -Maximum overclock=Maksimal clockfrekvens -Set the maximum overclock for launching links=Indstil maksimal clockfrekvens ved opstart af genvej -Global Volume=Global lydstyrke -Set the default volume for the gp2x soundcard=Indstil standard lydstyrke for gp2x lydkort -Output logs=Vis logs -Logs the output of the links. Use the Log Viewer to read them.=Danner logs for genvejene. Anvend Vis log for at åbne dem. -Number of columns=Antal spalter -Set the number of columns of links to display on a page=Angiv antallet af spalter for genveje per side -Number of rows=Antal rækker -Set the number of rows of links to display on a page= Angiv antallet af rækker for genveje per side -Top Bar Color=Øverste bjælkes farve -Color of the top bar= Øverste bjælkes farve -Bottom Bar Color=Nederste bjælkes farve -Color of the bottom bar=Nederste bjælkes farve -Selection Color=Markørens farve -Color of the selection and other interface details= Markøren og grænseflades farve -You should disable Usb Networking to do this.=Du bør fravælge USB netværket nå du vælger dette -Operation not permitted.=Dette er ikke tilladt. -Language=Sprog -Set the language used by GMenu2X=Indstil sprog der anvendes i GMenu2X -Increase=Op -Decrease=Ned -Change color component=Ændre farven på komponent -Increase value=Op -Decrease value=Ned -Switch=Ændre -Change value=Ændre værdi -Edit=Rediger -Clear=Ryd -Select a directory=Vælg en mappe -Select a file=Vælg en fil -Clock (default: 200)=Clockfrekvens (normal: 200) -Volume (default: -1)=Lydstyrke (normal: -1) -Wrapper=Wrapper -Enter folder=Åbn mappe -Confirm=Bekræft -Enter folder/Confirm=Åbn mappe/Bekræft -Up one folder=Tilbage -Select an application=Vælg en applikation -Space=Mellemrum -Shift=Skift -Cancel=Afbryd -OK=OK -Backspace=Slet -Skin=Tema -Set the skin used by GMenu2X =Angiv tema for GMenu2X -Add link in $1=Tilføj genvej i $1 -Edit $1=Rediger $1 -Delete $1 link=Slet $1 -Deleting $1=Sletter $1 -Are you sure?=Er du sikker? -Insert a name for the new section=Angiv navn for den nye sektion -Insert a new name for this section=Angiv nyt navn for denne sektion -Yes=Ja -No=Nej -You will lose all the links in this section.=Du vil miste alle genveje i denne sektion. -Exit=Afslut -Link Scanner=Skan genveje -Scanning SD filesystem...=Skanner SD filsystem... -Scanning NAND filesystem...=Skanner NAND filsystem... -$1 files found.=$1 fil(er) fundet. -Creating links...=Opretter genveje... -$1 links created.=$1 genvej(e) oprettet. -Version $1 (Build date: $2)=Version $1 (den: $2) -Log Viewer=Vis log -Displays last launched program's output=Vis log fra sidst kørte program -Do you want to delete the log file?=Vil du slette denne log fil? -USB Enabled (SD)=USB Aktiveret (SD) -USB Enabled (Nand)=USB Aktiveret (Nand) -Turn off=Afbryd -Launching $1=Starter $1 -Change page=Skift side -Page=Side -Scroll=Rulle -Untitled=Ikke navngivet -Wallpaper=Baggrund -Configure skin=Konfigurer tema -Message Box Color=Farve på Konfigurations vinduet -Message Box Border Color= Farve på Konfig vinduets kant -Message Box Selection Color=Konfig vinduets markør farve -Background color of the message box= Konfigurations vinduets baggrundsfarve -Border color of the message box=Farve på Konfigurations vinduets kant -Color of the selection of the message box=Farven på markøren i Konfigurations vinduet +Lng=da +settings=Indstillinger +Configure GMenu2X's options=Konfigurer GMenu2X's Indstillinger +Activate Usb on SD=Aktiver Usb på SD +Activate Usb on Nand=Aktiver Usb på Nand +Info about GMenu2X=Information om GMenu2X +Activate/deactivate tv-out=Aktiver/deaktiver tv-udgang +Exit GMenu2X to the official frontend=Lukker GMenu2X +Change GMenu2X wallpaper=Skift baggrund +About=Om +Add section=Tilføj sektion +Rename section=Ændre navn på sektion +Delete section=Slet sektion +Scan for applications and games=Skan hukommelsen for applikationer og spil +applications=applikationer +Edit link=Rediger genveje +Title=Titel +Link title=Genvejs titel +Description=Beskrivelse +Link description=Genvejs beskrivelse +Section=Seektion +The section this link belongs to=Sektionen for denne genvej +Icon=Ikon +Select an icon for the link=Vælg et ikon til denne genvej +Manual=Manual +Select a graphic/textual manual or a readme=Vælg en grafisk/tekstbaseret manual eller en readme fil +Cpu clock frequency to set when launching this link=Cpu-clockfrekvens indstilling for denne genvej +Volume to set for this link=Lydstyrke indstilling for denne genvej +Parameters=Parametre +Parameters to pass to the application=Angiv parametre for applikationen +Selector Directory=Selector oversigt +Directory to scan for the selector=Angiv Mappe som selector skal skanne +Selector Browser=Selector Browser +Allow the selector to change directory=Tillad selector at ændre mappe +Selector Filter=Selector filter +Filter for the selector (Separate values with a comma)=Filter til selector (separer værdier med komma) +Selector Screenshots= Selector Screenshots +Directory of the screenshots for the selector=Mappe med Screenshots af selector +Selector Aliases=Selector alias +File containing a list of aliases for the selector=Fil som indeholder en liste over alias for selector +Explicitly relaunch GMenu2X after this link's execution ends=Tving GMenu2X til at genstarte når denne genvej køres +Don't Leave=Forlad ikke +Don't quit GMenu2X when launching this link=Afslut ikke GMenu2X når denne genvej startes +Save last selection=Gem sidste ændring +Save the last selected link and section on exit= Gem sidst valgte genvej og sektion ved afslutning +Clock for GMenu2X=Clockfrekvens for GMenu2X +Set the cpu working frequency when running GMenu2X=Indstil cpu-clockfrekvens for GMenu2X +Maximum overclock=Maksimal clockfrekvens +Set the maximum overclock for launching links=Indstil maksimal clockfrekvens ved opstart af genvej +Global Volume=Global lydstyrke +Set the default volume for the gp2x soundcard=Indstil standard lydstyrke for gp2x lydkort +Output logs=Vis logs +Logs the output of the links. Use the Log Viewer to read them.=Danner logs for genvejene. Anvend Vis log for at åbne dem. +Number of columns=Antal spalter +Set the number of columns of links to display on a page=Angiv antallet af spalter for genveje per side +Number of rows=Antal rækker +Set the number of rows of links to display on a page= Angiv antallet af rækker for genveje per side +Top Bar=Øverste bjælke +Color of the top bar= Øverste bjælkes farve +Bottom Bar=Nederste bjælke +Color of the bottom bar=Nederste bjælkes farve +Selection=Markøren +Color of the selection and other interface details= Markøren og grænseflades farve +You should disable Usb Networking to do this.=Du bør fravælge USB netværket nå du vælger dette +Operation not permitted.=Dette er ikke tilladt. +Language=Sprog +Set the language used by GMenu2X=Indstil sprog der anvendes i GMenu2X +Increase=Op +Decrease=Ned +Change color component=Ændre farven på komponent +Increase value=Op +Decrease value=Ned +Switch=Ændre +Change value=Ændre værdi +Edit=Rediger +Clear=Ryd +Select a directory=Vælg en mappe +Select a file=Vælg en fil +Clock (default: 200)=Clockfrekvens (normal: 200) +Volume (default: -1)=Lydstyrke (normal: -1) +Wrapper=Wrapper +Enter folder=Åbn mappe +Confirm=Bekræft +Enter folder/Confirm=Åbn mappe/Bekræft +Up one folder=Tilbage +Select an application=Vælg en applikation +Space=Mellemrum +Shift=Skift +Cancel=Afbryd +OK=OK +Backspace=Slet +Skin=Tema +Set the skin used by GMenu2X =Angiv tema for GMenu2X +Add link in $1=Tilføj genvej i $1 +Edit $1=Rediger $1 +Delete $1 link=Slet $1 +Deleting $1=Sletter $1 +Are you sure?=Er du sikker? +Insert a name for the new section=Angiv navn for den nye sektion +Insert a new name for this section=Angiv nyt navn for denne sektion +Yes=Ja +No=Nej +You will lose all the links in this section.=Du vil miste alle genveje i denne sektion. +Exit=Afslut +Link Scanner=Skan genveje +Scanning SD filesystem...=Skanner SD filsystem... +Scanning NAND filesystem...=Skanner NAND filsystem... +$1 files found.=$1 fil(er) fundet. +Creating links...=Opretter genveje... +$1 links created.=$1 genvej(e) oprettet. +Version $1 (Build date: $2)=Version $1 (den: $2) +Log Viewer=Vis log +Displays last launched program's output=Vis log fra sidst kørte program +Do you want to delete the log file?=Vil du slette denne log fil? +USB Enabled (SD)=USB Aktiveret (SD) +USB Enabled (Nand)=USB Aktiveret (Nand) +Turn off=Afbryd +Launching $1=Starter $1 +Change page=Skift side +Page=Side +Scroll=Rulle +Untitled=Ikke navngivet +Wallpaper=Baggrund +Configure skin=Konfigurer tema +Message Box=Konfigurations vinduet +Message Box Border=Konfig vinduets kant +Message Box Selection=Konfig vinduets markør +Background color of the message box= Konfigurations vinduets baggrundsfarve +Border color of the message box=Farve på Konfigurations vinduets kant +Color of the selection of the message box=Farven på markøren i Konfigurations vinduet diff --git a/data/translations/Dutch b/data/translations/Dutch index eaa3062..17dcf6a 100644 --- a/data/translations/Dutch +++ b/data/translations/Dutch @@ -1,3 +1,4 @@ +Lng=nl Settings=Instellingen Configure GMenu2X's options=Instellingen van GMenu2X Activate Usb on SD=Activeer USB op SD @@ -51,11 +52,11 @@ Number of columns=Aantal kolommen Set the number of columns of links to display on a page=Stel het aantal getoonde pictogrammen in (horizontaal) Number of rows=Aantal rijen Set the number of rows of links to display on a page=Stel het aantal getoonde pictogrammen in (verticaal) -Top Bar Color=Kleur bovenste balk +Top Bar=Bovenste balk Color of the top bar=Kleur van de bovenste balk -Bottom Bar Color=Kleur onderste balk +Bottom Bar=Onderste balk Color of the bottom bar=Kleur van de onderste balk -Selection Color=Kleur selectie +Selection=Selectie Color of the selection and other interface details=Kleur van de selectie en andere interface details You should disable Usb Networking to do this.=Zet USB Netwerk uit om dit te gebruiken. Operation not permitted.=Handeling niet toegestaan. diff --git a/data/translations/Finnish b/data/translations/Finnish index c01f595..05d4f3e 100644 --- a/data/translations/Finnish +++ b/data/translations/Finnish @@ -1,117 +1,119 @@ -Settings=Asetukset -Configure GMenu2X's options=Muuta GMenu2X:n asetuksia -Activate Usb on SD=Aktivoi USB SD-kortille -Activate Usb on Nand=Aktivoi USB NAND-muistille -Info about GMenu2X=Tietoa GMenu2X:st� -About=Tietoa -Add section=Lis�� v�lilehti -Rename section=Nime� v�lilehti uudelleen -Delete section=Poista v�lilehti -Scan for applications and games=Etsi ohjelmia ja pelej� -applications=ohjelmat -Edit link=Muokkaa linkki� -Title=Otsikko -Link title=Linkin otsikko -Description=Kuvaus -Link description=Linkin kuvaus -Section=V�lilehti -The section this link belongs to=V�lilehti johon t�m� linkki kuuluu -Icon=Kuvake -Select an icon for the link: $1=Valitse kuvake linkille: $1 -Manual=Ohjetiedosto -Select a graphic/textual manual or a readme=Valitse graafinen/tekstipohjainen ohjetiedosto -Cpu clock frequency to set when launching this link=CPU kellotaajuus t�m�n linkin k�ynnistyksess� -Volume to set for this link=��nenvoimakkuus t�lle linkille -Parameters=Parametrit -Parameters to pass to the application=Ohjelmalle annettavat parametrit -Selector Directory=Ohjelmanvalitsimen hakemisto -Directory to scan for the selector=Hakemisto joka skannataan ohjelmanvalitsimelle -Selector Browser=Ohjelmanvalitsimen selain -Allow the selector to change directory=Anna ohjelmanvalitsimen vaihtaa hakemistoa -Selector Filter=Ohjelmavalitsimen filtteri -Filter for the selector (Separate values with a comma)=Filtteri ohjelmanvalitsimelle (Eroita arvot pilkulla) -Selector Screenshots=Kuvakaappaukset ohjelmanvalitsimesta -Directory of the screenshots for the selector=Ohjelmanvalitsimen kuvakaappausten hakemisto -Selector Aliases=Ohjelmanvalitsimen peitenimet -File containing a list of aliases for the selector=Tiedosto, joka sis�lt�� listan peitenimist� ohjelmavalitsimelle -Explicitly relaunch GMenu2X after this link's execution ends=K�ynnist� GMenu2X uudelleen kun linkin ajo on suoritettu -Don't Leave=�l� poistu -Don't quit GMenu2X when launching this link=�l� sulje GMenu2X:�� kun linkki k�ynnistet��n -Save last selection=Muista viimeisin valinta -Save the last selected link and section on exit=Muista viimeisin valinta ja v�lilehti poistuttaessa -Clock for GMenu2X=Kellotaajuus GMenu2X:lle -Set the cpu working frequency when running GMenu2X=S��d� CPU kellotaajuutta GMenu2X:lle -Maximum overclock=Ylikellotusrajoitus -Set the maximum overclock for launching links=S��d� suurin mahdollinen ylikellotus k�ynnistett�ess� linkkej� -Global Volume=Yleinen ��nenvoimakkuus -Set the default volume fo the gp2x soundcard=S��d� perus��nenvoimakkuus gp2x:n ��nikortille -Output logs=Tulosteloki -Logs the output of the links. Use the Log Viewer to read them.=Kirjoita linkkien tuloste lokiin. K�yt� lokilukijaa niiden lukemiseen. -Number of columns=Sarakkeiden lukum��r� -Set the number of columns of links to display on a page=Aseta linkkisarakkeiden lukum��r� sivulla -Number of rows=Rivien lukum��r� -Set the number of rows of links to display on a page=Aseta linkkirivien lukum��r� sivulla -Top Bar Color=V�ri yl�palkille -Color of the top bar=Yl�palkin v�ri -Color of the bottom bar=Alapalkin v�ri -Selection Color=Valinnan v�ri -Color of the selection and other interface details=Valinnan ja muiden ykstiyiskohtien v�ri -You should disable Usb Networking to do this.=Usb Networking:in pit�� olla poissa k�yt�st� jotta voit tehd� t�m�n. -Operation not permitted.=Toiminto ei ole sallittu. -Language=Kieli -Set the language used by GMenu2X=Valitse GMenu2X:n k�ytt�m� kieli -Increase=Lis�� -Decrease=V�henn� -Change color component=Vaihda v�rikomponenttia -Increase value=Nosta arvoa -Decrease value=Laske arvoa -Switch=Vaihda -Change value=Vaihda arvoa -Edit=Muokkaa -Clear=Tyhjenn� -Select a directory=Valitse hakemisto -Select a file=Valitse tiedosto -Clock (default: 200)=Kellotaajuus (oletusarvo: 200) -Volume (default: -1)=��nenvoimakkuus (oletusarvo: -1) -Wrapper=Wrapperi -Enter folder=Avaa kansio -Confirm=Vahvista -Enter folder/Confirm=Avaa kansio/Vahvista -Up one folder=Yksi hakemisto yl�sp�in -Select an application=Valitse ohjelma -Space=V�lily�nti -Shift=Vaihto -Cancel=Peruuta -OK=OK -Backspace=Askelpalautin -Skin=Teema -Set the skin used by GMenu2X=Aseta GMenu2X:n k�ytt�m� teema -Add link in $1=Lis�� linkki v�lilehteen $1 -Edit $1=Muokkaa v�lilehte� $1 -Delete $1 link=Poista v�lilehti $1 -Deleting $1=Poistetaan v�lilehte� $1 -Are you sure?=Oletko varma? -Insert a name for the new section=Anna uuden v�lilehden nimi -Insert a new name for this section=Anna uusi nimi t�lle v�lilehdelle -Yes=Kyll� -No=Ei -You will lose all the links in this section.=Menet�t kaikki t�ss� v�lilehdess� olevat linkit. -Exit=Poistu -Link Scanner=Linkkiskanneri -Scanning SD filesystem...=Skannataan SD-tiedostoj�rjestelm��... -Scanning NAND filesystem...=Skannataan NAND-tiedostoj�rjestelm��... -$1 files found.=$1 tiedosto(a) l�ydetty. -Creating links...=Luodaan linkkej�... -$1 links created.=$1 linkki(�) luotu. -Version $1 (Build date: $2)=Versio $1 (K��nt�p�iv�m��r�: $2) -Log Viewer=Lokilukija -Displays last launched program's output=N�ytt�� viimeksi k�ynnistetyn ohjelman tulosteen -Do you want to delete the log file?=Haluatko poistaa logitiedoston? -USB Enabled (SD)=USB Aktivoitu (SD) -USB Enabled (Nand)=USB Aktivoitu (Nand) -Turn off=Sammuta -Launching $1=K�ynnistet��n $1 -Change page=Vaihda sivua -Page=Sivu -Scroll=Vierit� -Untitled=Nime�m�t�n +Lng=fi +Settings=Asetukset +Configure GMenu2X's options=Muuta GMenu2X:n asetuksia +Activate Usb on SD=Aktivoi USB SD-kortille +Activate Usb on Nand=Aktivoi USB NAND-muistille +Info about GMenu2X=Tietoa GMenu2X:st� +About=Tietoa +Add section=Lis�� v�lilehti +Rename section=Nime� v�lilehti uudelleen +Delete section=Poista v�lilehti +Scan for applications and games=Etsi ohjelmia ja pelej� +applications=ohjelmat +Edit link=Muokkaa linkki� +Title=Otsikko +Link title=Linkin otsikko +Description=Kuvaus +Link description=Linkin kuvaus +Section=V�lilehti +The section this link belongs to=V�lilehti johon t�m� linkki kuuluu +Icon=Kuvake +Select an icon for the link: $1=Valitse kuvake linkille: $1 +Manual=Ohjetiedosto +Select a graphic/textual manual or a readme=Valitse graafinen/tekstipohjainen ohjetiedosto +Cpu clock frequency to set when launching this link=CPU kellotaajuus t�m�n linkin k�ynnistyksess� +Volume to set for this link=��nenvoimakkuus t�lle linkille +Parameters=Parametrit +Parameters to pass to the application=Ohjelmalle annettavat parametrit +Selector Directory=Ohjelmanvalitsimen hakemisto +Directory to scan for the selector=Hakemisto joka skannataan ohjelmanvalitsimelle +Selector Browser=Ohjelmanvalitsimen selain +Allow the selector to change directory=Anna ohjelmanvalitsimen vaihtaa hakemistoa +Selector Filter=Ohjelmavalitsimen filtteri +Filter for the selector (Separate values with a comma)=Filtteri ohjelmanvalitsimelle (Eroita arvot pilkulla) +Selector Screenshots=Kuvakaappaukset ohjelmanvalitsimesta +Directory of the screenshots for the selector=Ohjelmanvalitsimen kuvakaappausten hakemisto +Selector Aliases=Ohjelmanvalitsimen peitenimet +File containing a list of aliases for the selector=Tiedosto, joka sis�lt�� listan peitenimist� ohjelmavalitsimelle +Explicitly relaunch GMenu2X after this link's execution ends=K�ynnist� GMenu2X uudelleen kun linkin ajo on suoritettu +Don't Leave=�l� poistu +Don't quit GMenu2X when launching this link=�l� sulje GMenu2X:�� kun linkki k�ynnistet��n +Save last selection=Muista viimeisin valinta +Save the last selected link and section on exit=Muista viimeisin valinta ja v�lilehti poistuttaessa +Clock for GMenu2X=Kellotaajuus GMenu2X:lle +Set the cpu working frequency when running GMenu2X=S��d� CPU kellotaajuutta GMenu2X:lle +Maximum overclock=Ylikellotusrajoitus +Set the maximum overclock for launching links=S��d� suurin mahdollinen ylikellotus k�ynnistett�ess� linkkej� +Global Volume=Yleinen ��nenvoimakkuus +Set the default volume fo the gp2x soundcard=S��d� perus��nenvoimakkuus gp2x:n ��nikortille +Output logs=Tulosteloki +Logs the output of the links. Use the Log Viewer to read them.=Kirjoita linkkien tuloste lokiin. K�yt� lokilukijaa niiden lukemiseen. +Number of columns=Sarakkeiden lukum��r� +Set the number of columns of links to display on a page=Aseta linkkisarakkeiden lukum��r� sivulla +Number of rows=Rivien lukum��r� +Set the number of rows of links to display on a page=Aseta linkkirivien lukum��r� sivulla +Top Bar=Yl�palkille +Color of the top bar=Yl�palkin v�ri +Bottom Bar=Alapalkin +Color of the bottom bar=Alapalkin v�ri +Selection=Valinnan +Color of the selection and other interface details=Valinnan ja muiden ykstiyiskohtien v�ri +You should disable Usb Networking to do this.=Usb Networking:in pit�� olla poissa k�yt�st� jotta voit tehd� t�m�n. +Operation not permitted.=Toiminto ei ole sallittu. +Language=Kieli +Set the language used by GMenu2X=Valitse GMenu2X:n k�ytt�m� kieli +Increase=Lis�� +Decrease=V�henn� +Change color component=Vaihda v�rikomponenttia +Increase value=Nosta arvoa +Decrease value=Laske arvoa +Switch=Vaihda +Change value=Vaihda arvoa +Edit=Muokkaa +Clear=Tyhjenn� +Select a directory=Valitse hakemisto +Select a file=Valitse tiedosto +Clock (default: 200)=Kellotaajuus (oletusarvo: 200) +Volume (default: -1)=��nenvoimakkuus (oletusarvo: -1) +Wrapper=Wrapperi +Enter folder=Avaa kansio +Confirm=Vahvista +Enter folder/Confirm=Avaa kansio/Vahvista +Up one folder=Yksi hakemisto yl�sp�in +Select an application=Valitse ohjelma +Space=V�lily�nti +Shift=Vaihto +Cancel=Peruuta +OK=OK +Backspace=Askelpalautin +Skin=Teema +Set the skin used by GMenu2X=Aseta GMenu2X:n k�ytt�m� teema +Add link in $1=Lis�� linkki v�lilehteen $1 +Edit $1=Muokkaa v�lilehte� $1 +Delete $1 link=Poista v�lilehti $1 +Deleting $1=Poistetaan v�lilehte� $1 +Are you sure?=Oletko varma? +Insert a name for the new section=Anna uuden v�lilehden nimi +Insert a new name for this section=Anna uusi nimi t�lle v�lilehdelle +Yes=Kyll� +No=Ei +You will lose all the links in this section.=Menet�t kaikki t�ss� v�lilehdess� olevat linkit. +Exit=Poistu +Link Scanner=Linkkiskanneri +Scanning SD filesystem...=Skannataan SD-tiedostoj�rjestelm��... +Scanning NAND filesystem...=Skannataan NAND-tiedostoj�rjestelm��... +$1 files found.=$1 tiedosto(a) l�ydetty. +Creating links...=Luodaan linkkej�... +$1 links created.=$1 linkki(�) luotu. +Version $1 (Build date: $2)=Versio $1 (K��nt�p�iv�m��r�: $2) +Log Viewer=Lokilukija +Displays last launched program's output=N�ytt�� viimeksi k�ynnistetyn ohjelman tulosteen +Do you want to delete the log file?=Haluatko poistaa logitiedoston? +USB Enabled (SD)=USB Aktivoitu (SD) +USB Enabled (Nand)=USB Aktivoitu (Nand) +Turn off=Sammuta +Launching $1=K�ynnistet��n $1 +Change page=Vaihda sivua +Page=Sivu +Scroll=Vierit� +Untitled=Nime�m�t�n diff --git a/data/translations/French b/data/translations/French index f3d6081..211881a 100644 --- a/data/translations/French +++ b/data/translations/French @@ -1,3 +1,4 @@ +Lng=fr Settings=Configurations Configure GMenu2X's options=Configurer les options de GMenu2X Activate Usb on SD=Activer l'Usb sur la SD @@ -51,11 +52,11 @@ Number of columns=Nombre de colonnes Set the number of columns of links to display on a page=Définir le nombre de colonnes de liens à afficher sur une page Number of rows=Nombres de rangées Set the number of rows of links to display on a page=Définir le nombre de rangées de liens à afficher sur une page -Top Bar Color=Couleur de la bar supérieur +Top Bar=Bar supérieur Color of the top bar=Couleur de la bar supérieur -Bottom Bar Color=Couleur de la bar inférieur +Bottom Bar=Bar inférieur Color of the bottom bar=Couleur de la bar inférieur -Selection Color=Couleur de sélection +Selection=Sélection Color of the selection and other interface details=Couleur de la sélection et des autres détails de l'interface You should disable Usb Networking to do this.=Vous devez désactiver le réseau Usb pour faire ceci. Operation not permitted.=Opération non permise @@ -126,4 +127,4 @@ Encoding of the tv-out signal=Encodage du signal de la sortie TV Tweak RAM Timings=Modification des timings de la RAM This usually speeds up the application at the cost of stability=Ceci accélère, normalement, l'application mais en contre partie de la stabilité Gamma (default: 0)=Gamma (par défaut: 0) -Gamma value to set when launching this link=Valeur de gamma à définir lors du lancement de ce lien \ No newline at end of file +Gamma value to set when launching this link=Valeur de gamma à définir lors du lancement de ce lien diff --git a/data/translations/German b/data/translations/German index c34ba94..e372a57 100644 --- a/data/translations/German +++ b/data/translations/German @@ -1,3 +1,4 @@ +Lng=de Settings=Einstellungen Configure GMenu2X's options=Optionen des GMenu2X konfigurieren Activate Usb on SD=Aktiviert USB für die SD-Karte @@ -51,11 +52,11 @@ Number of columns=Anzahl der Spalten Set the number of columns of links to display on a page=Anzahl der Spalten mit Links, pro Seite Number of rows=Anzahl der Zeilen Set the number of rows of links to display on a page=Anzahl der Zeilen mit Links, pro Seite -Top Bar Color=Farbe der Kopfleiste +Top Bar=Kopfleiste Color of the top bar= Stellt Farbe und Transparenz der oberen Menüleiste ein -Bottom Bar Color=Farbe der Fußleiste +Bottom Bar=Fußleiste Color of the bottom bar=Stellt Farbe und Transparenz der unteren Menüleiste ein -Selection Color=Farbe der Auswahl +Selection=Auswahl Color of the selection and other interface details=Farbe der Auswahl-Hervorhebung und anderer Interface-Details You should disable Usb Networking to do this.=Du solltest USB Networking deaktivieren um dies zu tun. Operation not permitted.=Operation nicht gestattet. diff --git a/data/translations/Italian b/data/translations/Italian index 64488f5..da8400b 100644 --- a/data/translations/Italian +++ b/data/translations/Italian @@ -1,3 +1,4 @@ +Lng=it Settings=Impostazioni Configure GMenu2X's options=Configura le opzioni di GMenu2X Activate Usb on SD=Attiva USB sulla SD @@ -51,11 +52,11 @@ Number of columns=Numero di colonne Set the number of columns of links to display on a page=Imposta il numero di colonne di collegamenti da visualizzare in una pagina Number of rows=Numero di righe Set the number of rows of links to display on a page=Imposta il numero di righe di collegamenti da visualizzare in una pagina -Top Bar Color=Colore barra superiore +Top Bar=Barra superiore Color of the top bar=Colore della barra superiore -Bottom Bar Color=Colore barra inferiore +Bottom Bar=Barra inferiore Color of the bottom bar=Colore della barra inferiore -Selection Color=Colore selezione +Selection=Selezione Color of the selection and other interface details=Colore della selezione e altri dettagli dell'interfaccia You should disable Usb Networking to do this.=Dovresti disattivare le impostazioni di rete per farlo. Operation not permitted.=Operazione non consentita. @@ -129,9 +130,9 @@ Gamma (default: 0)=Gamma (predefinito: 0) Gamma value to set when launching this link=Valore di gamma da impostare quando si lancia questo collegamento Wallpaper=Sfondo Configure skin=Configura skin -Message Box Color=Colore Finestra Messaggi -Message Box Border Color=Colore Bordo Finestra Messaggi -Message Box Selection Color=Color Selezione Finestra Messaggi +Message Box=Finestra Messaggi +Message Box Border=Bordo Finestra Messaggi +Message Box Selection=Selezione Finestra Messaggi Background color of the message box=Colore di sfondo della finestra dei messaggi Border color of the message box=Colore del bordo della finestra dei messaggi Color of the selection of the message box=Colore della selezione della finestra dei messaggi @@ -139,4 +140,4 @@ Color of the selection of the message box=Colore della selezione della finestra Show root=Mostra radice Show root folder in the file selection dialogs=Mostra la cartella radice nelle finestre di selezione di file Change keys=Cambia tasti -Launch an application=Esegue un'applicazione \ No newline at end of file +Launch an application=Esegue un'applicazione diff --git a/data/translations/Norwegian b/data/translations/Norwegian index ec61db7..2d56c40 100644 --- a/data/translations/Norwegian +++ b/data/translations/Norwegian @@ -1,3 +1,4 @@ +Lng=no Settings=Instillinger Configure GMenu2X's options=Konfigurer GMenu2X's innstillinger Activate Usb on SD=Aktiver USB på SD @@ -51,14 +52,14 @@ Number of columns=Antall spalter Set the number of columns of links to display on a page=Velg antall spalter med linker som skal vises per side Number of rows=Antall rader Set the number of rows of links to display on a page=Velg antall rader med linker som skal vises per side -Top Bar Color=Øverste felts farge +Top Bar=Øverste felt Color of the top bar=Farge på det øverste feltet -Bottom Bar Color=Nederste felts farge +Bottom Bar=Nederste felt Color of the bottom bar=Färge på det nederste feltet -Selection Color=Markørfarge +Selection=Markør Color of the selection and other interface details=Farge på markøren og andre deler av grensesnittet You should disable Usb Networking to do this.=Du bør slå av USB-nettverket når du gjør dette. -Operation not permitted.=Utillat operasjon. +Operation not permitted.=Utillat operasjon. Language=Språk Set the language used by GMenu2X=Still inn språk for GMenu2X Increase=Øk @@ -115,4 +116,4 @@ Launching $1=Starter $1 Change page=Bytt side Page=Side Scroll=Rull -Untitled=Uten navn \ No newline at end of file +Untitled=Uten navn diff --git a/data/translations/Portuguese (Portugal) b/data/translations/Portuguese (Portugal) index 70c9084..48a4a1c 100644 --- a/data/translations/Portuguese (Portugal) +++ b/data/translations/Portuguese (Portugal) @@ -1,3 +1,4 @@ +Lng=pt Settings= Configurações Configure GMenu2X's options=Configurar opções do GMenu2X Activate Usb on SD=Activar USB para SD @@ -7,20 +8,20 @@ About=Sobre Add section=Adicionar Secção Rename section= Renomear Secção Delete section= Eliminar Secção -Scan for applications and games=Procurar aplicações e jogos +Scan for applications and games=Procurar aplicações e jogos applications=aplicações Edit link=Editar Link Title=Título -Link title=Título do Link +Link title=Título do Link Description=Descrição Link description=Descrição do Link Section=Secção -The section this link belongs to=A secção a que pertence este link +The section this link belongs to=A secção a que pertence este link Icon=Ícone Select an icon for the link: $1=Seleccionar um ícone para o link: $1 Manual=Manual Select a graphic/textual manual or a readme=Seleccionar um manual gráfico e/ou de texto -Cpu clock frequency to set when launching this link=Frequência de relógio do CPU ao lançar este link +Cpu clock frequency to set when launching this link=Frequência de relógio do CPU ao lançar este link Volume to set for this link=Ajustar o volume para este link Parameters=Parâmetros Parameters to pass to the application=Parâmetros a enviar para a aplicação @@ -33,34 +34,34 @@ Filter for the selector (Separate values with a comma)=Filtro do selector (Separ Selector Screenshots=Capturas de ecrã do selector Directory of the screenshots for the selector=Directório das capturas de ecrã do selector Selector Aliases=Alias do selector -File containing a list of aliases for the selector=Arquivo que contém a lista de alias para o selector +File containing a list of aliases for the selector=Arquivo que contém a lista de alias para o selector Explicitly relaunch GMenu2X after this link's execution ends=Forçar relançamento do GMenu2x após fim da execução deste link Don't Leave=Não Sair Don't quit GMenu2X when launching this link=Não sair do GMenu2X ao lançar este link Save last selection=Gravar a última selecção Save the last selected link and section on exit=Recordar link e secção seleccionadas ao sair Clock for GMenu2X=Relógio no GMenu2X -Set the cpu working frequency when running GMenu2X=Ajustar a frequência do CPU durante a execução do GMenu2X +Set the cpu working frequency when running GMenu2X=Ajustar a frequência do CPU durante a execução do GMenu2X Maximum overclock=Overclock máximo Set the maximum overclock for launching links=Ajustar o overclock máximo ao lançar um link Global Volume=Volume global -Set the default volume fo the gp2x soundcard=Ajustar o volume por defeito da gp2x +Set the default volume fo the gp2x soundcard=Ajustar o volume por defeito da gp2x Output logs=Logs de Output Logs the output of the links. Use the Log Viewer to read them.=Regista o output dos links. Usar o Leitor de Logs para consultar. Number of columns=Número de colunas -Set the number of columns of links to display on a page=Ajustar o número de colunas (de links) por página +Set the number of columns of links to display on a page=Ajustar o número de colunas (de links) por página Number of rows=Número de filas -Set the number of rows of links to display on a page=Ajustar o número de filas (de links) por página -Top Bar Color=Cor da barra superior +Set the number of rows of links to display on a page=Ajustar o número de filas (de links) por página +Top Bar=Barra superior Color of the top bar= Cor da barra superior -Bottom Bar Color= Cor da barra inferior +Bottom Bar=Barra inferior Color of the bottom bar= Cor da barra inferior -Selection Color=Cor da selecção -Color of the selection and other interface details=Cor da selecção e outros detalhes do interface +Selection=Selecção +Color of the selection and other interface details=Cor da selecção e outros detalhes do interface You should disable Usb Networking to do this.=Deve desactivar a função Networking por USB para executar este comando. Operation not permitted.=Operação não permitida. Language=Idioma -Set the language used by GMenu2X=Ajustar o idioma usado no GMenu2X +Set the language used by GMenu2X=Ajustar o idioma usado no GMenu2X Increase=Aumentar Decrease=Reduzir Change color component=Alterar componente da cor @@ -91,7 +92,7 @@ Add link in $1=Adicionar link em $1 Edit $1=Modificar $1 Delete $1 link=Eliminar o link $1 Deleting $1=Removendo $1 -Are you sure?=Tem a certeza? +Are you sure?=Tem a certeza? Insert a name for the new section=Insira o nome da nova secção Insert a new name for this section=Insira um novo nome para esta secção Yes=Sim diff --git a/data/translations/Russian b/data/translations/Russian index 900cab0..f055509 100644 --- a/data/translations/Russian +++ b/data/translations/Russian @@ -1,132 +1,133 @@ -Settings=Настройки -Configure GMenu2X's options=Изменить настройки GMenu2X -Activate Usb on SD=Активировать SD через USB -Activate Usb on Nand=Активировать NAND через USB -Info about GMenu2X=Информация о GMenu2X -About=Информация -Add section=Добавить секцию -Rename section=Переименовать секцию -Delete section=Удалить секцию -Scan for applications and games= Поиск игр и приложений -applications=Приложения -Edit link=Изменить ссылку -Title=Заголовок -Link title=Имя ссылки -Description=Описание -Link description=Описание ссылки -Section=Секция -The section this link belongs to=Секция, которой принадлежит ссылка -Icon=Иконка -Select an icon for the link: $1=Выберите иконку к ссылке: $1 -Manual=Инструкция -Select a graphic/textual manual or a readme=Выберите текстовую инструкцию -Cpu clock frequency to set when launching this link=Частота CPU при запуске данной ссылки -Volume to set for this link=Громкость установленная для этой ссылки -Parameters=Параметры -Parameters to pass to the application=Параметры для передачи приложению -Selector Directory=Папка проводника -Directory to scan for the selector=Папка для сканирования проводником -Selector Browser=Выбрать браузером -Allow the selector to change directory=Разрешить проводнику выбирать папку -Selector Filter=Выбрать фильтр -Filter for the selector (Separate values with a comma)=Фильтр для проводника -Selector Screenshots=Обзор скриншотов -Directory of the screenshots for the selector=Папка с скриншотами для проводника -Selector Aliases=Обзор списков с именами -File containing a list of aliases for the selector=Файл, содержащий список имён-псевдонимов -Explicitly relaunch GMenu2X after this link's execution ends=Перезапуск GMenu2X после завершения выполнения ссылки -Don't Leave=Не покидать -Don't quit GMenu2X when launching this link=Не выключать Gmenu2X когда запускается эта ссылка -Save last selection=Сохранять последней выбор -Save the last selected link and section on exit=Сохранение последней выбранной ссылки и секции при выключение -Clock for GMenu2X=Частота CPU для Gmenu2X -Set the cpu working frequency when running GMenu2X=Устанавливает частоту CPU пока запущен Gmenu2X -Maximum overclock=Максимальная частота CPU -Set the maximum overclock for launching links=Максимальная частота CPU для запуска ссылок -Global Volume=Громкость -Set the default volume for the gp2x soundcard=Устанавливает громкость для звуковой карты GP2X -Output logs=Отчёты -Logs the output of the links. Use the Log Viewer to read them.=Создавать отчёты ссылок -Number of columns=Количество столбцов -Set the number of columns of links to display on a page=Установите количество столбцов для отображения на странице -Number of rows=Количество колонок -Set the number of rows of links to display on a page=Установите количество колонок для отображения на странице -Top Bar Color=Цвет панели сверху -Color of the top bar=Выберите цвет панели сверху -Bottom Bar Color=Цвет панели внизу -Color of the bottom bar= Выберите цвет панели внизу -Selection Color=Цвет панели выбора -Color of the selection and other interface details=Выберите цвет панели выбора -You should disable Usb Networking to do this.=Вы должны выключить USB Networking чтобы сделать это. -Operation not permitted.=Операция не разрешена. -Language=Язык -Set the language used by GMenu2X=Выберите язык интерфейса -Increase=Прибавить -Decrease=Убавить -Change color component=Изменить компонент цвета -Increase value=Увеличить значение -Decrease value=Уменьшить значение -Switch=Переключить -Change value=Изменить значение -Edit=Изменить -Clear=Очистить -Select a directory=Выбрать папку -Select a file=Выбрать файл -Clock (default: 200)=Частота CPU (Стандарт: 200) -Volume (default: -1)=Громкость (Стандарт: -1) -Wrapper=Перезапуск -Enter folder=Открыть папку -Confirm=Подтвердить -Enter folder/Confirm=Выбрать папку/подтвердить -Up one folder=Назад на одну папку -Select an application=Выберите приложение -Space=Пробел -Shift=Shift -Cancel=Выход -OK=OK -Backspace=Стереть -Skin=Скин -Set the skin used by GMenu2X=Выберите скин для GMenu2X -Add link in $1=Добавить ссылку в $1 -Edit $1=Именить $1 -Delete $1 link=Удалить ссылку $1 -Deleting $1=Удаление $1 -Are you sure?=Вы уверены? -Insert a name for the new section=Впишите имя для новой секции -Insert a new name for this section=Впишите новое имя для этой секции -Yes=Да -No=Нет -You will lose all the links in this section.=Вы потеряете все ссылки в этой секции -Exit=Выход -Link Scanner=Поиск ссылок -Scanning SD filesystem...=Сканирование SD... -Scanning NAND filesystem...=Сканирование NAND... -$1 files found.=$1 Файлов найдено. -Creating links...=Создание ссылок... -$1 links created.=$1 ссылок создано. -Version $1 (Build date: $2)=Версия $1 (Дата сборки: $2) -Log Viewer=Отчёты -Displays last launched program's output=Отображает последний запущенный отчёт программы -Do you want to delete the log file?=Вы хотите удалить этот отчёт? -USB Enabled (SD)=USB включен (SD) -USB Enabled (Nand)=USB включен (Nand) -Turn off=Выключить -Launching $1=Запуск $1... -Change page=Изменить страницу -Page=Страница -Scroll=Прокрутка -Untitled=Не названный - - -Change GMenu2X wallpaper=Изменить обои Gmenu2X -Activate/deactivate tv-out=Активировать/дезактивировать ТВ-выход -Select wallpaper=Выберите обои -Gamma=Гамма -Set gp2x gamma value (default: 10)=Значение гаммы экрана GP2X (стандарт: 10) -Tv-Out encoding=Технология вывода на ТВ -Encoding of the tv-out signal=Шифровка ТВ сигнала -Tweak RAM Timings=Изменение параметров RAM -This usually speeds up the application at the cost of stability=Это обычно убыстряет приложение -Gamma (default: 0)=Гамма (стандарт: 0) -Gamma value to set when launching this link=Значение гаммы при запуске этой ссылки - +Lng=ru +Settings=Настройки +Configure GMenu2X's options=Изменить настройки GMenu2X +Activate Usb on SD=Активировать SD через USB +Activate Usb on Nand=Активировать NAND через USB +Info about GMenu2X=Информация о GMenu2X +About=Информация +Add section=Добавить секцию +Rename section=Переименовать секцию +Delete section=Удалить секцию +Scan for applications and games= Поиск игр и приложений +applications=Приложения +Edit link=Изменить ссылку +Title=Заголовок +Link title=Имя ссылки +Description=Описание +Link description=Описание ссылки +Section=Секция +The section this link belongs to=Секция, которой принадлежит ссылка +Icon=Иконка +Select an icon for the link: $1=Выберите иконку к ссылке: $1 +Manual=Инструкция +Select a graphic/textual manual or a readme=Выберите текстовую инструкцию +Cpu clock frequency to set when launching this link=Частота CPU при запуске данной ссылки +Volume to set for this link=Громкость установленная для этой ссылки +Parameters=Параметры +Parameters to pass to the application=Параметры для передачи приложению +Selector Directory=Папка проводника +Directory to scan for the selector=Папка для сканирования проводником +Selector Browser=Выбрать браузером +Allow the selector to change directory=Разрешить проводнику выбирать папку +Selector Filter=Выбрать фильтр +Filter for the selector (Separate values with a comma)=Фильтр для проводника +Selector Screenshots=Обзор скриншотов +Directory of the screenshots for the selector=Папка с скриншотами для проводника +Selector Aliases=Обзор списков с именами +File containing a list of aliases for the selector=Файл, содержащий список имён-псевдонимов +Explicitly relaunch GMenu2X after this link's execution ends=Перезапуск GMenu2X после завершения выполнения ссылки +Don't Leave=Не покидать +Don't quit GMenu2X when launching this link=Не выключать Gmenu2X когда запускается эта ссылка +Save last selection=Сохранять последней выбор +Save the last selected link and section on exit=Сохранение последней выбранной ссылки и секции при выключение +Clock for GMenu2X=Частота CPU для Gmenu2X +Set the cpu working frequency when running GMenu2X=Устанавливает частоту CPU пока запущен Gmenu2X +Maximum overclock=Максимальная частота CPU +Set the maximum overclock for launching links=Максимальная частота CPU для запуска ссылок +Global Volume=Громкость +Set the default volume for the gp2x soundcard=Устанавливает громкость для звуковой карты GP2X +Output logs=Отчёты +Logs the output of the links. Use the Log Viewer to read them.=Создавать отчёты ссылок +Number of columns=Количество столбцов +Set the number of columns of links to display on a page=Установите количество столбцов для отображения на странице +Number of rows=Количество колонок +Set the number of rows of links to display on a page=Установите количество колонок для отображения на странице +Top Bar=Сверху +Color of the top bar=Выберите цвет панели сверху +Bottom Bar=Внизу +Color of the bottom bar= Выберите цвет панели внизу +Selection=Выбора +Color of the selection and other interface details=Выберите цвет панели выбора +You should disable Usb Networking to do this.=Вы должны выключить USB Networking чтобы сделать это. +Operation not permitted.=Операция не разрешена. +Language=Язык +Set the language used by GMenu2X=Выберите язык интерфейса +Increase=Прибавить +Decrease=Убавить +Change color component=Изменить компонент цвета +Increase value=Увеличить значение +Decrease value=Уменьшить значение +Switch=Переключить +Change value=Изменить значение +Edit=Изменить +Clear=Очистить +Select a directory=Выбрать папку +Select a file=Выбрать файл +Clock (default: 200)=Частота CPU (Стандарт: 200) +Volume (default: -1)=Громкость (Стандарт: -1) +Wrapper=Перезапуск +Enter folder=Открыть папку +Confirm=Подтвердить +Enter folder/Confirm=Выбрать папку/подтвердить +Up one folder=Назад на одну папку +Select an application=Выберите приложение +Space=Пробел +Shift=Shift +Cancel=Выход +OK=OK +Backspace=Стереть +Skin=Скин +Set the skin used by GMenu2X=Выберите скин для GMenu2X +Add link in $1=Добавить ссылку в $1 +Edit $1=Именить $1 +Delete $1 link=Удалить ссылку $1 +Deleting $1=Удаление $1 +Are you sure?=Вы уверены? +Insert a name for the new section=Впишите имя для новой секции +Insert a new name for this section=Впишите новое имя для этой секции +Yes=Да +No=Нет +You will lose all the links in this section.=Вы потеряете все ссылки в этой секции +Exit=Выход +Link Scanner=Поиск ссылок +Scanning SD filesystem...=Сканирование SD... +Scanning NAND filesystem...=Сканирование NAND... +$1 files found.=$1 Файлов найдено. +Creating links...=Создание ссылок... +$1 links created.=$1 ссылок создано. +Version $1 (Build date: $2)=Версия $1 (Дата сборки: $2) +Log Viewer=Отчёты +Displays last launched program's output=Отображает последний запущенный отчёт программы +Do you want to delete the log file?=Вы хотите удалить этот отчёт? +USB Enabled (SD)=USB включен (SD) +USB Enabled (Nand)=USB включен (Nand) +Turn off=Выключить +Launching $1=Запуск $1... +Change page=Изменить страницу +Page=Страница +Scroll=Прокрутка +Untitled=Не названный + + +Change GMenu2X wallpaper=Изменить обои Gmenu2X +Activate/deactivate tv-out=Активировать/дезактивировать ТВ-выход +Select wallpaper=Выберите обои +Gamma=Гамма +Set gp2x gamma value (default: 10)=Значение гаммы экрана GP2X (стандарт: 10) +Tv-Out encoding=Технология вывода на ТВ +Encoding of the tv-out signal=Шифровка ТВ сигнала +Tweak RAM Timings=Изменение параметров RAM +This usually speeds up the application at the cost of stability=Это обычно убыстряет приложение +Gamma (default: 0)=Гамма (стандарт: 0) +Gamma value to set when launching this link=Значение гаммы при запуске этой ссылки + diff --git a/data/translations/Slovak b/data/translations/Slovak index 15bda3a..ce40490 100644 --- a/data/translations/Slovak +++ b/data/translations/Slovak @@ -1,137 +1,138 @@ -Settings=Nastavenia -Configure GMenu2X's options=Nastaviť voľby pre GMenu2X -Activate Usb on SD=Aktivovať USB pre SD kartu -Activate Usb on Nand=Aktivovať USB pre pamäť Nand -Info about GMenu2X=Informácie o GMenu2X -About=O programe -Add section=Pridať sekciu -Rename section=Premenovať sekciu -Delete section=Vymazať sekciu -Scan for applications and games= Hľadať aplikácie a hry -applications=aplikácie -Edit link=Upraviť odkaz -Title=Názov -Link title=Názov odkazu -Description=Popis -Link description=Popis pre odkaz -Section=Sekcia -The section this link belongs to=Sekcia, do ktorej patrí tento odkaz -Icon=Ikona -Select an icon for the link=Vyberte ikonu pre tento odkaz -Manual=Návod -Select a graphic/textual manual or a readme=Vyberte grafický/textový návod alebo readme -Cpu clock frequency to set when launching this link=Taktovacia frekvencia procesora, s ktorou bude spustený odkaz -Volume to set for this link=Nastavenie hlasitosti pre tento odkaz -Parameters=Parametre -Parameters to pass to the application=Parametre, ktoré majú byť predané aplikácii -Selector Directory=Adresár selektora -Directory to scan for the selector=Adresár, v ktorom má byť hľadaný selektor -Selector Browser=Prehliadač selektora -Allow the selector to change directory=Povolí selektorovi zmeniť adresár -Selector Filter=Filter pre selektor -Filter for the selector (Separate values with a comma)=Filter pre selektor (hodnoty oddeľujte čiarkou) -Selector Screenshots=Snímky obrazovky selektora -Directory of the screenshots for the selector=Adresár so snímkami obrazovky selektora -Selector Aliases=Aliasy selektora -File containing a list of aliases for the selector=Súbor obsahujúci zoznam aliasov pre selektor -Explicitly relaunch GMenu2X after this link's execution ends=Explicitne opätovne spustiť GMenu2X po ukončení spustenia tohto odkazu -Don't Leave=Neopúšťať -Don't quit GMenu2X when launching this link=Neukončovať GMenu2X pri spúšťaní tohto odkazu -Save last selection=Ulož posledný výber -Save the last selected link and section on exit=Ulož naposledy vybraný odkaz a sekciu pri ukončení -Clock for GMenu2X=Takt. frekvencia pre GMenu2X -Set the cpu working frequency when running GMenu2X=Nastavte frekvenciu cpu počas behu GMenu2X -Maximum overclock=Maximálne pretaktovanie -Set the maximum overclock for launching links=Nastavte maximálne pretaktovanie pre spúšťanie odkazov -Global Volume=Globálna hlasitosť -Set the default volume for the gp2x soundcard=Nastavte východziu hlasitosť pre zvukovú kartu gp2x -Output logs=Výstupné logy -Logs the output of the links. Use the Log Viewer to read them.=Loguje výstup odkazov. Na prezretie použite Log Viewer. -Number of columns=Počet stĺpcov -Set the number of columns of links to display on a page=Nastavte počet stĺpcov pre odkazy zobrazené na stránke -Number of rows=Počet riadkov -Set the number of rows of links to display on a page=Počet riadkov odkazov zobrazených na stránke -Top Bar Color=Farba hornej lišty -Color of the top bar= Farba hornej lišty -Bottom Bar Color=Farba spodnej lišty -Color of the bottom bar=Farba spodnej lišty -Selection Color=Farba výberu -Color of the selection and other interface details=Farba výberu a iných detailov interfacu -You should disable Usb Networking to do this.=Pre vykonanie tejto operácie by ste mali deaktivovať Usb sieťovanie. -Operation not permitted.=Operácia nepovolená. -Language=Jazyk -Set the language used by GMenu2X=Nastavte jazyk pre GMenu2X -Increase=Zvýšiť -Decrease=Znížiť -Change color component=Zmeniť farebnú zložku -Increase value=Zvýšiť hodnotu -Decrease value=Znížiť hodnotu -Switch=Prepnúť -Change value=Zmeniť hodnotu -Edit=Upraviť -Clear=Vyčistiť -Select a directory=Vyberte adresár -Select a file=Vyberte súbor -Clock (default: 200)=Takt (štandardne: 200) -Volume (default: -1)=Hlasitosť (štandardne: -1) -Wrapper=Obaľovač -Enter folder=Zadajte priečinok -Confirm=Potvrdiť -Enter folder/Confirm=Zadajte priečinok/Potvrdiť -Up one folder=O jeden priečinok vyššie -Select an application=Vyberte aplikáciu -Space=Medzera -Shift=Shift -Cancel=Zrušiť -OK=OK -Backspace=Backspace -Skin=Skin -Set the skin used by GMenu2X=Nastavte skin pre GMenu2X -Add link in $1=Pridať odkaz do $1 -Edit $1=Upraviť $1 -Delete $1 link=Vymazať odkaz na $1 -Deleting $1=Mažem $1 -Are you sure?=Ste si istý? -Insert a name for the new section=Zadajte názov novej sekcie -Insert a new name for this section=Zadajte nový názov pre túto sekciu -Yes=Áno -No=Nie -You will lose all the links in this section.=Stratíte všetky odkazy v tejto sekcii. -Exit=Ukončiť -Link Scanner=Vyhľadávač odkazov -Scanning SD filesystem...=Prehľadávam súborový systém na SD karte... -Scanning NAND filesystem...=Prehľadávam súborový systém na pamäti NAND... -$1 files found.=$1 súbor(ov) nájdených. -Creating links...=Vytváram odkazy... -$1 links created.=$1 odkazov vytvorených. -Version $1 (Build date: $2)=Verzia $1 (dátum zostavenia: $2) -Log Viewer=Prehliadač log súborov -Displays last launched program's output=Zobrazuje výstup naposledy spusteného súboru -Do you want to delete the log file?=Želáte si vymazať log súbor? -USB Enabled (SD)=USB aktivované (SD) -USB Enabled (Nand)=USB aktivované (Nand) -Turn off=Vypnúť -Launching $1=Spúšťam $1 -Change page=Zmeniť stránku -Page=Stránka -Scroll=Skrolovať -Untitled=Bez mena -Change GMenu2X wallpaper=Zmeniť pozadie GMenu2X -Activate/deactivate tv-out=Aktivovať/deaktivovať výstup na TV -Select wallpaper=Vyberte pozadie -Gamma=Gamma -Set gp2x gamma value (default: 10)=Nastavte hodnotu gamma (implic: 10) -Tv-Out encoding=Kódovanie výstupu na TV -Encoding of the tv-out signal=Kódovanie televízneho signálu -Tweak RAM Timings=Upraviť časovanie RAM -This usually speeds up the application at the cost of stability=Toto nastavenie zvyčajne zrýchli aplikáciu na úkor stability -Gamma (default: 0)=Gamma (implic: 0) -Gamma value to set when launching this link=Hodnota gamma pri spúšťaní tohto odkazu -Wallpaper=Pozadie -Configure skin=Nastaviť skin -Message Box Color=Farba textového okna -Message Box Border Color=Farba okraja textového okna -Message Box Selection Color=Farba výberu textového okna -Background color of the message box=Farba pozadia textového okna -Border color of the message box=Farba okraja textového okna -Color of the selection of the message box=Farba výberu textového okna +Lng=sk +Settings=Nastavenia +Configure GMenu2X's options=Nastaviť voľby pre GMenu2X +Activate Usb on SD=Aktivovať USB pre SD kartu +Activate Usb on Nand=Aktivovať USB pre pamäť Nand +Info about GMenu2X=Informácie o GMenu2X +About=O programe +Add section=Pridať sekciu +Rename section=Premenovať sekciu +Delete section=Vymazať sekciu +Scan for applications and games= Hľadať aplikácie a hry +applications=aplikácie +Edit link=Upraviť odkaz +Title=Názov +Link title=Názov odkazu +Description=Popis +Link description=Popis pre odkaz +Section=Sekcia +The section this link belongs to=Sekcia, do ktorej patrí tento odkaz +Icon=Ikona +Select an icon for the link=Vyberte ikonu pre tento odkaz +Manual=Návod +Select a graphic/textual manual or a readme=Vyberte grafický/textový návod alebo readme +Cpu clock frequency to set when launching this link=Taktovacia frekvencia procesora, s ktorou bude spustený odkaz +Volume to set for this link=Nastavenie hlasitosti pre tento odkaz +Parameters=Parametre +Parameters to pass to the application=Parametre, ktoré majú byť predané aplikácii +Selector Directory=Adresár selektora +Directory to scan for the selector=Adresár, v ktorom má byť hľadaný selektor +Selector Browser=Prehliadač selektora +Allow the selector to change directory=Povolí selektorovi zmeniť adresár +Selector Filter=Filter pre selektor +Filter for the selector (Separate values with a comma)=Filter pre selektor (hodnoty oddeľujte čiarkou) +Selector Screenshots=Snímky obrazovky selektora +Directory of the screenshots for the selector=Adresár so snímkami obrazovky selektora +Selector Aliases=Aliasy selektora +File containing a list of aliases for the selector=Súbor obsahujúci zoznam aliasov pre selektor +Explicitly relaunch GMenu2X after this link's execution ends=Explicitne opätovne spustiť GMenu2X po ukončení spustenia tohto odkazu +Don't Leave=Neopúšťať +Don't quit GMenu2X when launching this link=Neukončovať GMenu2X pri spúšťaní tohto odkazu +Save last selection=Ulož posledný výber +Save the last selected link and section on exit=Ulož naposledy vybraný odkaz a sekciu pri ukončení +Clock for GMenu2X=Takt. frekvencia pre GMenu2X +Set the cpu working frequency when running GMenu2X=Nastavte frekvenciu cpu počas behu GMenu2X +Maximum overclock=Maximálne pretaktovanie +Set the maximum overclock for launching links=Nastavte maximálne pretaktovanie pre spúšťanie odkazov +Global Volume=Globálna hlasitosť +Set the default volume for the gp2x soundcard=Nastavte východziu hlasitosť pre zvukovú kartu gp2x +Output logs=Výstupné logy +Logs the output of the links. Use the Log Viewer to read them.=Loguje výstup odkazov. Na prezretie použite Log Viewer. +Number of columns=Počet stĺpcov +Set the number of columns of links to display on a page=Nastavte počet stĺpcov pre odkazy zobrazené na stránke +Number of rows=Počet riadkov +Set the number of rows of links to display on a page=Počet riadkov odkazov zobrazených na stránke +Top Bar=Hornej lišty +Color of the top bar= Farba hornej lišty +Bottom Bar=Spodnej lišty +Color of the bottom bar=Farba spodnej lišty +Selection=Výberu +Color of the selection and other interface details=Farba výberu a iných detailov interfacu +You should disable Usb Networking to do this.=Pre vykonanie tejto operácie by ste mali deaktivovať Usb sieťovanie. +Operation not permitted.=Operácia nepovolená. +Language=Jazyk +Set the language used by GMenu2X=Nastavte jazyk pre GMenu2X +Increase=Zvýšiť +Decrease=Znížiť +Change color component=Zmeniť farebnú zložku +Increase value=Zvýšiť hodnotu +Decrease value=Znížiť hodnotu +Switch=Prepnúť +Change value=Zmeniť hodnotu +Edit=Upraviť +Clear=Vyčistiť +Select a directory=Vyberte adresár +Select a file=Vyberte súbor +Clock (default: 200)=Takt (štandardne: 200) +Volume (default: -1)=Hlasitosť (štandardne: -1) +Wrapper=Obaľovač +Enter folder=Zadajte priečinok +Confirm=Potvrdiť +Enter folder/Confirm=Zadajte priečinok/Potvrdiť +Up one folder=O jeden priečinok vyššie +Select an application=Vyberte aplikáciu +Space=Medzera +Shift=Shift +Cancel=Zrušiť +OK=OK +Backspace=Backspace +Skin=Skin +Set the skin used by GMenu2X=Nastavte skin pre GMenu2X +Add link in $1=Pridať odkaz do $1 +Edit $1=Upraviť $1 +Delete $1 link=Vymazať odkaz na $1 +Deleting $1=Mažem $1 +Are you sure?=Ste si istý? +Insert a name for the new section=Zadajte názov novej sekcie +Insert a new name for this section=Zadajte nový názov pre túto sekciu +Yes=Áno +No=Nie +You will lose all the links in this section.=Stratíte všetky odkazy v tejto sekcii. +Exit=Ukončiť +Link Scanner=Vyhľadávač odkazov +Scanning SD filesystem...=Prehľadávam súborový systém na SD karte... +Scanning NAND filesystem...=Prehľadávam súborový systém na pamäti NAND... +$1 files found.=$1 súbor(ov) nájdených. +Creating links...=Vytváram odkazy... +$1 links created.=$1 odkazov vytvorených. +Version $1 (Build date: $2)=Verzia $1 (dátum zostavenia: $2) +Log Viewer=Prehliadač log súborov +Displays last launched program's output=Zobrazuje výstup naposledy spusteného súboru +Do you want to delete the log file?=Želáte si vymazať log súbor? +USB Enabled (SD)=USB aktivované (SD) +USB Enabled (Nand)=USB aktivované (Nand) +Turn off=Vypnúť +Launching $1=Spúšťam $1 +Change page=Zmeniť stránku +Page=Stránka +Scroll=Skrolovať +Untitled=Bez mena +Change GMenu2X wallpaper=Zmeniť pozadie GMenu2X +Activate/deactivate tv-out=Aktivovať/deaktivovať výstup na TV +Select wallpaper=Vyberte pozadie +Gamma=Gamma +Set gp2x gamma value (default: 10)=Nastavte hodnotu gamma (implic: 10) +Tv-Out encoding=Kódovanie výstupu na TV +Encoding of the tv-out signal=Kódovanie televízneho signálu +Tweak RAM Timings=Upraviť časovanie RAM +This usually speeds up the application at the cost of stability=Toto nastavenie zvyčajne zrýchli aplikáciu na úkor stability +Gamma (default: 0)=Gamma (implic: 0) +Gamma value to set when launching this link=Hodnota gamma pri spúšťaní tohto odkazu +Wallpaper=Pozadie +Configure skin=Nastaviť skin +Message Box=Textového okna +Message Box Border=Okraja textového okna +Message Box Selection=Výberu textového okna +Background color of the message box=Farba pozadia textového okna +Border color of the message box=Farba okraja textového okna +Color of the selection of the message box=Farba výberu textového okna diff --git a/data/translations/Spanish b/data/translations/Spanish index 74f5a8e..be2f876 100644 --- a/data/translations/Spanish +++ b/data/translations/Spanish @@ -1,3 +1,4 @@ +Lng=es Settings=Ajustes Configure GMenu2X's options=Configura las opciones de GMenu2X Activate Usb on SD=Activa USB para SD @@ -50,11 +51,11 @@ Number of columns=Número de columnas Set the number of columns of links to display on a page=Ajuste el número de columnas de enlaces que mostrar por página Number of rows=Número de líneas Set the number of rows of links to display on a page=Ajuste el número de líneas de enlaces que mostrar por página -Top Bar Color=Color de barra superior +Top Bar=Barra superior Color of the top bar=Color de la barra superior -Bottom Bar Color=Color de barra inferior +Bottom Bar=Barra inferior Color of the bottom bar=Color de la barra inferior -Selection Color=Color de selección +Selection=Selección Color of the selection and other interface details=Color de la selección y otros detalles del interfaz You should disable Usb Networking to do this.=Debe desactivar Red por USB para hacer esto. Operation not permitted.=Operación no permitida. diff --git a/data/translations/Swedish b/data/translations/Swedish index 5501464..6ff5348 100644 --- a/data/translations/Swedish +++ b/data/translations/Swedish @@ -1,3 +1,4 @@ +Lng=sv Settings=Inställningar Configure GMenu2X's options=Konfigurera GMenu2X's inställningar Activate Usb on SD=Aktivera Usb på SD @@ -51,14 +52,14 @@ Number of columns=Antal spalter Set the number of columns of links to display on a page=Välj antal spalter med länkar som skall visas per sida Number of rows=Antal rader Set the number of rows of links to display on a page=Välj antal rader med länkar som skall visas per sida -Top Bar Color=Översta fältets färg +Top Bar=Översta fältet Color of the top bar=Färg på det översta fältet -Bottom Bar Color=Nedersta fältets färg +Bottom Bar=Nedersta fältet Color of the bottom bar=Färg på det nedersta fältet -Selection Color=Markörfärg +Selection=Markör Color of the selection and other interface details=Färg på markören och andra delar av gränssnittet You should disable Usb Networking to do this.=Du bör slå av usb-nätverket när du gör detta. -Operation not permitted.=Otillåten användning. +Operation not permitted.=Otillåten användning. Language=Språk Set the language used by GMenu2X=Ställ in språk för GMenu2X Increase=Öka diff --git a/data/translations/Turkish b/data/translations/Turkish index 7554ced..7740c6f 100644 --- a/data/translations/Turkish +++ b/data/translations/Turkish @@ -1,4 +1,5 @@ -Settings=Ayarlar +Lng=tr +Settings=Ayarlar Configure GMenu2X's options=GMenu2X'in ayarlarini degistir Activate Usb on SD=SD Karti için USB baglantisini aktive et Activate Usb on Nand=Nand Bellegi için USB baglantisini aktive et @@ -51,11 +52,11 @@ Number of columns=Sütun sayisi Set the number of columns of links to display on a page=Bir sayfada gösterilecek sütun sayisini belirleyin Number of rows=Satir sayisi Set the number of rows of links to display on a page=Bir sayfada gösterilecek satir sayisini belirleyin -Top Bar Color=Baslik çubugunun rengi +Top Bar=Baslik çubugunun Color of the top bar=Baslik çubugunun rengini ve saydamligini belirler -Bottom Bar Color=Statü çubugunun rengi +Bottom Bar=Statü çubugunun Color of the bottom bar=Statü çubugunun rengini ve saydamligini belirler -Selection Color=Seçim rengi +Selection=Seçim Color of the selection and other interface details=Seçim rengi ve baska arabirim detaylarinin rengi You should disable Usb Networking to do this.=Bunu yapmadan önce USB-Ag destegini kapatmalisiniz. Operation not permitted.=Isleme izin verilmedi. diff --git a/src/FastDelegate.h b/src/FastDelegate.h deleted file mode 100644 index 9b13f7d..0000000 --- a/src/FastDelegate.h +++ /dev/null @@ -1,2108 +0,0 @@ -// FastDelegate.h -// Efficient delegates in C++ that generate only two lines of asm code! -// Documentation is found at http://www.codeproject.com/cpp/FastDelegate.asp -// -// - Don Clugston, Mar 2004. -// Major contributions were made by Jody Hagins. -// History: -// 24-Apr-04 1.0 * Submitted to CodeProject. -// 28-Apr-04 1.1 * Prevent most unsafe uses of evil static function hack. -// * Improved syntax for horrible_cast (thanks Paul Bludov). -// * Tested on Metrowerks MWCC and Intel ICL (IA32) -// * Compiled, but not run, on Comeau C++ and Intel Itanium ICL. -// 27-Jun-04 1.2 * Now works on Borland C++ Builder 5.5 -// * Now works on /clr "managed C++" code on VC7, VC7.1 -// * Comeau C++ now compiles without warnings. -// * Prevent the virtual inheritance case from being used on -// VC6 and earlier, which generate incorrect code. -// * Improved warning and error messages. Non-standard hacks -// now have compile-time checks to make them safer. -// * implicit_cast used instead of static_cast in many cases. -// * If calling a const member function, a const class pointer can be used. -// * MakeDelegate() global helper function added to simplify pass-by-value. -// * Added fastdelegate.clear() -// 16-Jul-04 1.2.1* Workaround for gcc bug (const member function pointers in templates) -// 30-Oct-04 1.3 * Support for (non-void) return values. -// * No more workarounds in client code! -// MSVC and Intel now use a clever hack invented by John Dlugosz: -// - The FASTDELEGATEDECLARE workaround is no longer necessary. -// - No more warning messages for VC6 -// * Less use of macros. Error messages should be more comprehensible. -// * Added include guards -// * Added FastDelegate::empty() to test if invocation is safe (Thanks Neville Franks). -// * Now tested on VS 2005 Express Beta, PGI C++ -// 24-Dec-04 1.4 * Added DelegateMemento, to allow collections of disparate delegates. -// * <,>,<=,>= comparison operators to allow storage in ordered containers. -// * Substantial reduction of code size, especially the 'Closure' class. -// * Standardised all the compiler-specific workarounds. -// * MFP conversion now works for CodePlay (but not yet supported in the full code). -// * Now compiles without warnings on _any_ supported compiler, including BCC 5.5.1 -// * New syntax: FastDelegate< int (char *, double) >. -// 14-Feb-05 1.4.1* Now treats =0 as equivalent to .clear(), ==0 as equivalent to .empty(). (Thanks elfric). -// * Now tested on Intel ICL for AMD64, VS2005 Beta for AMD64 and Itanium. -// 30-Mar-05 1.5 * Safebool idiom: "if (dg)" is now equivalent to "if (!dg.empty())" -// * Fully supported by CodePlay VectorC -// * Bugfix for Metrowerks: empty() was buggy because a valid MFP can be 0 on MWCC! -// * More optimal assignment,== and != operators for static function pointers. - -#ifndef FASTDELEGATE_H -#define FASTDELEGATE_H -#if defined(_MSC_VER) && _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include // to allow <,> comparisons - -//////////////////////////////////////////////////////////////////////////////// -// Configuration options -// -//////////////////////////////////////////////////////////////////////////////// - -// Uncomment the following #define for optimally-sized delegates. -// In this case, the generated asm code is almost identical to the code you'd get -// if the compiler had native support for delegates. -// It will not work on systems where sizeof(dataptr) < sizeof(codeptr). -// Thus, it will not work for DOS compilers using the medium model. -// It will also probably fail on some DSP systems. -#define FASTDELEGATE_USESTATICFUNCTIONHACK - -// Uncomment the next line to allow function declarator syntax. -// It is automatically enabled for those compilers where it is known to work. -//#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX - -//////////////////////////////////////////////////////////////////////////////// -// Compiler identification for workarounds -// -//////////////////////////////////////////////////////////////////////////////// - -// Compiler identification. It's not easy to identify Visual C++ because -// many vendors fraudulently define Microsoft's identifiers. -#if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__VECTOR_C) && !defined(__ICL) && !defined(__BORLANDC__) -#define FASTDLGT_ISMSVC - -#if defined(_MSC_VER) && _MSC_VER < 1300 // Many workarounds are required for VC6. -#define FASTDLGT_VC6 -#pragma warning(disable:4786) // disable this ridiculous warning -#endif - -#endif - -// Does the compiler uses Microsoft's member function pointer structure? -// If so, it needs special treatment. -// Metrowerks CodeWarrior, Intel, and CodePlay fraudulently define Microsoft's -// identifier, _MSC_VER. We need to filter Metrowerks out. -#if defined(_MSC_VER) && !defined(__MWERKS__) -#define FASTDLGT_MICROSOFT_MFP - -#if !defined(__VECTOR_C) -// CodePlay doesn't have the __single/multi/virtual_inheritance keywords -#define FASTDLGT_HASINHERITANCE_KEYWORDS -#endif -#endif - -// Does it allow function declarator syntax? The following compilers are known to work: -#if defined(FASTDLGT_ISMSVC) && (_MSC_VER >=1310) // VC 7.1 -#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX -#endif - -// Gcc(2.95+), and versions of Digital Mars, Intel and Comeau in common use. -#if defined (__DMC__) || defined(__GNUC__) || defined(__ICL) || defined(__COMO__) -#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX -#endif - -// It works on Metrowerks MWCC 3.2.2. From boost.Config it should work on earlier ones too. -#if defined (__MWERKS__) -#define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX -#endif - -#ifdef __GNUC__ // Workaround GCC bug #8271 - // At present, GCC doesn't recognize constness of MFPs in templates -#define FASTDELEGATE_GCC_BUG_8271 -#endif - - - -//////////////////////////////////////////////////////////////////////////////// -// General tricks used in this code -// -// (a) Error messages are generated by typdefing an array of negative size to -// generate compile-time errors. -// (b) Warning messages on MSVC are generated by declaring unused variables, and -// enabling the "variable XXX is never used" warning. -// (c) Unions are used in a few compiler-specific cases to perform illegal casts. -// (d) For Microsoft and Intel, when adjusting the 'this' pointer, it's cast to -// (char *) first to ensure that the correct number of *bytes* are added. -// -//////////////////////////////////////////////////////////////////////////////// -// Helper templates -// -//////////////////////////////////////////////////////////////////////////////// - - -namespace fastdelegate { -namespace detail { // we'll hide the implementation details in a nested namespace. - -// implicit_cast< > -// I believe this was originally going to be in the C++ standard but -// was left out by accident. It's even milder than static_cast. -// I use it instead of static_cast<> to emphasize that I'm not doing -// anything nasty. -// Usage is identical to static_cast<> -template -inline OutputClass implicit_cast(InputClass input){ - return input; -} - -// horrible_cast< > -// This is truly evil. It completely subverts C++'s type system, allowing you -// to cast from any class to any other class. Technically, using a union -// to perform the cast is undefined behaviour (even in C). But we can see if -// it is OK by checking that the union is the same size as each of its members. -// horrible_cast<> should only be used for compiler-specific workarounds. -// Usage is identical to reinterpret_cast<>. - -// This union is declared outside the horrible_cast because BCC 5.5.1 -// can't inline a function with a nested class, and gives a warning. -template -union horrible_union{ - OutputClass out; - InputClass in; -}; - -template -inline OutputClass horrible_cast(const InputClass input){ - horrible_union u; - // Cause a compile-time error if in, out and u are not the same size. - // If the compile fails here, it means the compiler has peculiar - // unions which would prevent the cast from working. - typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u) - && sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1]; - u.in = input; - return u.out; -} - -//////////////////////////////////////////////////////////////////////////////// -// Workarounds -// -//////////////////////////////////////////////////////////////////////////////// - -// Backwards compatibility: This macro used to be necessary in the virtual inheritance -// case for Intel and Microsoft. Now it just forward-declares the class. -#define FASTDELEGATEDECLARE(CLASSNAME) class CLASSNAME; - -// Prevent use of the static function hack with the DOS medium model. -#ifdef __MEDIUM__ -#undef FASTDELEGATE_USESTATICFUNCTIONHACK -#endif - -// DefaultVoid - a workaround for 'void' templates in VC6. -// -// (1) VC6 and earlier do not allow 'void' as a default template argument. -// (2) They also doesn't allow you to return 'void' from a function. -// -// Workaround for (1): Declare a dummy type 'DefaultVoid' which we use -// when we'd like to use 'void'. We convert it into 'void' and back -// using the templates DefaultVoidToVoid<> and VoidToDefaultVoid<>. -// Workaround for (2): On VC6, the code for calling a void function is -// identical to the code for calling a non-void function in which the -// return value is never used, provided the return value is returned -// in the EAX register, rather than on the stack. -// This is true for most fundamental types such as int, enum, void *. -// Const void * is the safest option since it doesn't participate -// in any automatic conversions. But on a 16-bit compiler it might -// cause extra code to be generated, so we disable it for all compilers -// except for VC6 (and VC5). -#ifdef FASTDLGT_VC6 -// VC6 workaround -typedef const void * DefaultVoid; -#else -// On any other compiler, just use a normal void. -typedef void DefaultVoid; -#endif - -// Translate from 'DefaultVoid' to 'void'. -// Everything else is unchanged -template -struct DefaultVoidToVoid { typedef T type; }; - -template <> -struct DefaultVoidToVoid { typedef void type; }; - -// Translate from 'void' into 'DefaultVoid' -// Everything else is unchanged -template -struct VoidToDefaultVoid { typedef T type; }; - -template <> -struct VoidToDefaultVoid { typedef DefaultVoid type; }; - - - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 1: -// -// Conversion of member function pointer to a standard form -// -//////////////////////////////////////////////////////////////////////////////// - -// GenericClass is a fake class, ONLY used to provide a type. -// It is vitally important that it is never defined, so that the compiler doesn't -// think it can optimize the invocation. For example, Borland generates simpler -// code if it knows the class only uses single inheritance. - -// Compilers using Microsoft's structure need to be treated as a special case. -#ifdef FASTDLGT_MICROSOFT_MFP - -#ifdef FASTDLGT_HASINHERITANCE_KEYWORDS - // For Microsoft and Intel, we want to ensure that it's the most efficient type of MFP - // (4 bytes), even when the /vmg option is used. Declaring an empty class - // would give 16 byte pointers in this case.... - class __single_inheritance GenericClass; -#endif - // ...but for Codeplay, an empty class *always* gives 4 byte pointers. - // If compiled with the /clr option ("managed C++"), the JIT compiler thinks - // it needs to load GenericClass before it can call any of its functions, - // (compiles OK but crashes at runtime!), so we need to declare an - // empty class to make it happy. - // Codeplay and VC4 can't cope with the unknown_inheritance case either. - class GenericClass {}; -#else - class GenericClass; -#endif - -// The size of a single inheritance member function pointer. -const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)()); - -// SimplifyMemFunc< >::Convert() -// -// A template function that converts an arbitrary member function pointer into the -// simplest possible form of member function pointer, using a supplied 'this' pointer. -// According to the standard, this can be done legally with reinterpret_cast<>. -// For (non-standard) compilers which use member function pointers which vary in size -// depending on the class, we need to use knowledge of the internal structure of a -// member function pointer, as used by the compiler. Template specialization is used -// to distinguish between the sizes. Because some compilers don't support partial -// template specialisation, I use full specialisation of a wrapper struct. - -// general case -- don't know how to convert it. Force a compile failure -template -struct SimplifyMemFunc { - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { - // Unsupported member function type -- force a compile failure. - // (it's illegal to have a array with negative size). - typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100]; - return 0; - } -}; - -// For compilers where all member func ptrs are the same size, everything goes here. -// For non-standard compilers, only single_inheritance classes go here. -template <> -struct SimplifyMemFunc { - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { -#if defined __DMC__ - // Digital Mars doesn't allow you to cast between abitrary PMF's, - // even though the standard says you can. The 32-bit compiler lets you - // static_cast through an int, but the DOS compiler doesn't. - bound_func = horrible_cast(function_to_bind); -#else - bound_func = reinterpret_cast(function_to_bind); -#endif - return reinterpret_cast(pthis); - } -}; - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 1b: -// -// Workarounds for Microsoft and Intel -// -//////////////////////////////////////////////////////////////////////////////// - - -// Compilers with member function pointers which violate the standard (MSVC, Intel, Codeplay), -// need to be treated as a special case. -#ifdef FASTDLGT_MICROSOFT_MFP - -// We use unions to perform horrible_casts. I would like to use #pragma pack(push, 1) -// at the start of each function for extra safety, but VC6 seems to ICE -// intermittently if you do this inside a template. - -// __multiple_inheritance classes go here -// Nasty hack for Microsoft and Intel (IA32 and Itanium) -template<> -struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(int) > { - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { - // We need to use a horrible_cast to do this conversion. - // In MSVC, a multiple inheritance member pointer is internally defined as: - union { - XFuncType func; - struct { - GenericMemFuncType funcaddress; // points to the actual member function - int delta; // #BYTES to be added to the 'this' pointer - }s; - } u; - // Check that the horrible_cast will work - typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)? 1 : -1]; - u.func = function_to_bind; - bound_func = u.s.funcaddress; - return reinterpret_cast(reinterpret_cast(pthis) + u.s.delta); - } -}; - -// virtual inheritance is a real nuisance. It's inefficient and complicated. -// On MSVC and Intel, there isn't enough information in the pointer itself to -// enable conversion to a closure pointer. Earlier versions of this code didn't -// work for all cases, and generated a compile-time error instead. -// But a very clever hack invented by John M. Dlugosz solves this problem. -// My code is somewhat different to his: I have no asm code, and I make no -// assumptions about the calling convention that is used. - -// In VC++ and ICL, a virtual_inheritance member pointer -// is internally defined as: -struct MicrosoftVirtualMFP { - void (GenericClass::*codeptr)(); // points to the actual member function - int delta; // #bytes to be added to the 'this' pointer - int vtable_index; // or 0 if no virtual inheritance -}; -// The CRUCIAL feature of Microsoft/Intel MFPs which we exploit is that the -// m_codeptr member is *always* called, regardless of the values of the other -// members. (This is *not* true for other compilers, eg GCC, which obtain the -// function address from the vtable if a virtual function is being called). -// Dlugosz's trick is to make the codeptr point to a probe function which -// returns the 'this' pointer that was used. - -// Define a generic class that uses virtual inheritance. -// It has a trival member function that returns the value of the 'this' pointer. -struct GenericVirtualClass : virtual public GenericClass -{ - typedef GenericVirtualClass * (GenericVirtualClass::*ProbePtrType)(); - GenericVirtualClass * GetThis() { return this; } -}; - -// __virtual_inheritance classes go here -template <> -struct SimplifyMemFunc -{ - - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { - union { - XFuncType func; - GenericClass* (X::*ProbeFunc)(); - MicrosoftVirtualMFP s; - } u; - u.func = function_to_bind; - bound_func = reinterpret_cast(u.s.codeptr); - union { - GenericVirtualClass::ProbePtrType virtfunc; - MicrosoftVirtualMFP s; - } u2; - // Check that the horrible_cast<>s will work - typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s) - && sizeof(function_to_bind)==sizeof(u.ProbeFunc) - && sizeof(u2.virtfunc)==sizeof(u2.s) ? 1 : -1]; - // Unfortunately, taking the address of a MF prevents it from being inlined, so - // this next line can't be completely optimised away by the compiler. - u2.virtfunc = &GenericVirtualClass::GetThis; - u.s.codeptr = u2.s.codeptr; - return (pthis->*u.ProbeFunc)(); - } -}; - -#if (_MSC_VER <1300) - -// Nasty hack for Microsoft Visual C++ 6.0 -// unknown_inheritance classes go here -// There is a compiler bug in MSVC6 which generates incorrect code in this case!! -template <> -struct SimplifyMemFunc -{ - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { - // There is an apalling but obscure compiler bug in MSVC6 and earlier: - // vtable_index and 'vtordisp' are always set to 0 in the - // unknown_inheritance case! - // This means that an incorrect function could be called!!! - // Compiling with the /vmg option leads to potentially incorrect code. - // This is probably the reason that the IDE has a user interface for specifying - // the /vmg option, but it is disabled - you can only specify /vmg on - // the command line. In VC1.5 and earlier, the compiler would ICE if it ever - // encountered this situation. - // It is OK to use the /vmg option if /vmm or /vms is specified. - - // Fortunately, the wrong function is only called in very obscure cases. - // It only occurs when a derived class overrides a virtual function declared - // in a virtual base class, and the member function - // points to the *Derived* version of that function. The problem can be - // completely averted in 100% of cases by using the *Base class* for the - // member fpointer. Ie, if you use the base class as an interface, you'll - // stay out of trouble. - // Occasionally, you might want to point directly to a derived class function - // that isn't an override of a base class. In this case, both vtable_index - // and 'vtordisp' are zero, but a virtual_inheritance pointer will be generated. - // We can generate correct code in this case. To prevent an incorrect call from - // ever being made, on MSVC6 we generate a warning, and call a function to - // make the program crash instantly. - typedef char ERROR_VC6CompilerBug[-100]; - return 0; - } -}; - - -#else - -// Nasty hack for Microsoft and Intel (IA32 and Itanium) -// unknown_inheritance classes go here -// This is probably the ugliest bit of code I've ever written. Look at the casts! -// There is a compiler bug in MSVC6 which prevents it from using this code. -template <> -struct SimplifyMemFunc -{ - template - inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind, - GenericMemFuncType &bound_func) { - // The member function pointer is 16 bytes long. We can't use a normal cast, but - // we can use a union to do the conversion. - union { - XFuncType func; - // In VC++ and ICL, an unknown_inheritance member pointer - // is internally defined as: - struct { - GenericMemFuncType m_funcaddress; // points to the actual member function - int delta; // #bytes to be added to the 'this' pointer - int vtordisp; // #bytes to add to 'this' to find the vtable - int vtable_index; // or 0 if no virtual inheritance - } s; - } u; - // Check that the horrible_cast will work - typedef int ERROR_CantUsehorrible_cast[sizeof(XFuncType)==sizeof(u.s)? 1 : -1]; - u.func = function_to_bind; - bound_func = u.s.funcaddress; - int virtual_delta = 0; - if (u.s.vtable_index) { // Virtual inheritance is used - // First, get to the vtable. - // It is 'vtordisp' bytes from the start of the class. - const int * vtable = *reinterpret_cast( - reinterpret_cast(pthis) + u.s.vtordisp ); - - // 'vtable_index' tells us where in the table we should be looking. - virtual_delta = u.s.vtordisp + *reinterpret_cast( - reinterpret_cast(vtable) + u.s.vtable_index); - } - // The int at 'virtual_delta' gives us the amount to add to 'this'. - // Finally we can add the three components together. Phew! - return reinterpret_cast( - reinterpret_cast(pthis) + u.s.delta + virtual_delta); - }; -}; -#endif // MSVC 7 and greater - -#endif // MS/Intel hacks - -} // namespace detail - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 2: -// -// Define the delegate storage, and cope with static functions -// -//////////////////////////////////////////////////////////////////////////////// - -// DelegateMemento -- an opaque structure which can hold an arbitary delegate. -// It knows nothing about the calling convention or number of arguments used by -// the function pointed to. -// It supplies comparison operators so that it can be stored in STL collections. -// It cannot be set to anything other than null, nor invoked directly: -// it must be converted to a specific delegate. - -// Implementation: -// There are two possible implementations: the Safe method and the Evil method. -// DelegateMemento - Safe version -// -// This implementation is standard-compliant, but a bit tricky. -// A static function pointer is stored inside the class. -// Here are the valid values: -// +-- Static pointer --+--pThis --+-- pMemFunc-+-- Meaning------+ -// | 0 | 0 | 0 | Empty | -// | !=0 |(dontcare)| Invoker | Static function| -// | 0 | !=0 | !=0* | Method call | -// +--------------------+----------+------------+----------------+ -// * For Metrowerks, this can be 0. (first virtual function in a -// single_inheritance class). -// When stored stored inside a specific delegate, the 'dontcare' entries are replaced -// with a reference to the delegate itself. This complicates the = and == operators -// for the delegate class. - -// DelegateMemento - Evil version -// -// For compilers where data pointers are at least as big as code pointers, it is -// possible to store the function pointer in the this pointer, using another -// horrible_cast. In this case the DelegateMemento implementation is simple: -// +--pThis --+-- pMemFunc-+-- Meaning---------------------+ -// | 0 | 0 | Empty | -// | !=0 | !=0* | Static function or method call| -// +----------+------------+-------------------------------+ -// * For Metrowerks, this can be 0. (first virtual function in a -// single_inheritance class). -// Note that the Sun C++ and MSVC documentation explicitly state that they -// support static_cast between void * and function pointers. - -class DelegateMemento { -protected: - // the data is protected, not private, because many - // compilers have problems with template friends. - typedef void (detail::GenericClass::*GenericMemFuncType)(); // arbitrary MFP. - GenericMemFuncType m_pFunction; - detail::GenericClass *m_pthis; - -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - typedef void (*GenericFuncPtr)(); // arbitrary code pointer - GenericFuncPtr m_pStaticFunction; -#endif - -public: -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - DelegateMemento() : m_pthis(0), m_pFunction(0), m_pStaticFunction(0) {}; - void clear() { - m_pthis=0; m_pFunction=0; m_pStaticFunction=0; - } -#else - DelegateMemento() : m_pFunction(0), m_pthis(0) {}; - void clear() { m_pthis=0; m_pFunction=0; } -#endif -public: -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - inline bool IsEqual (const DelegateMemento &x) const{ - // We have to cope with the static function pointers as a special case - if (m_pFunction!=x.m_pFunction) return false; - // the static function ptrs must either both be equal, or both be 0. - if (m_pStaticFunction!=x.m_pStaticFunction) return false; - if (m_pStaticFunction!=0) return m_pthis==x.m_pthis; - else return true; - } -#else // Evil Method - inline bool IsEqual (const DelegateMemento &x) const{ - return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction; - } -#endif - // Provide a strict weak ordering for DelegateMementos. - inline bool IsLess(const DelegateMemento &right) const { - // deal with static function pointers first -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0) - return m_pStaticFunction < right.m_pStaticFunction; -#endif - if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis; - // There are no ordering operators for member function pointers, - // but we can fake one by comparing each byte. The resulting ordering is - // arbitrary (and compiler-dependent), but it permits storage in ordered STL containers. - return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0; - - } - // BUGFIX (Mar 2005): - // We can't just compare m_pFunction because on Metrowerks, - // m_pFunction can be zero even if the delegate is not empty! - inline bool operator ! () const // Is it bound to anything? - { return m_pthis==0 && m_pFunction==0; } - inline bool empty() const // Is it bound to anything? - { return m_pthis==0 && m_pFunction==0; } -public: - DelegateMemento & operator = (const DelegateMemento &right) { - SetMementoFrom(right); - return *this; - } - inline bool operator <(const DelegateMemento &right) { - return IsLess(right); - } - inline bool operator >(const DelegateMemento &right) { - return right.IsLess(*this); - } - DelegateMemento (const DelegateMemento &right) : - m_pFunction(right.m_pFunction), m_pthis(right.m_pthis) -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - , m_pStaticFunction (right.m_pStaticFunction) -#endif - {} -protected: - void SetMementoFrom(const DelegateMemento &right) { - m_pFunction = right.m_pFunction; - m_pthis = right.m_pthis; -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - m_pStaticFunction = right.m_pStaticFunction; -#endif - } -}; - - -// ClosurePtr<> -// -// A private wrapper class that adds function signatures to DelegateMemento. -// It's the class that does most of the actual work. -// The signatures are specified by: -// GenericMemFunc: must be a type of GenericClass member function pointer. -// StaticFuncPtr: must be a type of function pointer with the same signature -// as GenericMemFunc. -// UnvoidStaticFuncPtr: is the same as StaticFuncPtr, except on VC6 -// where it never returns void (returns DefaultVoid instead). - -// An outer class, FastDelegateN<>, handles the invoking and creates the -// necessary typedefs. -// This class does everything else. - -namespace detail { - -template < class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr> -class ClosurePtr : public DelegateMemento { -public: - // These functions are for setting the delegate to a member function. - - // Here's the clever bit: we convert an arbitrary member function into a - // standard form. XMemFunc should be a member function of class X, but I can't - // enforce that here. It needs to be enforced by the wrapper class. - template < class X, class XMemFunc > - inline void bindmemfunc(X *pthis, XMemFunc function_to_bind ) { - m_pthis = SimplifyMemFunc< sizeof(function_to_bind) > - ::Convert(pthis, function_to_bind, m_pFunction); -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - m_pStaticFunction = 0; -#endif - } - // For const member functions, we only need a const class pointer. - // Since we know that the member function is const, it's safe to - // remove the const qualifier from the 'this' pointer with a const_cast. - // VC6 has problems if we just overload 'bindmemfunc', so we give it a different name. - template < class X, class XMemFunc> - inline void bindconstmemfunc(const X *pthis, XMemFunc function_to_bind) { - m_pthis= SimplifyMemFunc< sizeof(function_to_bind) > - ::Convert(const_cast(pthis), function_to_bind, m_pFunction); -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - m_pStaticFunction = 0; -#endif - } -#ifdef FASTDELEGATE_GCC_BUG_8271 // At present, GCC doesn't recognize constness of MFPs in templates - template < class X, class XMemFunc> - inline void bindmemfunc(const X *pthis, XMemFunc function_to_bind) { - bindconstmemfunc(pthis, function_to_bind); -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - m_pStaticFunction = 0; -#endif - } -#endif - // These functions are required for invoking the stored function - inline GenericClass *GetClosureThis() const { return m_pthis; } - inline GenericMemFunc GetClosureMemPtr() const { return reinterpret_cast(m_pFunction); } - -// There are a few ways of dealing with static function pointers. -// There's a standard-compliant, but tricky method. -// There's also a straightforward hack, that won't work on DOS compilers using the -// medium memory model. It's so evil that I can't recommend it, but I've -// implemented it anyway because it produces very nice asm code. - -#if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - -// ClosurePtr<> - Safe version -// -// This implementation is standard-compliant, but a bit tricky. -// I store the function pointer inside the class, and the delegate then -// points to itself. Whenever the delegate is copied, these self-references -// must be transformed, and this complicates the = and == operators. -public: - // The next two functions are for operator ==, =, and the copy constructor. - // We may need to convert the m_pthis pointers, so that - // they remain as self-references. - template< class DerivedClass > - inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &x) { - SetMementoFrom(x); - if (m_pStaticFunction!=0) { - // transform self references... - m_pthis=reinterpret_cast(pParent); - } - } - // For static functions, the 'static_function_invoker' class in the parent - // will be called. The parent then needs to call GetStaticFunction() to find out - // the actual function to invoke. - template < class DerivedClass, class ParentInvokerSig > - inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, - StaticFuncPtr function_to_bind ) { - if (function_to_bind==0) { // cope with assignment to 0 - m_pFunction=0; - } else { - bindmemfunc(pParent, static_function_invoker); - } - m_pStaticFunction=reinterpret_cast(function_to_bind); - } - inline UnvoidStaticFuncPtr GetStaticFunction() const { - return reinterpret_cast(m_pStaticFunction); - } -#else - -// ClosurePtr<> - Evil version -// -// For compilers where data pointers are at least as big as code pointers, it is -// possible to store the function pointer in the this pointer, using another -// horrible_cast. Invocation isn't any faster, but it saves 4 bytes, and -// speeds up comparison and assignment. If C++ provided direct language support -// for delegates, they would produce asm code that was almost identical to this. -// Note that the Sun C++ and MSVC documentation explicitly state that they -// support static_cast between void * and function pointers. - - template< class DerivedClass > - inline void CopyFrom (DerivedClass */*pParent*/, const DelegateMemento &right) { - SetMementoFrom(right); - } - // For static functions, the 'static_function_invoker' class in the parent - // will be called. The parent then needs to call GetStaticFunction() to find out - // the actual function to invoke. - // ******** EVIL, EVIL CODE! ******* - template < class DerivedClass, class ParentInvokerSig> - inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker, - StaticFuncPtr function_to_bind) { - if (function_to_bind==0) { // cope with assignment to 0 - m_pFunction=0; - } else { - // We'll be ignoring the 'this' pointer, but we need to make sure we pass - // a valid value to bindmemfunc(). - bindmemfunc(pParent, static_function_invoker); - } - - // WARNING! Evil hack. We store the function in the 'this' pointer! - // Ensure that there's a compilation failure if function pointers - // and data pointers have different sizes. - // If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK. - typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1]; - m_pthis = horrible_cast(function_to_bind); - // MSVC, SunC++ and DMC accept the following (non-standard) code: -// m_pthis = static_cast(static_cast(function_to_bind)); - // BCC32, Comeau and DMC accept this method. MSVC7.1 needs __int64 instead of long -// m_pthis = reinterpret_cast(reinterpret_cast(function_to_bind)); - } - // ******** EVIL, EVIL CODE! ******* - // This function will be called with an invalid 'this' pointer!! - // We're just returning the 'this' pointer, converted into - // a function pointer! - inline UnvoidStaticFuncPtr GetStaticFunction() const { - // Ensure that there's a compilation failure if function pointers - // and data pointers have different sizes. - // If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK. - typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1]; - return horrible_cast(this); - } -#endif // !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) - - // Does the closure contain this static function? - inline bool IsEqualToStaticFuncPtr(StaticFuncPtr funcptr){ - if (funcptr==0) return empty(); - // For the Evil method, if it doesn't actually contain a static function, this will return an arbitrary - // value that is not equal to any valid function pointer. - else return funcptr==reinterpret_cast(GetStaticFunction()); - } -}; - - -} // namespace detail - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 3: -// -// Wrapper classes to ensure type safety -// -//////////////////////////////////////////////////////////////////////////////// - - -// Once we have the member function conversion templates, it's easy to make the -// wrapper classes. So that they will work with as many compilers as possible, -// the classes are of the form -// FastDelegate3 -// They can cope with any combination of parameters. The max number of parameters -// allowed is 8, but it is trivial to increase this limit. -// Note that we need to treat const member functions seperately. -// All this class does is to enforce type safety, and invoke the delegate with -// the correct list of parameters. - -// Because of the weird rule about the class of derived member function pointers, -// you sometimes need to apply a downcast to the 'this' pointer. -// This is the reason for the use of "implicit_cast(pthis)" in the code below. -// If CDerivedClass is derived from CBaseClass, but doesn't override SimpleVirtualFunction, -// without this trick you'd need to write: -// MyDelegate(static_cast(&d), &CDerivedClass::SimpleVirtualFunction); -// but with the trick you can write -// MyDelegate(&d, &CDerivedClass::SimpleVirtualFunction); - -// RetType is the type the compiler uses in compiling the template. For VC6, -// it cannot be void. DesiredRetType is the real type which is returned from -// all of the functions. It can be void. - -// Implicit conversion to "bool" is achieved using the safe_bool idiom, -// using member data pointers (MDP). This allows "if (dg)..." syntax -// Because some compilers (eg codeplay) don't have a unique value for a zero -// MDP, an extra padding member is added to the SafeBool struct. -// Some compilers (eg VC6) won't implicitly convert from 0 to an MDP, so -// in that case the static function constructor is not made explicit; this -// allows "if (dg==0) ..." to compile. - -//N=0 -template -class FastDelegate0 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(); - typedef RetType (*UnvoidStaticFunctionPtr)(); - typedef RetType (detail::GenericClass::*GenericMemFn)(); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate0 type; - - // Construction and comparison functions - FastDelegate0() { clear(); } - FastDelegate0(const FastDelegate0 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate0 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate0 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate0 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate0 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate0 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate0(Y *pthis, DesiredRetType (X::* function_to_bind)() ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)()) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate0(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate0(DesiredRetType (*function_to_bind)() ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)() ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)()) { - m_Closure.bindstaticfunc(this, &FastDelegate0::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() () const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction() const { - return (*(m_Closure.GetStaticFunction()))(); } -}; - -//N=1 -template -class FastDelegate1 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate1 type; - - // Construction and comparison functions - FastDelegate1() { clear(); } - FastDelegate1(const FastDelegate1 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate1 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate1 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate1 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate1 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate1 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate1(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate1(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate1(DesiredRetType (*function_to_bind)(Param1 p1) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1)) { - m_Closure.bindstaticfunc(this, &FastDelegate1::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1) const { - return (*(m_Closure.GetStaticFunction()))(p1); } -}; - -//N=2 -template -class FastDelegate2 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate2 type; - - // Construction and comparison functions - FastDelegate2() { clear(); } - FastDelegate2(const FastDelegate2 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate2 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate2 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate2 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate2 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate2 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate2(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate2(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate2(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2)) { - m_Closure.bindstaticfunc(this, &FastDelegate2::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2); } -}; - -//N=3 -template -class FastDelegate3 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate3 type; - - // Construction and comparison functions - FastDelegate3() { clear(); } - FastDelegate3(const FastDelegate3 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate3 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate3 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate3 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate3 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate3 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate3(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate3(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate3(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) { - m_Closure.bindstaticfunc(this, &FastDelegate3::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3); } -}; - -//N=4 -template -class FastDelegate4 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate4 type; - - // Construction and comparison functions - FastDelegate4() { clear(); } - FastDelegate4(const FastDelegate4 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate4 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate4 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate4 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate4 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate4 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate4(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate4(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate4(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { - m_Closure.bindstaticfunc(this, &FastDelegate4::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4); } -}; - -//N=5 -template -class FastDelegate5 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate5 type; - - // Construction and comparison functions - FastDelegate5() { clear(); } - FastDelegate5(const FastDelegate5 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate5 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate5 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate5 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate5 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate5 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate5(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate5(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate5(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { - m_Closure.bindstaticfunc(this, &FastDelegate5::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5); } -}; - -//N=6 -template -class FastDelegate6 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate6 type; - - // Construction and comparison functions - FastDelegate6() { clear(); } - FastDelegate6(const FastDelegate6 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate6 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate6 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate6 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate6 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate6 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate6(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate6(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate6(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { - m_Closure.bindstaticfunc(this, &FastDelegate6::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6); } -}; - -//N=7 -template -class FastDelegate7 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate7 type; - - // Construction and comparison functions - FastDelegate7() { clear(); } - FastDelegate7(const FastDelegate7 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate7 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate7 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate7 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate7 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate7 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate7(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate7(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate7(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) { - m_Closure.bindstaticfunc(this, &FastDelegate7::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7); } -}; - -//N=8 -template -class FastDelegate8 { -private: - typedef typename detail::DefaultVoidToVoid::type DesiredRetType; - typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8); - typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8); - typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8); - typedef detail::ClosurePtr ClosureType; - ClosureType m_Closure; -public: - // Typedefs to aid generic programming - typedef FastDelegate8 type; - - // Construction and comparison functions - FastDelegate8() { clear(); } - FastDelegate8(const FastDelegate8 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - void operator = (const FastDelegate8 &x) { - m_Closure.CopyFrom(this, x.m_Closure); } - bool operator ==(const FastDelegate8 &x) const { - return m_Closure.IsEqual(x.m_Closure); } - bool operator !=(const FastDelegate8 &x) const { - return !m_Closure.IsEqual(x.m_Closure); } - bool operator <(const FastDelegate8 &x) const { - return m_Closure.IsLess(x.m_Closure); } - bool operator >(const FastDelegate8 &x) const { - return x.m_Closure.IsLess(m_Closure); } - // Binding to non-const member functions - template < class X, class Y > - FastDelegate8(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) { - m_Closure.bindmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Binding to const member functions. - template < class X, class Y > - FastDelegate8(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - template < class X, class Y > - inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) { - m_Closure.bindconstmemfunc(detail::implicit_cast(pthis), function_to_bind); } - // Static functions. We convert them into a member function call. - // This constructor also provides implicit conversion - FastDelegate8(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) { - bind(function_to_bind); } - // for efficiency, prevent creation of a temporary - void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) { - bind(function_to_bind); } - inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) { - m_Closure.bindstaticfunc(this, &FastDelegate8::InvokeStaticFunction, - function_to_bind); } - // Invoke the delegate - RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const { - return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8); } - // Implicit conversion to "bool" using the safe_bool idiom -private: - typedef struct SafeBoolStruct { - int a_data_pointer_to_this_is_0_on_buggy_compilers; - StaticFunctionPtr m_nonzero; - } UselessTypedef; - typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type; -public: - operator unspecified_bool_type() const { - return empty()? 0: &SafeBoolStruct::m_nonzero; - } - // necessary to allow ==0 to work despite the safe_bool idiom - inline bool operator==(StaticFunctionPtr funcptr) { - return m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator!=(StaticFunctionPtr funcptr) { - return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } - inline bool operator ! () const { // Is it bound to anything? - return !m_Closure; } - inline bool empty() const { - return !m_Closure; } - void clear() { m_Closure.clear();} - // Conversion to and from the DelegateMemento storage class - const DelegateMemento & GetMemento() { return m_Closure; } - void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); } - -private: // Invoker for static functions - RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const { - return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8); } -}; - - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 4: -// -// FastDelegate<> class (Original author: Jody Hagins) -// Allows boost::function style syntax like: -// FastDelegate< double (int, long) > -// instead of: -// FastDelegate2< int, long, double > -// -//////////////////////////////////////////////////////////////////////////////// - -#ifdef FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX - -// Declare FastDelegate as a class template. It will be specialized -// later for all number of arguments. -template -class FastDelegate; - -//N=0 -// Specialization to allow use of -// FastDelegate< R ( ) > -// instead of -// FastDelegate0 < R > -template -class FastDelegate< R ( ) > - // Inherit from FastDelegate0 so that it can be treated just like a FastDelegate0 - : public FastDelegate0 < R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate0 < R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=1 -// Specialization to allow use of -// FastDelegate< R ( Param1 ) > -// instead of -// FastDelegate1 < Param1, R > -template -class FastDelegate< R ( Param1 ) > - // Inherit from FastDelegate1 so that it can be treated just like a FastDelegate1 - : public FastDelegate1 < Param1, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate1 < Param1, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=2 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2 ) > -// instead of -// FastDelegate2 < Param1, Param2, R > -template -class FastDelegate< R ( Param1, Param2 ) > - // Inherit from FastDelegate2 so that it can be treated just like a FastDelegate2 - : public FastDelegate2 < Param1, Param2, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate2 < Param1, Param2, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=3 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3 ) > -// instead of -// FastDelegate3 < Param1, Param2, Param3, R > -template -class FastDelegate< R ( Param1, Param2, Param3 ) > - // Inherit from FastDelegate3 so that it can be treated just like a FastDelegate3 - : public FastDelegate3 < Param1, Param2, Param3, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate3 < Param1, Param2, Param3, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=4 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3, Param4 ) > -// instead of -// FastDelegate4 < Param1, Param2, Param3, Param4, R > -template -class FastDelegate< R ( Param1, Param2, Param3, Param4 ) > - // Inherit from FastDelegate4 so that it can be treated just like a FastDelegate4 - : public FastDelegate4 < Param1, Param2, Param3, Param4, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate4 < Param1, Param2, Param3, Param4, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=5 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) > -// instead of -// FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > -template -class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) > - // Inherit from FastDelegate5 so that it can be treated just like a FastDelegate5 - : public FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=6 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) > -// instead of -// FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > -template -class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) > - // Inherit from FastDelegate6 so that it can be treated just like a FastDelegate6 - : public FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=7 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) > -// instead of -// FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > -template -class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) > - // Inherit from FastDelegate7 so that it can be treated just like a FastDelegate7 - : public FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - -//N=8 -// Specialization to allow use of -// FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) > -// instead of -// FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > -template -class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) > - // Inherit from FastDelegate8 so that it can be treated just like a FastDelegate8 - : public FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > -{ -public: - // Make using the base type a bit easier via typedef. - typedef FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > BaseType; - - // Allow users access to the specific type of this delegate. - typedef FastDelegate SelfType; - - // Mimic the base class constructors. - FastDelegate() : BaseType() { } - - template < class X, class Y > - FastDelegate(Y * pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 )) - : BaseType(pthis, function_to_bind) { } - - template < class X, class Y > - FastDelegate(const Y *pthis, - R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ) const) - : BaseType(pthis, function_to_bind) - { } - - FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 )) - : BaseType(function_to_bind) { } - void operator = (const BaseType &x) { - *static_cast(this) = x; } -}; - - -#endif //FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX - -//////////////////////////////////////////////////////////////////////////////// -// Fast Delegates, part 5: -// -// MakeDelegate() helper function -// -// MakeDelegate(&x, &X::func) returns a fastdelegate of the type -// necessary for calling x.func() with the correct number of arguments. -// This makes it possible to eliminate many typedefs from user code. -// -//////////////////////////////////////////////////////////////////////////////// - -// Also declare overloads of a MakeDelegate() global function to -// reduce the need for typedefs. -// We need seperate overloads for const and non-const member functions. -// Also, because of the weird rule about the class of derived member function pointers, -// implicit downcasts may need to be applied later to the 'this' pointer. -// That's why two classes (X and Y) appear in the definitions. Y must be implicitly -// castable to X. - -// Workaround for VC6. VC6 needs void return types converted into DefaultVoid. -// GCC 3.2 and later won't compile this unless it's preceded by 'typename', -// but VC6 doesn't allow 'typename' in this context. -// So, I have to use a macro. - -#ifdef FASTDLGT_VC6 -#define FASTDLGT_RETTYPE detail::VoidToDefaultVoid::type -#else -#define FASTDLGT_RETTYPE RetType -#endif - -//N=0 -template -FastDelegate0 MakeDelegate(Y* x, RetType (X::*func)()) { - return FastDelegate0(x, func); -} - -template -FastDelegate0 MakeDelegate(Y* x, RetType (X::*func)() const) { - return FastDelegate0(x, func); -} - -//N=1 -template -FastDelegate1 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1)) { - return FastDelegate1(x, func); -} - -template -FastDelegate1 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1) const) { - return FastDelegate1(x, func); -} - -//N=2 -template -FastDelegate2 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2)) { - return FastDelegate2(x, func); -} - -template -FastDelegate2 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2) const) { - return FastDelegate2(x, func); -} - -//N=3 -template -FastDelegate3 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3)) { - return FastDelegate3(x, func); -} - -template -FastDelegate3 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3) const) { - return FastDelegate3(x, func); -} - -//N=4 -template -FastDelegate4 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { - return FastDelegate4(x, func); -} - -template -FastDelegate4 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { - return FastDelegate4(x, func); -} - -//N=5 -template -FastDelegate5 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { - return FastDelegate5(x, func); -} - -template -FastDelegate5 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { - return FastDelegate5(x, func); -} - -//N=6 -template -FastDelegate6 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { - return FastDelegate6(x, func); -} - -template -FastDelegate6 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { - return FastDelegate6(x, func); -} - -//N=7 -template -FastDelegate7 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) { - return FastDelegate7(x, func); -} - -template -FastDelegate7 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) { - return FastDelegate7(x, func); -} - -//N=8 -template -FastDelegate8 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) { - return FastDelegate8(x, func); -} - -template -FastDelegate8 MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) { - return FastDelegate8(x, func); -} - - - // clean up after ourselves... -#undef FASTDLGT_RETTYPE - -} // namespace fastdelegate - -#endif // !defined(FASTDELEGATE_H) - diff --git a/src/Makefile.am b/src/Makefile.am index c1746d3..c5ad333 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS = gmenu2x -gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ +gmenu2x_SOURCES = font.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp \ inputmanager.cpp linkapp.cpp link.cpp \ menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp \ @@ -12,9 +12,10 @@ gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \ utilities.cpp wallpaperdialog.cpp \ browsedialog.cpp buttonbox.cpp dialog.cpp \ - imageio.cpp powersaver.cpp + imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp \ + helppopup.cpp contextmenu.cpp background.cpp battery.cpp -noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \ +noinst_HEADERS = font.h cpu.h dirdialog.h \ filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \ inputdialog.h inputmanager.h linkapp.h link.h \ menu.h menusettingbool.h menusettingdir.h \ @@ -25,12 +26,13 @@ noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \ surfacecollection.h surface.h textdialog.h textmanualdialog.h \ touchscreen.h translator.h utilities.h wallpaperdialog.h \ browsedialog.h buttonbox.h dialog.h \ - imageio.h powersaver.h + imageio.h powersaver.h monitor.h mediamonitor.h clock.h \ + layer.h helppopup.h contextmenu.h background.h battery.h AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@ AM_CXXFLAGS = @CXXFLAGS@ @SDL_CFLAGS@ \ -fno-exceptions \ - -Wall -Wextra -Wundef -Wunused-macros + -Wall -Wextra -Wundef -Wunused-macros -std=c++11 gmenu2x_LDADD = @LIBS@ @SDL_LIBS@ diff --git a/src/asfont.cpp b/src/asfont.cpp deleted file mode 100644 index 7fb2b55..0000000 --- a/src/asfont.cpp +++ /dev/null @@ -1,200 +0,0 @@ -#include "asfont.h" -#include "imageio.h" -#include "surface.h" -#include "utilities.h" - -#include -#include -#include - -#define SFONTPLUS_CHARSET "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¿ÀÁÈÉÌÍÒÓÙÚÝÄËÏÖÜŸÂÊÎÔÛÅÃÕÑÆÇČĎĚĽĹŇÔŘŔŠŤŮŽàáèéìíòóùúýäëïöüÿâêîôûåãõñæçčďěľĺňôřŕšťžůðßÐÞþАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюяØøąćęłńśżźĄĆĘŁŃŚŻŹ" - -ASFont::ASFont(const std::string &fontImagePath) - : characters(SFONTPLUS_CHARSET) -{ - surface = loadPNG(fontImagePath); - if (!surface) { - return; - } - assert(surface->format->BytesPerPixel == 4); - - SDL_LockSurface(surface); - - // Determine character widths. - Uint32 pink = SDL_MapRGB(surface->format, 255, 0, 255); - Uint32 *topLine = static_cast(surface->pixels); - const unsigned width = surface->w; - unsigned x = 0; - unsigned c = 0; - while (c < characters.length()) { - while (x < width && topLine[x] != pink) x++; - unsigned startx = x; - x++; - while (x < width && topLine[x] == pink) x++; - - charpos.push_back(startx); - charpos.push_back(x); - if (c > 0 && utf8Code(characters[c - 1])) { - // UTF8 character - charpos.push_back(startx); - charpos.push_back(x); - c++; - } - c++; - } - - // Scan height of "0" glyph. - std::string::size_type pos = characters.find("0") * 2; - SDL_Rect srcrect = { - static_cast(charpos[pos]), - 1, - static_cast(charpos[pos + 2] - charpos[pos]), - static_cast(surface->h - 1) - }; - const unsigned alphaMask = surface->format->Amask; - unsigned y = srcrect.h; - bool nonTransparentFound = false; - while (!nonTransparentFound && y-- > 0) { - Uint32 *line = reinterpret_cast( - reinterpret_cast(surface->pixels) - + (srcrect.y + y) * surface->pitch - ); - for (unsigned x = 0; !nonTransparentFound && x < srcrect.w; x++) { - nonTransparentFound = (line[srcrect.x + x] & alphaMask) != 0; - } - } - lineHeight = y + 1; - - SDL_UnlockSurface(surface); -} - -ASFont::~ASFont() { - if (surface) { - SDL_FreeSurface(surface); - } -} - -bool ASFont::utf8Code(unsigned char c) { - return (c>=194 && c<=198) || c==208 || c==209; - //return c>=194; -} - -void ASFont::writeLine(Surface *s, const std::string &text, int x, int y) { - if (text.empty()) return; - - std::string::size_type pos; - SDL_Rect srcrect, dstrect; - - // these values won't change in the loop - srcrect.y = 1; - dstrect.y = y; - srcrect.h = dstrect.h = surface->h-1; - - for(unsigned i=0; iw; i++) { - //Utf8 characters - if (utf8Code(text[i]) && i+1raw, &dstrect); - - x += charpos[pos+2] - charpos[pos+1]; - } -} - -int ASFont::getTextWidth(const char *text) { - int maxWidth = 0, width = 0; - while (char ch = *text++) { - if (ch == '\n') { - // New line. - maxWidth = std::max(width, maxWidth); - width = 0; - } else { - std::string::size_type pos; - if (utf8Code(ch) && *text) { - // 2-byte character. - pos = characters.find(std::string(&text[-1], 2)); - text++; - } else { - // 1-byte character. - pos = characters.find(ch); - } - if (pos == std::string::npos) { - pos = 0; - } - width += charpos[pos * 2 + 2] - charpos[pos * 2 + 1]; - } - } - return std::max(width, maxWidth); -} - -int ASFont::getTextWidth(const std::string& text) { - return getTextWidth(text.c_str()); -} - -void ASFont::writeLine(Surface* surface, const std::string& text, int x, int y, HAlign halign) { - switch (halign) { - case HAlignLeft: - break; - case HAlignCenter: - x -= getTextWidth(text) / 2; - break; - case HAlignRight: - x -= getTextWidth(text); - break; - } - writeLine(surface, text, x, y); -} - -void ASFont::writeLine(Surface* surface, const std::string& text, int x, int y, HAlign halign, VAlign valign) { - switch (valign) { - case VAlignTop: - break; - case VAlignMiddle: - y -= getHeight() / 2; - break; - case VAlignBottom: - y -= getHeight(); - break; - } - writeLine(surface, text, x, y, halign); -} - -void ASFont::writeLine(Surface* surface, const std::vector &text, int x, int y, HAlign halign, VAlign valign) { - switch (valign) { - case VAlignTop: - break; - case VAlignMiddle: - y -= (getHeight() / 2) * text.size(); - break; - case VAlignBottom: - y -= getHeight() * text.size(); - break; - } - - for (std::vector::const_iterator it = text.begin(); it != text.end(); ++it) { - write(surface, *it, x, y, halign); - y += getHeight(); - } -} - -void ASFont::write(Surface* surface, const std::string& text, int x, int y, HAlign halign, VAlign valign) { - if (text.find("\n", 0) != std::string::npos) { - std::vector textArr; - split(textArr, text, "\n"); - writeLine(surface, textArr, x, y, halign, valign); - } else - writeLine(surface, text, x, y, halign, valign); -} diff --git a/src/asfont.h b/src/asfont.h deleted file mode 100644 index 80e08e7..0000000 --- a/src/asfont.h +++ /dev/null @@ -1,49 +0,0 @@ -// Based on SFont by Karl Bartel. -// Adapted to C++ by Massimiliano Torromeo. -// Refactored by Maarten ter Huurne and several others (see git log). -// License: GPL version 2 or later. - -#ifndef ASFONT_H -#define ASFONT_H - -#include -#include -#include - -class Surface; - -class ASFont { -public: - enum HAlign { HAlignLeft, HAlignRight, HAlignCenter }; - enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle }; - - ASFont(const std::string &font); - ~ASFont(); - - bool utf8Code(unsigned char c); - - int getTextWidth(const char *text); - int getTextWidth(const std::string& text); - - int getHeight() { - return surface->h - 1; - } - int getLineHeight() { - return lineHeight; - } - - void write(Surface* surface, const std::string& text, int x, int y, HAlign halign = HAlignLeft, VAlign valign = VAlignTop); - -private: - void writeLine(Surface *surface, const std::string &text, int x, int y); - void writeLine(Surface *surface, const std::string &text, int x, int y, HAlign halign); - void writeLine(Surface *surface, const std::string &text, int x, int y, HAlign halign, VAlign valign); - void writeLine(Surface *surface, const std::vector &text, int x, int y, HAlign halign, VAlign valign); - - SDL_Surface *surface; - std::vector charpos; - std::string characters; - int lineHeight; -}; - -#endif /* ASFONT_H */ diff --git a/src/background.cpp b/src/background.cpp new file mode 100644 index 0000000..05e41af --- /dev/null +++ b/src/background.cpp @@ -0,0 +1,43 @@ +// Various authors. +// License: GPL version 2 or later. + +#include "background.h" + +#include "gmenu2x.h" + + +Background::Background(GMenu2X &gmenu2x) + : gmenu2x(gmenu2x) + , battery(gmenu2x.sc) +{ +} + +void Background::paint(Surface &s) { + Font &font = *gmenu2x.font; + SurfaceCollection &sc = gmenu2x.sc; + + sc["bgmain"]->blit(&s, 0, 0); + + s.write(&font, clock.getTime(), + s.width() / 2, gmenu2x.bottomBarTextY, + Font::HAlignCenter, Font::VAlignMiddle); + + battery.getIcon().blit(&s, s.width() - 19, gmenu2x.bottomBarIconY); +} + +bool Background::handleButtonPress(InputManager::Button button) { + switch (button) { + case InputManager::CANCEL: + gmenu2x.showHelpPopup(); + return true; + case InputManager::SETTINGS: + gmenu2x.showSettings(); + return true; + default: + return false; + } +} + +bool Background::handleTouchscreen(Touchscreen &/*ts*/) { + return false; +} diff --git a/src/background.h b/src/background.h new file mode 100644 index 0000000..ced3470 --- /dev/null +++ b/src/background.h @@ -0,0 +1,32 @@ +// Various authors. +// License: GPL version 2 or later. + +#ifndef BACKGROUND_H +#define BACKGROUND_H + +#include "battery.h" +#include "clock.h" +#include "layer.h" + +class GMenu2X; + + +/** + * The backmost layer. + */ +class Background : public Layer { +public: + Background(GMenu2X &gmenu2x); + + // Layer implementation: + virtual void paint(Surface &s); + virtual bool handleButtonPress(InputManager::Button button); + virtual bool handleTouchscreen(Touchscreen &ts); + +private: + GMenu2X &gmenu2x; + Battery battery; + Clock clock; +}; + +#endif // BACKGROUND_H diff --git a/src/battery.cpp b/src/battery.cpp new file mode 100644 index 0000000..6ad9e20 --- /dev/null +++ b/src/battery.cpp @@ -0,0 +1,78 @@ +#include "battery.h" + +#include "surfacecollection.h" + +#include +#include +#include + + +/** + * Reads the current battery state and returns a number representing its level + * of charge. + * @return A number representing battery charge: 0 means fully discharged, + * 5 means fully charged, 6 represents running on external power. + */ +static unsigned short getBatteryLevel() +{ + FILE *batteryHandle = NULL, *usbHandle = NULL; + +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE) + usbHandle = fopen("/sys/class/power_supply/usb/online", "r"); +#endif + if (usbHandle) { + int usbval = 0; + fscanf(usbHandle, "%d", &usbval); + fclose(usbHandle); + if (usbval == 1) + return 6; + } + +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE) + batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r"); +#endif + if (batteryHandle) { + int battval = 0; + fscanf(batteryHandle, "%d", &battval); + fclose(batteryHandle); + + if (battval>90) return 5; + if (battval>70) return 4; + if (battval>50) return 3; + if (battval>30) return 2; + if (battval>10) return 1; + } + + return 0; +} + +Battery::Battery(SurfaceCollection &sc_) + : sc(sc_) +{ + lastUpdate = SDL_GetTicks(); + update(); +} + +const Surface &Battery::getIcon() +{ + // Check battery status every 60 seconds. + unsigned int now = SDL_GetTicks(); + if (now - lastUpdate >= 60000) { + lastUpdate = now; + update(); + } + + return *sc.skinRes(iconPath); +} + +void Battery::update() +{ + unsigned short battlevel = getBatteryLevel(); + if (battlevel > 5) { + iconPath = "imgs/battery/ac.png"; + } else { + std::stringstream ss; + ss << "imgs/battery/" << battlevel << ".png"; + ss >> iconPath; + } +} diff --git a/src/battery.h b/src/battery.h new file mode 100644 index 0000000..964e5fd --- /dev/null +++ b/src/battery.h @@ -0,0 +1,30 @@ +#ifndef __BATTERY_H__ +#define __BATTERY_H__ + +#include + +class Surface; +class SurfaceCollection; + + +/** + * Keeps track of the battery status. + */ +class Battery { +public: + Battery(SurfaceCollection &sc); + + /** + * Gets the icon that reflects the current battery status. + */ + const Surface &getIcon(); + +private: + void update(); + + SurfaceCollection ≻ + std::string iconPath; + unsigned int lastUpdate; +}; + +#endif /* __BATTERY_H__ */ diff --git a/src/browsedialog.cpp b/src/browsedialog.cpp index c8cbc60..d5e7d76 100644 --- a/src/browsedialog.cpp +++ b/src/browsedialog.cpp @@ -1,12 +1,11 @@ #include "browsedialog.h" -#include "FastDelegate.h" #include "filelister.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" -using namespace fastdelegate; using std::string; BrowseDialog::BrowseDialog( @@ -23,19 +22,19 @@ BrowseDialog::BrowseDialog( buttonBox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png")); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Up one folder"]); - btn->setAction(MakeDelegate(this, &BrowseDialog::directoryUp)); + btn->setAction(BIND(&BrowseDialog::directoryUp)); buttonBox.add(btn); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Enter folder"]); - btn->setAction(MakeDelegate(this, &BrowseDialog::directoryEnter)); + btn->setAction(BIND(&BrowseDialog::directoryEnter)); buttonBox.add(btn); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/start.png", gmenu2x->tr["Confirm"]); - btn->setAction(MakeDelegate(this, &BrowseDialog::confirm)); + btn->setAction(BIND(&BrowseDialog::confirm)); buttonBox.add(btn); btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/select.png", gmenu2x->tr["Exit"]); - btn->setAction(MakeDelegate(this, &BrowseDialog::quit)); + btn->setAction(BIND(&BrowseDialog::quit)); buttonBox.add(btn); iconGoUp = gmenu2x->sc.skinRes("imgs/go-up.png"); @@ -53,7 +52,8 @@ bool BrowseDialog::exec() return false; string path = fl->getPath(); - if (path.empty() || !fileExists(path) || path.compare(0, CARD_ROOT_LEN, CARD_ROOT) != 0) + if (path.empty() || !fileExists(path) || path.compare(0, + strlen(CARD_ROOT), CARD_ROOT) != 0) setPath(CARD_ROOT); fl->browse(); @@ -270,7 +270,7 @@ void BrowseDialog::paint() } icon->blit(gmenu2x->s, 5, offsetY); gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, - ASFont::HAlignLeft, ASFont::VAlignMiddle); + Font::HAlignLeft, Font::VAlignMiddle); if (ts.available() && ts.pressed() && ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) { @@ -282,7 +282,6 @@ void BrowseDialog::paint() } gmenu2x->s->clearClipRect(); - gmenu2x->drawScrollBar( - numRows,fl->size(), firstElement, clipRect.y, clipRect.h); + gmenu2x->drawScrollBar(numRows,fl->size(), firstElement); gmenu2x->s->flip(); } diff --git a/src/button.cpp b/src/button.cpp deleted file mode 100644 index a02640d..0000000 --- a/src/button.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "button.h" -#include "gmenu2x.h" - -using namespace std; -using namespace fastdelegate; - -Button::Button(Touchscreen &ts_, bool doubleClick_) - : ts(ts_) - , action(MakeDelegate(this, &Button::voidAction)) - , rect((SDL_Rect) { 0, 0, 0, 0 }) - , doubleClick(doubleClick_) - , lastTick(0) -{ -} - -void Button::paint() { - if (ts.inRect(rect)) - if (!paintHover()) return; -} - -bool Button::paintHover() { - return false; -} - -bool Button::isPressed() { - return ts.pressed() && ts.inRect(rect); -} - -bool Button::isReleased() { - return ts.released() && ts.inRect(rect); -} - -bool Button::handleTS() { - if (isReleased()) { - if (doubleClick) { - int tickNow = SDL_GetTicks(); - if (tickNow - lastTick < 400) - exec(); - lastTick = tickNow; - } else { - exec(); - } - return true; - } - return false; -} - -void Button::exec() { - ts.setHandled(); - action(); -} - -SDL_Rect Button::getRect() { - return rect; -} - -void Button::setSize(int w, int h) { - rect.w = w; - rect.h = h; -} - -void Button::setPosition(int x, int y) { - rect.x = x; - rect.y = y; -} - -void Button::setAction(ButtonAction action) { - this->action = action; -} diff --git a/src/button.h b/src/button.h deleted file mode 100644 index f7baacc..0000000 --- a/src/button.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Massimiliano Torromeo * - * massimiliano.torromeo@gmail.com * - * * - * 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, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef BUTTON_H -#define BUTTON_H - -#include "FastDelegate.h" - -#include - -typedef fastdelegate::FastDelegate0<> ButtonAction; -class Touchscreen; - -class Button { -protected: - Touchscreen &ts; - ButtonAction action; - SDL_Rect rect; - bool doubleClick; - int lastTick; - -public: - Button(Touchscreen &ts, bool doubleClick = false); - virtual ~Button() {}; - - SDL_Rect getRect(); - void setSize(int w, int h); - virtual void setPosition(int x, int y); - - virtual void paint(); - virtual bool paintHover(); - - bool isPressed(); - bool isReleased(); - bool handleTS(); - - void exec(); - void voidAction() {}; - void setAction(ButtonAction action); -}; - -#endif // BUTTON_H diff --git a/src/buttonbox.cpp b/src/buttonbox.cpp index af2791f..9ace08a 100644 --- a/src/buttonbox.cpp +++ b/src/buttonbox.cpp @@ -1,9 +1,8 @@ - -#include "button.h" -#include "gmenu2x.h" - #include "buttonbox.h" +#include "gmenu2x.h" +#include "iconbutton.h" + ButtonBox::ButtonBox(GMenu2X *gmenu2x) : gmenu2x(gmenu2x) { } @@ -13,7 +12,7 @@ ButtonBox::~ButtonBox() clear(); } -void ButtonBox::add(Button *button) +void ButtonBox::add(IconButton *button) { buttons.push_back(button); } @@ -25,12 +24,12 @@ void ButtonBox::clear() void ButtonBox::paint(unsigned int posX) { - for (ButtonList::const_iterator it = buttons.begin(); it != buttons.end(); ++it) - posX = gmenu2x->drawButton(*it, posX); + for (auto button : buttons) + posX = gmenu2x->drawButton(button, posX); } void ButtonBox::handleTS() { - for (ButtonList::iterator it = buttons.begin(); it != buttons.end(); ++it) - (*it)->handleTS(); + for (auto button : buttons) + button->handleTS(); } diff --git a/src/buttonbox.h b/src/buttonbox.h index 52a8e4b..e4b639e 100644 --- a/src/buttonbox.h +++ b/src/buttonbox.h @@ -4,7 +4,7 @@ #include class GMenu2X; -class Button; +class IconButton; class ButtonBox { @@ -12,15 +12,14 @@ public: ButtonBox(GMenu2X *gmenu2x); ~ButtonBox(); - void add(Button *button); + void add(IconButton *button); void clear(); void paint(unsigned int posX); void handleTS(); -private: - typedef std::vector ButtonList; - ButtonList buttons; +private: + std::vector buttons; GMenu2X *gmenu2x; }; diff --git a/src/clock.cpp b/src/clock.cpp new file mode 100644 index 0000000..92ad25d --- /dev/null +++ b/src/clock.cpp @@ -0,0 +1,143 @@ +#include "clock.h" + +#include "debug.h" +#include "inputmanager.h" +#include "utilities.h" + +#include +#include +#include + + +class Clock::Timer { +public: + Timer(); + ~Timer(); + void start(); + void getTime(unsigned int &hours, unsigned int &minutes); + unsigned int callback(); + +private: + unsigned int update(); + + SDL_TimerID timerID; + struct Timestamp { unsigned char hours, minutes; }; + std::atomic timestamp; +}; + +static std::weak_ptr globalTimer; + +/** + * Gets the global timer instance, or create it if it doesn't exist already. + * This function is not thread safe: only one thread at a time may call it. + */ +static std::shared_ptr globalTimerInstance() +{ + std::shared_ptr timer = globalTimer.lock(); + if (timer) { + return timer; + } else { + // Note: Separate start method is necessary because globalTimer must + // be written before callbacks can occur. + timer.reset(new Clock::Timer()); + globalTimer = timer; + timer->start(); + return timer; + } +} + +extern "C" Uint32 callbackFunc(Uint32 /*timeout*/, void */*d*/) +{ + std::shared_ptr timer = globalTimer.lock(); + return timer ? timer->callback() : 0; +} + +Clock::Timer::Timer() + : timerID(NULL) +{ + tzset(); +} + +Clock::Timer::~Timer() +{ + if (timerID) { + SDL_RemoveTimer(timerID); + } +} + +void Clock::Timer::start() +{ + if (timerID) { + ERROR("SDL timer was already started\n"); + return; + } + unsigned int ms = update(); + timerID = SDL_AddTimer(ms, callbackFunc, this); + if (!timerID) { + ERROR("Could not initialize SDL timer: %s\n", SDL_GetError()); + } +} + +void Clock::Timer::getTime(unsigned int &hours, unsigned int &minutes) +{ + struct Timestamp ts = timestamp.load(); + hours = ts.hours; + minutes = ts.minutes; +} + +unsigned int Clock::Timer::update() +{ + struct timeval tv; + struct tm result; + gettimeofday(&tv, NULL); + localtime_r(&tv.tv_sec, &result); + timestamp.store({ + static_cast(result.tm_hour), + static_cast(result.tm_min) + }); + DEBUG("Time updated: %02i:%02i:%02i\n", + result.tm_hour, result.tm_min, result.tm_sec); + + // Compute number of milliseconds to next minute boundary. + // We don't need high precision, but it is important that any deviation is + // past the minute mark, so the fetched hour and minute number belong to + // the freshly started minute. + // TODO: Does the SDL timer in fact guarantee we're never called early? + // "ms = t->interval - SDL_TIMESLICE;" worries me. + // Clamping it at 1 sec both avoids overloading the system in case our + // computation goes haywire and avoids passing 0 to SDL, which would stop + // the recurring timer. + return std::max(1, (60 - result.tm_sec)) * 1000; +} + +unsigned int Clock::Timer::callback() +{ + unsigned int ms = update(); + inject_user_event(); + + // TODO: SDL timer forgets adjusted interval if a timer was inserted or + // removed during the callback. So we should either fix that bug + // in SDL or ensure we don't insert/remove timers at runtime. + // The blanking timer is inserted/removed quite a lot at time moment, + // but it could be reprogrammed to adjust the interval instead. + return ms; +} + +std::string Clock::getTime(bool is24) +{ + unsigned int hours, minutes; + timer->getTime(hours, minutes); + + bool pm = hours >= 12; + if (!is24 && pm) + hours -= 12; + + char buf[9]; + sprintf(buf, "%02i:%02i%s", hours, minutes, is24 ? "" : (pm ? "pm" : "am")); + return std::string(buf); +} + +Clock::Clock() + : timer(globalTimerInstance()) +{ +} diff --git a/src/clock.h b/src/clock.h new file mode 100644 index 0000000..5ddd7ef --- /dev/null +++ b/src/clock.h @@ -0,0 +1,32 @@ +#ifndef __CLOCK_H__ +#define __CLOCK_H__ + +#include +#include + + +/** + * A keeper of wall clock time with minute accuracy. + * Sends a user event on every minute boundary, to force a repaint of the + * clock display. + */ +class Clock { +public: + /** + * Used by implementation; please ignore. + */ + class Timer; + + Clock(); + + /** + * Gets a string representation of the current time. + * Uses 24-hour format if is24 is true, otherwise AM/PM. + */ + std::string getTime(bool is24 = true); + +private: + std::shared_ptr timer; +}; + +#endif /* __CLOCK_H__ */ diff --git a/src/contextmenu.cpp b/src/contextmenu.cpp new file mode 100644 index 0000000..52735f0 --- /dev/null +++ b/src/contextmenu.cpp @@ -0,0 +1,177 @@ +// Various authors. +// License: GPL version 2 or later. + +#include "contextmenu.h" + +#include "delegate.h" +#include "gmenu2x.h" +#include "linkapp.h" +#include "menu.h" +#include "utilities.h" + +#include + + +struct ContextMenu::MenuOption { + MenuOption(std::string text, function_t action) + : text(text), action(action) {} + std::string text; + function_t action; +}; + +ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu) + : gmenu2x(gmenu2x) + , menu(menu) + , selected(0) +{ + Translator &tr = gmenu2x.tr; + Font *font = gmenu2x.font; + LinkApp* app = menu.selLinkApp(); + + // Init menu options: + + options.push_back(std::make_shared( + tr.translate("Add link in $1", menu.selSection().c_str(), NULL), + std::bind(&GMenu2X::addLink, &gmenu2x))); + + if (app && !app->getManual().empty()) { + options.push_back(std::make_shared( + tr.translate("Show manual of $1", app->getTitle().c_str(), NULL), + std::bind(&GMenu2X::showManual, &gmenu2x))); + } + + if (app && app->isEditable()) { + + /* FIXME(percuei): This permits to mask the "Edit link" entry + * on the contextual menu in case CPUFREQ support is + * not compiled in and the link corresponds to an OPK. + * This is not a good idea as it'll break things if + * a new config option is added to the contextual menu. + */ + if (!app->isOpk() +#if defined(ENABLE_CPUFREQ) + || true +#endif + || !app->getSelectorDir().empty() + ) { + options.push_back(std::make_shared( + tr.translate("Edit $1", app->getTitle().c_str(), NULL), + std::bind(&GMenu2X::editLink, &gmenu2x))); + } + if (!app->isOpk()) { + options.push_back(std::make_shared( + tr.translate("Delete $1 link", app->getTitle().c_str(), NULL), + std::bind(&GMenu2X::deleteLink, &gmenu2x))); + } + } + + options.push_back(std::make_shared( + tr["Add section"], + std::bind(&GMenu2X::addSection, &gmenu2x))); + options.push_back(std::make_shared( + tr["Rename section"], + std::bind(&GMenu2X::renameSection, &gmenu2x))); + options.push_back(std::make_shared( + tr["Delete section"], + std::bind(&GMenu2X::deleteSection, &gmenu2x))); + options.push_back(std::make_shared( + tr["Scan for applications and games"], + std::bind(&GMenu2X::scanner, &gmenu2x))); + + // Compute bounding box. + int w = 0; + for (auto option : options) { + w = std::max(w, font->getTextWidth(option->text)); + } + w += 23; + const int h = (font->getHeight() + 2) * options.size() + 8; + box = { + static_cast((gmenu2x.resX - w) / 2), + static_cast((gmenu2x.resY - h) / 2), + static_cast(w), + static_cast(h) + }; + + // Init background fade animation. + tickStart = SDL_GetTicks(); + fadeAlpha = 0; +} + +bool ContextMenu::runAnimations() +{ + if (fadeAlpha < 200) { + const long tickNow = SDL_GetTicks(); + fadeAlpha = intTransition(0, 200, tickStart, 500, tickNow); + } + return fadeAlpha < 200; +} + +void ContextMenu::paint(Surface &s) +{ + Font *font = gmenu2x.font; + + // Darken background. + s.box(0, 0, gmenu2x.resX, gmenu2x.resY, 0, 0, 0, fadeAlpha); + + // Draw popup box. + s.box(box, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BG]); + s.rectangle(box.x + 2, box.y + 2, box.w - 4, box.h - 4, + gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]); + + // Draw selection background. + const int h = font->getHeight(); + SDL_Rect selbox = { + static_cast(box.x + 4), + static_cast(box.y + 4 + (h + 2) * selected), + static_cast(box.w - 8), + static_cast(h + 2) + }; + s.box(selbox, gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_SELECTION]); + + // List options. + for (uint i = 0; i < options.size(); i++) { + s.write(font, options[i]->text, box.x + 12, box.y + 5 + (h + 2) * i, + Font::HAlignLeft, Font::VAlignTop); + } +} + +bool ContextMenu::handleButtonPress(InputManager::Button button) { + switch (button) { + case InputManager::MENU: + dismiss(); + break; + case InputManager::UP: + selected--; + if (selected < 0) selected = options.size() - 1; + break; + case InputManager::DOWN: + selected++; + if (selected >= static_cast(options.size())) selected = 0; + break; + case InputManager::ACCEPT: + options[selected]->action(); + dismiss(); + break; + default: + break; + } + return true; +} + +bool ContextMenu::handleTouchscreen(Touchscreen &ts) { + if (ts.inRect(box)) { + int i = std::max(0, std::min(static_cast(options.size()) - 1, + (ts.getY() - (box.y + 4)) / (gmenu2x.font->getHeight() + 2))); + if (ts.released()) { + options[i]->action(); + dismiss(); + } else if (ts.pressed()) { + selected = i; + } + } else { + if (ts.released()) { + dismiss(); + } + } + return true; +} diff --git a/src/contextmenu.h b/src/contextmenu.h new file mode 100644 index 0000000..7b6a78d --- /dev/null +++ b/src/contextmenu.h @@ -0,0 +1,42 @@ +// Various authors. +// License: GPL version 2 or later. + +#ifndef __CONTEXTMENU_H__ +#define __CONTEXTMENU_H__ + +#include "layer.h" + +#include +#include + +class GMenu2X; +class Menu; + + +/** + * A popup dialog containing action on the current section or link. + */ +class ContextMenu : public Layer { +public: + ContextMenu(GMenu2X &gmenu2x, Menu &menu); + + // Layer implementation: + virtual bool runAnimations(); + virtual void paint(Surface &s); + virtual bool handleButtonPress(InputManager::Button button); + virtual bool handleTouchscreen(Touchscreen &ts); + +private: + struct MenuOption; + + GMenu2X &gmenu2x; + Menu &menu; + std::vector> options; + SDL_Rect box; + + int fadeAlpha; + int selected; + long tickStart; +}; + +#endif // __CONTEXTMENU_H__ diff --git a/src/debug.h b/src/debug.h index 12e101b..2086788 100644 --- a/src/debug.h +++ b/src/debug.h @@ -20,7 +20,7 @@ #define COLOR_DEBUG "\e[0;34m" #endif #ifndef COLOR_WARNING -#define COLOR_WARNING "\e[01;33m" +#define COLOR_WARNING "\e[01;35m" #endif #ifndef COLOR_ERROR #define COLOR_ERROR "\e[01;31m" diff --git a/src/delegate.h b/src/delegate.h new file mode 100644 index 0000000..e2aa065 --- /dev/null +++ b/src/delegate.h @@ -0,0 +1,10 @@ +#ifndef __DELEGATE_H__ +#define __DELEGATE_H__ + +#include + +typedef std::function function_t; + +#define BIND(function) std::bind(function, this) + +#endif /* __DELEGATE_H__ */ diff --git a/src/dialog.cpp b/src/dialog.cpp index 5749532..3eed2df 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -2,7 +2,7 @@ #include "dialog.h" #include "gmenu2x.h" -#include "asfont.h" +#include "font.h" Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x) { @@ -31,14 +31,14 @@ void Dialog::writeTitle(const std::string &title, Surface *s) { if (s==NULL) s = gmenu2x->s; - s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"]/4, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"] / 4, Font::HAlignLeft, Font::VAlignMiddle); } void Dialog::writeSubTitle(const std::string &subtitle, Surface *s) { if (s==NULL) s = gmenu2x->s; - s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"]/4*3, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"] / 4 * 3, Font::HAlignLeft, Font::VAlignMiddle); } diff --git a/src/filedialog.h b/src/filedialog.h index d8da99b..51ae092 100644 --- a/src/filedialog.h +++ b/src/filedialog.h @@ -27,7 +27,7 @@ class FileDialog : public BrowseDialog { public: FileDialog( GMenu2X *gmenu2x, Touchscreen &ts, const std::string &text, - const std::string &filter="", const std::string &file="", + const std::string &filter="*", const std::string &file="", const std::string &title = "File Dialog"); virtual ~FileDialog(); bool exec(); diff --git a/src/filelister.cpp b/src/filelister.cpp index b33186c..d417b6e 100644 --- a/src/filelister.cpp +++ b/src/filelister.cpp @@ -80,17 +80,12 @@ void FileLister::browse(bool clean) return; } - vector vfilter; - split(vfilter, getFilter(), ","); - - string filepath, file, file_lowercase; + string filepath, file; struct stat st; struct dirent *dptr; while ((dptr = readdir(dirp))) { file = dptr->d_name; - file_lowercase = file; - std::transform(file_lowercase.begin(), file_lowercase.end(), file_lowercase.begin(), ::tolower); if (file[0] == '.' && file != "..") continue; @@ -119,9 +114,35 @@ void FileLister::browse(bool clean) if (std::find(files.begin(), files.end(), file) != files.end()) continue; + if (filter.compare("*") == 0) { + files.push_back(file); + continue; + } + + vector vfilter; + split(vfilter, filter, ","); for (vector::iterator it = vfilter.begin(); it != vfilter.end(); ++it) { - if (it->length() <= file.length()) { - if (file_lowercase.compare(file.length() - it->length(), it->length(), *it) == 0) { + if (file.find('.') == string::npos) { + if (!it->empty()) + continue; + + files.push_back(file); + break; + } + + if (it->length() < file.length()) { + if (file[file.length() - it->length() - 1] != '.') + continue; + + string file_lowercase = + file.substr(file.length() - it->length()); + + /* XXX: This won't accept UTF-8 codes. + * Thanksfully file extensions shouldn't contain any. */ + transform(file_lowercase.begin(), file_lowercase.end(), + file_lowercase.begin(), ::tolower); + + if (file_lowercase.compare(0, it->length(), *it) == 0) { files.push_back(file); break; } diff --git a/src/font.cpp b/src/font.cpp new file mode 100644 index 0000000..a508d1e --- /dev/null +++ b/src/font.cpp @@ -0,0 +1,124 @@ +#include "font.h" + +#include "debug.h" +#include "surface.h" +#include "utilities.h" + +#include +#include +#include + +/* TODO: Let the theme choose the font and font size */ +#define TTF_FONT "/usr/share/fonts/truetype/dejavu/DejaVuSansCondensed.ttf" +#define TTF_FONT_SIZE 12 + +using namespace std; + +Font *Font::defaultFont() +{ + if (!TTF_WasInit() && TTF_Init() < 0) { + ERROR("Unable to init SDL_ttf library\n"); + return nullptr; + } + + TTF_Font *font = TTF_OpenFont(TTF_FONT, TTF_FONT_SIZE); + if (!font) { + ERROR("Unable to open font\n"); + return nullptr; + } + + return new Font(font); +} + +Font::Font(TTF_Font *font) + : font(font) +{ + fontheight = TTF_FontHeight(font); +} + +Font::~Font() +{ + TTF_CloseFont(font); + TTF_Quit(); +} + +int Font::getTextWidth(const char *text) +{ + int w, h; + TTF_SizeUTF8(font, text, &w, &h); + return w; +} + +void Font::write(Surface *surface, const string &text, + int x, int y, HAlign halign, VAlign valign) +{ + if (text.find("\n", 0) == string::npos) { + writeLine(surface, text.c_str(), x, y, halign, valign); + return; + } + + vector v; + split(v, text, "\n"); + + for (vector::const_iterator it = v.begin(); it != v.end(); it++) { + writeLine(surface, it->c_str(), x, y, halign, valign); + y += fontheight; + } +} + +void Font::writeLine(Surface *surface, const char *text, + int x, int y, HAlign halign, VAlign valign) +{ + switch (halign) { + case HAlignLeft: + break; + case HAlignCenter: + x -= getTextWidth(text) / 2; + break; + case HAlignRight: + x -= getTextWidth(text); + break; + } + + switch (valign) { + case VAlignTop: + break; + case VAlignMiddle: + y -= fontheight / 2; + break; + case VAlignBottom: + y -= fontheight; + break; + } + + SDL_Color color = { 0, 0, 0, 0 }; + SDL_Surface *s = TTF_RenderUTF8_Blended(font, text, color); + + SDL_Rect rect = { (Sint16) x, (Sint16) (y - 1), 0, 0 }; + SDL_BlitSurface(s, NULL, surface->raw, &rect); + + /* Note: rect.x / rect.y are reset everytime because SDL_BlitSurface + * will modify them if negative */ + rect.x = x; + rect.y = y + 1; + SDL_BlitSurface(s, NULL, surface->raw, &rect); + + rect.x = x - 1; + rect.y = y; + SDL_BlitSurface(s, NULL, surface->raw, &rect); + + rect.x = x + 1; + rect.y = y; + SDL_BlitSurface(s, NULL, surface->raw, &rect); + SDL_FreeSurface(s); + + rect.x = x; + rect.y = y; + color.r = 0xff; + color.g = 0xff; + color.b = 0xff; + + s = TTF_RenderUTF8_Blended(font, text, color); + SDL_BlitSurface(s, NULL, surface->raw, &rect); + SDL_FreeSurface(s); +} diff --git a/src/font.h b/src/font.h new file mode 100644 index 0000000..4f76962 --- /dev/null +++ b/src/font.h @@ -0,0 +1,50 @@ +// Original font class was replaced by an SDL_ttf based one by Paul Cercueil. +// License: GPL version 2 or later. + +#ifndef FONT_H +#define FONT_H + +#include +#include + +class Surface; + +class Font { +public: + enum HAlign { HAlignLeft, HAlignRight, HAlignCenter }; + enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle }; + + /** + * Returns a newly created Font object for the default font, + * or nullptr if there was a problem creating it. + */ + static Font *defaultFont(); + ~Font(); + + int getTextWidth(const char *text); + + int getTextWidth(const std::string& text) + { + return getTextWidth(text.c_str()); + } + + int getHeight() + { + return fontheight; + } + + void write(Surface *surface, + const std::string &text, int x, int y, + HAlign halign = HAlignLeft, VAlign valign = VAlignTop); + +private: + Font(TTF_Font *font); + + void writeLine(Surface *surface, const char *text, + int x, int y, HAlign halign, VAlign valign); + + TTF_Font *font; + unsigned int fontheight; +}; + +#endif /* FONT_H */ diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 4047f14..c389a20 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -20,15 +20,18 @@ #include "gp2x.h" -#include "asfont.h" +#include "background.h" #include "cpu.h" #include "debug.h" #include "filedialog.h" #include "filelister.h" +#include "font.h" #include "gmenu2x.h" +#include "helppopup.h" #include "iconbutton.h" #include "inputdialog.h" #include "linkapp.h" +#include "mediamonitor.h" #include "menu.h" #include "menusettingbool.h" #include "menusettingdir.h" @@ -61,13 +64,6 @@ #include //for battery -#ifdef PLATFORM_DINGUX -# define UNLOCK_VT -# include -# include -# include -#endif - #ifdef PLATFORM_PANDORA //#include //#include @@ -85,14 +81,7 @@ #include -typedef fastdelegate::FastDelegate0<> MenuAction; -struct MenuOption { - std::string text; - MenuAction action; -}; - using namespace std; -using namespace fastdelegate; #ifndef DEFAULT_WALLPAPER_PATH #define DEFAULT_WALLPAPER_PATH \ @@ -101,12 +90,11 @@ using namespace fastdelegate; #ifdef _CARD_ROOT const char *CARD_ROOT = _CARD_ROOT; -#elif defined(PLATFORM_DINGUX) -const char *CARD_ROOT = "/media/"; +#elif defined(PLATFORM_A320) || defined(PLATFORM_GCW0) +const char *CARD_ROOT = "/media"; #else -const char *CARD_ROOT = "/card/"; //Note: Add a trailing /! +const char *CARD_ROOT = "/card"; #endif -const int CARD_ROOT_LEN = strlen(CARD_ROOT)-1; static GMenu2X *app; static string gmenu2x_home; @@ -141,63 +129,25 @@ static void quit_all(int err) { exit(err); } -#ifdef UNLOCK_VT - -#define FB_TTY "/dev/tty%i" -static void unlockVT() -{ - int i; - int fd; - char tty[10]; - - for (i=0; i < 10; i++) { - int mode; - - sprintf(tty, FB_TTY, i); - fd = open(tty, O_RDWR); - if (fd < 0) - continue; - - if (ioctl(fd, KDGETMODE, &mode) < 0) { - WARNING("Unable to get mode for tty %i.\n", i); - close(fd); - return; - } - - if (mode != KD_TEXT) - break; - - close(fd); - } - - if (i==10) { - DEBUG("No graphic tty found.\n"); - return; - } - - DEBUG("Graphic tty found on %s.\n", tty); - - if (ioctl(fd, KDSETMODE, KD_TEXT) < 0) - WARNING("unable to set keyboard mode.\n"); - - if (ioctl(fd, VT_UNLOCKSWITCH, 1) < 0) - WARNING("unable to unlock terminal.\n"); - - close(fd); -} -#endif - const string GMenu2X::getHome(void) { return gmenu2x_home; } -int main(int /*argc*/, char * /*argv*/[]) { - INFO("----\nGMenu2X starting: If you read this message in the logs, check http://gmenu2x.sourceforge.net/page/Troubleshooting for a solution\n----\n"); +static void set_handler(int signal, void (*handler)(int)) +{ + struct sigaction sig; + sigaction(signal, NULL, &sig); + sig.sa_handler = handler; + sigaction(signal, &sig, NULL); +} - signal(SIGINT, &quit_all); - signal(SIGSEGV,&quit_all); - signal(SIGTERM,&quit_all); +int main(int /*argc*/, char * /*argv*/[]) { + INFO("---- GMenu2X starting ----\n"); + + set_handler(SIGINT, &quit_all); + set_handler(SIGSEGV, &quit_all); + set_handler(SIGTERM, &quit_all); char *home = getenv("HOME"); if (home == NULL) { @@ -220,6 +170,7 @@ int main(int /*argc*/, char * /*argv*/[]) { return 0; } +#ifdef ENABLE_CPUFREQ void GMenu2X::initCPULimits() { // Note: These values are for the Dingoo. // The NanoNote does not have cpufreq enabled in its kernel and @@ -240,13 +191,17 @@ void GMenu2X::initCPULimits() { cpuFreqMenuDefault = (cpuFreqMenuDefault / cpuFreqMultiple) * cpuFreqMultiple; cpuFreqAppDefault = (cpuFreqAppDefault / cpuFreqMultiple) * cpuFreqMultiple; } +#endif GMenu2X::GMenu2X() + : appToLaunch(nullptr) { usbnet = samba = inet = web = false; useSelectionPng = false; +#ifdef ENABLE_CPUFREQ initCPULimits(); +#endif //load config data readConfig(); @@ -255,10 +210,6 @@ GMenu2X::GMenu2X() bottomBarIconY = resY-18; bottomBarTextY = resY-10; -#ifdef UNLOCK_VT - unlockVT(); -#endif - /* Do not clear the screen on exit. * This may require an SDL patch available at * https://github.com/mthuurne/opendingux-buildroot/blob @@ -267,7 +218,7 @@ GMenu2X::GMenu2X() setenv("SDL_FBCON_DONT_CLEAR", "1", 0); //Screen - if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK)<0 ) { + if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { ERROR("Could not initialize SDL: %s\n", SDL_GetError()); quit(); } @@ -276,10 +227,14 @@ GMenu2X::GMenu2X() bg = NULL; font = NULL; - menu = NULL; - setSkin(confStr["skin"], false); + setSkin(confStr["skin"], !fileExists(confStr["wallpaper"])); + layers.insert(layers.begin(), make_shared(*this)); initMenu(); +#ifdef ENABLE_INOTIFY + monitor = new MediaMonitor(CARD_ROOT); +#endif + if (!fileExists(confStr["wallpaper"])) { DEBUG("No wallpaper defined; we will take the default one.\n"); confStr["wallpaper"] = DEFAULT_WALLPAPER_PATH; @@ -297,18 +252,15 @@ GMenu2X::GMenu2X() DEBUG("Loading system input.conf file: %s.\n", input_file.c_str()); } - input.init(input_file); + input.init(input_file, menu.get()); if (confInt["backlightTimeout"] > 0) PowerSaver::getInstance()->setScreenTimeout( confInt["backlightTimeout"] ); setInputSpeed(); +#ifdef ENABLE_CPUFREQ setClock(confInt["menuClock"]); - //recover last session - readTmp(); - if (lastSelectorElement>-1 && menu->selLinkApp()!=NULL && (!menu->selLinkApp()->getSelectorDir().empty() || !lastSelectorDir.empty())) - menu->selLinkApp()->selector(lastSelectorElement,lastSelectorDir); - +#endif } GMenu2X::~GMenu2X() { @@ -316,8 +268,10 @@ GMenu2X::~GMenu2X() { delete PowerSaver::getInstance(); quit(); - delete menu; delete font; +#ifdef ENABLE_INOTIFY + delete monitor; +#endif } void GMenu2X::quit() { @@ -348,20 +302,24 @@ void GMenu2X::initBG() { Surface *sd = Surface::loadImage("imgs/sd.png", confStr["skin"]); if (sd) sd->blit(bgmain, 3, bottomBarIconY); -#ifdef PLATFORM_DINGUX +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) string df = getDiskFree("/boot"); #else string df = getDiskFree(CARD_ROOT); #endif - bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle); + bgmain->write(font, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle); delete sd; - Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]); cpuX = font->getTextWidth(df)+32; +#ifdef ENABLE_CPUFREQ + Surface *cpu = Surface::loadImage("imgs/cpu.png", confStr["skin"]); if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY); cpuX += 19; manualX = cpuX+font->getTextWidth("300MHz")+5; delete cpu; +#else + manualX = cpuX; +#endif int serviceX = resX-38; if (usbnet) { @@ -391,47 +349,41 @@ void GMenu2X::initBG() { } void GMenu2X::initFont() { - if (font != NULL) { - delete font; - font = NULL; - } - - string fontFile = sc.getSkinFilePath("imgs/font.png"); - if (fontFile.empty()) { - ERROR("Font png not found!\n"); + delete font; + font = Font::defaultFont(); + if (!font) { + ERROR("Cannot function without font; aborting...\n"); quit(); exit(-1); } - font = new ASFont(fontFile); } void GMenu2X::initMenu() { //Menu structure handler - menu = new Menu(this, ts); + menu.reset(new Menu(this, ts)); for (uint i=0; igetSections().size(); i++) { //Add virtual links in the applications section if (menu->getSections()[i]=="applications") { - menu->addActionLink(i,"Explorer",MakeDelegate(this,&GMenu2X::explorer),tr["Launch an application"],"skin:icons/explorer.png"); + menu->addActionLink(i,"Explorer", BIND(&GMenu2X::explorer),tr["Launch an application"],"skin:icons/explorer.png"); } //Add virtual links in the setting section else if (menu->getSections()[i]=="settings") { - menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png"); - menu->addActionLink(i,tr["Skin"],MakeDelegate(this,&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png"); - menu->addActionLink(i,tr["Wallpaper"],MakeDelegate(this,&GMenu2X::changeWallpaper),tr["Change GMenu2X wallpaper"],"skin:icons/wallpaper.png"); + menu->addActionLink(i,"GMenu2X",BIND(&GMenu2X::showSettings),tr["Configure GMenu2X's options"],"skin:icons/configure.png"); + menu->addActionLink(i,tr["Skin"],BIND(&GMenu2X::skinMenu),tr["Configure skin"],"skin:icons/skin.png"); + menu->addActionLink(i,tr["Wallpaper"],BIND(&GMenu2X::changeWallpaper),tr["Change GMenu2X wallpaper"],"skin:icons/wallpaper.png"); if (fileExists(getHome()+"/log.txt")) - menu->addActionLink(i,tr["Log Viewer"],MakeDelegate(this,&GMenu2X::viewLog),tr["Displays last launched program's output"],"skin:icons/ebook.png"); - menu->addActionLink(i,tr["About"],MakeDelegate(this,&GMenu2X::about),tr["Info about GMenu2X"],"skin:icons/about.png"); + menu->addActionLink(i,tr["Log Viewer"],BIND(&GMenu2X::viewLog),tr["Displays last launched program's output"],"skin:icons/ebook.png"); + menu->addActionLink(i,tr["About"],BIND(&GMenu2X::about),tr["Info about GMenu2X"],"skin:icons/about.png"); } } + menu->skinUpdated(); + menu->setSectionIndex(confInt["section"]); menu->setLinkIndex(confInt["link"]); - menu->loadIcons(); - - //DEBUG - //menu->addLink( CARD_ROOT, "sample.pxml", "applications" ); + layers.push_back(menu); } void GMenu2X::about() { @@ -515,10 +467,12 @@ void GMenu2X::readConfig(string conffile) { confStr["skin"] = "Default"; evalIntConf( &confInt["outputLogs"], 0, 0,1 ); +#ifdef ENABLE_CPUFREQ evalIntConf( &confInt["maxClock"], cpuFreqSafeMax, cpuFreqMin, cpuFreqMax ); evalIntConf( &confInt["menuClock"], cpuFreqMenuDefault, cpuFreqMin, cpuFreqSafeMax ); +#endif evalIntConf( &confInt["backlightTimeout"], 15, 0,120 ); evalIntConf( &confInt["videoBpp"], 32, 16, 32 ); @@ -527,6 +481,15 @@ void GMenu2X::readConfig(string conffile) { resY = constrain( confInt["resolutionY"], 240,1200 ); } +void GMenu2X::saveSelection() { + if (confInt["saveSelection"] && ( + confInt["section"] != menu->selSectionIndex() + || confInt["link"] != menu->selLinkIndex() + )) { + writeConfig(); + } +} + void GMenu2X::writeConfig() { string conffile = getHome() + "/gmenu2x.conf"; ofstream inf(conffile.c_str()); @@ -615,7 +578,7 @@ void GMenu2X::writeTmp(int selelem, const string &selectordir) { inf << "link=" << menu->selLinkIndex() << endl; if (selelem>-1) inf << "selectorelem=" << selelem << endl; - if (selectordir!="") + if (!selectordir.empty()) inf << "selectordir=" << selectordir << endl; inf.close(); sync(); @@ -623,215 +586,77 @@ void GMenu2X::writeTmp(int selelem, const string &selectordir) { } void GMenu2X::main() { - uint linksPerPage = linkColumns*linkRows; - int linkSpacingX = (resX-10 - linkColumns*skinConfInt["linkWidth"])/linkColumns; - int linkSpacingY = (resY-35 - skinConfInt["topBarHeight"] - linkRows*skinConfInt["linkHeight"])/linkRows; - uint sectionLinkPadding = (skinConfInt["topBarHeight"] - 32 - font->getLineHeight()) / 3; - - bool quit = false; - int x,y, offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6; - int helpBoxHeight = 154; - uint i; - long tickBattery = -60000, tickNow; - string batteryIcon = "imgs/battery/0.png"; - stringstream ss; - uint sectionsCoordX = 24; - SDL_Rect re = {0,0,0,0}; - bool helpDisplayed = false; -#ifdef WITH_DEBUG - //framerate - long tickFPS = SDL_GetTicks(); - int drawn_frames = 0; - string fps = ""; -#endif - - IconButton btnContextMenu(this, ts, "skin:imgs/menu.png"); - btnContextMenu.setPosition(resX-38, bottomBarIconY); - btnContextMenu.setAction(MakeDelegate(this, &GMenu2X::contextMenu)); - if (!fileExists(CARD_ROOT)) - CARD_ROOT = "/"; + CARD_ROOT = ""; - while (!quit) { - tickNow = SDL_GetTicks(); + appToLaunch = nullptr; - //Background - sc["bgmain"]->blit(s,0,0); + // Recover last session + readTmp(); + if (lastSelectorElement > -1 && menu->selLinkApp() && + (!menu->selLinkApp()->getSelectorDir().empty() + || !lastSelectorDir.empty())) + menu->selLinkApp()->selector(lastSelectorElement, lastSelectorDir); - //Sections - sectionsCoordX = halfX - (constrain((uint)menu->getSections().size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2; - if (menu->firstDispSection()>0) - sc.skinRes("imgs/l_enabled.png")->blit(s,0,0); - else - sc.skinRes("imgs/l_disabled.png")->blit(s,0,0); - if (menu->firstDispSection()+linkColumnsgetSections().size()) - sc.skinRes("imgs/r_enabled.png")->blit(s,resX-10,0); - else - sc.skinRes("imgs/r_disabled.png")->blit(s,resX-10,0); - for (i=menu->firstDispSection(); igetSections().size() && ifirstDispSection()+linkColumns; i++) { - string sectionIcon = "skin:sections/"+menu->getSections()[i]+".png"; - x = (i-menu->firstDispSection())*skinConfInt["linkWidth"]+sectionsCoordX; - if (menu->selSectionIndex()==(int)i) - s->box(x, 0, skinConfInt["linkWidth"], - skinConfInt["topBarHeight"], skinConfColors[COLOR_SELECTION_BG]); - x += skinConfInt["linkWidth"]/2; - if (sc.exists(sectionIcon)) - sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32); - else - sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding); - s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, ASFont::HAlignCenter, ASFont::VAlignBottom ); - } - - //Links - s->setClipRect(offset,skinConfInt["topBarHeight"],resX-9,resY-74); //32*2+10 - for (i=menu->firstDispRow()*linkColumns; i<(menu->firstDispRow()*linkColumns)+linksPerPage && isectionLinks()->size(); i++) { - int ir = i-menu->firstDispRow()*linkColumns; - x = (ir%linkColumns)*(skinConfInt["linkWidth"]+linkSpacingX)+offset; - y = ir/linkColumns*(skinConfInt["linkHeight"]+linkSpacingY)+skinConfInt["topBarHeight"]+2; - menu->sectionLinks()->at(i)->setPosition(x,y); - - if (i==(uint)menu->selLinkIndex()) - menu->sectionLinks()->at(i)->paintHover(); - - menu->sectionLinks()->at(i)->paint(); - } - s->clearClipRect(); - - drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81); - - if (menu->selLink()!=NULL) { - s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom ); - if (menu->selLinkApp()!=NULL) { - s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle ); - //Manual indicator - if (!menu->selLinkApp()->getManual().empty()) - sc.skinRes("imgs/manual.png")->blit(s,manualX,bottomBarIconY); - } - } - - if (ts.available()) { - btnContextMenu.paint(); - } - //check battery status every 60 seconds - if (tickNow-tickBattery >= 60000) { - tickBattery = tickNow; - unsigned short battlevel = getBatteryLevel(); - if (battlevel>5) { - batteryIcon = "imgs/battery/ac.png"; + while (true) { + // Remove dismissed layers from the stack. + for (auto it = layers.begin(); it != layers.end(); ) { + if ((*it)->getStatus() == Layer::Status::DISMISSED) { + it = layers.erase(it); } else { - ss.clear(); - ss << battlevel; - ss >> batteryIcon; - batteryIcon = "imgs/battery/"+batteryIcon+".png"; + ++it; } } - sc.skinRes(batteryIcon)->blit( s, resX-19, bottomBarIconY ); - //s->write( font, tr[batstr.c_str()], 20, 170 ); - //On Screen Help - - if (helpDisplayed) { - s->box(10,50,300,helpBoxHeight+4, skinConfColors[COLOR_MESSAGE_BOX_BG]); - s->rectangle( 12,52,296,helpBoxHeight, - skinConfColors[COLOR_MESSAGE_BOX_BORDER] ); - s->write( font, tr["CONTROLS"], 20, 60 ); -#ifdef PLATFORM_DINGUX - s->write( font, tr["A: Launch link / Confirm action"], 20, 80 ); - s->write( font, tr["B: Show this help menu"], 20, 95 ); - s->write( font, tr["L, R: Change section"], 20, 110 ); - s->write( font, tr["SELECT: Show contextual menu"], 20, 155 ); - s->write( font, tr["START: Show options menu"], 20, 170 ); -#endif - s->flip(); - while (input.waitForPressedButton() != InputManager::CANCEL) {} - helpDisplayed=false; - continue; + // Run animations. + bool animating = false; + for (auto layer : layers) { + animating |= layer->runAnimations(); } -#ifdef WITH_DEBUG - //framerate - drawn_frames++; - if (tickNow-tickFPS>=1000) { - ss.clear(); - ss << drawn_frames*(tickNow-tickFPS+1)/1000; - ss >> fps; - tickFPS = tickNow; - drawn_frames = 0; + // Paint layers. + for (auto layer : layers) { + layer->paint(*s); + } + if (appToLaunch) { + break; } - s->write( font, fps+" FPS", resX-1,1 ,ASFont::HAlignRight ); -#endif - s->flip(); - //touchscreen + // Handle touchscreen events. if (ts.available()) { ts.poll(); - btnContextMenu.handleTS(); - re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX; - if (ts.pressed() && ts.inRect(re)) { - re.w = skinConfInt["linkWidth"]; - sectionsCoordX = halfX - (constrain((uint)menu->getSections().size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2; - for (i=menu->firstDispSection(); !ts.handled() && igetSections().size() && ifirstDispSection()+linkColumns; i++) { - re.x = (i-menu->firstDispSection())*re.w+sectionsCoordX; - - if (ts.inRect(re)) { - menu->setSectionIndex(i); - ts.setHandled(); - } + for (auto it = layers.rbegin(); it != layers.rend(); ++it) { + if ((*it)->handleTouchscreen(ts)) { + break; } } - - i=menu->firstDispRow()*linkColumns; - while ( i<(menu->firstDispRow()*linkColumns)+linksPerPage && isectionLinks()->size()) { - if (menu->sectionLinks()->at(i)->isPressed()) - menu->setLinkIndex(i); - if (menu->sectionLinks()->at(i)->handleTS()) - i = menu->sectionLinks()->size(); - i++; - } } - switch (input.waitForPressedButton()) { - case InputManager::ACCEPT: - if (menu->selLink() != NULL) menu->selLink()->run(); - break; - case InputManager::CANCEL: - helpDisplayed=true; - break; - case InputManager::SETTINGS: - options(); - break; - case InputManager::MENU: - contextMenu(); - break; - case InputManager::UP: - menu->linkUp(); - break; - case InputManager::DOWN: - menu->linkDown(); - break; - case InputManager::LEFT: - menu->linkLeft(); - break; - case InputManager::RIGHT: - menu->linkRight(); - break; - case InputManager::ALTLEFT: - menu->decSectionIndex(); - offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6; - break; - case InputManager::ALTRIGHT: - menu->incSectionIndex(); - offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6; - break; - default: - break; - } + // Handle other input events. + InputManager::Button button; + bool gotEvent; + const bool wait = !animating; + do { + gotEvent = input.getButton(&button, wait); + } while (wait && !gotEvent); + if (gotEvent) { + for (auto it = layers.rbegin(); it != layers.rend(); ++it) { + if ((*it)->handleButtonPress(button)) { + break; + } + } + } + } + + if (appToLaunch) { + appToLaunch->drawRun(); + appToLaunch->launch(fileToLaunch); } } void GMenu2X::explorer() { - FileDialog fd(this, ts, tr["Select an application"], ".gpu,.dge,.sh,"); + FileDialog fd(this, ts, tr["Select an application"], "dge,sh,bin,py,elf,"); if (fd.exec()) { if (confInt["saveSelection"] && (confInt["section"]!=menu->selSectionIndex() || confInt["link"]!=menu->selLinkIndex())) writeConfig(); @@ -839,7 +664,9 @@ void GMenu2X::explorer() { string command = cmdclean(fd.getPath()+"/"+fd.getFile()); chdir(fd.getPath().c_str()); quit(); +#ifdef ENABLE_CPUFREQ setClock(cpuFreqAppDefault); +#endif execlp("/bin/sh","/bin/sh","-c",command.c_str(),NULL); //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue @@ -849,14 +676,29 @@ void GMenu2X::explorer() { } } -void GMenu2X::options() { +void GMenu2X::queueLaunch(LinkApp *app, const std::string &file) { + appToLaunch = app; + fileToLaunch = file; +} + +void GMenu2X::showHelpPopup() { + layers.push_back(make_shared(*this)); +} + +void GMenu2X::showSettings() { +#ifdef ENABLE_CPUFREQ int curMenuClock = confInt["menuClock"]; +#endif bool showRootFolder = fileExists(CARD_ROOT); - FileLister fl_tr(getHome() + "/translations"); + FileLister fl_tr(GMENU2X_SYSTEM_DIR "/translations"); fl_tr.browse(); - fl_tr.setPath(GMENU2X_SYSTEM_DIR "/translations", false); - fl_tr.browse(false); + + string tr_path = getHome() + "/translations"; + if (fileExists(tr_path)) { + fl_tr.setPath(tr_path, false); + fl_tr.browse(false); + } fl_tr.insertFile("English"); string lang = tr.lang(); @@ -868,15 +710,19 @@ void GMenu2X::options() { SettingsDialog sd(this, input, ts, tr["Settings"]); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Language"], tr["Set the language used by GMenu2X"], &lang, &fl_tr.getFiles())); sd.addSetting(new MenuSettingBool(this, ts, tr["Save last selection"], tr["Save the last selected link and section on exit"], &confInt["saveSelection"])); +#ifdef ENABLE_CPUFREQ sd.addSetting(new MenuSettingInt(this, ts, tr["Clock for GMenu2X"], tr["Set the cpu working frequency when running GMenu2X"], &confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)); sd.addSetting(new MenuSettingInt(this, ts, tr["Maximum overclock"], tr["Set the maximum overclock for launching links"], &confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)); +#endif sd.addSetting(new MenuSettingBool(this, ts, tr["Output logs"], tr["Logs the output of the links. Use the Log Viewer to read them."], &confInt["outputLogs"])); sd.addSetting(new MenuSettingInt(this, ts, tr["Screen Timeout"], tr["Set screen's backlight timeout in seconds"], &confInt["backlightTimeout"], 0, 120)); // sd.addSetting(new MenuSettingMultiString(this, ts, tr["Tv-Out encoding"], tr["Encoding of the tv-out signal"], &confStr["tvoutEncoding"], &encodings)); sd.addSetting(new MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder)); if (sd.exec() && sd.edited()) { +#ifdef ENABLE_CPUFREQ if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]); +#endif if (confInt["backlightTimeout"] == 0) { if (PowerSaver::isRunning()) @@ -910,12 +756,12 @@ void GMenu2X::skinMenu() { SettingsDialog sd(this, input, ts, tr["Skin"]); sd.addSetting(new MenuSettingMultiString(this, ts, tr["Skin"], tr["Set the skin used by GMenu2X"], &confStr["skin"], &fl_sk.getDirectories())); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Top Bar Color"], tr["Color of the top bar"], &skinConfColors[COLOR_TOP_BAR_BG])); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Bottom Bar Color"], tr["Color of the bottom bar"], &skinConfColors[COLOR_BOTTOM_BAR_BG])); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Selection Color"], tr["Color of the selection and other interface details"], &skinConfColors[COLOR_SELECTION_BG])); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Color"], tr["Background color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BG])); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Border Color"], tr["Border color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BORDER])); - sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Selection Color"], tr["Color of the selection of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_SELECTION])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Top Bar"], tr["Color of the top bar"], &skinConfColors[COLOR_TOP_BAR_BG])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Bottom Bar"], tr["Color of the bottom bar"], &skinConfColors[COLOR_BOTTOM_BAR_BG])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Selection"], tr["Color of the selection and other interface details"], &skinConfColors[COLOR_SELECTION_BG])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box"], tr["Background color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BG])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Border"], tr["Border color of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_BORDER])); + sd.addSetting(new MenuSettingRGBA(this, ts, tr["Message Box Selection"], tr["Color of the selection of the message box"], &skinConfColors[COLOR_MESSAGE_BOX_SELECTION])); if (sd.exec() && sd.edited()) { if (curSkin != confStr["skin"]) { @@ -976,20 +822,22 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) { } skinconf.close(); - if (setWallpaper && !skinConfStr["wallpaper"].empty() && fileExists("skins/"+skin+"/wallpapers/"+skinConfStr["wallpaper"])) - confStr["wallpaper"] = "skins/"+skin+"/wallpapers/"+skinConfStr["wallpaper"]; + if (setWallpaper && !skinConfStr["wallpaper"].empty()) { + string fp = sc.getSkinFilePath("wallpapers/" + skinConfStr["wallpaper"]); + if (!fp.empty()) + confStr["wallpaper"] = fp; + else + WARNING("Unable to find wallpaper defined on skin %s\n", skin.c_str()); + } } } - evalIntConf( &skinConfInt["topBarHeight"], 40, 32,120 ); - evalIntConf( &skinConfInt["linkHeight"], 40, 32,120 ); - evalIntConf( &skinConfInt["linkWidth"], 60, 32,120 ); + evalIntConf(&skinConfInt["topBarHeight"], 40, 32, 120); + evalIntConf(&skinConfInt["bottomBarHeight"], 20, 20, 120); + evalIntConf(&skinConfInt["linkHeight"], 40, 32, 120); + evalIntConf(&skinConfInt["linkWidth"], 60, 32, 120); - //recalculate some coordinates based on the new element sizes - linkColumns = (resX-10)/skinConfInt["linkWidth"]; - linkRows = (resY-35-skinConfInt["topBarHeight"])/skinConfInt["linkHeight"]; - - if (menu != NULL) menu->loadIcons(); + if (menu != NULL) menu->skinUpdated(); //Selection png useSelectionPng = sc.addSkinRes("imgs/selection.png", false) != NULL; @@ -1002,150 +850,8 @@ void GMenu2X::showManual() { menu->selLinkApp()->showManual(); } -void GMenu2X::contextMenu() { - vector voices; - { - MenuOption opt = {tr.translate("Add link in $1",menu->selSection().c_str(),NULL), MakeDelegate(this, &GMenu2X::addLink)}; - voices.push_back(opt); - } - - { - LinkApp* app = menu->selLinkApp(); - if (app && fileExists(app->getManual())) { - MenuOption opt = {tr.translate("Show manual of $1",menu->selLink()->getTitle().c_str(),NULL), - MakeDelegate(this, &GMenu2X::showManual), - }; - voices.push_back(opt); - } - } - - if (menu->selLinkApp()!=NULL) { - { - MenuOption opt = {tr.translate("Edit $1",menu->selLink()->getTitle().c_str(),NULL), MakeDelegate(this, &GMenu2X::editLink)}; - voices.push_back(opt); - }{ - MenuOption opt = {tr.translate("Delete $1 link",menu->selLink()->getTitle().c_str(),NULL), MakeDelegate(this, &GMenu2X::deleteLink)}; - voices.push_back(opt); - } - } - - { - MenuOption opt = {tr["Add section"], MakeDelegate(this, &GMenu2X::addSection)}; - voices.push_back(opt); - }{ - MenuOption opt = {tr["Rename section"], MakeDelegate(this, &GMenu2X::renameSection)}; - voices.push_back(opt); - }{ - MenuOption opt = {tr["Delete section"], MakeDelegate(this, &GMenu2X::deleteSection)}; - voices.push_back(opt); - }{ - MenuOption opt = {tr["Scan for applications and games"], MakeDelegate(this, &GMenu2X::scanner)}; - voices.push_back(opt); - } - - bool close = false; - uint i, fadeAlpha=0; - int sel = 0; - - int h = font->getHeight(); - SDL_Rect box; - box.h = (h+2)*voices.size()+8; - box.w = 0; - for (i=0; igetTextWidth(voices[i].text); - if (w>box.w) box.w = w; - } - box.w += 23; - box.x = halfX - box.w/2; - box.y = halfY - box.h/2; - - SDL_Rect selbox = { - static_cast(box.x + 4), - 0, - static_cast(box.w - 8), - static_cast(h + 2) - }; - long tickNow, tickStart = SDL_GetTicks(); - - Surface bg(s); - /*//Darken background - bg.box(0, 0, resX, resY, 0,0,0,150); - bg.box(box.x, box.y, box.w, box.h, skinConfColors["messageBoxBg"]); - bg.rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors["messageBoxBorder"] );*/ - - InputManager::ButtonEvent event; - while (!close) { - tickNow = SDL_GetTicks(); - - selbox.y = box.y+4+(h+2)*sel; - bg.blit(s,0,0); - - if (fadeAlpha<200) fadeAlpha = intTransition(0,200,tickStart,500,tickNow); - s->box(0, 0, resX, resY, 0,0,0,fadeAlpha); - s->box(box.x, box.y, box.w, box.h, skinConfColors[COLOR_MESSAGE_BOX_BG]); - s->rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors[COLOR_MESSAGE_BOX_BORDER] ); - - - //draw selection rect - s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] ); - for (i=0; iwrite( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignTop ); - s->flip(); - - //touchscreen - if (ts.available()) { - ts.poll(); - if (ts.released()) { - if (!ts.inRect(box)) - close = true; - else if (ts.getX() >= selbox.x - && ts.getX() <= selbox.x + selbox.w) - for (i=0; i= selbox.y - && ts.getY() <= selbox.y + selbox.h) { - voices[i].action(); - close = true; - i = voices.size(); - } - } - } else if (ts.pressed() && ts.inRect(box)) { - for (i=0; i= selbox.y - && ts.getY() <= selbox.y + selbox.h) { - sel = i; - i = voices.size(); - } - } - } - } - - - if (fadeAlpha < 200) { - if (!input.pollEvent(&event) || event.state != InputManager::PRESSED) continue; - } else { - event.button = input.waitForPressedButton(); - } - - switch(event.button) { - case InputManager::MENU: - close = true; - break; - case InputManager::UP: - sel = std::max(0, sel-1); - break; - case InputManager::DOWN: - sel = std::min((int)voices.size()-1, sel+1); - break; - case InputManager::ACCEPT: - voices[sel].action(); - close = true; - break; - default: - break; - } - } +void GMenu2X::showContextMenu() { + layers.push_back(make_shared(*this, *menu)); } void GMenu2X::changeWallpaper() { @@ -1158,7 +864,7 @@ void GMenu2X::changeWallpaper() { } void GMenu2X::addLink() { - FileDialog fd(this, ts, tr["Select an application"]); + FileDialog fd(this, ts, tr["Select an application"], "dge,sh,bin,py,elf,"); if (fd.exec()) { menu->addLink(fd.getPath(), fd.getFile()); sync(); @@ -1166,60 +872,69 @@ void GMenu2X::addLink() { } void GMenu2X::editLink() { - if (menu->selLinkApp()==NULL) return; + LinkApp *linkApp = menu->selLinkApp(); + if (!linkApp) return; vector pathV; - split(pathV,menu->selLinkApp()->getFile(),"/"); + split(pathV,linkApp->getFile(),"/"); string oldSection = ""; if (pathV.size()>1) oldSection = pathV[pathV.size()-2]; string newSection = oldSection; - string linkTitle = menu->selLinkApp()->getTitle(); - string linkDescription = menu->selLinkApp()->getDescription(); - string linkIcon = menu->selLinkApp()->getIcon(); - string linkManual = menu->selLinkApp()->getManual(); - string linkParams = menu->selLinkApp()->getParams(); - string linkSelFilter = menu->selLinkApp()->getSelectorFilter(); - string linkSelDir = menu->selLinkApp()->getSelectorDir(); - bool linkSelBrowser = menu->selLinkApp()->getSelectorBrowser(); - string linkSelScreens = menu->selLinkApp()->getSelectorScreens(); - string linkSelAliases = menu->selLinkApp()->getAliasFile(); - int linkClock = menu->selLinkApp()->clock(); + string linkTitle = linkApp->getTitle(); + string linkDescription = linkApp->getDescription(); + string linkIcon = linkApp->getIcon(); + string linkManual = linkApp->getManual(); + string linkSelFilter = linkApp->getSelectorFilter(); + string linkSelDir = linkApp->getSelectorDir(); + bool linkSelBrowser = linkApp->getSelectorBrowser(); + string linkSelScreens = linkApp->getSelectorScreens(); + string linkSelAliases = linkApp->getAliasFile(); + int linkClock = linkApp->clock(); string diagTitle = tr.translate("Edit link: $1",linkTitle.c_str(),NULL); - string diagIcon = menu->selLinkApp()->getIconPath(); + string diagIcon = linkApp->getIconPath(); SettingsDialog sd(this, input, ts, diagTitle, diagIcon); - sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingMultiString(this, ts, tr["Section"], tr["The section this link belongs to"], &newSection, &menu->getSections())); - sd.addSetting(new MenuSettingImage(this, ts, tr["Icon"], tr.translate("Select an icon for the link: $1", linkTitle.c_str(), NULL), &linkIcon, ".png,.bmp,.jpg,.jpeg")); - sd.addSetting(new MenuSettingFile(this, ts, tr["Manual"], tr["Select a graphic/textual manual or a readme"], &linkManual, ".man.png,.txt")); - sd.addSetting(new MenuSettingInt(this, ts, tr["Clock (default: 336)"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)); - sd.addSetting(new MenuSettingString(this, ts, tr["Parameters"], tr["Parameters to pass to the application"], &linkParams, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); - sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); - sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); - sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); - sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &menu->selLinkApp()->runsInBackgroundRef())); -#ifdef PLATFORM_DINGUX - sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &menu->selLinkApp()->consoleApp)); + if (!linkApp->isOpk()) { + sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingMultiString(this, ts, tr["Section"], tr["The section this link belongs to"], &newSection, &menu->getSections())); + sd.addSetting(new MenuSettingImage(this, ts, tr["Icon"], + tr.translate("Select an icon for the link: $1", + linkTitle.c_str(), NULL), &linkIcon, "png")); + sd.addSetting(new MenuSettingFile(this, ts, tr["Manual"], + tr["Select a graphic/textual manual or a readme"], + &linkManual, "man.png,txt")); + } + if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) { + sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); + sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); + } +#ifdef ENABLE_CPUFREQ + sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)); #endif + if (!linkApp->isOpk()) { + sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); + sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) + sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp)); +#endif + } if (sd.exec() && sd.edited()) { - menu->selLinkApp()->setTitle(linkTitle); - menu->selLinkApp()->setDescription(linkDescription); - menu->selLinkApp()->setIcon(linkIcon); - menu->selLinkApp()->setManual(linkManual); - menu->selLinkApp()->setParams(linkParams); - menu->selLinkApp()->setSelectorFilter(linkSelFilter); - menu->selLinkApp()->setSelectorDir(linkSelDir); - menu->selLinkApp()->setSelectorBrowser(linkSelBrowser); - menu->selLinkApp()->setSelectorScreens(linkSelScreens); - menu->selLinkApp()->setAliasFile(linkSelAliases); - menu->selLinkApp()->setClock(linkClock); + linkApp->setTitle(linkTitle); + linkApp->setDescription(linkDescription); + linkApp->setIcon(linkIcon); + linkApp->setManual(linkManual); + linkApp->setSelectorFilter(linkSelFilter); + linkApp->setSelectorDir(linkSelDir); + linkApp->setSelectorBrowser(linkSelBrowser); + linkApp->setSelectorScreens(linkSelScreens); + linkApp->setAliasFile(linkSelAliases); + linkApp->setClock(linkClock); INFO("New Section: '%s'\n", newSection.c_str()); @@ -1235,14 +950,14 @@ void GMenu2X::editLink() { newFileName = "sections/"+newSection+"/"+linkTitle+id; x++; } - rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str()); - menu->selLinkApp()->renameFile(newFileName); + rename(linkApp->getFile().c_str(),newFileName.c_str()); + linkApp->renameFile(newFileName); INFO("New section index: %i.\n", newSectionIndex - menu->getSections().begin()); menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->getSections().begin()); } - menu->selLinkApp()->save(); + linkApp->save(); sync(); } } @@ -1324,7 +1039,7 @@ void GMenu2X::scanner() { Surface scanbg(bg); drawButton(&scanbg, "cancel", tr["Exit"], drawButton(&scanbg, "accept", "", 5)-10); - scanbg.write(font,tr["Link Scanner"],halfX,7,ASFont::HAlignCenter,ASFont::VAlignMiddle); + scanbg.write(font,tr["Link Scanner"],halfX,7,Font::HAlignCenter,Font::VAlignMiddle); scanbg.convertToDisplayFormat(); uint lineY = 42; @@ -1332,13 +1047,9 @@ void GMenu2X::scanner() { #ifdef PLATFORM_PANDORA //char *configpath = pnd_conf_query_searchpath(); #else - if (confInt["menuClock"]<336) { - setClock(336); - scanbg.write(font,tr["Raising cpu clock to 336MHz"],5,lineY); - scanbg.blit(s,0,0); - s->flip(); - lineY += 26; - } +#ifdef ENABLE_CPUFREQ + setSafeMaxClock(); +#endif scanbg.write(font,tr["Scanning filesystem..."],5,lineY); scanbg.blit(s,0,0); @@ -1381,14 +1092,9 @@ void GMenu2X::scanner() { s->flip(); lineY += 26; - if (confInt["menuClock"]<336) { - setClock(confInt["menuClock"]); - scanbg.write(font,tr["Decreasing cpu clock"],5,lineY); - scanbg.blit(s,0,0); - s->flip(); - lineY += 26; - } - +#ifdef ENABLE_CPUFREQ + setMenuClock(); +#endif sync(); #endif @@ -1418,7 +1124,7 @@ void GMenu2X::scanPath(string path, vector *files) { scanPath(filepath, files); if (statRet != -1) { ext = filepath.substr(filepath.length()-4,4); -#if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE) +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE) if (ext==".dge") #else if (ext==".pxml") @@ -1435,69 +1141,43 @@ typedef struct { unsigned short remocon; } MMSP2ADC; -unsigned short GMenu2X::getBatteryLevel() { - FILE *batteryHandle = NULL, - *usbHandle = NULL; - -#if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE) - usbHandle = fopen("/sys/class/power_supply/usb/online", "r"); -#endif - if (usbHandle) { - int usbval = 0; - fscanf(usbHandle, "%d", &usbval); - fclose(usbHandle); - if (usbval == 1) - return 6; - } - -#if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE) - batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r"); -#endif - if (batteryHandle) { - int battval = 0; - fscanf(batteryHandle, "%d", &battval); - fclose(batteryHandle); - - if (battval>90) return 5; - if (battval>70) return 4; - if (battval>50) return 3; - if (battval>30) return 2; - if (battval>10) return 1; - } - - return 0; -} - void GMenu2X::setInputSpeed() { - SDL_EnableKeyRepeat(1,150); + SDL_EnableKeyRepeat(250, 150); } +#ifdef ENABLE_CPUFREQ void GMenu2X::setClock(unsigned mhz) { mhz = constrain(mhz, cpuFreqMin, confInt["maxClock"]); -#if defined(PLATFORM_DINGUX) || defined(PLATFORM_NANONOTE) +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) || defined(PLATFORM_NANONOTE) jz_cpuspeed(mhz); #endif } +#endif string GMenu2X::getDiskFree(const char *path) { - stringstream ss; string df = ""; struct statvfs b; int ret = statvfs(path, &b); - if (ret==0) { + if (ret == 0) { // Make sure that the multiplication happens in 64 bits. - unsigned long long free = - ((unsigned long long)b.f_bfree * b.f_bsize) / 1048576; - unsigned long long total = - ((unsigned long long)b.f_blocks * b.f_frsize) / 1048576; - ss << free << "/" << total << "MB"; + unsigned long freeMiB = + ((unsigned long long)b.f_bfree * b.f_bsize) / (1024 * 1024); + unsigned long totalMiB = + ((unsigned long long)b.f_blocks * b.f_frsize) / (1024 * 1024); + stringstream ss; + if (totalMiB >= 10000) { + ss << (freeMiB / 1024) << "." << ((freeMiB % 1024) * 10) / 1024 << "/" + << (totalMiB / 1024) << "." << ((totalMiB % 1024) * 10) / 1024 << "GiB"; + } else { + ss << freeMiB << "/" << totalMiB << "MiB"; + } ss >> df; } else WARNING("statvfs failed with error '%s'.\n", strerror(errno)); return df; } -int GMenu2X::drawButton(Button *btn, int x, int y) { +int GMenu2X::drawButton(IconButton *btn, int x, int y) { if (y<0) y = resY+y; btn->setPosition(x, y-7); btn->paint(); @@ -1510,7 +1190,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); re.w = sc["imgs/buttons/"+btn+".png"]->width() + 3; - s->write(font, text, x+re.w, y, ASFont::HAlignLeft, ASFont::VAlignMiddle); + s->write(font, text, x+re.w, y, Font::HAlignLeft, Font::VAlignMiddle); re.w += font->getTextWidth(text); } return x+re.w+6; @@ -1522,46 +1202,50 @@ int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text, x -= 16; sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); x -= 3; - s->write(font, text, x, y, ASFont::HAlignRight, ASFont::VAlignMiddle); + s->write(font, text, x, y, Font::HAlignRight, Font::VAlignMiddle); return x-6-font->getTextWidth(text); } return x-6; } -void GMenu2X::drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height) { - if (totalsize<=pagesize) return; +void GMenu2X::drawScrollBar(uint pageSize, uint totalSize, uint pagePos) { + if (totalSize <= pageSize) { + // Everything fits on one screen, no scroll bar needed. + return; + } - s->rectangle(resX-8, top, 7, height, skinConfColors[COLOR_SELECTION_BG]); + unsigned int top, height; + tie(top, height) = getContentArea(); + top += 1; + height -= 2; - //internal bar total height = height-2 - //bar size - uint bs = (height-2) * pagesize / totalsize; - //bar y position - uint by = (height-2) * pagepos / totalsize; - by = top+2+by; - if (by+bs>top+height-2) by = top+height-2-bs; + s->rectangle(resX - 8, top, 7, height, skinConfColors[COLOR_SELECTION_BG]); + top += 2; + height -= 4; + const uint barSize = height * pageSize / totalSize; + const uint barPos = (height - barSize) * pagePos / (totalSize - pageSize); - s->box(resX-6, by, 3, bs, skinConfColors[COLOR_SELECTION_BG]); + s->box(resX - 6, top + barPos, 3, barSize, + skinConfColors[COLOR_SELECTION_BG]); } void GMenu2X::drawTopBar(Surface *s) { - if (s==NULL) s = this->s; - Surface *bar = sc.skinRes("imgs/topbar.png", false); - if (bar != NULL) + if (bar) { bar->blit(s, 0, 0); - else - s->box(0, 0, resX, skinConfInt["topBarHeight"], - skinConfColors[COLOR_TOP_BAR_BG]); + } else { + const int h = skinConfInt["topBarHeight"]; + s->box(0, 0, resX, h, skinConfColors[COLOR_TOP_BAR_BG]); + } } void GMenu2X::drawBottomBar(Surface *s) { - if (s==NULL) s = this->s; - Surface *bar = sc.skinRes("imgs/bottombar.png", false); - if (bar != NULL) + if (bar) { bar->blit(s, 0, resY-bar->height()); - else - s->box(0, resY-20, resX, 20, skinConfColors[COLOR_BOTTOM_BAR_BG]); + } else { + const int h = skinConfInt["bottomBarHeight"]; + s->box(0, resY - h, resX, h, skinConfColors[COLOR_BOTTOM_BAR_BG]); + } } diff --git a/src/gmenu2x.h b/src/gmenu2x.h index 6fb2542..4ce36d7 100644 --- a/src/gmenu2x.h +++ b/src/gmenu2x.h @@ -21,20 +21,26 @@ #ifndef GMENU2X_H #define GMENU2X_H +#include "contextmenu.h" #include "surfacecollection.h" #include "translator.h" -#include "FastDelegate.h" #include "touchscreen.h" #include "inputmanager.h" #include "surface.h" #include +#include #include +#include #include -#include -class ASFont; class Button; +class Font; +class HelpPopup; +class IconButton; +class Layer; +class LinkApp; +class MediaMonitor; class Menu; class Surface; @@ -45,7 +51,6 @@ class Surface; const int LOOP_DELAY = 30000; extern const char *CARD_ROOT; -extern const int CARD_ROOT_LEN; // Note: Keep this in sync with colorNames! enum color { @@ -59,37 +64,39 @@ enum color { NUM_COLORS, }; -typedef std::tr1::unordered_map > ConfStrHash; -typedef std::tr1::unordered_map > ConfIntHash; +typedef std::unordered_map > ConfStrHash; +typedef std::unordered_map > ConfIntHash; class GMenu2X { private: Touchscreen ts; + std::shared_ptr menu; +#ifdef ENABLE_INOTIFY + MediaMonitor *monitor; +#endif + + LinkApp *appToLaunch; + std::string fileToLaunch; + + std::vector> layers; /*! Retrieves the free disk space on the sd @return String containing a human readable representation of the free disk space */ std::string getDiskFree(const char *path); - unsigned short cpuX; //!< Offset for displaying cpu clock information - unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar +#ifdef ENABLE_CPUFREQ unsigned cpuFreqMin; //!< Minimum CPU frequency unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps unsigned cpuFreqMultiple; //!< All valid CPU frequencies are a multiple of this - /*! - Reads the current battery state and returns a number representing it's level of charge - @return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power. - */ - unsigned short getBatteryLevel(); + + void initCPULimits(); +#endif void browsePath(const std::string &path, std::vector* directories, std::vector* files); /*! - Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections. - */ - void scanner(); - /*! Performs the actual scan in the given path and populates the files vector with the results. The creation of the links is not performed here. @see scanner */ @@ -114,9 +121,7 @@ private: void initServices(); void initFont(); void initMenu(); - void initCPULimits(); - - void showManual(); + void initBG(); public: GMenu2X(); @@ -131,7 +136,18 @@ public: * Variables needed for elements disposition */ uint resX, resY, halfX, halfY; - uint bottomBarIconY, bottomBarTextY, linkColumns, linkRows; + uint bottomBarIconY, bottomBarTextY; + unsigned short cpuX; //!< Offset for displaying cpu clock information + unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar + + /** + * Gets the position and height of the area between the top and bottom bars. + */ + std::pair getContentArea() { + const unsigned int top = skinConfInt["topBarHeight"]; + const unsigned int bottom = skinConfInt["bottomBarHeight"]; + return std::make_pair(top, resY - top - bottom); + } InputManager input; @@ -147,21 +163,40 @@ public: SurfaceCollection sc; Translator tr; Surface *s, *bg; - ASFont *font; + Font *font; //Status functions void main(); - void options(); + /** + * Starts the scanning of the nand and sd filesystems, searching for dge + * and gpu files and creating the links in 2 dedicated sections. + */ + void scanner(); + void showContextMenu(); + void showHelpPopup(); + void showManual(); + void showSettings(); void skinMenu(); void about(); void viewLog(); - void contextMenu(); void changeWallpaper(); +#ifdef ENABLE_CPUFREQ void setClock(unsigned mhz); + void setMenuClock() { setClock(cpuFreqMenuDefault); } + void setSafeMaxClock() { setClock(cpuFreqSafeMax); } + unsigned getDefaultAppClock() { return cpuFreqAppDefault; } +#endif void setInputSpeed(); + /** + * Requests that the given application be launched. + * The launch won't happen immediately; it will happen after control + * returns to the main loop. + */ + void queueLaunch(LinkApp *app, const std::string &file); + void saveSelection(); void writeConfig(); void writeSkinConfig(); void writeTmp(int selelem=-1, const std::string &selectordir=""); @@ -173,16 +208,15 @@ public: void renameSection(); void deleteSection(); - void initBG(); - int drawButton(Button *btn, int x=5, int y=-10); + int drawButton(IconButton *btn, int x=5, int y=-10); int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); - void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height); + void drawScrollBar(uint pageSize, uint totalSize, uint pagePos); - void drawTopBar(Surface *s=NULL); - void drawBottomBar(Surface *s=NULL); + void drawTopBar(Surface *s); + void drawBottomBar(Surface *s); - Menu *menu; + Touchscreen &getTouchscreen() { return ts; } }; #endif // GMENU2X_H diff --git a/src/helppopup.cpp b/src/helppopup.cpp new file mode 100644 index 0000000..1501b24 --- /dev/null +++ b/src/helppopup.cpp @@ -0,0 +1,46 @@ +// Various authors. +// License: GPL version 2 or later. + +#include "helppopup.h" + +#include "gmenu2x.h" + + +HelpPopup::HelpPopup(GMenu2X &gmenu2x) + : gmenu2x(gmenu2x) +{ +} + +void HelpPopup::paint(Surface &s) { + Font *font = gmenu2x.font; + Translator &tr = gmenu2x.tr; + int helpBoxHeight = 154; + + s.box(10, 50, 300, helpBoxHeight + 4, + gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BG]); + s.rectangle(12, 52, 296, helpBoxHeight, + gmenu2x.skinConfColors[COLOR_MESSAGE_BOX_BORDER]); + s.write(font, tr["CONTROLS"], 20, 60); +#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) + s.write(font, tr["A: Launch link / Confirm action"], 20, 80); + s.write(font, tr["B: Show this help menu"], 20, 95); + s.write(font, tr["L, R: Change section"], 20, 110); + s.write(font, tr["SELECT: Show contextual menu"], 20, 155); + s.write(font, tr["START: Show options menu"], 20, 170); +#endif +} + +bool HelpPopup::handleButtonPress(InputManager::Button button) { + if (button == InputManager::CANCEL) { + dismiss(); + } + return true; +} + +bool HelpPopup::handleTouchscreen(Touchscreen &ts) { + if (ts.pressed()) { + dismiss(); + ts.setHandled(); + } + return true; +} diff --git a/src/helppopup.h b/src/helppopup.h new file mode 100644 index 0000000..c2e64ae --- /dev/null +++ b/src/helppopup.h @@ -0,0 +1,28 @@ +// Various authors. +// License: GPL version 2 or later. + +#ifndef HELPPOPUP_H +#define HELPPOPUP_H + +#include "layer.h" + +class GMenu2X; + + +/** + * A passive dialog containing some helpful text for the user. + */ +class HelpPopup : public Layer { +public: + HelpPopup(GMenu2X &gmenu2x); + + // Layer implementation: + virtual void paint(Surface &s); + virtual bool handleButtonPress(InputManager::Button button); + virtual bool handleTouchscreen(Touchscreen &ts); + +private: + GMenu2X &gmenu2x; +}; + +#endif // HELPPOPUP_H diff --git a/src/iconbutton.cpp b/src/iconbutton.cpp index 25a2fa8..e6ceac4 100644 --- a/src/iconbutton.cpp +++ b/src/iconbutton.cpp @@ -1,62 +1,49 @@ #include "iconbutton.h" -#include "asfont.h" +#include "font.h" #include "gmenu2x.h" #include "surface.h" using namespace std; -using namespace fastdelegate; + IconButton::IconButton( - GMenu2X *gmenu2x_, Touchscreen &ts_, + GMenu2X *gmenu2x, Touchscreen &ts, const string &icon, const string &label) - : Button(ts_) - , gmenu2x(gmenu2x_) + : gmenu2x(gmenu2x) + , ts(ts) + , icon(icon) + , label(label) + , action([] {}) + , rect({ 0, 0, 0, 0 }) { - this->icon = icon; - this->label = label; - updateSurfaces(); + iconSurface = gmenu2x->sc[icon]; + recalcRects(); } -void IconButton::updateSurfaces() { - iconSurface = gmenu2x->sc[icon]; - recalcSize(); +void IconButton::setAction(function_t action) { + this->action = action; } void IconButton::setPosition(int x, int y) { if (rect.x != x || rect.y != y) { - Button::setPosition(x,y); - recalcSize(); + rect.x = x; + rect.y = y; + recalcRects(); } } -void IconButton::paint() { - if (iconSurface) { - iconSurface->blit(gmenu2x->s, iconRect); - } - if (label != "") { - gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y, - ASFont::HAlignLeft, ASFont::VAlignMiddle); - } -} - -bool IconButton::paintHover() { - return true; -} - -void IconButton::recalcSize() { +void IconButton::recalcRects() { Uint16 h = 0, w = 0; if (iconSurface) { w += iconSurface->width(); h += iconSurface->height(); - iconRect = (SDL_Rect) { rect.x, rect.y, w, h }; - } else { - iconRect = (SDL_Rect) { 0, 0, 0, 0 }; } + iconRect = { rect.x, rect.y, w, h }; - if (label != "") { - uint margin = iconSurface ? 2 : 0; - labelRect = (SDL_Rect) { + if (!label.empty()) { + Uint16 margin = iconSurface ? 2 : 0; + labelRect = { static_cast(iconRect.x + iconRect.w + margin), static_cast(rect.y + h / 2), static_cast(gmenu2x->font->getTextWidth(label)), @@ -65,9 +52,25 @@ void IconButton::recalcSize() { w += margin + labelRect.w; } - setSize(w, h); + rect.w = w; + rect.h = h; } -void IconButton::setAction(ButtonAction action) { - this->action = action; +bool IconButton::handleTS() { + if (ts.released() && ts.inRect(rect)) { + ts.setHandled(); + action(); + return true; + } + return false; +} + +void IconButton::paint() { + if (iconSurface) { + iconSurface->blit(gmenu2x->s, iconRect); + } + if (!label.empty()) { + gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y, + Font::HAlignLeft, Font::VAlignMiddle); + } } diff --git a/src/iconbutton.h b/src/iconbutton.h index 159d28d..87a017b 100644 --- a/src/iconbutton.h +++ b/src/iconbutton.h @@ -1,34 +1,39 @@ #ifndef ICONBUTTON_H #define ICONBUTTON_H -#include "button.h" +#include "delegate.h" +#include #include class GMenu2X; class Surface; +class Touchscreen; -class IconButton : public Button { + +class IconButton { public: IconButton(GMenu2X *gmenu2x, Touchscreen &ts, const std::string &icon, const std::string &label = ""); - virtual ~IconButton() {}; - virtual void paint(); - virtual bool paintHover(); + void setAction(function_t action); - virtual void setPosition(int x, int y); + SDL_Rect getRect() { return rect; } + void setPosition(int x, int y); - void setAction(ButtonAction action); + bool handleTS(); + + void paint(); private: - void updateSurfaces(); + void recalcRects(); GMenu2X *gmenu2x; + Touchscreen &ts; std::string icon, label; - void recalcSize(); - SDL_Rect iconRect, labelRect; + function_t action; + SDL_Rect rect, iconRect, labelRect; Surface *iconSurface; }; diff --git a/src/imageio.cpp b/src/imageio.cpp index 988fc56..8dbed46 100644 --- a/src/imageio.cpp +++ b/src/imageio.cpp @@ -12,6 +12,17 @@ #include #include +#ifdef HAVE_LIBOPK +#include + +static void __readFromOpk(png_structp png_ptr, png_bytep ptr, png_size_t length) +{ + char **buf = (char **) png_get_io_ptr(png_ptr); + + memcpy(ptr, *buf, length); + *buf += length; +} +#endif SDL_Surface *loadPNG(const std::string &path) { // Declare these with function scope and initialize them to NULL, @@ -20,6 +31,11 @@ SDL_Surface *loadPNG(const std::string &path) { FILE *fp = NULL; png_structp png = NULL; png_infop info = NULL; +#ifdef HAVE_LIBOPK + std::string::size_type pos; + struct OPK *opk = NULL; + void *buffer = NULL, *param; +#endif // Create and initialize the top-level libpng struct. png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -37,11 +53,40 @@ SDL_Surface *loadPNG(const std::string &path) { goto cleanup; } - // Open input file. - fp = fopen(path.c_str(), "rb"); - if (!fp) goto cleanup; - // Set up the input control if you are using standard C streams. - png_init_io(png, fp); +#ifdef HAVE_LIBOPK + pos = path.find('#'); + if (pos != path.npos) { + int ret; + size_t length; + + DEBUG("Registering specific callback for icon %s\n", path.c_str()); + + opk = opk_open(path.substr(0, pos).c_str()); + if (!opk) { + ERROR("Unable to open OPK\n"); + goto cleanup; + } + + ret = opk_extract_file(opk, path.substr(pos + 1).c_str(), + &buffer, &length); + if (ret < 0) { + ERROR("Unable to extract icon from OPK\n"); + goto cleanup; + } + + param = buffer; + + png_set_read_fn(png, ¶m, __readFromOpk); + } else { +#else + if (1) { +#endif /* HAVE_LIBOPK */ + fp = fopen(path.c_str(), "rb"); + if (!fp) goto cleanup; + + // Set up the input control if you are using standard C streams. + png_init_io(png, fp); + } // The call to png_read_info() gives us all of the information from the // PNG file before the first IDAT (image data chunk). @@ -117,6 +162,12 @@ cleanup: // Clean up. png_destroy_read_struct(&png, &info, NULL); if (fp) fclose(fp); +#ifdef HAVE_LIBOPK + if (buffer) + free(buffer); + if (opk) + opk_close(opk); +#endif return surface; } diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index ac2d0a9..595569a 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -21,19 +21,25 @@ #include "inputdialog.h" #include "buttonbox.h" +#include "delegate.h" #include "gmenu2x.h" #include "iconbutton.h" +#include "surface.h" #include "utilities.h" #include using namespace std; -using namespace fastdelegate; #define KEY_WIDTH 20 #define KEY_HEIGHT 20 #define KB_TOP 90 +static bool utf8Code(unsigned char c) +{ + return (c>=194 && c<=198) || c==208 || c==209; +} + InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, Touchscreen &ts_, const string &text, const string &startvalue, const string &title, const string &icon) @@ -41,7 +47,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, , inputMgr(inputMgr_) , ts(ts_) { - if (title == "") { + if (title.empty()) { this->title = text; this->text = ""; } else { @@ -49,7 +55,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, this->text = text; } this->icon = ""; - if (icon != "" && gmenu2x->sc[icon] != NULL) { + if (!icon.empty() && gmenu2x->sc[icon] != NULL) { this->icon = icon; } @@ -96,22 +102,22 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, buttonbox = new ButtonBox(gmenu2x); IconButton *btnBackspace = new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png", gmenu2x->tr["Backspace"]); - btnBackspace->setAction(MakeDelegate(this, &InputDialog::backspace)); + btnBackspace->setAction(BIND(&InputDialog::backspace)); buttonbox->add(btnBackspace); IconButton *btnSpace = new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png", gmenu2x->tr["Space"]); - btnSpace->setAction(MakeDelegate(this, &InputDialog::space)); + btnSpace->setAction(BIND(&InputDialog::space)); buttonbox->add(btnSpace); IconButton *btnConfirm = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Confirm"]); - btnConfirm->setAction(MakeDelegate(this, &InputDialog::confirm)); + btnConfirm->setAction(BIND(&InputDialog::confirm)); buttonbox->add(btnConfirm); IconButton *btnChangeKeys = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Change keys"]); - btnChangeKeys->setAction(MakeDelegate(this, &InputDialog::changeKeys)); + btnChangeKeys->setAction(BIND(&InputDialog::changeKeys)); buttonbox->add(btnChangeKeys); } @@ -121,7 +127,7 @@ void InputDialog::setKeyboard(int kb) { this->kb = &(keyboard[kb]); kbLength = this->kb->at(0).length(); for (int x = 0, l = kbLength; x < l; x++) { - if (gmenu2x->font->utf8Code(this->kb->at(0)[x])) { + if (utf8Code(this->kb->at(0)[x])) { kbLength--; x++; } @@ -163,7 +169,7 @@ bool InputDialog::exec() { gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->write(gmenu2x->font, input, box.x + 5, box.y + box.h - 2, - ASFont::HAlignLeft, ASFont::VAlignBottom); + Font::HAlignLeft, Font::VAlignBottom); curTick = SDL_GetTicks(); if (curTick - caretTick >= 600) { @@ -221,7 +227,7 @@ bool InputDialog::exec() { void InputDialog::backspace() { // Check for UTF8 characters. input = input.substr(0, input.length() - - (gmenu2x->font->utf8Code(input[input.length() - 2]) ? 2 : 1)); + - (utf8Code(input[input.length() - 2]) ? 2 : 1)); } void InputDialog::space() { @@ -237,7 +243,7 @@ void InputDialog::confirm() { } else { int xc = 0; for (uint x = 0; x < kb->at(selRow).length(); x++) { - bool utf8 = gmenu2x->font->utf8Code(kb->at(selRow)[x]); + bool utf8 = utf8Code(kb->at(selRow)[x]); if (xc == selCol) input += kb->at(selRow).substr(x, utf8 ? 2 : 1); if (utf8) x++; xc++; @@ -281,7 +287,7 @@ void InputDialog::drawVirtualKeyboard() { for (uint x=0, xc=0; xfont->utf8Code(line[x])) { + if (utf8Code(line[x])) { charX = line.substr(x,2); x++; } else @@ -305,7 +311,7 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, charX, kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1, KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); xc++; } } @@ -325,7 +331,7 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], (int)(160 - kbLength * KEY_WIDTH / 4), KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1; gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); @@ -336,5 +342,5 @@ void InputDialog::drawVirtualKeyboard() { gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], (int)(160 + kbLength * KEY_WIDTH / 4), KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, - ASFont::HAlignCenter, ASFont::VAlignMiddle); + Font::HAlignCenter, Font::VAlignMiddle); } diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index d3f5293..970564d 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -22,13 +22,16 @@ #include "inputmanager.h" #include "utilities.h" #include "powersaver.h" +#include "menu.h" #include #include using namespace std; -void InputManager::init(const string &conffile) { +void InputManager::init(const string &conffile, Menu *menu) { + this->menu = menu; + for (int i = 0; i < BUTTON_TYPE_SIZE; i++) { buttonMap[i].source = UNMAPPED; } @@ -38,19 +41,29 @@ void InputManager::init(const string &conffile) { InputManager::InputManager() { #ifndef SDL_JOYSTICK_DISABLED - if (SDL_NumJoysticks() > 0) { - joystick = SDL_JoystickOpen(0); - } else { - joystick = NULL; + int i; + + if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { + ERROR("Unable to init joystick subsystem\n"); + return; } + + for (i = 0; i < SDL_NumJoysticks(); i++) { + struct Joystick joystick = { + SDL_JoystickOpen(i), false, false, false, false, + }; + joysticks.push_back(joystick); + } + + DEBUG("Opening %i joysticks\n", i); #endif } -InputManager::~InputManager() { +InputManager::~InputManager() +{ #ifndef SDL_JOYSTICK_DISABLED - if (joystick) { - SDL_JoystickClose(joystick); - } + for (auto it : joysticks) + SDL_JoystickClose(it.joystick); #endif } @@ -78,10 +91,6 @@ void InputManager::readConfFile(const string &conffile) { else if (name == "altright") button = ALTRIGHT; else if (name == "menu") button = MENU; else if (name == "settings") button = SETTINGS; - else if (name == "volup") button = VOLUP; - else if (name == "voldown") button = VOLDOWN; - else if (name == "power") button = POWER; - else if (name == "lock") button = LOCK; else { WARNING("InputManager: Ignoring unknown button name \"%s\"\n", name.c_str()); @@ -112,86 +121,112 @@ void InputManager::readConfFile(const string &conffile) { } InputManager::Button InputManager::waitForPressedButton() { - return waitForButton(PRESSED); + Button button; + while (!getButton(&button, true)); + return button; } -InputManager::Button InputManager::waitForReleasedButton() { - return waitForButton(RELEASED); +bool InputManager::pollButton(Button *button) { + return getButton(button, false); } -InputManager::Button InputManager::waitForButton(ButtonState state) { - ButtonEvent event; - while (!waitForEvent(&event) || event.state != state); - return event.button; -} - -bool InputManager::waitForEvent(ButtonEvent *event) { - return getEvent(event, true); -} - -bool InputManager::pollEvent(ButtonEvent *event) { - return getEvent(event, false); -} - -bool InputManager::getEvent(ButtonEvent *bevent, bool wait) { +bool InputManager::getButton(Button *button, bool wait) { //TODO: when an event is processed, program a new event //in some time, and when it occurs, do a key repeat - int i; - #ifndef SDL_JOYSTICK_DISABLED - if (joystick) { + if (joysticks.size() > 0) SDL_JoystickUpdate(); - } #endif + SDL_Event event; - if (wait) { + if (wait) SDL_WaitEvent(&event); - } else { - bevent->state = RELEASED; - if (!SDL_PollEvent(&event)) { - return false; - } - } + else if (!SDL_PollEvent(&event)) + return false; ButtonSource source; switch(event.type) { case SDL_KEYDOWN: - bevent->state = PRESSED; - source = KEYBOARD; - break; - case SDL_KEYUP: - bevent->state = RELEASED; source = KEYBOARD; break; #ifndef SDL_JOYSTICK_DISABLED case SDL_JOYBUTTONDOWN: - bevent->state = PRESSED; - source = JOYSTICK; - break; - case SDL_JOYBUTTONUP: - bevent->state = RELEASED; source = JOYSTICK; break; + case SDL_JOYAXISMOTION: { + source = JOYSTICK; + + unsigned int axis = event.jaxis.axis; + /* We only handle the first joystick */ + if (axis > 1) + return false; + + bool *axisState = joysticks[event.jaxis.which].axisState[axis]; + + if (event.jaxis.value < -20000) { + if (axisState[AXIS_STATE_NEGATIVE]) + return false; + axisState[AXIS_STATE_NEGATIVE] = true; + axisState[AXIS_STATE_POSITIVE] = false; + *button = axis ? UP : LEFT; + } else if (event.jaxis.value > 20000) { + if (axisState[AXIS_STATE_POSITIVE]) + return false; + axisState[AXIS_STATE_NEGATIVE] = false; + axisState[AXIS_STATE_POSITIVE] = true; + *button = axis ? DOWN : RIGHT; + } else { + axisState[0] = axisState[1] = false; + return false; + } + break; + } #endif + case SDL_USEREVENT: + switch ((enum EventCode) event.user.code) { +#ifdef HAVE_LIBOPK + case REMOVE_LINKS: + menu->removePackageLink((const char *) event.user.data1); + break; + case OPEN_PACKAGE: + menu->openPackage((const char *) event.user.data1); + break; + case OPEN_PACKAGES_FROM_DIR: + menu->openPackagesFromDir( + ((string) (const char *) event.user.data1 + + "/apps").c_str()); + break; +#endif /* HAVE_LIBOPK */ + case REPAINT_MENU: + default: + break; + } + + if (event.user.data1) + free(event.user.data1); + *button = REPAINT; + return true; + default: return false; } + int i = 0; if (source == KEYBOARD) { for (i = 0; i < BUTTON_TYPE_SIZE; i++) { if (buttonMap[i].source == KEYBOARD && (unsigned int)event.key.keysym.sym == buttonMap[i].code) { - bevent->button = static_cast