From 21ff02a69331fbcd53dc93a1af9a93618225b4bf Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 18 Feb 2015 14:35:00 -0600 Subject: GUI: Support styles in xml to reduce xml file size Also allow sliders to have their own text label instead of requiring a whole separate text object for the label in the xml. Change-Id: I6e314efb4bb454d496555ff7e003d743063a1308 --- gui/action.cpp | 8 +- gui/animation.cpp | 27 +- gui/button.cpp | 43 +- gui/checkbox.cpp | 4 +- gui/console.cpp | 13 +- gui/devices/landscape/res/landscape.xml | 1191 +++++++----------------------- gui/devices/portrait/res/portrait.xml | 1199 ++++++++----------------------- gui/devices/watch/res/watch.xml | 1165 +++++++----------------------- gui/fileselector.cpp | 10 +- gui/fill.cpp | 16 +- gui/image.cpp | 13 +- gui/input.cpp | 58 +- gui/keyboard.cpp | 36 +- gui/listbox.cpp | 6 +- gui/mousecursor.cpp | 6 +- gui/object.cpp | 6 +- gui/objects.hpp | 7 +- gui/pages.cpp | 90 ++- gui/pages.hpp | 4 + gui/partitionlist.cpp | 6 +- gui/progressbar.cpp | 6 +- gui/scrolllist.cpp | 23 +- gui/slider.cpp | 28 +- gui/slidervalue.cpp | 53 +- gui/text.cpp | 14 +- 25 files changed, 1055 insertions(+), 2977 deletions(-) (limited to 'gui') diff --git a/gui/action.cpp b/gui/action.cpp index aa81dff16..f9de4e9d8 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -226,9 +226,9 @@ GUIAction::GUIAction(xml_node<>* node) } // First, get the action - actions = node->first_node("actions"); - if (actions) child = actions->first_node("action"); - else child = node->first_node("action"); + actions = FindNode(node, "actions"); + if (actions) child = FindNode(actions, "action"); + else child = FindNode(node, "action"); if (!child) return; @@ -247,7 +247,7 @@ GUIAction::GUIAction(xml_node<>* node) } // Now, let's get either the key or region - child = node->first_node("touch"); + child = FindNode(node, "touch"); if (child) { attr = child->first_attribute("key"); diff --git a/gui/animation.cpp b/gui/animation.cpp index 1e9a87d3f..888b4ab08 100644 --- a/gui/animation.cpp +++ b/gui/animation.cpp @@ -29,7 +29,6 @@ extern "C" { GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) { xml_node<>* child; - xml_attribute<>* attr; mAnimation = NULL; mFrame = 1; @@ -40,36 +39,26 @@ GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) if (!node) return; - child = node->first_node("resource"); - if (child) - { - mAnimation = LoadAttrAnimation(child, "name"); - } + mAnimation = LoadAttrAnimation(FindNode(node, "resource"), "name"); // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); - child = node->first_node("speed"); + child = FindNode(node, "speed"); if (child) { - attr = child->first_attribute("fps"); - if (attr) - mFPS = atoi(attr->value()); - attr = child->first_attribute("render"); - if (attr) - mRender = atoi(attr->value()); + mFPS = LoadAttrInt(child, "fps", mFPS); + mRender = LoadAttrInt(child, "render", mRender); } if (mFPS > 30) mFPS = 30; - child = node->first_node("loop"); + child = FindNode(node, "loop"); if (child) { - attr = child->first_attribute("frame"); + xml_attribute<>* attr = child->first_attribute("frame"); if (attr) mLoop = atoi(attr->value()) - 1; - attr = child->first_attribute("start"); - if (attr) - mFrame = atoi(attr->value()); + mFrame = LoadAttrInt(child, "start", mFrame); } // Fetch the render sizes diff --git a/gui/button.cpp b/gui/button.cpp index 6ea0beec9..18b5560c4 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -63,15 +63,11 @@ GUIButton::GUIButton(xml_node<>* node) mButtonLabel = new GUIText(node); mAction = new GUIAction(node); - child = node->first_node("image"); - if (child) + mButtonImg = new GUIImage(node); + if (mButtonImg->Render() < 0) { - mButtonImg = new GUIImage(node); - if (mButtonImg->Render() < 0) - { - delete mButtonImg; - mButtonImg = NULL; - } + delete mButtonImg; + mButtonImg = NULL; } if (mButtonLabel->Render() < 0) { @@ -79,45 +75,22 @@ GUIButton::GUIButton(xml_node<>* node) mButtonLabel = NULL; } // Load fill if it exists - memset(&mFillColor, 0, sizeof(COLOR)); - child = node->first_node("fill"); - if (child) - { - attr = child->first_attribute("color"); - if (attr) { - hasFill = true; - std::string color = attr->value(); - ConvertStrToColor(color, &mFillColor); - } - } + mFillColor = LoadAttrColor(FindNode(node, "fill"), "color", &hasFill); if (!hasFill && mButtonImg == NULL) { LOGERR("No image resource or fill specified for button.\n"); } // The icon is a special case - child = node->first_node("icon"); - if (child) - { - mButtonIcon = LoadAttrImage(child, "resource"); - } + mButtonIcon = LoadAttrImage(FindNode(node, "icon"), "resource"); - memset(&mHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("highlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasHighlightColor = true; - std::string color = attr->value(); - ConvertStrToColor(color, &mHighlightColor); - } - } + mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlightColor); int x, y, w, h; TextPlacement = TOP_LEFT; if (mButtonImg) { mButtonImg->GetRenderPos(x, y, w, h); } else if (hasFill) { - LoadPlacement(node->first_node("placement"), &x, &y, &w, &h, &TextPlacement); + LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h, &TextPlacement); } SetRenderPos(x, y, w, h); } diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp index f4900ba2c..46a770861 100644 --- a/gui/checkbox.cpp +++ b/gui/checkbox.cpp @@ -45,7 +45,7 @@ GUICheckbox::GUICheckbox(xml_node<>* node) mLabel = new GUIText(node); // Read the check states - child = node->first_node("image"); + child = FindNode(node, "image"); if (child) { mChecked = LoadAttrImage(child, "checked"); @@ -53,7 +53,7 @@ GUICheckbox::GUICheckbox(xml_node<>* node) } // Get the variable data - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("variable"); diff --git a/gui/console.cpp b/gui/console.cpp index bb70400c9..3623f5558 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -101,7 +101,6 @@ extern "C" void gui_set_FILE(FILE* f) GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node) { - xml_attribute<>* attr; xml_node<>* child; mFont = NULL; @@ -126,13 +125,9 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node) } else { - child = node->first_node("font"); - if (child) - { - mFont = LoadAttrFont(child, "resource"); - } + mFont = LoadAttrFont(FindNode(node, "font"), "resource"); - child = node->first_node("color"); + child = FindNode(node, "color"); if (child) { mForegroundColor = LoadAttrColor(child, "foreground", mForegroundColor); @@ -141,9 +136,9 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIObject(node) } // Load the placement - LoadPlacement(node->first_node("placement"), &mConsoleX, &mConsoleY, &mConsoleW, &mConsoleH); + LoadPlacement(FindNode(node, "placement"), &mConsoleX, &mConsoleY, &mConsoleW, &mConsoleH); - child = node->first_node("slideout"); + child = FindNode(node, "slideout"); if (child) { mSlideout = 1; diff --git a/gui/devices/landscape/res/landscape.xml b/gui/devices/landscape/res/landscape.xml index eb6d9ddd6..fd5fcfe42 100644 --- a/gui/devices/landscape/res/landscape.xml +++ b/gui/devices/landscape/res/landscape.xml @@ -1,6 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,11 +116,8 @@ - - Install - install @@ -27,65 +125,44 @@ - - Backup - backup - - Restore - restore - - Wipe - wipe - - Mount - mount - - Settings - settings - - Advanced - advanced - - Reboot - reboot @@ -95,17 +172,13 @@ - - + Select Zip to Install - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=install @@ -114,32 +187,16 @@ - -
- Folders: - - - - -
- -
- %tw_zip_location% - - - - - @@ -149,11 +206,8 @@ - - Images... - install_image @@ -183,72 +237,57 @@ - - + WARNING: This operation may install incompatible software and render your device unusable. - - + Folder: - - + %tw_zip_location% - - + File to flash: - - + %tw_file% - - + Press back to cancel adding this zip. - Zip file signature verification? - - - + File %tw_zip_queue_count% of max of 10 - - + - Add More Zips - install - - + - Clear Queue - install @@ -256,15 +295,8 @@ - - - flash_zip - - - - - Swipe to Confirm Flash + flash_zip @@ -288,14 +320,12 @@ - - + Flashing file %tw_zip_index% of %tw_zip_queue_count% - - + %tw_filename% @@ -313,26 +343,23 @@ - + - + Failed - + - + Successful - - Wipe Cache/Dalvik - tw_back=flash_done tw_action=wipe @@ -348,36 +375,13 @@ - - - + - - Reboot System - - - tw_back=main2 - tw_action=reboot - tw_action_param=system - tw_has_action2=0 - tw_text1=No OS Installed! Are you - tw_text2=sure you wish to reboot? - tw_text3= - tw_text4= - tw_action_text1=Rebooting... - tw_action_text2= - tw_complete_text1=Rebooting... - tw_slider_text=Swipe to Reboot - rebootcheck - - - Home - tw_clear_destination=main2 clear_vars @@ -404,17 +408,13 @@ - - + Select Image to Flash - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=install_image @@ -423,32 +423,16 @@ - -
- Folders: - - - - -
- -
- %tw_zip_location% - - - - - @@ -458,11 +442,8 @@ - - Zips... - install @@ -490,46 +471,35 @@ - -
- Select Partition to Flash Image: - - -
- - + Folder: - - + %tw_zip_location% - - + File to flash: - - + %tw_file% - - + Swipe to Confirm Flash tw_back=flashimage_confirm tw_action=flashimage @@ -542,12 +512,6 @@ - - - - Swipe to Confirm Flash - - @@ -592,46 +556,34 @@ - - + %tw_text1% - - + %tw_text2% - - + %tw_text3% - - + %tw_text4% - - + Press back button to cancel. - - - action_page - - - - - %tw_slider_text% + action_page @@ -653,14 +605,12 @@ - - + %tw_action_text1% - - + %tw_action_text2% @@ -668,12 +618,9 @@ - - - + Cancel - %tw_cancel_param% @@ -705,14 +652,12 @@ - - + %tw_action_text1% - - + %tw_action_text2% @@ -747,22 +692,21 @@ - - + %tw_complete_text1% - + - + Failed - + - + Successful @@ -770,40 +714,18 @@ - - Back - tw_clear_destination=%tw_back% clear_vars - - + - - Reboot System - - - tw_back=main2 - tw_action=reboot - tw_action_param=system - tw_has_action2=0 - tw_text1=No OS Installed! Are you - tw_text2=sure you wish to reboot? - tw_text3= - tw_text4= - tw_action_text1=Rebooting... - tw_action_text2= - tw_complete_text1=Rebooting... - tw_slider_text=Swipe to Reboot - rebootcheck - @@ -866,40 +788,20 @@ - - + Reboot Menu - - - + - System - - - tw_back=reboot - tw_action=reboot - tw_action_param=system - tw_has_action2=0 - tw_text1=No OS Installed! Are you - tw_text2=sure you wish to reboot? - tw_action_text1=Rebooting... - tw_complete_text1=Rebooting... - tw_slider_text=Swipe to Reboot - rebootcheck - - - Power Off - tw_back=reboot tw_action=reboot @@ -915,12 +817,9 @@ - - Recovery - tw_back=reboot tw_action=reboot @@ -936,12 +835,9 @@ - - Bootloader - tw_back=reboot tw_action=reboot @@ -957,12 +853,9 @@ - - Download - tw_back=reboot tw_action=reboot @@ -994,25 +887,16 @@ - -
- Select Storage: - - -
- - OK - tw_clear_destination=%tw_back% clear_vars @@ -1037,91 +921,66 @@ - - + Mount Menu - -
- Select Partitions to Mount: - - - -
- - Decrypt Data - decrypt - Mount USB Storage - usb_mount - - Enable MTP - - - Disable MTP - - - Decrypt Data - decrypt - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=mount @@ -1145,24 +1004,14 @@ - + - USB Storage Mounted -- Be sure to safely remove your device from your computer before unmounting! - - - - - - - - Unmount - usb_umount @@ -1188,58 +1037,47 @@ - - + Factory Reset: Wipes Data, Cache, and Dalvik - + - (not including internal storage) - + - Android Secure - + - SD-EXT - - + Most of the time this is the only wipe that you need. - - Advanced Wipe - advancedwipe - - Format Data - formatdata @@ -1250,11 +1088,8 @@ - - Wipe Encryption - tw_back=wipe tw_action=wipe @@ -1269,15 +1104,13 @@ - - + Press back button to cancel. - - + Swipe to Factory Reset tw_back=wipe tw_action=wipe @@ -1288,12 +1121,6 @@ - - - - Swipe to Factory Reset - - main @@ -1311,24 +1138,14 @@ - -
- Select Partitions to Wipe: - - - -
- - - + - Repair or Change File System @@ -1336,16 +1153,15 @@ - + - + Invalid partition selection - - + Swipe to Wipe tw_back=advancedwipe tw_action=wipe @@ -1357,12 +1173,6 @@ - - - - Swipe to Wipe - - main @@ -1379,35 +1189,28 @@ - - + Format Data will wipe all of your apps, backups, pictures, - - + videos, media, and removes encryption on internal storage. - - + This cannot be undone. Press back to cancel. - - + Type yes to continue. - - - %tw_confirm_formatdata% @@ -1471,83 +1274,69 @@ - - + Partition Options for: %tw_partition_name% - - + Mount Point: %tw_partition_mount_point% - - + Current file system: %tw_partition_file_system% - + - Present: Yes - + - Present: No - + - Removable: Yes - + - Removable: No - - + Size: %tw_partition_size%MB - - + Used: %tw_partition_used%MB - - + Free: %tw_partition_free%MB - - + Backup Size: %tw_partition_backup_size%MB - - Repair - tw_back=partitionoptions tw_action=repair @@ -1563,11 +1352,8 @@ - - Change File System - selectfilesystem @@ -1607,37 +1393,30 @@ - - + Change file system for: %tw_partition_name% - - + Mount Point: %tw_partition_mount_point% - - + Current file system: %tw_partition_file_system% - - + Some ROMs or kernels may not support some file systems. Proceed with caution! - - EXT2 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1655,11 +1434,8 @@ - - EXT3 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1677,11 +1453,8 @@ - - EXT4 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1699,11 +1472,8 @@ - - F2FS - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1721,11 +1491,8 @@ - - FAT - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1743,11 +1510,8 @@ - - exFAT - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1779,38 +1543,26 @@ - - + Back Up Device - -
- Select Partitions to Back Up: - - - -
- - + Backup Name: %tw_backup_name% - - Refresh Sizes - backup @@ -1818,22 +1570,16 @@ - - Set Backup Name - tw_fileexists=0 backupname1 - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=backup @@ -1841,30 +1587,24 @@ - + - - - No Encryption backupencryption - + - - - Using Encryption backupencryption @@ -1873,35 +1613,24 @@ - Enable Compression (Requires more time) - - Skip MD5 generation on backups - - - + Swipe to Back Up tw_operation_state=0 backup_run - - - - Swipe to Back Up - - main @@ -1929,17 +1658,13 @@ - + - Please Enter a Backup Name - - - %tw_backup_name% @@ -1951,28 +1676,22 @@ - + - + A backup with that name already exists! - - Append Date - - - Cancel / Clear - tw_backup_name=(Auto Generate) backup @@ -2003,36 +1722,29 @@ - - + Encrypt your backup? Please enter a password: - - - %tw_backup_encrypt_display% backupencryption2 - + - + Passwords Do Not Match - - Cancel - tw_encrypt_backup=0 tw_backup_password= @@ -2061,17 +1773,13 @@ - - + Encrypt your backup? Please Enter Password Again: - - - %tw_backup_encrypt_display2% @@ -2081,11 +1789,8 @@ - - Cancel - tw_encrypt_backup=0 tw_backup_password= @@ -2137,32 +1842,26 @@ - - + %tw_operation% %tw_partition% - - + %tw_file_progress% - - + %tw_size_progress% - - - - + + Cancel - @@ -2202,11 +1901,8 @@ - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=restore @@ -2215,16 +1911,8 @@ - -
- Select Package to Restore: - - - - - @@ -2274,17 +1962,13 @@ - - + Backup encrypted. Please enter your password: - - - %tw_restore_display% @@ -2293,19 +1977,16 @@ - + - + Password Failed, Please Try Again - - Cancel - tw_page_done=1 restore @@ -2313,11 +1994,8 @@ - - Delete - tw_back=restore tw_action=cmd @@ -2349,8 +2027,7 @@ - - + Trying Decryption with Your Password @@ -2389,46 +2066,32 @@ - - + Package to Restore: %tw_restore_name% - - + Package Date: %tw_restore_file_date% - -
- Select Partitions to Restore: - - - -
- Enable MD5 checking of backup files - - - Rename Backup - tw_backup_rename= tw_fileexists=0 @@ -2437,11 +2100,8 @@ - - Delete Backup - tw_back=restore tw_action=cmd @@ -2456,15 +2116,8 @@ - - - restore_run - - - - - Swipe to Restore + restore_run @@ -2483,17 +2136,13 @@ - + - Please Enter a New Backup Name - - - %tw_backup_rename% @@ -2513,19 +2162,16 @@ - + - + A backup with that name already exists! - - Cancel - restore_select @@ -2547,14 +2193,12 @@ - - + %tw_operation% %tw_partition% - - + %tw_size_progress% @@ -2581,102 +2225,75 @@ - - + Settings - Zip file signature verification? - - + > - Use rm -rf instead of formatting? - - Skip MD5 generation on backups - - Enable MD5 checking of backup files - - Use 24-hour clock - - Simulate most actions for theme testing - - Simulate failure for actions - - - Time Zone - timezone - - Restore Defaults - - - Vibration Duration - Vibrate - - Screen - screen @@ -2696,22 +2313,15 @@ - - + Select Time Zone - - + -
- Select Time Zone: - - - BST11;BDT HST10;HDT @@ -2741,65 +2351,46 @@ - Do you use daylight savings time (DST)? - - - + Offset (usually 0): %tw_time_zone_guioffset% - - + - 0 - tw_time_zone_guioffset=0 - - + - 15 - tw_time_zone_guioffset=15 - - + - 30 - tw_time_zone_guioffset=30 - - + - 45 - tw_time_zone_guioffset=45 - - Set Time Zone - - - + Current Time Zone: %tw_time_zone% @@ -2820,15 +2411,13 @@ - - + Screen Settings - Enable screen timeout. @@ -2838,7 +2427,6 @@ - Enable screen timeout. @@ -2847,12 +2435,11 @@ - - + + + + - - - Screen timeout in seconds: @@ -2860,9 +2447,6 @@ - - - Brightness: %tw_brightness_pct%% @@ -2889,15 +2473,13 @@ - - + Vibration Settings : - Button Vibration: @@ -2905,7 +2487,6 @@ - Keyboard Vibration: @@ -2913,7 +2494,6 @@ - Action Vibration: @@ -2935,18 +2515,14 @@ - - + Advanced - - Copy Log to SD - tw_back=advanced tw_action=copylog @@ -2959,67 +2535,46 @@ - - Fix Permissions - fixperms - - Terminal Command - terminalfolder - - ADB Sideload - sideload - - Partition SD Card - partsdcard - - File Manager - filemanagerlist - - Reload Theme - - - HTC Dumlock - htcdumlock @@ -3039,100 +2594,79 @@ - - + Partition SD Card - - tw_sdext_size-128 - - tw_sdext_size+128 - - + EXT Size: %tw_sdext_size% - - tw_swap_size-32 - - tw_swap_size+32 - - + Swap Size: %tw_swap_size% - - + File system: %tw_sdpart_file_system% - - + - EXT3 - tw_sdpart_file_system=ext3 - - + - EXT4 - tw_sdpart_file_system=ext4 - - + You will lose all files on your SD card! - - + This action cannot be undone! - - + Swipe to Confirm Partition tw_back=partsdcard tw_action=partitionsd @@ -3146,12 +2680,6 @@ - - - - Swipe to Confirm Partition - - main @@ -3169,19 +2697,14 @@ - - + HTC Dumlock - - - Restore Original Boot - tw_back=htcdumlock tw_action=htcdumlockrestoreboot @@ -3194,12 +2717,8 @@ - - - Reflash Recovery->Boot - tw_back=htcdumlock tw_action=htcdumlockreflashrecovery @@ -3212,12 +2731,8 @@ - - - Install HTC Dumlock - tw_back=htcdumlock tw_action=installhtcdumlock @@ -3251,15 +2766,8 @@ - - - - - - - - Swipe to Unlock + @@ -3267,23 +2775,14 @@ - - + File Manager: Select a File or Folder - -
- Folders: - - - - - @@ -3291,16 +2790,8 @@
- -
- %tw_file_location1% - - - - - @@ -3334,11 +2825,8 @@
- - Select Folder - tw_filename1=tw_file_location1 tw_fm_isfolder=1 @@ -3353,25 +2841,20 @@ - - + %tw_fm_type% Selected: - - + %tw_filename1% - - Copy File - tw_filemanager_command=cp tw_fm_text1=Copying @@ -3380,12 +2863,9 @@ - - Copy Folder - tw_filemanager_command=cd "%tw_file_location1%" && cd .. && cp -R tw_fm_text1=Copying @@ -3394,11 +2874,8 @@ - - Move - tw_filemanager_command=mv tw_fm_text1=Moving @@ -3407,11 +2884,8 @@ - - chmod 755 - tw_filemanager_command=chmod 755 tw_fm_text1=chmod 755 @@ -3424,11 +2898,8 @@ - - chmod - tw_filemanager_rename=0000 tw_fm_text2= @@ -3440,11 +2911,8 @@ - - Delete - tw_filemanager_command=rm -rf tw_fm_text1=Deleting @@ -3457,12 +2925,9 @@ - - Rename File - tw_filemanager_rename=tw_selection1 tw_fm_text1=Renaming @@ -3472,12 +2937,9 @@ - - Rename Folder - tw_filemanager_rename=tw_selection1 tw_fm_text1=Renaming @@ -3502,22 +2964,14 @@ - - + Browse to Destination Folder & Press Select - -
- %tw_file_location2% - - - - @@ -3537,11 +2991,8 @@
- - Select Folder - tw_fm_text2=to tw_fm_text3=%tw_file_location2% @@ -3557,17 +3008,14 @@ - + - + Please Enter a New %tw_fm_type% Name - - - %tw_filemanager_rename% @@ -3581,11 +3029,8 @@ - - Cancel - filemanageroptions @@ -3607,17 +3052,13 @@ - + - Please Enter a New %tw_fm_type% Name - - - %tw_filemanager_rename% @@ -3631,11 +3072,8 @@ - - Cancel - filemanageroptions @@ -3657,17 +3095,13 @@ - + - Please Enter New Permissions - - - %tw_filemanager_rename% @@ -3680,11 +3114,8 @@ - - Cancel - filemanageroptions @@ -3706,48 +3137,35 @@ - - + %tw_fm_text1% - - + %tw_filename1% - - + %tw_fm_text2% - - + %tw_fm_text3% - - + Press back button to cancel. - - filemanageracction - - - - Swipe to Confirm - - %tw_back% @@ -3764,8 +3182,7 @@ - - + %tw_fm_text1% @@ -3815,17 +3232,13 @@ - - + Please Enter Your Password - - - %tw_crypto_display% @@ -3834,19 +3247,16 @@ - + - + Password Failed, Please Try Again - - Cancel - tw_page_done=1 main @@ -3861,8 +3271,7 @@ - - + Trying Decryption with Your Password @@ -3901,23 +3310,14 @@ - - + Browse to Starting Folder - -
- %tw_terminal_location% - - - - - @@ -3937,11 +3337,8 @@
- - Select Folder - terminalcommand @@ -3955,42 +3352,31 @@ - - - + - Starting Path: %tw_terminal_location% - - - %tw_terminal_command% %tw_terminal_command% - - + - KILL - - - @@ -3998,9 +3384,7 @@ - - @@ -4033,31 +3417,25 @@ - - + ADB Sideload - Wipe Dalvik Cache. - - Wipe Cache. - - - + Swipe to Start Sideload tw_back=advanced tw_action=adbsideload @@ -4071,12 +3449,6 @@ - - - - Swipe to Start Sideload - - main @@ -4093,35 +3465,29 @@ - - + Fix Permissions - - + Note: Fixing permissions is rarely needed. - Also fix SELinux contexts - - - + Fixing SELinux contexts may cause your device to not boot properly. - - + Swipe to Fix Permissions tw_back=advanced tw_action=fixpermissions @@ -4133,12 +3499,6 @@ - - - - Swipe to Fix Permissions - - main @@ -4155,36 +3515,29 @@ - - + Install SuperSU? - - + Your device does not appear to be rooted. - - + Install SuperSU now? This will root your device. - - Do Not Install - tw_page_done=1 - - + Swipe to Install tw_action=installsu tw_action_text1=Installing SuperSU @@ -4192,12 +3545,6 @@ singleaction_page - - - - - Swipe to Install - diff --git a/gui/devices/portrait/res/portrait.xml b/gui/devices/portrait/res/portrait.xml index fe6167155..6fb52f300 100644 --- a/gui/devices/portrait/res/portrait.xml +++ b/gui/devices/portrait/res/portrait.xml @@ -1,6 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,11 +111,8 @@ - - Install - install @@ -27,66 +120,44 @@ - - Wipe - wipe - - Backup - backup - - Restore - restore - - Mount - mount - - Settings - settings - - - Advanced - advanced - - Reboot - reboot @@ -96,17 +167,13 @@ - - + Select Zip to Install - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=install @@ -115,16 +182,8 @@ - -
- %tw_zip_location% - - - - - @@ -133,12 +192,9 @@ - - + - Images... - install_image @@ -168,99 +224,76 @@ - - + This operation may install incompatible - - + software and render your device unusable. - - + Folder: - - + + %tw_zip_location% - - + File to flash: - - + + %tw_file% - - + Press back to cancel adding this zip. - Zip file signature verification. - - Inject TWRP after install. - - - + File %tw_zip_queue_count% of max of 10 - - - flash_zip - - - - - Swipe to Confirm Flash + flash_zip - - Add More Zips - install - - Clear Zip Queue - install @@ -288,18 +321,15 @@ - - - - + Flashing file %tw_zip_index% of %tw_zip_queue_count% - - + + %tw_filename% @@ -315,24 +345,18 @@ - - + Zip Install Complete - - - - Wipe cache/dalvik - tw_back=flash_done tw_action=wipe @@ -349,50 +373,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -17,75 +113,51 @@ - - Install - install_select - - Wipe - wipe - - Backup - backup - - Restore - restore - - Mount - mount - - Settings - settings - - Advanced - advanced - - Reboot - reboot @@ -98,11 +170,8 @@ - - Install Zips - install @@ -110,11 +179,8 @@ - - Install Images - install_image @@ -134,17 +200,13 @@ - - + Select Zip to Install - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=install @@ -153,16 +215,8 @@ - -
- %tw_zip_location% - - - - - @@ -195,93 +249,71 @@ - - + This operation may install incompatible - - + software and render your device unusable. - - + Folder and File: - - + + %tw_zip_location% - - + + %tw_file% - - + Press back to cancel adding this zip. - Zip file signature verification. - - Inject TWRP after install. - - - + File %tw_zip_queue_count% of max of 10 - - - flash_zip - - - - - Swipe to Confirm Flash + flash_zip - - Add More Zips - install - - Clear Zip Queue - install @@ -307,19 +339,16 @@ - - - - - + + Flashing file %tw_zip_index% of %tw_zip_queue_count% - - - + + + %tw_filename% @@ -334,24 +363,18 @@ - - + Zip Install Complete - - - - Wipe cache/dalvik - tw_back=flash_done tw_action=wipe @@ -367,39 +390,20 @@ - - + - - Reboot System - - - tw_back=main2 - tw_action=reboot - tw_action_param=system - tw_has_action2=0 - tw_text1=No OS Installed! Are you - tw_text2=sure you wish to reboot? - tw_text3= - tw_text4= - tw_action_text1=Rebooting... - tw_action_text2= - tw_complete_text1=Rebooting... - tw_slider_text=Swipe to Reboot - rebootcheck - - + - + Failed - + - + Successful @@ -424,17 +428,13 @@ - - + Select Image to Install - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=install_image @@ -443,16 +443,8 @@ - -
- %tw_zip_location% - - - - - @@ -483,46 +475,37 @@ - -
- Select Partition to Flash Image: - - -
- - + Folder: - - + + %tw_zip_location% - - + File to flash: - - + + %tw_file% - - + Swipe to Confirm Flash tw_back=flashimage_confirm tw_action=flashimage @@ -535,12 +518,6 @@ - - - - Swipe to Confirm Flash - - @@ -583,46 +560,34 @@ - - + %tw_text1% - - + %tw_text2% - - + %tw_text3% - - + %tw_text4% - - + Press back button to cancel. - - - action_page - - - - - %tw_slider_text% + action_page @@ -642,27 +607,22 @@ - - + %tw_action_text1% - - + %tw_action_text2% - - + - Cancel - %tw_cancel_param% @@ -694,14 +654,12 @@ - - + %tw_action_text1% - - + %tw_action_text2% @@ -736,22 +694,21 @@ - - + %tw_complete_text1% - + - + Failed - + - + Successful @@ -818,66 +775,55 @@ - - + Factory Reset - - + Wipes Data, Cache, and Dalvik - + - (not including internal storage) - + - Android Secure - + - SD-EXT - - + Most of the time this is - - + the only wipe that you need. - - + Press back button to cancel. - - Advanced Wipe - partitionlisterror=0 advancedwipe @@ -886,11 +832,8 @@ - - Format Data - formatdata @@ -901,11 +844,8 @@ - - Wipe Encryption - tw_back=wipe tw_action=wipe @@ -921,8 +861,7 @@ - - + Swipe to Factory Reset tw_back=wipe tw_action=wipe @@ -933,12 +872,6 @@ - - - - Swipe to Factory Reset - - main @@ -957,29 +890,20 @@ tw_wipe_list= - - + Wipe Menu - -
- Select Partitions to Wipe: - - - -
- - + Swipe to Wipe tw_back=advancedwipe tw_action=wipe @@ -991,11 +915,8 @@ - - - + - Repair or Change File System @@ -1003,19 +924,13 @@ - + - + Invalid partition selection - - - - Swipe to Wipe - - main @@ -1030,41 +945,33 @@ - - + Format Data will wipe all of your apps, - - + backups, pictures, videos, media, and - - + removes encryption on internal storage. - - + This cannot be undone. Press back to cancel. - - + Type yes to continue. - - - %tw_confirm_formatdata% @@ -1128,83 +1035,69 @@ - - + Partition Options for: %tw_partition_name% - - + Mount Point: %tw_partition_mount_point% - - + Current file system: %tw_partition_file_system% - + - Present: Yes - + - Present: No - + - Removable: Yes - + - Removable: No - - + Size: %tw_partition_size%MB - - + Used: %tw_partition_used%MB - - + Free: %tw_partition_free%MB - - + Backup Size: %tw_partition_backup_size%MB - - Repair - tw_back=partitionoptions tw_action=repair @@ -1220,11 +1113,8 @@ - - Change File Sys - selectfilesystem @@ -1264,37 +1154,30 @@ - - + Change file system for: %tw_partition_name% - - + Mount Point: %tw_partition_mount_point% - - + Current file system: %tw_partition_file_system% - - + Proceed with caution! - - EXT2 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1312,11 +1195,8 @@ - - EXT3 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1334,11 +1214,8 @@ - - EXT4 - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1356,11 +1233,8 @@ - - F2FS - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1378,11 +1252,8 @@ - - FAT - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1400,11 +1271,8 @@ - - exFAT - tw_back=refreshfilesystem tw_action=changefilesystem @@ -1436,11 +1304,8 @@ - - - + - Backup Name: %tw_backup_name% tw_fileexists=0 @@ -1449,33 +1314,20 @@ - -
- Select Partitions to Back Up: - - - -
- - - + - More... backupoptions - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=backup @@ -1485,22 +1337,13 @@ - Compression - - - - backup_run - - - - - Swipe to Back Up + backup_run @@ -1517,36 +1360,29 @@ - - + More Backup Options - + - - - No Encryption backupencryption - + - - - Using Encryption tw_password_not_match=0 @@ -1554,11 +1390,8 @@ - - - + - Refresh Sizes @@ -1566,11 +1399,8 @@ - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=backupotions @@ -1580,18 +1410,14 @@ - Enable compression. - - Skip MD5 generation during backup. - @@ -1619,17 +1445,13 @@ - + - Please Enter a Backup Name - - - %tw_backup_name% @@ -1641,28 +1463,22 @@ - + - + A backup with that name already exists! - - Append Date - - - Cancel - tw_backup_name=(Auto Generate) backup @@ -1693,42 +1509,34 @@ - - + Encrypt your backup? - - + Please Enter A Password: - - - %tw_backup_encrypt_display% backupencryption2 - + - + Passwords Do Not Match - - Cancel - tw_encrypt_backup=0 tw_backup_password= @@ -1757,23 +1565,18 @@ - - + Encrypt your backup? - - + Please Enter Password Again: - - - %tw_backup_encrypt_display2% @@ -1783,11 +1586,8 @@ - - Cancel - tw_encrypt_backup=0 tw_backup_password= @@ -1839,20 +1639,17 @@ - - + %tw_operation% %tw_partition% - - + %tw_file_progress% - - + %tw_size_progress% @@ -1863,12 +1660,9 @@ - - + - Cancel - @@ -1906,11 +1700,8 @@ - - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=restore @@ -1919,16 +1710,8 @@ - -
- Select Package to Restore: - - - - - @@ -1978,23 +1761,18 @@ - - + Backup Encrypted - - + Please Enter Your Password: - - - %tw_restore_display% @@ -2003,19 +1781,16 @@ - + - + Password Failed, Please Try Again - - Cancel - tw_page_done=1 restore @@ -2023,11 +1798,8 @@ - - Delete - tw_back=restore tw_action=cmd @@ -2059,8 +1831,7 @@ - - + Trying Decryption with Your Password @@ -2100,24 +1871,14 @@ - -
- Restoring: %tw_restore_name% - - - -
- - - + - Rename Backup tw_backup_rename= @@ -2126,11 +1887,8 @@ - - - + - Delete Backup tw_back=restore @@ -2147,22 +1905,13 @@ - Enable MD5 verification of backup. - - - - restore_run - - - - - Swipe to Restore + restore_run @@ -2179,17 +1928,13 @@ - + - Please Enter a New Backup Name - - - %tw_backup_rename% @@ -2209,19 +1954,16 @@ - + - + A backup with that name already exists! - - Cancel - restore_select @@ -2243,14 +1985,12 @@ - - + %tw_operation% %tw_partition% - - + %tw_size_progress% @@ -2278,25 +2018,16 @@ - -
- Select Storage: - - -
- - OK - tw_clear_destination=%tw_back% clear_vars @@ -2322,23 +2053,13 @@ - -
- Select Partitions to Mount: - - - -
- - - + - Storage: %tw_storage_display_name% (%tw_storage_free_size% MB) tw_back=mount @@ -2347,51 +2068,39 @@ - - USB Storage - usb_mount - - Enable MTP - - - Disable MTP - - - Decrypt Data - decrypt @@ -2411,8 +2120,7 @@ - - + USB Storage Mounted @@ -2423,18 +2131,14 @@ Be sure to safely remove your device - + - from your computer before unmounting! - - Unmount - usb_umount @@ -2458,40 +2162,20 @@ - - + Reboot Menu - - - System - - - tw_back=reboot - tw_action=reboot - tw_action_param=system - tw_has_action2=0 - tw_text1=No OS Installed! Are you - tw_text2=sure you wish to reboot? - tw_action_text1=Rebooting... - tw_complete_text1=Rebooting... - tw_slider_text=Swipe to Reboot - rebootcheck - - - Power Off - tw_back=reboot tw_action=reboot @@ -2507,12 +2191,9 @@ - - Recovery - tw_back=reboot tw_action=reboot @@ -2528,12 +2209,9 @@ - - Bootloader - tw_back=reboot tw_action=reboot @@ -2549,12 +2227,9 @@ - - Download - tw_back=reboot tw_action=reboot @@ -2587,94 +2262,68 @@ - Zip file signature verification. - - Use rm -rf instead of formatting. - - Skip MD5 generation during backup. - - Enable MD5 verification of backup files. - - Use 24-hour clock. - - Simulate actions for theme testing. - - Simulate failure for actions. - - - Time Zone - timezone - - Screen - screen - - Restore Defaults - - - Vibration - vibrate @@ -2694,16 +2343,10 @@ - - + -
- Select Time Zone: - - - BST11;BDT HST10;HDT @@ -2733,65 +2376,46 @@ - Do you use daylight savings time (DST)? - - - + Offset (usually 0): %tw_time_zone_guioffset% - - + - None - tw_time_zone_guioffset=0 - - + - 15 - tw_time_zone_guioffset=15 - - + - 30 - tw_time_zone_guioffset=30 - - + - 45 - tw_time_zone_guioffset=45 - - Set Time Zone - - - + Current Time Zone: %tw_time_zone% @@ -2810,8 +2434,7 @@ - - + Screen Settings @@ -2837,12 +2460,11 @@ - - + + + + - - - Screen timeout in seconds: @@ -2850,9 +2472,6 @@ - - - Brightness: %tw_brightness_pct%% @@ -2879,34 +2498,27 @@ - - + Vibration Settings : - Button Vibration: - - Keyboard Vibration: - - Action Vibration: - @@ -2925,18 +2537,14 @@ - - + Advanced - - Copy Log to SD - tw_back=advanced tw_action=copylog @@ -2949,77 +2557,53 @@ - - Fix Permissions - fixperms - - Partition SD Card - partsdcard - - File Manager - filemanagerlist - - Terminal Command - terminalfolder - - Reload Theme - - - ADB Sideload - sideload - - HTC Dumlock - htcdumlock - - Re-Inject TWRP - tw_back=advanced tw_action=reinjecttwrp @@ -3047,101 +2631,81 @@ - - + Partition SD Card - - tw_sdext_size-128 - - tw_sdext_size+128 - - + EXT Size: %tw_sdext_size% - - tw_swap_size-32 - - tw_swap_size+32 - - + Swap Size: %tw_swap_size% - - + File system: %tw_sdpart_file_system% - EXT3 - tw_sdpart_file_system=ext3 - - EXT4 tw_sdpart_file_system=ext4 - - + You will lose all files on your SD card! - - + This action cannot be undone! - - - partsdcardaction + Swipe to Partition tw_back=partsdcard tw_action=partitionsd @@ -3155,12 +2719,6 @@ - - - - Swipe to Partition - - main @@ -3175,19 +2733,14 @@ - - + HTC Dumlock - - - Restore Original Boot - tw_back=htcdumlock tw_action=htcdumlockrestoreboot @@ -3200,12 +2753,8 @@ - - - Reflash Recovery - tw_back=htcdumlock tw_action=htcdumlockreflashrecovery @@ -3218,12 +2767,8 @@ - - - Install HTC Dumlock - tw_back=htcdumlock tw_action=installhtcdumlock @@ -3257,38 +2802,22 @@ - - - - - - - - Swipe to Unlock + - - + File Manager: Select a File or Folder - -
- %tw_file_location1% - - - - - @@ -3321,12 +2850,9 @@
- - + - Select - tw_filename1=tw_file_location1 tw_fm_isfolder=1 @@ -3339,25 +2865,20 @@ - - + %tw_fm_type% Selected: - - + %tw_filename1% - - Copy File - tw_filemanager_command=cp tw_fm_text1=Copying @@ -3366,12 +2887,9 @@ - - Copy Folder - tw_filemanager_command=cd "%tw_file_location1%" && cd .. && cp -R tw_fm_text1=Copying @@ -3380,11 +2898,8 @@ - - Move - tw_filemanager_command=mv tw_fm_text1=Moving @@ -3393,11 +2908,8 @@ - - chmod 755 - tw_filemanager_command=chmod 755 tw_fm_text1=chmod 755 @@ -3410,11 +2922,8 @@ - - chmod - tw_filemanager_rename=0000 tw_fm_text2= @@ -3426,11 +2935,8 @@ - - Delete - tw_filemanager_command=rm -rf tw_fm_text1=Deleting @@ -3443,12 +2949,9 @@ - - Rename File - tw_filemanager_rename=tw_selection1 tw_fm_text1=Renaming @@ -3458,12 +2961,9 @@ - - Rename Folder - tw_filemanager_rename=tw_selection1 tw_fm_text1=Renaming @@ -3488,23 +2988,14 @@ - - + Browse to Destination & Press Select - -
- %tw_file_location2% - - - - - @@ -3523,12 +3014,9 @@ filemanageroptions
- - + - Select - tw_fm_text2=to tw_fm_text3=%tw_file_location2% @@ -3542,17 +3030,13 @@ - + - Please Enter a New %tw_fm_type% Name - - - %tw_filemanager_rename% @@ -3566,11 +3050,8 @@ - - Cancel - filemanageroptions @@ -3592,17 +3073,13 @@ - + - Please Enter a New %tw_fm_type% Name - - - %tw_filemanager_rename% @@ -3616,11 +3093,8 @@ - - Cancel - filemanageroptions @@ -3650,9 +3124,6 @@ - - - %tw_filemanager_rename% @@ -3665,11 +3136,8 @@ - - Cancel - filemanageroptions @@ -3691,48 +3159,35 @@ - - + %tw_fm_text1% - - + %tw_filename1% - - + %tw_fm_text2% - - + %tw_fm_text3% - - + Press back button to cancel. - - filemanageracction - - - - Swipe to Confirm - - %tw_back% @@ -3747,9 +3202,7 @@ - - - + %tw_fm_text1% @@ -3799,17 +3252,13 @@ - - + Please Enter Your Password - - - %tw_crypto_display% @@ -3818,19 +3267,16 @@ - + - + Password Failed, Please Try Again - - Cancel - tw_page_done=1 main @@ -3845,8 +3291,7 @@ - - + Trying Decryption with Your Password @@ -3885,23 +3330,14 @@ - - + Browse to Starting Folder - -
- %tw_terminal_location% - - - - - @@ -3920,12 +3356,9 @@ advanced
- - + - Select - terminalcommand @@ -3937,35 +3370,26 @@ - - - + - Starting Path: %tw_terminal_location% - - - %tw_terminal_command% %tw_terminal_command% - - + - KILL - @@ -3985,31 +3409,25 @@ - - + ADB Sideload - Wipe Dalvik Cache. - - Wipe Cache. - - - + Swipe to Start Sideload tw_back=advanced tw_action=adbsideload @@ -4023,12 +3441,6 @@ - - - - Swipe to Start Sideload - - main @@ -4043,41 +3455,34 @@ - - + Fix Permissions - - + Note: Fixing permissions is rarely needed. - Also fix SELinux contexts - - - + Fixing SELinux contexts may cause - - + your device to not boot properly. - - + Swipe to Fix Permissions tw_back=advanced tw_action=fixpermissions @@ -4089,12 +3494,6 @@ - - - - Swipe to Fix Permissions - - main @@ -4111,42 +3510,34 @@ - - + Install SuperSU? - - + Your device does not appear to be rooted. - - + Install SuperSU now? - - + This will root your device. - - Do Not Install - tw_page_done=1 - - + Swipe to Install tw_action=installsu tw_action_text1=Installing SuperSU @@ -4154,12 +3545,6 @@ singleaction_page - - - - - Swipe to Install - diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index 5c287c34d..2602eb257 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -70,8 +70,10 @@ GUIFileSelector::GUIFileSelector(xml_node<>* node) : GUIScrollList(node) if (attr) mPathVar = attr->value(); attr = child->first_attribute("default"); - if (attr) + if (attr) { + mPathDefault = attr->value(); DataManager::SetValue(mPathVar, attr->value()); + } } // Handle the result variable @@ -168,6 +170,8 @@ int GUIFileSelector::NotifyVarChange(const std::string& varName, const std::stri } else { // Reset the list to the top SetVisibleListLocation(0); + if (value.empty()) + DataManager::SetValue(mPathVar, mPathDefault); } updateFileList = true; mUpdate = 1; @@ -288,6 +292,10 @@ void GUIFileSelector::SetPageFocus(int inFocus) { GUIScrollList::SetPageFocus(inFocus); if (inFocus) { + std::string value; + DataManager::GetValue(mPathVar, value); + if (value.empty()) + DataManager::SetValue(mPathVar, mPathDefault); updateFileList = true; mUpdate = 1; } diff --git a/gui/fill.cpp b/gui/fill.cpp index 1ddefaa9b..b315cd08a 100644 --- a/gui/fill.cpp +++ b/gui/fill.cpp @@ -27,23 +27,15 @@ extern "C" { GUIFill::GUIFill(xml_node<>* node) : GUIObject(node) { - xml_attribute<>* attr; - xml_node<>* child; - - if (!node) - return; - - attr = node->first_attribute("color"); - if (!attr) { + bool has_color = false; + mColor = LoadAttrColor(node, "color", &has_color); + if (!has_color) { LOGERR("No color specified for fill\n"); return; } - std::string color = attr->value(); - ConvertStrToColor(color, &mColor); - // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); return; } diff --git a/gui/image.cpp b/gui/image.cpp index 60b1cb956..8b43aaa34 100644 --- a/gui/image.cpp +++ b/gui/image.cpp @@ -27,9 +27,6 @@ extern "C" { GUIImage::GUIImage(xml_node<>* node) : GUIObject(node) { - xml_attribute<>* attr; - xml_node<>* child; - mImage = NULL; mHighlightImage = NULL; isHighlighted = false; @@ -37,15 +34,11 @@ GUIImage::GUIImage(xml_node<>* node) : GUIObject(node) if (!node) return; - child = node->first_node("image"); - if (child) - { - mImage = LoadAttrImage(child, "resource"); - mHighlightImage = LoadAttrImage(child, "highlightresource"); - } + mImage = LoadAttrImage(FindNode(node, "image"), "resource"); + mHighlightImage = LoadAttrImage(FindNode(node, "image"), "highlightresource"); // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement); if (mImage && mImage->GetResource()) { diff --git a/gui/input.cpp b/gui/input.cpp index 299034a2c..ca27ea812 100644 --- a/gui/input.cpp +++ b/gui/input.cpp @@ -85,7 +85,7 @@ GUIInput::GUIInput(xml_node<>* node) } // Load the background - child = node->first_node("background"); + child = FindNode(node, "background"); if (child) { mBackground = LoadAttrImage(child, "resource"); @@ -98,7 +98,7 @@ GUIInput::GUIInput(xml_node<>* node) } // Load the cursor color - child = node->first_node("cursor"); + child = FindNode(node, "cursor"); if (child) { mCursor = LoadAttrImage(child, "resource"); @@ -106,31 +106,26 @@ GUIInput::GUIInput(xml_node<>* node) attr = child->first_attribute("hasfocus"); if (attr) { - std::string color = attr->value(); - SetInputFocus(atoi(color.c_str())); - } - attr = child->first_attribute("width"); - if (attr) - { - std::string cwidth = gui_parse_text(attr->value()); - CursorWidth = scale_theme_x(atoi(cwidth.c_str())); + std::string focus = attr->value(); + SetInputFocus(atoi(focus.c_str())); } + CursorWidth = LoadAttrIntScaleX(child, "width", CursorWidth); } DrawCursor = HasInputFocus; // Load the font - child = node->first_node("font"); + child = FindNode(node, "font"); if (child) { mFont = LoadAttrFont(child, "resource"); mFontHeight = mFont->GetHeight(); } - child = node->first_node("text"); + child = FindNode(node, "text"); if (child) mText = child->value(); mLastValue = gui_parse_text(mText); - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("name"); @@ -139,11 +134,8 @@ GUIInput::GUIInput(xml_node<>* node) attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mVariable, attr->value()); - attr = child->first_attribute("mask"); - if (attr) { - mMask = attr->value(); - HasMask = true; - } + mMask = LoadAttrString(child, "mask"); + HasMask = !mMask.empty(); attr = child->first_attribute("maskvariable"); if (attr) mMaskVariable = attr->value(); @@ -152,33 +144,19 @@ GUIInput::GUIInput(xml_node<>* node) } // Load input restrictions - child = node->first_node("restrict"); + child = FindNode(node, "restrict"); if (child) { - attr = child->first_attribute("minlen"); - if (attr) { - std::string attrib = attr->value(); - MinLen = atoi(attrib.c_str()); - } - attr = child->first_attribute("maxlen"); - if (attr) { - std::string attrib = attr->value(); - MaxLen = atoi(attrib.c_str()); - } - attr = child->first_attribute("allow"); - if (attr) { - HasAllowed = true; - AllowedList = attr->value(); - } - attr = child->first_attribute("disable"); - if (attr) { - HasDisabled = true; - DisabledList = attr->value(); - } + MinLen = LoadAttrInt(child, "minlen", MinLen); + MaxLen = LoadAttrInt(child, "maxlen", MaxLen); + AllowedList = LoadAttrString(child, "allow"); + HasAllowed = !AllowedList.empty(); + DisabledList = LoadAttrString(child, "disable"); + HasDisabled = !DisabledList.empty(); } // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); if (mInputText && mFontHeight && mFontHeight < (unsigned)mRenderH) { diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 5528be936..d0262aac2 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -48,7 +48,8 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) { int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; rowY = colX = -1; - highlightRenderCount = hasHighlight = hasCapsHighlight = 0; + highlightRenderCount = 0; + hasHighlight = hasCapsHighlight = false; char resource[10], layout[8], row[5], key[6], longpress[7]; xml_attribute<>* attr; xml_node<>* child; @@ -66,36 +67,17 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) if (!node) return; // Load the action - child = node->first_node("action"); + child = FindNode(node, "action"); if (child) { mAction = new GUIAction(node); } - memset(&mHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("highlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasHighlight = 1; - std::string color = attr->value(); - ConvertStrToColor(color, &mHighlightColor); - } - } - - memset(&mCapsHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("capshighlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasCapsHighlight = 1; - std::string color = attr->value(); - ConvertStrToColor(color, &mCapsHighlightColor); - } - } + mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight); + mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight); // Load the images for the different layouts - child = node->first_node("layout"); + child = FindNode(node, "layout"); if (child) { layoutindex = 1; @@ -120,7 +102,7 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) // Load all of the layout maps layoutindex = 1; strcpy(layout, "layout1"); - keylayout = node->first_node(layout); + keylayout = FindNode(node, layout); while (keylayout) { if (layoutindex > MAX_KEYBOARD_LAYOUTS) { @@ -212,12 +194,12 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node) } layoutindex++; layout[6] = (char)(layoutindex + 48); - keylayout = node->first_node(layout); + keylayout = FindNode(node, layout); } int x, y, w, h; // Load the placement - LoadPlacement(node->first_node("placement"), &x, &y, &w, &h); + LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h); SetActionPos(x, y, KeyboardWidth, KeyboardHeight); SetRenderPos(x, y, w, h); return; diff --git a/gui/listbox.cpp b/gui/listbox.cpp index 7c7afa957..625b4b7d1 100644 --- a/gui/listbox.cpp +++ b/gui/listbox.cpp @@ -37,7 +37,7 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node) mUpdate = 0; // Get the icons, if any - child = node->first_node("icon"); + child = FindNode(node, "icon"); if (child) { mIconSelected = LoadAttrImage(child, "selected"); mIconUnselected = LoadAttrImage(child, "unselected"); @@ -47,7 +47,7 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node) SetMaxIconSize(iconWidth, iconHeight); // Handle the result variable - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("name"); if (attr) @@ -60,7 +60,7 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node) } // Get the data for the list - child = node->first_node("listitem"); + child = FindNode(node, "listitem"); if (!child) return; while (child) { ListData data; diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp index 625588629..84e6322a4 100644 --- a/gui/mousecursor.cpp +++ b/gui/mousecursor.cpp @@ -51,11 +51,11 @@ void MouseCursor::LoadData(xml_node<>* node) xml_attribute<>* attr; xml_node<>* child; - child = node->first_node("placement"); + child = FindNode(node, "placement"); if(child) LoadPlacement(child, &mRenderX, &mRenderY, &mRenderW, &mRenderH); - child = node->first_node("background"); + child = FindNode(node, "background"); if(child) { m_color = LoadAttrColor(child, "color", m_color); @@ -67,7 +67,7 @@ void MouseCursor::LoadData(xml_node<>* node) } } - child = node->first_node("speed"); + child = FindNode(node, "speed"); if(child) { attr = child->first_attribute("multiplier"); diff --git a/gui/object.cpp b/gui/object.cpp index d496414c3..7cce5db8b 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -35,9 +35,9 @@ GUIObject::GUIObject(xml_node<>* node) if (!node) return; // First, get the action - xml_node<>* condition = node->first_node("conditions"); - if (condition) condition = condition->first_node("condition"); - else condition = node->first_node("condition"); + xml_node<>* condition = FindNode(node, "conditions"); + if (condition) condition = FindNode(condition, "condition"); + else condition = FindNode(node, "condition"); if (!condition) return; diff --git a/gui/objects.hpp b/gui/objects.hpp index b6937a215..ceb2c6c0c 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -649,6 +649,7 @@ protected: std::vector mFolderList; std::vector mFileList; std::string mPathVar; // current path displayed, saved in the data manager + std::string mPathDefault; // default value for the path if none is set in mPathVar std::string mExtn; // used for filtering the file list, for example, *.zip std::string mVariable; // set when the user selects an item, pull path like /path/to/foo std::string mSortVariable; // data manager variable used to change the sorting of files @@ -812,6 +813,7 @@ public: protected: GUIAction* sAction; + GUIText* sSliderLabel; ImageResource* sSlider; ImageResource* sSliderUsed; ImageResource* sTouch; @@ -875,7 +877,8 @@ protected: int currentLayout; int row_heights[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS]; unsigned int KeyboardWidth, KeyboardHeight; - int rowY, colX, highlightRenderCount, hasHighlight, hasCapsHighlight; + int rowY, colX, highlightRenderCount; + bool hasHighlight, hasCapsHighlight; GUIAction* mAction; COLOR mHighlightColor; COLOR mCapsHighlightColor; @@ -1064,10 +1067,12 @@ private: }; // Helper APIs +xml_node<>* FindNode(xml_node<>* parent, const char* nodename, int depth = 0); std::string LoadAttrString(xml_node<>* element, const char* attrname, const char* defaultvalue = ""); int LoadAttrInt(xml_node<>* element, const char* attrname, int defaultvalue = 0); int LoadAttrIntScaleX(xml_node<>* element, const char* attrname, int defaultvalue = 0); int LoadAttrIntScaleY(xml_node<>* element, const char* attrname, int defaultvalue = 0); +COLOR LoadAttrColor(xml_node<>* element, const char* attrname, bool* found_color, COLOR defaultvalue = COLOR(0,0,0,0)); COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalue = COLOR(0,0,0,0)); FontResource* LoadAttrFont(xml_node<>* element, const char* attrname); ImageResource* LoadAttrImage(xml_node<>* element, const char* attrname); diff --git a/gui/pages.cpp b/gui/pages.cpp index 58e99e60c..50c60a695 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -103,6 +103,56 @@ int ConvertStrToColor(std::string str, COLOR* color) } // Helper APIs +xml_node<>* FindNode(xml_node<>* parent, const char* nodename, int depth /* = 0 */) +{ + xml_node<>* child = parent->first_node(nodename); + if (child) + return child; + + if (depth == 10) { + LOGERR("Too many style loops detected.\n"); + return NULL; + } + + xml_node<>* style = parent->first_node("style"); + if (style) { + while (style) { + if (!style->first_attribute("name")) { + LOGERR("No name given for style.\n"); + continue; + } else { + std::string name = style->first_attribute("name")->value(); + xml_node<>* node = PageManager::FindStyle(name); + + if (node) { + // We found the style that was named + xml_node<>* stylenode = FindNode(node, nodename, depth + 1); + if (stylenode) + return stylenode; + } + } + style = style->next_sibling("style"); + } + } else { + // Search for stylename in the parent node + xml_attribute<>* attr = parent->first_attribute("style"); + // If no style is found anywhere else and the node wasn't found in the object itself + // as a special case we will search for a style that uses the same style name as the + // object type, so would search for a style named "button" + if (!attr) + attr = parent->first_attribute("type"); + if (attr) { + xml_node<>* node = PageManager::FindStyle(attr->value()); + if (node) { + xml_node<>* stylenode = FindNode(node, nodename, depth + 1); + if (stylenode) + return stylenode; + } + } + } + return NULL; +} + std::string LoadAttrString(xml_node<>* element, const char* attrname, const char* defaultvalue) { if (!element) @@ -130,9 +180,10 @@ int LoadAttrIntScaleY(xml_node<>* element, const char* attrname, int defaultvalu return scale_theme_y(LoadAttrInt(element, attrname, defaultvalue)); } -COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalue) +COLOR LoadAttrColor(xml_node<>* element, const char* attrname, bool* found_color, COLOR defaultvalue) { string value = LoadAttrString(element, attrname); + *found_color = !value.empty(); // resolve variables DataManager::GetValue(value, value); COLOR ret = defaultvalue; @@ -142,6 +193,12 @@ COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalu return defaultvalue; } +COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalue) +{ + bool found_color = false; + return LoadAttrColor(element, attrname, &found_color, defaultvalue); +} + FontResource* LoadAttrFont(xml_node<>* element, const char* attrname) { std::string name = LoadAttrString(element, attrname, ""); @@ -621,8 +678,7 @@ int PageSet::Load(ZipArchive* package) xml_node<>* parent; xml_node<>* child; xml_node<>* xmltemplate; - xml_node<>* blank_templates; - int pages_loaded = -1, ret; + xml_node<>* xmlstyle; parent = mDoc.first_node("recovery"); if (!parent) @@ -701,6 +757,11 @@ int PageSet::Load(ZipArchive* package) if (xmltemplate) templates.push_back(xmltemplate); + // Load styles if present + xmlstyle = parent->first_node("styles"); + if (xmlstyle) + styles.push_back(xmlstyle); + child = parent->first_node("pages"); if (child) { if (LoadPages(child)) { @@ -720,6 +781,7 @@ int PageSet::CheckInclude(ZipArchive* package, xml_document<> *parentDoc) xml_node<>* parent; xml_node<>* child; xml_node<>* xmltemplate; + xml_node<>* xmlstyle; long len; char* xmlFile = NULL; string filename; @@ -817,6 +879,11 @@ int PageSet::CheckInclude(ZipArchive* package, xml_document<> *parentDoc) if (xmltemplate) templates.push_back(xmltemplate); + // Load styles if present + xmlstyle = parent->first_node("styles"); + if (xmlstyle) + styles.push_back(xmlstyle); + child = parent->first_node("pages"); if (child && LoadPages(child)) { @@ -1288,6 +1355,23 @@ HardwareKeyboard *PageManager::GetHardwareKeyboard() return mHardwareKeyboard; } +xml_node<>* PageManager::FindStyle(std::string name) +{ + for (std::vector*>::iterator itr = mCurrentSet->styles.begin(); itr != mCurrentSet->styles.end(); itr++) { + xml_node<>* node = (*itr)->first_node("style"); + + while (node) { + if (!node->first_attribute("name")) + continue; + + if (name == node->first_attribute("name")->value()) + return node; + node = node->next_sibling("style"); + } + } + return NULL; +} + MouseCursor *PageManager::GetMouseCursor() { if(!mMouseCursor) diff --git a/gui/pages.hpp b/gui/pages.hpp index 31ccadb51..8eec9a951 100644 --- a/gui/pages.hpp +++ b/gui/pages.hpp @@ -102,6 +102,8 @@ public: int SetKeyBoardFocus(int inFocus); int NotifyVarChange(std::string varName, std::string value); + std::vector*> styles; + protected: int LoadPages(xml_node<>* pages); int LoadVariables(xml_node<>* vars); @@ -153,6 +155,8 @@ public: static HardwareKeyboard *GetHardwareKeyboard(); + static xml_node<>* FindStyle(std::string name); + protected: static PageSet* FindPackage(std::string name); diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp index 8facfe7e5..ba8a94bb7 100644 --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -39,7 +39,7 @@ GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIScrollList(node) mUpdate = 0; updateList = false; - child = node->first_node("icon"); + child = FindNode(node, "icon"); if (child) { mIconSelected = LoadAttrImage(child, "selected"); @@ -47,7 +47,7 @@ GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIScrollList(node) } // Handle the result variable - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("name"); @@ -62,7 +62,7 @@ GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIScrollList(node) int iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight()); SetMaxIconSize(iconWidth, iconHeight); - child = node->first_node("listtype"); + child = FindNode(node, "listtype"); if (child && (attr = child->first_attribute("name"))) { ListType = attr->value(); updateList = true; diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp index a49e0abb2..a478a40d0 100644 --- a/gui/progressbar.cpp +++ b/gui/progressbar.cpp @@ -42,7 +42,7 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node) return; } - child = node->first_node("resource"); + child = FindNode(node, "resource"); if (child) { mEmptyBar = LoadAttrImage(child, "empty"); @@ -50,10 +50,10 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node) } // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY); // Load the data - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { mMinValVar = LoadAttrString(child, "min"); diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp index 8d9ab42f2..4b772d45d 100644 --- a/gui/scrolllist.cpp +++ b/gui/scrolllist.cpp @@ -65,18 +65,9 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) mLastHeaderValue = gui_parse_text(mHeaderText); mHeaderIsStatic = (mLastHeaderValue == mHeaderText); - memset(&mHighlightColor, 0, sizeof(COLOR)); - child = node->first_node("highlight"); - if (child) { - attr = child->first_attribute("color"); - if (attr) { - hasHighlightColor = true; - std::string color = attr->value(); - ConvertStrToColor(color, &mHighlightColor); - } - } + mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlightColor); - child = node->first_node("background"); + child = FindNode(node, "background"); if (child) { mBackground = LoadAttrImage(child, "resource"); @@ -84,11 +75,11 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color - child = node->first_node("font"); + child = FindNode(node, "font"); if (child) { mFont = LoadAttrFont(child, "resource"); @@ -98,7 +89,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Load the separator if it exists - child = node->first_node("separator"); + child = FindNode(node, "separator"); if (child) { mSeparatorColor = LoadAttrColor(child, "color"); @@ -106,7 +97,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) } // Fast scroll - child = node->first_node("fastscroll"); + child = FindNode(node, "fastscroll"); if (child) { mFastScrollLineColor = LoadAttrColor(child, "linecolor"); @@ -123,7 +114,7 @@ GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node) actualItemHeight = mFontHeight + mItemSpacing + mSeparatorH; // Load the header if it exists - child = node->first_node("header"); + child = FindNode(node, "header"); if (child) { mHeaderH = mFontHeight; diff --git a/gui/slider.cpp b/gui/slider.cpp index c53dabc28..2fd114d88 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -33,6 +33,7 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) xml_node<>* child; sAction = NULL; + sSliderLabel = NULL; sSlider = NULL; sSliderUsed = NULL; sTouch = NULL; @@ -44,7 +45,8 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) return; } - child = node->first_node("resource"); + // Load the resources + child = FindNode(node, "resource"); if (child) { sSlider = LoadAttrImage(child, "base"); @@ -52,11 +54,27 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) sTouch = LoadAttrImage(child, "touch"); } + // Load the text label + sSliderLabel = new GUIText(node); + if (sSliderLabel->Render() < 0) + { + delete sSliderLabel; + sSliderLabel = NULL; + } + // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY); + Placement TextPlacement = CENTER; + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &TextPlacement); mRenderW = sSlider->GetWidth(); mRenderH = sSlider->GetHeight(); + if (sSliderLabel) { + int sTextX = mRenderX + (mRenderW / 2); + int w, h; + sSliderLabel->GetCurrentBounds(w, h); + int sTextY = mRenderY + ((mRenderH - h) / 2); + sSliderLabel->SetRenderPos(sTextX, sTextY); + } if (sTouch && sTouch->GetResource()) { sTouchW = sTouch->GetWidth(); // Width of the "touch image" that follows the touch (arrow) @@ -78,6 +96,7 @@ GUISlider::GUISlider(xml_node<>* node) : GUIObject(node) GUISlider::~GUISlider() { delete sAction; + delete sSliderLabel; } int GUISlider::Render(void) @@ -99,6 +118,11 @@ int GUISlider::Render(void) if (sTouch && sTouch->GetResource()) gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2))); + if (sSliderLabel) { + int ret = sSliderLabel->Render(); + if (ret < 0) return ret; + } + sUpdate = 0; return 0; } diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index 5be58dcf3..3974c37d0 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -70,7 +70,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mAction = new GUIAction(node); - child = node->first_node("font"); + child = FindNode(node, "font"); if (child) { mFont = LoadAttrFont(child, "resource"); @@ -78,21 +78,16 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) } // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW); - child = node->first_node("colors"); + child = FindNode(node, "colors"); if (child) { - attr = child->first_attribute("line"); - if (attr) - ConvertStrToColor(attr->value(), &mLineColor); - - attr = child->first_attribute("slider"); - if (attr) - ConvertStrToColor(attr->value(), &mSliderColor); + mLineColor = LoadAttrColor(child, "line"); + mSliderColor = LoadAttrColor(child, "slider"); } - child = node->first_node("resource"); + child = FindNode(node, "resource"); if (child) { mBackgroundImage = LoadAttrImage(child, "background"); @@ -100,7 +95,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mHandleHoverImage = LoadAttrImage(child, "handlehover"); } - child = node->first_node("data"); + child = FindNode(node, "data"); if (child) { attr = child->first_attribute("variable"); @@ -150,37 +145,13 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mChangeOnDrag = atoi(attr->value()); } - child = node->first_node("dimensions"); + child = FindNode(node, "dimensions"); if (child) { - attr = child->first_attribute("lineh"); - if (attr) - { - string parsevalue = gui_parse_text(attr->value()); - mLineH = scale_theme_y(atoi(parsevalue.c_str())); - } - - attr = child->first_attribute("linepadding"); - if (attr) - { - string parsevalue = gui_parse_text(attr->value()); - mPadding = scale_theme_x(atoi(parsevalue.c_str())); - mLinePadding = mPadding; - } - - attr = child->first_attribute("sliderw"); - if (attr) - { - string parsevalue = gui_parse_text(attr->value()); - mSliderW = scale_theme_x(atoi(parsevalue.c_str())); - } - - attr = child->first_attribute("sliderh"); - if (attr) - { - string parsevalue = gui_parse_text(attr->value()); - mSliderH = scale_theme_y(atoi(parsevalue.c_str())); - } + mLineH = LoadAttrIntScaleY(child, "lineh", mLineH); + mLinePadding = LoadAttrIntScaleX(child, "linepadding", mLinePadding); + mSliderW = LoadAttrIntScaleX(child, "sliderw", mSliderW); + mSliderH = LoadAttrIntScaleY(child, "sliderh", mSliderH); } mFontHeight = mFont->GetHeight(); diff --git a/gui/text.cpp b/gui/text.cpp index cc18b170f..3487f7a82 100644 --- a/gui/text.cpp +++ b/gui/text.cpp @@ -44,18 +44,14 @@ GUIText::GUIText(xml_node<>* node) mHighlightColor = LoadAttrColor(node, "highlightcolor", mColor); // Load the font, and possibly override the color - xml_node<>* child = node->first_node("font"); - if (child) - { - mFont = LoadAttrFont(child, "resource"); - mColor = LoadAttrColor(child, "color", mColor); - mHighlightColor = LoadAttrColor(child, "highlightcolor", mColor); - } + mFont = LoadAttrFont(FindNode(node, "font"), "resource"); + mColor = LoadAttrColor(FindNode(node, "font"), "color", mColor); + mHighlightColor = LoadAttrColor(FindNode(node, "font"), "highlightcolor", mColor); // Load the placement - LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &mPlacement); + LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &mPlacement); - child = node->first_node("text"); + xml_node<>* child = FindNode(node, "text"); if (child) mText = child->value(); // Simple way to check for static state -- cgit v1.2.3