├── .editorconfig ├── .github └── workflows │ └── cmake.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── Demo ├── CMakeLists.txt ├── VisualStudio │ ├── Demo.sln │ ├── Demo.vcxproj │ ├── Demo.vcxproj.filters │ ├── tb_static.vcxproj │ └── tb_static.vcxproj.filters ├── demo01 │ ├── Demo.h │ ├── Demo01.cpp │ ├── ListWindow.cpp │ ├── ListWindow.h │ ├── ResourceEditWindow.cpp │ ├── ResourceEditWindow.h │ ├── images │ │ ├── image_1.png │ │ ├── image_2.png │ │ ├── image_3.png │ │ ├── image_4.png │ │ ├── image_5.png │ │ ├── image_6.png │ │ ├── image_7.png │ │ ├── image_8.png │ │ └── image_9.png │ ├── skin │ │ ├── bg_tile.png │ │ ├── bg_tile.psd │ │ ├── focus_r8.png │ │ ├── icon128.png │ │ ├── icon16.png │ │ ├── icon48.png │ │ ├── image_frame.png │ │ ├── image_frame.psd │ │ ├── remove.png │ │ ├── skin.tb.txt │ │ ├── special_button.png │ │ ├── special_button.psd │ │ ├── special_button_pressed.png │ │ ├── star.psd │ │ ├── star_gold.png │ │ ├── star_gold@192.png │ │ ├── star_gold@288.png │ │ ├── star_gold@384.png │ │ ├── star_gray.png │ │ ├── star_gray@192.png │ │ ├── star_gray@288.png │ │ └── star_gray@384.png │ └── ui_resources │ │ ├── resource_edit_test.tb.txt │ │ ├── resource_edit_window.tb.txt │ │ ├── test_animations.tb.txt │ │ ├── test_batching01.tb.txt │ │ ├── test_connections.tb.txt │ │ ├── test_image_widget.tb.txt │ │ ├── test_layout01.tb.txt │ │ ├── test_layout02.tb.txt │ │ ├── test_layout03.tb.txt │ │ ├── test_list_item.tb.txt │ │ ├── test_radio_checkbox.tb.txt │ │ ├── test_scrollcontainer.tb.txt │ │ ├── test_scroller_snap.tb.txt │ │ ├── test_select.tb.txt │ │ ├── test_select_advanced.tb.txt │ │ ├── test_skin_conditions01.tb.txt │ │ ├── test_skin_conditions02.tb.txt │ │ ├── test_tabcontainer01.tb.txt │ │ ├── test_textwindow.tb.txt │ │ ├── test_toggle_containers.tb.txt │ │ └── test_ui.tb.txt ├── fonts │ ├── license.txt │ ├── neon.psd │ ├── neon.tb.txt │ ├── neon_42.png │ ├── orange.psd │ ├── orange.tb.txt │ ├── orange_30.png │ ├── orangutang.psd │ ├── orangutang.tb.txt │ └── orangutang_48.png ├── platform │ ├── Application.cpp │ ├── Application.h │ ├── glfw_extra.h │ ├── glfw_extra_linux.cpp │ ├── glfw_extra_win.cpp │ ├── main.cpp │ ├── port_glfw.cpp │ ├── port_glfw.hpp │ ├── port_sdl2.cpp │ └── port_sdl2.hpp └── screenshot │ └── screenshot_01.png ├── DemoAndroid ├── app │ ├── build.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ ├── images │ │ │ ├── image_1.png │ │ │ └── tb_logo.png │ │ └── layout │ │ │ └── main_layout.tb.txt │ │ ├── java │ │ └── org │ │ │ └── hastybadger │ │ │ └── demo │ │ │ ├── TBActivity.java │ │ │ ├── TBLib.java │ │ │ └── TBView.java │ │ ├── jni │ │ ├── Android.mk │ │ ├── App.cpp │ │ ├── App.h │ │ ├── Application.mk │ │ └── jni_glue.cpp │ │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-ldpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── Makefile ├── build.sh ├── cmake ├── AddResources.cmake └── iOS.cmake ├── doc ├── Doxyfile.in ├── footer.html ├── ghpages.sh ├── header.html ├── mainpage.h ├── skindoc.py └── stylesheet.css ├── ide_extensions └── VisualStudio │ ├── install.bat │ └── turbobadger.natvis ├── integration.txt ├── readme.md ├── resources ├── default_font │ ├── license.txt │ ├── segoe_white_with_shadow.tb.txt │ ├── segoe_white_with_shadow_14.png │ ├── segoe_white_with_shadow_14.psd │ └── segoe_white_with_shadow_28.png ├── default_skin │ ├── TBSectionContainer.png │ ├── TBSectionContainer.psd │ ├── TBSectionHeader.psd │ ├── arrow.psd │ ├── arrow_down.png │ ├── arrow_down@192.png │ ├── arrow_down@240.png │ ├── arrow_down@288.png │ ├── arrow_down@384.png │ ├── arrow_left.png │ ├── arrow_left@192.png │ ├── arrow_left@240.png │ ├── arrow_left@288.png │ ├── arrow_left@384.png │ ├── arrow_right.png │ ├── arrow_right@192.png │ ├── arrow_right@240.png │ ├── arrow_right@288.png │ ├── arrow_right@384.png │ ├── arrow_up.png │ ├── arrow_up@192.png │ ├── arrow_up@240.png │ ├── arrow_up@288.png │ ├── arrow_up@384.png │ ├── button.png │ ├── button.psd │ ├── button_flat.psd │ ├── button_flat_outline.png │ ├── button_flat_pressed.png │ ├── button_grouped.psd │ ├── button_grouped_x_first_down.png │ ├── button_grouped_x_first_up.png │ ├── button_grouped_x_last_down.png │ ├── button_grouped_x_last_up.png │ ├── button_grouped_x_middle_down.png │ ├── button_grouped_x_middle_up.png │ ├── button_pressed.png │ ├── checkbox.png │ ├── checkbox@192.png │ ├── checkbox@240.png │ ├── checkbox@288.png │ ├── checkbox@384.png │ ├── checkbox_mark.png │ ├── checkbox_mark@192.png │ ├── checkbox_mark@240.png │ ├── checkbox_mark@288.png │ ├── checkbox_mark@384.png │ ├── checkbox_pressed.png │ ├── checkbox_pressed@192.png │ ├── checkbox_pressed@240.png │ ├── checkbox_pressed@288.png │ ├── checkbox_pressed@384.png │ ├── checkradio.psd │ ├── container.png │ ├── container.psd │ ├── dropdown_button.psd │ ├── editfield.png │ ├── editfield.psd │ ├── fadeout.psd │ ├── fadeout_x.png │ ├── fadeout_y.png │ ├── focus.psd │ ├── focus_r4.png │ ├── focus_tabbutton_left.png │ ├── focus_tabbutton_top.png │ ├── hover.psd │ ├── item.psd │ ├── item_hover.png │ ├── item_selected.png │ ├── item_separator_x.png │ ├── item_separator_y.png │ ├── license.txt │ ├── messageicon.psd │ ├── mover_tile.psd │ ├── progress_spinner_gear.psd │ ├── progress_spinner_strip.png │ ├── progress_spinner_strip@192.png │ ├── progress_x.psd │ ├── progress_y.psd │ ├── radio.png │ ├── radio@192.png │ ├── radio@240.png │ ├── radio@288.png │ ├── radio@384.png │ ├── radio_mark.png │ ├── radio_mark@192.png │ ├── radio_mark@240.png │ ├── radio_mark@288.png │ ├── radio_mark@384.png │ ├── radio_pressed.png │ ├── radio_pressed@192.png │ ├── radio_pressed@240.png │ ├── radio_pressed@288.png │ ├── radio_pressed@384.png │ ├── resizer.png │ ├── resizer.psd │ ├── resizer@192.png │ ├── resizer@240.png │ ├── resizer@288.png │ ├── resizer@384.png │ ├── scroll_bg_x.png │ ├── scroll_bg_y.png │ ├── scroll_fg_x.png │ ├── scroll_fg_y.png │ ├── search.png │ ├── search.psd │ ├── search@192.png │ ├── search@240.png │ ├── search@288.png │ ├── search@384.png │ ├── selection.png │ ├── selection.psd │ ├── skin.tb.txt │ ├── slider.psd │ ├── slider_bg.psd │ ├── slider_bg_x.png │ ├── slider_bg_x@192.png │ ├── slider_bg_x@240.png │ ├── slider_bg_x@288.png │ ├── slider_bg_x@384.png │ ├── slider_bg_y.png │ ├── slider_bg_y@192.png │ ├── slider_bg_y@240.png │ ├── slider_bg_y@288.png │ ├── slider_bg_y@384.png │ ├── slider_handle.png │ ├── slider_handle.psd │ ├── slider_handle@192.png │ ├── slider_handle@240.png │ ├── slider_handle@288.png │ ├── slider_handle@384.png │ ├── tab_button_bottom_active.png │ ├── tab_button_bottom_inactive.png │ ├── tab_button_left_active.png │ ├── tab_button_left_inactive.png │ ├── tab_button_right_active.png │ ├── tab_button_right_inactive.png │ ├── tab_button_top_active.png │ ├── tab_button_top_inactive.png │ ├── tab_section_work.psd │ ├── tabbutton.psd │ ├── tabbutton_left_right.psd │ ├── teststuff.psd │ ├── testtabbuttons.psd │ ├── toggle_section_icon.psd │ ├── toggle_section_icon_down.png │ ├── toggle_section_icon_middle.png │ ├── toggle_section_icon_up.png │ ├── window.png │ ├── window.psd │ ├── window_active.png │ ├── window_close.png │ ├── window_close.psd │ ├── window_close@192.png │ ├── window_close@240.png │ ├── window_close@288.png │ ├── window_close@384.png │ ├── window_close_pressed.png │ ├── window_close_pressed@192.png │ ├── window_close_pressed@240.png │ ├── window_close_pressed@288.png │ ├── window_close_pressed@384.png │ ├── window_mover.psd │ ├── window_mover_bg_tile.png │ ├── window_mover_bg_tile@192.png │ ├── window_mover_bg_tile@240.png │ ├── window_mover_bg_tile@288.png │ ├── window_mover_bg_tile@384.png │ └── window_mover_overlay.png ├── icon │ ├── icon.psd │ ├── icon114.png │ ├── icon128.png │ ├── icon48.png │ └── icon_large.psd ├── language │ ├── lng_en.tb.txt │ └── lng_sv.tb.txt ├── metadata │ └── tb_widgets_attr.tb.txt └── vera.ttf ├── src └── tb │ ├── CMakeLists.txt │ ├── animation │ ├── tb_animation.cpp │ ├── tb_animation.h │ ├── tb_animation_utils.h │ ├── tb_widget_animation.cpp │ └── tb_widget_animation.h │ ├── image │ ├── tb_image_manager.cpp │ ├── tb_image_manager.h │ ├── tb_image_widget.cpp │ └── tb_image_widget.h │ ├── parser │ ├── tb_parser.cpp │ └── tb_parser.h │ ├── renderers │ ├── tb_renderer_batcher.cpp │ ├── tb_renderer_batcher.h │ ├── tb_renderer_gl.cpp │ └── tb_renderer_gl.h │ ├── tb_bitmap_fragment.cpp │ ├── tb_bitmap_fragment.h │ ├── tb_clipboard_dummy.cpp │ ├── tb_clipboard_glfw.cpp │ ├── tb_clipboard_sdl2.cpp │ ├── tb_clipboard_win.cpp │ ├── tb_color.cpp │ ├── tb_color.h │ ├── tb_core.cpp │ ├── tb_core.h │ ├── tb_debug.cpp │ ├── tb_debug.h │ ├── tb_dimension.cpp │ ├── tb_dimension.h │ ├── tb_editfield.cpp │ ├── tb_editfield.h │ ├── tb_file_android.cpp │ ├── tb_file_posix.cpp │ ├── tb_file_sdl2.cpp │ ├── tb_font_desc.h │ ├── tb_font_renderer.cpp │ ├── tb_font_renderer.h │ ├── tb_font_renderer_freetype.cpp │ ├── tb_font_renderer_freetypeX.cpp │ ├── tb_font_renderer_stb.cpp │ ├── tb_font_renderer_tbbf.cpp │ ├── tb_geometry.cpp │ ├── tb_geometry.h │ ├── tb_hash.cpp │ ├── tb_hash.h │ ├── tb_hashtable.cpp │ ├── tb_hashtable.h │ ├── tb_id.cpp │ ├── tb_id.h │ ├── tb_image_loader_stb.cpp │ ├── tb_inline_select.cpp │ ├── tb_inline_select.h │ ├── tb_language.cpp │ ├── tb_language.h │ ├── tb_layout.cpp │ ├── tb_layout.h │ ├── tb_linklist.cpp │ ├── tb_linklist.h │ ├── tb_list.cpp │ ├── tb_list.h │ ├── tb_menu_window.cpp │ ├── tb_menu_window.h │ ├── tb_message_window.cpp │ ├── tb_message_window.h │ ├── tb_msg.cpp │ ├── tb_msg.h │ ├── tb_node_ref_tree.cpp │ ├── tb_node_ref_tree.h │ ├── tb_node_tree.cpp │ ├── tb_node_tree.h │ ├── tb_object.cpp │ ├── tb_object.h │ ├── tb_popup_window.cpp │ ├── tb_popup_window.h │ ├── tb_renderer.cpp │ ├── tb_renderer.h │ ├── tb_scroll_container.cpp │ ├── tb_scroll_container.h │ ├── tb_scroller.cpp │ ├── tb_scroller.h │ ├── tb_select.cpp │ ├── tb_select.h │ ├── tb_select_item.cpp │ ├── tb_select_item.h │ ├── tb_skin.cpp │ ├── tb_skin.h │ ├── tb_skin_util.cpp │ ├── tb_skin_util.h │ ├── tb_sort.h │ ├── tb_str.cpp │ ├── tb_str.h │ ├── tb_style_edit.cpp │ ├── tb_style_edit.h │ ├── tb_style_edit_content.cpp │ ├── tb_style_edit_content.h │ ├── tb_system.h │ ├── tb_system_android.cpp │ ├── tb_system_linux.cpp │ ├── tb_system_sdl2.cpp │ ├── tb_system_win.cpp │ ├── tb_tab_container.cpp │ ├── tb_tab_container.h │ ├── tb_tempbuffer.cpp │ ├── tb_tempbuffer.h │ ├── tb_toggle_container.cpp │ ├── tb_toggle_container.h │ ├── tb_types.h │ ├── tb_value.cpp │ ├── tb_value.h │ ├── tb_widget_skin_condition_context.cpp │ ├── tb_widget_skin_condition_context.h │ ├── tb_widget_value.cpp │ ├── tb_widget_value.h │ ├── tb_widgets.cpp │ ├── tb_widgets.h │ ├── tb_widgets_common.cpp │ ├── tb_widgets_common.h │ ├── tb_widgets_listener.cpp │ ├── tb_widgets_listener.h │ ├── tb_widgets_reader.cpp │ ├── tb_widgets_reader.h │ ├── tb_window.cpp │ ├── tb_window.h │ ├── tests │ ├── tb_test.cpp │ ├── tb_test.h │ ├── test_tb_color.cpp │ ├── test_tb_dimension.cpp │ ├── test_tb_geometry.cpp │ ├── test_tb_linklist.cpp │ ├── test_tb_node_ref_tree.cpp │ ├── test_tb_object.cpp │ ├── test_tb_parser.cpp │ ├── test_tb_parser.tb.txt │ ├── test_tb_parser_definitions.tb.txt │ ├── test_tb_parser_included.tb.txt │ ├── test_tb_space_allocator.cpp │ ├── test_tb_style_edit.cpp │ ├── test_tb_tempbuffer.cpp │ ├── test_tb_test.cpp │ ├── test_tb_value.cpp │ └── test_tb_widget_value.cpp │ ├── thirdparty │ ├── nanosvg.h │ ├── nanosvgrast.h │ ├── stb_image.h │ └── stb_truetype.h │ └── utf8 │ ├── test files │ ├── TeX.txt │ ├── UTF-8-demo.txt │ ├── glass.txt │ └── quickbrown.txt │ ├── utf8.cpp │ └── utf8.h ├── tb_config.h.in └── thirdparty ├── Build_SDL2_framework.sh └── CMakeLists.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | [*] 3 | charset = utf-8 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{cpp,h}] 8 | indent_style = tab 9 | indent_size = 4 10 | 11 | [*.tb.txt] 12 | indent_style = tab 13 | indent_size = 4 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | 4 | *~ 5 | *.swp 6 | *.#* 7 | *.ilk 8 | *.ncb 9 | *.opt 10 | *.opensdf 11 | *.sdf 12 | *.user 13 | *.suo 14 | *.log 15 | *.exp 16 | *.pdb 17 | *.o 18 | *.tlog 19 | *.obj 20 | *.bak 21 | 22 | *.lnk 23 | 24 | *.sublime-workspace 25 | 26 | Debug 27 | Release 28 | ipch 29 | obj 30 | bin 31 | gen 32 | * gitignore 33 | 34 | documentation 35 | doc/html 36 | 37 | *.iml 38 | DemoAndroid2/.gradle 39 | DemoAndroid2/app/build/ 40 | DemoAndroid2/app/.externalNativeBuild/ 41 | DemoAndroid2/app/.cxx/ 42 | DemoAndroid2/build 43 | DemoAndroid2/local.properties 44 | DemoAndroid2/.idea 45 | DemoAndroid2/app/src/main/assets/demo_skin/ 46 | DemoAndroid2/app/src/main/assets/font/ 47 | DemoAndroid2/app/src/main/assets/language/ 48 | DemoAndroid2/app/src/main/assets/skin/ 49 | 50 | DemoAndroid/libs 51 | DemoAndroid/assets/demo_skin 52 | DemoAndroid/assets/font 53 | DemoAndroid/assets/language 54 | DemoAndroid/assets/skin 55 | Demo.exe 56 | 57 | TurboBadgerDemo* 58 | Build*/ 59 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/.gitmodules -------------------------------------------------------------------------------- /Demo/VisualStudio/Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo", "Demo.vcxproj", "{C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {156102D7-F2DD-4618-B2EB-2DFE607EE6DD} = {156102D7-F2DD-4618-B2EB-2DFE607EE6DD} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tb_static", "tb_static.vcxproj", "{156102D7-F2DD-4618-B2EB-2DFE607EE6DD}" 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Release|Win32 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Debug|Win32.Build.0 = Debug|Win32 19 | {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Release|Win32.ActiveCfg = Release|Win32 20 | {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Release|Win32.Build.0 = Release|Win32 21 | {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Debug|Win32.Build.0 = Debug|Win32 23 | {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Release|Win32.ActiveCfg = Release|Win32 24 | {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Release|Win32.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /Demo/demo01/Demo.h: -------------------------------------------------------------------------------- 1 | #ifndef DEMO_H 2 | #define DEMO_H 3 | 4 | #include "tb_widgets.h" 5 | #include "tb_widgets_common.h" 6 | #include "tb_widgets_reader.h" 7 | #include "tb_widgets_listener.h" 8 | #include "tb_message_window.h" 9 | #include "tb_msg.h" 10 | #include "tb_scroller.h" 11 | #include "platform/Application.h" 12 | 13 | using namespace tb; 14 | 15 | class DemoApplication : public App 16 | { 17 | public: 18 | DemoApplication() : App(1280, 700) {} 19 | 20 | virtual const char *GetTitle() const { return "Demo"; } 21 | virtual void OnBackendAttached(AppBackend *backend, int width, int height); 22 | virtual bool Init(); 23 | virtual void RenderFrame(); 24 | }; 25 | 26 | class DemoWindow : public TBWindow 27 | { 28 | public: 29 | DemoWindow(TBWidget *root); 30 | bool LoadResourceFile(const TBStr & filename); 31 | void LoadResourceData(const char *data); 32 | void LoadResource(TBNode &node); 33 | 34 | virtual bool OnEvent(const TBWidgetEvent &ev); 35 | }; 36 | 37 | class MainWindow : public DemoWindow, public TBMessageHandler 38 | { 39 | public: 40 | MainWindow(TBWidget *root); 41 | virtual bool OnEvent(const TBWidgetEvent &ev); 42 | 43 | // Implement TBMessageHandler 44 | virtual void OnMessageReceived(TBMessage *msg); 45 | }; 46 | 47 | class ImageWindow : public DemoWindow 48 | { 49 | public: 50 | ImageWindow(TBWidget *root); 51 | virtual bool OnEvent(const TBWidgetEvent &ev); 52 | }; 53 | 54 | class PageWindow : public DemoWindow, public TBScrollerSnapListener 55 | { 56 | public: 57 | PageWindow(TBWidget *root); 58 | virtual bool OnEvent(const TBWidgetEvent &ev); 59 | virtual void OnScrollSnap(TBWidget *target_widget, int &target_x, int &target_y); 60 | }; 61 | 62 | class AnimationsWindow : public DemoWindow 63 | { 64 | public: 65 | AnimationsWindow(TBWidget *root); 66 | void Animate(); 67 | virtual bool OnEvent(const TBWidgetEvent &ev); 68 | }; 69 | 70 | class LayoutWindow : public DemoWindow 71 | { 72 | public: 73 | LayoutWindow(TBWidget *root, const TBStr & filename); 74 | virtual bool OnEvent(const TBWidgetEvent &ev); 75 | }; 76 | 77 | class TabContainerWindow : public DemoWindow 78 | { 79 | public: 80 | TabContainerWindow(TBWidget *root); 81 | virtual bool OnEvent(const TBWidgetEvent &ev); 82 | }; 83 | 84 | class ConnectionWindow : public DemoWindow 85 | { 86 | public: 87 | ConnectionWindow(TBWidget *root); 88 | virtual bool OnEvent(const TBWidgetEvent &ev); 89 | }; 90 | 91 | class ScrollContainerWindow : public DemoWindow, public TBMessageHandler 92 | { 93 | public: 94 | ScrollContainerWindow(TBWidget *root); 95 | virtual bool OnEvent(const TBWidgetEvent &ev); 96 | 97 | // Implement TBMessageHandler 98 | virtual void OnMessageReceived(TBMessage *msg); 99 | }; 100 | 101 | #endif // DEMO_H 102 | -------------------------------------------------------------------------------- /Demo/demo01/ListWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTWINDOW_DEMO_H 2 | #define LISTWINDOW_DEMO_H 3 | 4 | #include "Demo.h" 5 | #include "tb_select.h" 6 | 7 | class AdvancedItemSource; 8 | 9 | /** Shows a list of items from *any* type of source. */ 10 | class ListWindow : public DemoWindow 11 | { 12 | public: 13 | ListWindow(TBWidget *root, TBSelectItemSource *source); 14 | virtual bool OnEvent(const TBWidgetEvent &ev); 15 | }; 16 | 17 | /** Shows a list of items from a source of type AdvancedItemSource. */ 18 | class AdvancedListWindow : public DemoWindow 19 | { 20 | public: 21 | AdvancedListWindow(TBWidget *root, AdvancedItemSource *source); 22 | virtual bool OnEvent(const TBWidgetEvent &ev); 23 | private: 24 | AdvancedItemSource *m_source; 25 | }; 26 | 27 | /** AdvancedItem adds extra info to a string item. */ 28 | class AdvancedItem : public TBGenericStringItem 29 | { 30 | public: 31 | AdvancedItem(const TBStr & str, const TBID &id, bool male) 32 | : TBGenericStringItem(str, id) 33 | , m_checked(false) 34 | , m_male(male) {} 35 | void SetChecked(bool checked) { m_checked = checked; } 36 | bool GetChecked() const { return m_checked; } 37 | bool GetMale() const { return m_male; } 38 | private: 39 | TBStr m_info; 40 | bool m_checked; 41 | bool m_male; 42 | }; 43 | 44 | /** AdvancedItemSource provides items of type AdvancedItem and makes sure 45 | the viewer is populated with the customized widget for each item. */ 46 | class AdvancedItemSource : public TBSelectItemSourceList 47 | { 48 | public: 49 | virtual bool Filter(int index, const TBStr & filter); 50 | virtual TBWidget *CreateItemWidget(int index, TBSelectItemViewer *viewer); 51 | }; 52 | 53 | /** AdvancedItemWidget is the widget representing a AdvancedItem. 54 | On changes to the item, it calls InvokeItemChanged on the source, so that all 55 | viewers of the source are updated to reflect the change. */ 56 | class AdvancedItemWidget : public TBLayout 57 | { 58 | public: 59 | AdvancedItemWidget(AdvancedItem *item, AdvancedItemSource *source, TBSelectItemViewer *source_viewer, int index); 60 | virtual bool OnEvent(const TBWidgetEvent &ev); 61 | private: 62 | AdvancedItemSource *m_source; 63 | TBSelectItemViewer *m_source_viewer; 64 | int m_index; 65 | }; 66 | 67 | #endif // LISTWINDOW_DEMO_H 68 | -------------------------------------------------------------------------------- /Demo/demo01/ResourceEditWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef ResourceEditWindow_H 2 | #define ResourceEditWindow_H 3 | 4 | #include "tb_widgets.h" 5 | #include "tb_select.h" 6 | #include "tb_widgets_common.h" 7 | #include "tb_widgets_listener.h" 8 | #include "tb_editfield.h" 9 | #include "tb_msg.h" 10 | 11 | using namespace tb; 12 | 13 | class ResourceItem : public TBGenericStringItem 14 | { 15 | public: 16 | ResourceItem(TBWidget *widget, const TBStr & str); 17 | TBWidget *GetWidget() { return m_widget; } 18 | private: 19 | TBWidget *m_widget; 20 | }; 21 | 22 | class ResourceEditWindow : public TBWindow, public TBMessageHandler, public TBWidgetListener 23 | { 24 | public: 25 | // For safe typecasting 26 | TBOBJECT_SUBCLASS(ResourceEditWindow, TBWindow); 27 | 28 | ResourceEditWindow(); 29 | ~ResourceEditWindow(); 30 | 31 | void UpdateWidgetList(bool immediately); 32 | 33 | struct ITEM_INFO { 34 | ResourceItem *item; 35 | int index; 36 | }; 37 | ITEM_INFO GetItemFromWidget(TBWidget *widget); 38 | TBWidget *GetSelectedWidget() { return m_selected_widget.Get(); } 39 | void SetSelectedWidget(TBWidget *widget); 40 | 41 | void Load(const TBStr & resource_file); 42 | void RefreshFromSource(); 43 | 44 | // == TBWindow ====================================================================== 45 | virtual bool OnEvent(const TBWidgetEvent &ev); 46 | virtual void OnPaintChildren(const PaintProps &paint_props); 47 | 48 | // == TBMessageHandler ============================================================== 49 | virtual void OnMessageReceived(TBMessage *msg); 50 | 51 | // == TBWidgetListener ======================================================== 52 | virtual bool OnWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev); 53 | virtual void OnWidgetAdded(TBWidget *parent, TBWidget *child); 54 | virtual void OnWidgetRemove(TBWidget *parent, TBWidget *child); 55 | private: 56 | TBSelectList *m_widget_list; 57 | TBSelectItemSourceList m_widget_list_source; 58 | TBScrollContainer *m_scroll_container; 59 | TBWidget *m_build_container; 60 | TBEditField *m_source_edit; 61 | TBStr m_resource_filename; 62 | TBWidgetSafePointer m_selected_widget; 63 | void AddWidgetListItemsRecursive(TBWidget *widget, int depth); 64 | bool OnDropFileEvent(const TBWidgetEvent &ev); 65 | }; 66 | 67 | #endif // ResourceEditWindow_H 68 | -------------------------------------------------------------------------------- /Demo/demo01/images/image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_1.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_2.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_3.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_4.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_5.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_6.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_7.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_8.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/images/image_9.png -------------------------------------------------------------------------------- /Demo/demo01/skin/bg_tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/bg_tile.png -------------------------------------------------------------------------------- /Demo/demo01/skin/bg_tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/bg_tile.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/focus_r8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/focus_r8.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/icon128.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/icon16.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/icon48.png -------------------------------------------------------------------------------- /Demo/demo01/skin/image_frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/image_frame.png -------------------------------------------------------------------------------- /Demo/demo01/skin/image_frame.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/image_frame.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/remove.png -------------------------------------------------------------------------------- /Demo/demo01/skin/skin.tb.txt: -------------------------------------------------------------------------------- 1 | # Demo skin override (contains some additions for the demo) 2 | elements 3 | Icon16 4 | bitmap icon16.png 5 | min-width 16 6 | min-height 16 7 | Icon48 8 | bitmap icon48.png 9 | cut 4 10 | min-width 20 11 | min-height 20 12 | Icon128 13 | bitmap icon128.png 14 | background 15 | bitmap bg_tile.png 16 | type Tile 17 | background_solid 18 | background-color #3b3b3b 19 | padding 10 20 | SpecialButton 21 | bitmap special_button.png 22 | cut 17 23 | expand 7 24 | padding 6 8 25 | overrides 26 | element SpecialButton.pressed 27 | state pressed 28 | overlays 29 | element generic_focus_r8 30 | state focused 31 | element Star 32 | condition: target: ancestors, property: skin, value: "Starry buttons" 33 | SpecialButton.pressed 34 | bitmap special_button_pressed.png 35 | cut 17 36 | expand 7 37 | content-ofs-x 1 38 | content-ofs-y 1 39 | ImageCaption 40 | background-color #00000066 41 | ImageFrame 42 | overlays 43 | element ImageFrame.overlay 44 | state all 45 | ImageFrame.overlay 46 | bitmap image_frame.png 47 | cut 22 48 | expand 15 49 | Remove 50 | bitmap remove.png 51 | type Image 52 | padding 5 53 | Star 54 | bitmap star_gray.png 55 | type Image 56 | img-position-x 0 57 | img-position-y 0 58 | img-ofs-x -8 59 | img-ofs-y -12 60 | overrides 61 | element Star.active 62 | condition: target: this, property: "window active" 63 | condition: target: parent, property: hover 64 | Star.active 65 | bitmap star_gold.png 66 | type Image 67 | img-position-x 0 68 | img-position-y 0 69 | img-ofs-x -10 70 | img-ofs-y -14 71 | generic_focus_r8 72 | bitmap focus_r8.png 73 | cut 14 74 | expand 4 75 | -------------------------------------------------------------------------------- /Demo/demo01/skin/special_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/special_button.png -------------------------------------------------------------------------------- /Demo/demo01/skin/special_button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/special_button.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/special_button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/special_button_pressed.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gold.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gold@192.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gold@288.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gold@384.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gray.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gray@192.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gray@288.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/demo01/skin/star_gray@384.png -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/resource_edit_test.tb.txt: -------------------------------------------------------------------------------- 1 | TBLayout 2 | distribution available 3 | axis y 4 | TBLayout 5 | TBButton 6 | text Button 1 7 | TBRadioButton 8 | TBCheckBox 9 | @if 1 10 | TBContainer 11 | TBLayout 12 | TBSlider 13 | value 0.5 14 | TBScrollBar 15 | TBEditField 16 | multiline 1 17 | readonly 1 18 | TBEditField 19 | text Hello world\nHello world 20 | adapt-to-content 1 21 | multiline 1 22 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/resource_edit_window.tb.txt: -------------------------------------------------------------------------------- 1 | TBLayout 2 | distribution gravity 3 | size available 4 | TBLayout 5 | gravity top bottom 6 | distribution available 7 | distribution-position top left 8 | size available 9 | axis y 10 | TBLayout 11 | distribution available 12 | TBButton 13 | text @new 14 | state disabled 15 | TBButton 16 | text @save 17 | state disabled 18 | TBButton 19 | text Test 20 | id test 21 | TBEditField 22 | placeholder @search 23 | type search 24 | id widget_list_search 25 | TBSelectList 26 | id widget_list 27 | TBLayout 28 | distribution available 29 | TBEditField 30 | id source_edit 31 | multiline 1 32 | gravity all 33 | TBLayout: axis: y, distribution: available, position: left 34 | TBScrollContainer 35 | id scroll_container 36 | gravity all 37 | TBClickLabel: text: "Adapt to container" 38 | TBCheckBox: id: "constrained" 39 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_animations.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Animations 3 | TBLayout: axis: y 4 | TBTextField: text: "Duration (in milliseconds):" 5 | TBInlineSelect: id: "duration", min: 0, max: 100000, value: 500 6 | TBTextField: text: "Curve:" 7 | TBSelectList: id: "curve", value: 1 8 | items 9 | item: text: "Linear" 10 | item: text: "Slow down" 11 | item: text: "Speed up" 12 | item: text: "Bezier" 13 | item: text: "Smooth" 14 | TBClickLabel: text: Fade 15 | TBCheckBox: id: fade, value: 1 16 | TBButton: text: "Animate!", id: "Animate!", skin: "SpecialButton" 17 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_connections.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBWidgetValue connections 3 | TBLayout 4 | axis y 5 | TBTextField 6 | text Numeric widgets sharing a connection 7 | TBContainer 8 | gravity all 9 | TBLayout 10 | TBInlineSelect 11 | connection master-volume 12 | min 0 13 | max 100 14 | TBSlider 15 | connection master-volume 16 | min 0 17 | max 100 18 | TBSlider 19 | axis y 20 | connection master-volume 21 | min 0 22 | max 100 23 | TBButton 24 | text Reset 25 | id reset-master-volume 26 | TBTextField 27 | text Text widgets sharing a connection 28 | TBContainer 29 | gravity all 30 | TBLayout 31 | TBEditField 32 | placeholder User name 33 | connection user-name 34 | min 0 35 | max 100 36 | TBEditField 37 | placeholder User name 38 | connection user-name 39 | min 0 40 | max 100 41 | TBButton 42 | text Reset 43 | id reset-user-name 44 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_image_widget.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBImageWidget 3 | size 350 500 4 | TBScrollContainer 5 | adapt-content 1 6 | TBLayout 7 | axis y 8 | spacing 20 9 | TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 10 | text: "Some images shown by TBImageWidget. This test requires enabling TB_IMAGE (see tb_config.h).\n" \ 11 | "Images are unloaded when all references are removed (this window is closed)." 12 | TBImageWidget: filename: "demo01/images/image_1.png", skin: ImageFrame 13 | TBButton: skin: "Remove", id: "remove", gravity: right 14 | TBImageWidget: filename: "demo01/images/image_2.png", skin: ImageFrame 15 | TBButton: skin: "Remove", id: "remove", gravity: right 16 | TBImageWidget: filename: "demo01/images/image_3.png", skin: ImageFrame 17 | TBButton: skin: "Remove", id: "remove", gravity: right 18 | TBImageWidget: filename: "demo01/images/image_4.png", skin: ImageFrame 19 | TBButton: skin: "Remove", id: "remove", gravity: right 20 | TBImageWidget: filename: "demo01/images/image_5.png", skin: ImageFrame 21 | TBButton: skin: "Remove", id: "remove", gravity: right 22 | TBImageWidget: filename: "demo01/images/image_6.png", skin: ImageFrame 23 | TBButton: skin: "Remove", id: "remove", gravity: right 24 | TBTextField: skin: "ImageCaption", text: "Öland", gravity: bottom left right 25 | TBImageWidget: filename: "demo01/images/image_7.png", skin: ImageFrame 26 | TBButton: skin: "Remove", id: "remove", gravity: right 27 | TBTextField: skin: "ImageCaption", text: "Öland", gravity: bottom left right 28 | TBImageWidget: filename: "demo01/images/image_8.png", skin: ImageFrame 29 | TBButton: skin: "Remove", id: "remove", gravity: right 30 | TBTextField: skin: "ImageCaption", text: "Örebro", gravity: bottom left right 31 | TBImageWidget: filename: "demo01/images/image_9.png", skin: ImageFrame 32 | TBButton: skin: "Remove", id: "remove", gravity: right 33 | TBTextField: skin: "ImageCaption", text: "Stockholm", gravity: bottom left right 34 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_layout01.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBLayout size & gravity 3 | # Declare a branch of layout nodes that is included in all three containers below. 4 | test_layout_content 5 | TBLayout 6 | TBButton 7 | text Default 8 | TBCheckBox 9 | value 1 10 | TBButton 11 | axis y 12 | text Foo Bar 13 | TBSkinImage 14 | skin Icon16 15 | TBButton 16 | gravity all 17 | text Gravity all 18 | TBButton 19 | gravity top 20 | text Gravity top 21 | TBButton 22 | gravity bottom 23 | text Gravity bottom 24 | TBLayout 25 | axis y 26 | TBLayout 27 | TBSelectDropdown 28 | text Select position 29 | id select position 30 | items 31 | item: text: "LAYOUT_POSITION_CENTER" 32 | item: text: "LAYOUT_POSITION_LEFT_TOP" 33 | item: text: "LAYOUT_POSITION_RIGHT_BOTTOM" 34 | item: text: "LAYOUT_POSITION_GRAVITY" 35 | TBButton 36 | text Toggle axis 37 | id toggle axis 38 | TBLayout 39 | id switch_layout 40 | axis y 41 | TBTextField: text: "size: preferred" 42 | TBContainer 43 | @include test_layout_content 44 | size preferred 45 | id 1 46 | TBTextField: text: "size: available" 47 | TBContainer 48 | @include test_layout_content 49 | size available 50 | id 2 51 | TBTextField: text: "size: gravity" 52 | TBContainer 53 | @include test_layout_content 54 | size gravity 55 | id 3 56 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_layout02.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBLayout distribution 3 | TBLayout: position: left top, axis: y 4 | TBTextField: text: "distribution: preferred" 5 | TBLayout: distribution: preferred 6 | TBButton: text: tab 1 7 | TBButton: text: tab 2 8 | TBButton: text: tab 3 9 | TBButton: text: tab 4 10 | TBEditField: placeholder: @search, gravity: left right, type: "search" 11 | TBTextField: text: "distribution: available" 12 | TBLayout: distribution: available 13 | TBButton: text: tab 1 14 | TBButton: text: tab 2 15 | TBButton: text: tab 3 16 | TBButton: text: tab 4 17 | TBEditField: placeholder: @search, gravity: left right, type: "search" 18 | TBTextField: text: "distribution: gravity" 19 | TBLayout: distribution: gravity 20 | TBButton: text: tab 1 21 | TBButton: text: tab 2 22 | TBButton: text: tab 3 23 | TBButton: text: tab 4 24 | TBEditField: placeholder: @search, gravity: left right, type: "search" 25 | TBTextField: text: gravity + trailing layout for right align 26 | TBLayout: distribution: gravity 27 | TBButton: text: tab 1 28 | TBButton: text: tab 2 29 | TBButton: text: tab 3 30 | TBButton: text: tab 4 31 | TBLayout: gravity: left right, distribution-position: right bottom 32 | TBEditField: placeholder: @search, type: "search" 33 | TBTextField: text: "gravity + mixed gravity" 34 | TBLayout: distribution: gravity 35 | TBButton: text: tab 1 36 | TBEditField: placeholder: @search, gravity: left right, type: "search" 37 | TBButton: text: tab 3 38 | TBButton: text: tab 4 39 | TBEditField: placeholder: @search, gravity: left right, type: "search" 40 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_layout03.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Default TBWidget positioning 3 | size 350 350 4 | TBLayout: axis: y, distribution: gravity 5 | TBLayout: distribution: available, gravity: left right 6 | TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1 7 | text: "Any widget may contain children and by default applies basic gravity positioning.\n" \ 8 | "To achieve more advanced layout, you would normally wrap a layouting " \ 9 | "widget (f.ex TBLayout) but sometimes the default is enough.\n" \ 10 | "The default preferred size is calculated to the largest child " \ 11 | "(or the skin if there are no children)." 12 | TBContainer: gravity: all 13 | TBTextField: text: "all", gravity: all 14 | TBTextField: text: "top, left, right", gravity: top left right 15 | TBTextField: text: "bottom, left, right", gravity: bottom left right 16 | TBTextField: text: "left, top, bottom", gravity: left top bottom 17 | TBTextField: text: "right, top, bottom", gravity: right top bottom 18 | TBButton: text: Upper left 19 | TBButton: text: Upper right, gravity: right 20 | TBButton: text: Lower left, gravity: bottom 21 | TBButton: text: Lower right, gravity: bottom right 22 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_list_item.tb.txt: -------------------------------------------------------------------------------- 1 | TBCheckBox: id: check 2 | TBSkinImage: id: icon, skin: Icon48, ignore-input: 1 3 | TBLayout: axis: y, position: left, spacing: 0, ignore-input: 1, size: available, position: left top 4 | TBTextField: id: name, text-align: left 5 | TBTextField: id: info, text-align: left, state: disabled 6 | TBButton: id: delete, skin: TBWindow.close -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_radio_checkbox.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Radiobutton & checkbox 3 | TBLayout: position: left top, axis: y 4 | TBTextField: text: "Radiobuttons, anonymous group:" 5 | TBLayout: distribution: preferred 6 | TBRadioButton 7 | TBRadioButton 8 | TBRadioButton: state: disabled 9 | TBTextField: text: "Radiobuttons, group-id: 'R1'": 10 | TBLayout: distribution: preferred 11 | TBRadioButton: group-id: R1 12 | TBRadioButton: group-id: R1 13 | TBRadioButton: group-id: R1, state: disabled 14 | TBTextField: text: "Radiobuttons, group-id: 'R2' value set": 15 | TBLayout: distribution: preferred 16 | TBRadioButton: group-id: R2, value: 1 17 | TBRadioButton: group-id: R2 18 | TBRadioButton: group-id: R2, state: disabled 19 | TBTextField: text: "Checkboxes" 20 | TBLayout: distribution: preferred 21 | TBCheckBox 22 | TBCheckBox: value: 1 23 | TBCheckBox: state: disabled 24 | TBCheckBox: state: disabled, value: 1 25 | TBTextField: text: "TBClickLabel with radio & check" 26 | TBClickLabel: text: Some text to click 27 | TBCheckBox 28 | TBClickLabel: text: Some text to click 29 | TBRadioButton 30 | TBClickLabel: text: Some text to click, state: disabled 31 | TBCheckBox 32 | TBClickLabel: text: Some text to click, state: disabled 33 | TBRadioButton 34 | TBTextField: text: "Regular buttons with group-id: 'R3'": 35 | TBLayout: distribution: preferred 36 | TBButton: text: "A", group-id: "R3", value: 1 37 | TBButton: text: "B", group-id: "R3" 38 | TBButton: text: "C", group-id: "R3" 39 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_scroller_snap.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBScrollerSnapListener 3 | definitions 4 | pagesize 5 | lp: width: 200, height: 300 6 | TBScrollContainer: id: "page-scroller" 7 | @include definitions>pagesize 8 | scroll-mode off 9 | TBLayout 10 | spacing 0 11 | TBContainer 12 | @include definitions>pagesize 13 | TBTextField: text: "One - Swipe to next page" 14 | TBContainer 15 | @include definitions>pagesize 16 | TBTextField: text: "Two" 17 | TBContainer 18 | @include definitions>pagesize 19 | TBTextField: text: "Three" 20 | TBContainer 21 | @include definitions>pagesize 22 | TBTextField: text: "Four" 23 | TBContainer 24 | @include definitions>pagesize 25 | TBTextField: text: "Five - Last page" 26 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_select.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title List and filter 3 | position 1100 50 4 | TBLayout 5 | axis y 6 | distribution gravity 7 | gravity all 8 | TBEditField 9 | id filter 10 | gravity left right 11 | placeholder @search 12 | type search 13 | TBSelectList 14 | id list 15 | gravity all 16 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_select_advanced.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Customized list items 3 | position 770 50 4 | size 300 300 5 | TBLayout 6 | axis y 7 | distribution gravity 8 | gravity all 9 | TBLayout 10 | distribution gravity 11 | TBEditField 12 | id filter 13 | gravity left right 14 | placeholder @search 15 | type search 16 | TBSelectList 17 | id list 18 | gravity all 19 | TBLayout 20 | distribution gravity 21 | TBEditField 22 | id add_name 23 | gravity left right 24 | placeholder Name 25 | TBButton 26 | id add 27 | text Add 28 | TBButton 29 | id delete all 30 | text Delete all 31 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_skin_conditions01.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Skin conditions 3 | position 200 170 4 | TBLayout: axis: y 5 | TBTextField: text: Normal layout with buttons: 6 | TBContainer 7 | TBLayout 8 | TBButton: text: " A ", skin: "SpecialButton" 9 | TBButton: text: " B ", skin: "SpecialButton" 10 | TBButton: text: " C ", skin: "SpecialButton" 11 | TBTextField: text: Layout with skin "Starry buttons": 12 | TBContainer 13 | TBLayout: skin: Starry buttons 14 | TBButton: text: " A ", skin: "SpecialButton" 15 | TBButton: text: " B ", skin: "SpecialButton" 16 | TBButton: text: " C ", skin: "SpecialButton" 17 | TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 18 | text The skin has a condition to show a upper left positioned overlay "Star" if placed under a ancestor widget with skin "Starry buttons". The Star skin has conditions to change bitmap if the window is active and the parent widget or any child to it is hovered. 19 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_skin_conditions02.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Skin conditions 3 | position 500 170 4 | TBLayout 5 | axis y 6 | TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 7 | text The TBButton skin has a condition to show a different skin when placed under a parent widget with skin "button_group". There is also conditions to use a different skin for the first and last button. 8 | TBLayout 9 | TBLayout: skin: button_group 10 | TBButton 11 | text < 12 | TBButton 13 | text > 14 | TBLayout: skin: button_group 15 | TBButton 16 | text 1 17 | TBButton 18 | text 2 19 | TBButton 20 | text 3 21 | TBLayout: skin: button_group 22 | TBButton 23 | text A 24 | TBButton 25 | text B 26 | TBButton 27 | text C 28 | TBLayout: skin: button_group 29 | TBButton 30 | text Hello 31 | TBButton 32 | text World! 33 | TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 34 | text The "button_group" skin overrides default layout spacing. It can also be overridden in the UI resource. 35 | TBLayout: skin: button_group 36 | spacing 2 37 | TBButton 38 | text Group 39 | TBButton 40 | text with 41 | TBButton 42 | text spacing 43 | TBButton 44 | text 2 45 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_tabcontainer01.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBTabContainer & misc tests 3 | position 770 430 4 | TBTabContainer 5 | gravity all 6 | id tabcontainer 7 | tabs 8 | TBButton: text: "Tab with long text" 9 | TBButton: text: "Skin" 10 | TBButton: text: "Spinner" 11 | TBSkinImage: skin: Icon16 12 | TBLayout: axis: y 13 | TBTextField: text: "Tab alignment:" 14 | TBLayout 15 | TBClickLabel: text: Left 16 | TBRadioButton: group-id: set_align, id: set_align, data: 0 17 | TBClickLabel: text: Up 18 | TBRadioButton: group-id: set_align, id: set_align, data: 1, value: 1 19 | TBClickLabel: text: Right 20 | TBRadioButton: group-id: set_align, id: set_align, data: 2 21 | TBClickLabel: text: Bottom 22 | TBRadioButton: group-id: set_align, id: set_align, data: 3 23 | TBButton 24 | text Toggle tab axis 25 | id toggle_tab_axis 26 | TBLayout 27 | TBLayout: axis: y, position: right bottom 28 | TBButton: text: Normal button 29 | TBButton: text: Overridden skin, skin: SpecialButton 30 | TBButton: text: Disabled button, state: disabled 31 | TBEditField 32 | text TBEditField 33 | multiline 1 34 | TBLayout 35 | axis y 36 | TBButton: id: start_spinner, text: Start spinner 37 | TBButton: id: stop_spinner, text: Stop spinner 38 | TBProgressSpinner: id: spinner 39 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_textwindow.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Text editing 3 | position 280 50 4 | size 450 630 5 | TBLayout: axis: y, distribution: available 6 | TBLayout: distribution: gravity 7 | TBButton: id: undo 8 | TBSkinImage: skin: arrow.left 9 | TBButton: id: redo 10 | TBSkinImage: skin: arrow.right 11 | TBButton: text: Clear, id: clear 12 | TBLayout 13 | gravity left right 14 | distribution-position right bottom 15 | TBTextField: id: info 16 | TBButton: id: menu 17 | TBSkinImage: skin: arrow.down 18 | TBTextField: text: Menu 19 | skin TBButton.flat 20 | TBEditField: multiline: 1, styling: 1, gravity: all, id: editfield, autofocus: 1 21 | text: "Turbo Badger - Fast UI toolkit\n\n" \ 22 | "Test zone\n" \ 23 | "The menu to the left spawns some examples of features in turbo badger.\n\n" \ 24 | "The code in Demo/* is more like a developers test zone than organized tutorial-like samples. " \ 25 | "This would be good to fix of course (help is welcome! ;)\n\n" \ 26 | "Some things to try out\n" \ 27 | " • All layouts provide panning of content automatically when squashed below the minimal size, so try resizing windows and pan.\n" \ 28 | " • Lines starting with a bullet sequence (like this one) should wrap in a smart way.\n" \ 29 | " • Message windows whose target is removed, are automatically removed. Close the menu window with open messages.\n" \ 30 | " • Keyboard navigation using tab.\n" \ 31 | " • Underline, Red, Green, Blue\n\n" \ 32 | "Good to know\n" \ 33 | " • The text widget handles styling and embedded content (Example: ), but does not handle editing of those fully. Those features are only ment for read-only text widgets for now.\n" \ 34 | " • You can emulate touch input by holding down shift, ctrl or alt. Touch input behaves differently in some widgets (f.ex long click to open context menu in textfields), and only invoke movement when down.\n" \ 35 | " • All resources are UTF-8.\n" 36 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_toggle_containers.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title TBToggleContainer 3 | TBLayout: axis: y 4 | TBEditField: gravity: all, adapt-to-content: 1, multiline: 1, readonly: 1, skin: 0, virtual-width: 400 5 | text: "TBToggleContainer used with TBWidgetValue connections to automatically toggle a group of items (no programming needed)." 6 | 7 | TBLayout: position: top left 8 | TBContainer 9 | TBLayout: axis: y 10 | TBClickLabel: text: "Check to enable stuff:" 11 | TBCheckBox: connection: toggle_demo_1 12 | 13 | # == Toggle enabled ===================================================== 14 | TBToggleContainer: connection: toggle_demo_1, toggle: enabled 15 | TBLayout: axis: y 16 | TBClickLabel: text: "Option 1" 17 | TBRadioButton: group-id: group1, value: 1 18 | TBClickLabel: text: "Option 2" 19 | TBRadioButton: group-id: group1 20 | 21 | TBClickLabel: text: "Check to disable stuff:" 22 | TBCheckBox: connection: toggle_demo_2 23 | 24 | # == Toggle enabled, with the invert flag set =========================== 25 | TBToggleContainer: connection: toggle_demo_2, toggle: enabled, invert: 1 26 | TBLayout: axis: y 27 | TBClickLabel: text: "Option 1" 28 | TBRadioButton: group-id: group2, value: 1 29 | TBClickLabel: text: "Option 2" 30 | TBRadioButton: group-id: group2 31 | 32 | TBContainer 33 | TBLayout: axis: y 34 | TBClickLabel: text: "Check to show stuff:" 35 | TBCheckBox: connection: toggle_demo_3 36 | 37 | # == Toggle opacity ===================================================== 38 | TBToggleContainer: connection: toggle_demo_3, toggle: opacity 39 | TBLayout: axis: y 40 | TBClickLabel: text: "Option 1" 41 | TBRadioButton: group-id: group3, value: 1 42 | TBClickLabel: text: "Option 2" 43 | TBRadioButton: group-id: group3 44 | 45 | TBClickLabel: text: "Check to expand stuff:" 46 | TBCheckBox: connection: toggle_demo_4 47 | 48 | # == Toggle expand ====================================================== 49 | TBToggleContainer: connection: toggle_demo_4, toggle: expanded 50 | TBLayout: axis: y 51 | TBClickLabel: text: "Option 1" 52 | TBRadioButton: group-id: group4, value: 1 53 | TBClickLabel: text: "Option 2" 54 | TBRadioButton: group-id: group4 55 | -------------------------------------------------------------------------------- /Demo/demo01/ui_resources/test_ui.tb.txt: -------------------------------------------------------------------------------- 1 | WindowInfo 2 | title Turbo Badger 3 | position 10 50 4 | size 250 630 5 | 6 | TBLayout: axis: y, distribution-position: "left top", distribution: "available" 7 | 8 | TBSection: value: 1, text: "Misc features" 9 | TBLayout: axis: y, spacing: 0, size: available 10 | TBButton: skin: "TBButton.flat", text: "Radiobutton & Checkbox" 11 | id: "test-layout" 12 | data: "test_radio_checkbox.tb.txt" 13 | TBButton: skin: "TBButton.flat", text: "TBSelectList", id: "test-list" 14 | TBButton: skin: "TBButton.flat", text: "ScrollContainer & misc.", id: "test-scroll-container" 15 | TBButton: skin: "TBButton.flat", text: "TBWidgetValue connections", id: "test-connections" 16 | TBButton: skin: "TBButton.flat", text: "TBImage", id: "test-image" 17 | TBButton: skin: "TBButton.flat", text: "TBScrollerSnapListener", id: "test-page" 18 | TBButton: skin: "TBButton.flat", text: "Animations", id: "test-animations" 19 | TBButton: skin: "TBButton.flat", text: "Skin conditions", id: "test-skin-conditions" 20 | TBButton: skin: "TBButton.flat", text: "TBToggleContainer" 21 | id: "test-layout" 22 | data: "test_toggle_containers.tb.txt" 23 | TBButton: skin: "TBButton.flat", text: "Close with dim & alert", id: "TBWindow.close" 24 | TBButton: skin: "TBButton.flat", text: "ResourceEditWindow", id: "test-resource-edit" 25 | 26 | TBSection: value: 0, text: "Layout tests" 27 | TBLayout: axis: y, spacing: 0, size: available 28 | TBButton: skin: "TBButton.flat", text: "Size, gravity, position" 29 | id: "test-layout" 30 | data: "test_layout01.tb.txt" 31 | TBButton: skin: "TBButton.flat", text: "Distribution" 32 | id: "test-layout" 33 | data: "test_layout02.tb.txt" 34 | TBButton: skin: "TBButton.flat", text: "TBWidget default" 35 | id: "test-layout" 36 | data: "test_layout03.tb.txt" 37 | 38 | TBSection: value: 0, text: "Graphics tests" 39 | TBLayout: axis: y, spacing: 0, size: available 40 | TBClickLabel: text: "Continous repaint" 41 | lp: max-width: 0 42 | TBCheckBox: connection: continous-repaint 43 | TBButton: skin: "TBButton.flat", text: "Reload skin bitmaps", id: "reload skin bitmaps" 44 | TBButton: skin: "TBButton.flat", text: "Context lost & restore", id: "test context lost" 45 | 46 | TBSection: value: 0, text: "Message tests" 47 | TBLayout: axis: y, spacing: 0, size: available 48 | TBButton: skin: "TBButton.flat", text: "PostMessage", id: "msg" 49 | TBButton: skin: "TBButton.flat", text: "PostMessageDelayed", id: "delayedmsg" 50 | TBClickLabel: text: "Busy message loop" 51 | lp: max-width: 0 52 | TBCheckBox: id: "busymsg" 53 | 54 | # We want the debug button at the bottom if there is space over, 55 | # so use an trailing layout which may expand a lot. 56 | TBLayout: axis: y, distribution-position: bottom 57 | lp: max-height: 10000 58 | TBButton: id: "debug settings", text: "Runtime debug settings..." 59 | -------------------------------------------------------------------------------- /Demo/fonts/license.txt: -------------------------------------------------------------------------------- 1 | This folder has some default fonts for demo purposes. 2 | 3 | The license of the files in this folder is Public Domain, however 4 | i can't guarantee that using rasterized graphics from copyrighted 5 | fonts as a bitmap font is ok. Use at your own risk! 6 | -------------------------------------------------------------------------------- /Demo/fonts/neon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/neon.psd -------------------------------------------------------------------------------- /Demo/fonts/neon.tb.txt: -------------------------------------------------------------------------------- 1 | info 2 | glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€£¥§•·©«»®¶ÅÄÖÆØåäöæø 3 | rgb 1 4 | name Neon 5 | size 42 6 | bitmap neon_42.png 7 | ascent 50 8 | descent 16 9 | x_ofs -6 10 | advance_delta -12 11 | space_advance 12 12 | -------------------------------------------------------------------------------- /Demo/fonts/neon_42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/neon_42.png -------------------------------------------------------------------------------- /Demo/fonts/orange.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/orange.psd -------------------------------------------------------------------------------- /Demo/fonts/orange.tb.txt: -------------------------------------------------------------------------------- 1 | info 2 | glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…ˆŠ‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¥¦§¨©«®´µ¶·¸¹º»¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüþÿ 3 | name Orange 4 | rgb 1 5 | size 30 6 | bitmap orange_30.png 7 | ascent 62 8 | descent 25 9 | x_ofs -7 10 | advance_delta -20 11 | space_advance 22 12 | -------------------------------------------------------------------------------- /Demo/fonts/orange_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/orange_30.png -------------------------------------------------------------------------------- /Demo/fonts/orangutang.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/orangutang.psd -------------------------------------------------------------------------------- /Demo/fonts/orangutang.tb.txt: -------------------------------------------------------------------------------- 1 | info 2 | glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€£¥§•·©«»®¶ÅÄÖÆØåäöæø 3 | rgb 1 4 | name Orangutang 5 | size 48 6 | bitmap orangutang_48.png 7 | ascent 51 8 | descent 15 9 | x_ofs -2 10 | advance_delta -4 11 | space_advance 12 12 | -------------------------------------------------------------------------------- /Demo/fonts/orangutang_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/fonts/orangutang_48.png -------------------------------------------------------------------------------- /Demo/platform/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "animation/tb_widget_animation.h" 2 | #include "Application.h" 3 | 4 | using namespace tb; 5 | 6 | // == AppRootWidget =============================================================================== 7 | 8 | void AppRootWidget::OnInvalid() 9 | { 10 | if (m_app->GetBackend()) 11 | m_app->GetBackend()->OnAppEvent(AppBackend::EVENT_PAINT_REQUEST); 12 | } 13 | 14 | bool AppRootWidget::OnEvent(const TBWidgetEvent & ev) 15 | { 16 | switch (ev.type) { 17 | case EVENT_TYPE_KEY_UP: 18 | if ((ev.modifierkeys & (TB_CTRL | TB_SUPER))) { 19 | switch (ev.key) { 20 | case 'q': 21 | case 'Q': 22 | m_app->GetBackend()->OnAppEvent(AppBackend::EVENT_QUIT_REQUEST); 23 | return true; 24 | } 25 | } 26 | //TBDebugPrint("Unhandled key event: %c, modifiers:0x%x\n", ev.key, ev.modifierkeys); 27 | default: 28 | break; 29 | } 30 | 31 | return false; 32 | } 33 | 34 | // == App ========================================================================================= 35 | 36 | App::App(int width, int height) 37 | : m_backend(nullptr) 38 | , m_root(this) 39 | { 40 | // Set initial size which suggest to the backend which size we want the window to be. 41 | m_root.SetRect(TBRect(0, 0, width, height)); 42 | } 43 | 44 | void App::OnBackendAttached(AppBackend *backend, int width, int height) 45 | { 46 | m_backend = backend; 47 | OnResized(width, height); 48 | } 49 | 50 | void App::OnBackendDetached() 51 | { 52 | m_root.DeleteAllChildren(); 53 | m_backend = nullptr; 54 | } 55 | 56 | void App::OnResized(int width, int height) 57 | { 58 | m_root.SetRect(TBRect(0, 0, width, height)); 59 | } 60 | 61 | bool App::Init() 62 | { 63 | TBWidgetsAnimationManager::Init(); 64 | return true; 65 | } 66 | 67 | void App::ShutDown() 68 | { 69 | TBWidgetsAnimationManager::Shutdown(); 70 | } 71 | 72 | void App::Process() 73 | { 74 | TBAnimationManager::Update(); 75 | m_root.InvokeProcessStates(); 76 | m_root.InvokeProcess(); 77 | } 78 | 79 | void App::RenderFrame() 80 | { 81 | g_renderer->BeginPaint(m_root.GetRect().w, m_root.GetRect().h); 82 | m_root.InvokePaint(TBWidget::PaintProps()); 83 | g_renderer->EndPaint(); 84 | 85 | // If animations are running, reinvalidate immediately 86 | if (TBAnimationManager::HasAnimationsRunning()) 87 | GetRoot()->Invalidate(); 88 | } 89 | -------------------------------------------------------------------------------- /Demo/platform/Application.h: -------------------------------------------------------------------------------- 1 | #ifndef APPLICATION_H 2 | #define APPLICATION_H 3 | 4 | #include "tb_widgets.h" 5 | 6 | // -------------------------------------------------------------------------------------- 7 | // This file contains some platform glue that is optional. It may help you set up a TB UI 8 | // for a game or application quicker or just function as a sample of how it can be done. 9 | // -------------------------------------------------------------------------------------- 10 | 11 | class App; 12 | class AppBackend; 13 | 14 | /** The root of widgets in a platform backend. */ 15 | class AppRootWidget : public tb::TBWidget 16 | { 17 | public: 18 | // For safe typecasting 19 | TBOBJECT_SUBCLASS(AppRootWidget, tb::TBWidget); 20 | 21 | AppRootWidget(App *app) : m_app(app) {} 22 | virtual void OnInvalid(); 23 | virtual bool OnEvent(const tb::TBWidgetEvent & ev); 24 | 25 | App *GetApp() { return m_app; } 26 | private: 27 | App *m_app; 28 | }; 29 | 30 | /** Backend interface that handles platform window & creating the renderer. */ 31 | class AppBackend 32 | { 33 | public: 34 | enum EVENT { 35 | EVENT_PAINT_REQUEST, 36 | EVENT_QUIT_REQUEST, 37 | EVENT_TITLE_CHANGED 38 | }; 39 | virtual ~AppBackend() {} 40 | virtual void EventLoop() = 0; 41 | virtual void OnAppEvent(const EVENT &ev) = 0; 42 | }; 43 | 44 | /** Application interface, for setting up the application using turbo badger. */ 45 | class App 46 | { 47 | public: 48 | App(int width, int height); 49 | virtual ~App() {} 50 | 51 | virtual const char *GetTitle() const { return ""; } 52 | int GetWidth() const { return m_root.GetRect().w; } 53 | int GetHeight() const { return m_root.GetRect().h; } 54 | 55 | tb::TBWidget *GetRoot() { return &m_root; } 56 | AppBackend *GetBackend() { return m_backend; } 57 | 58 | virtual void OnBackendAttached(AppBackend *backend, int width, int height); 59 | virtual void OnBackendDetached(); 60 | virtual void OnResized(int width, int height); 61 | 62 | virtual bool Init(); 63 | virtual void ShutDown(); 64 | virtual void Process(); 65 | virtual void RenderFrame(); 66 | protected: 67 | AppBackend *m_backend; 68 | AppRootWidget m_root; 69 | }; 70 | 71 | /** Should return new instance of App. */ 72 | App *app_create(); 73 | 74 | #endif // APPLICATION_H 75 | -------------------------------------------------------------------------------- /Demo/platform/glfw_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef GLFW_EXTRA_H 2 | #define GLFW_EXTRA_H 3 | 4 | #ifdef _WIN32 5 | #include // Avoid compilation warnings in GLFW/glfw.h 6 | #include 7 | #endif 8 | #include "GLFW/glfw3.h" 9 | 10 | /* Function pointer types */ 11 | typedef void (* GLFWtimerfun)(); 12 | 13 | /** Do something (like posting a dummy message) to get the message loop to stop waiting 14 | in glfwWaitMsgLoop. */ 15 | void glfwWakeUpMsgLoop(GLFWwindow *window); 16 | 17 | /** Wait for a new message in the message loop. Should stop waiting if glfwWakeUpMsgLoop is called. */ 18 | void glfwWaitMsgLoop(GLFWwindow *window); 19 | 20 | /** Handle message(s) waiting in the message loop, or return immediately if there are none. */ 21 | void glfwPollMsgLoop(GLFWwindow *window); 22 | 23 | /** Start a timer that after the delay will call the callback set by glfwSetTimerCallback. 24 | Calling this should cancel any previously scheduled time out that has not yet happened. */ 25 | void glfwRescheduleTimer(unsigned int delay_ms); 26 | 27 | /** Kill the timer started by glfwRescheduleTimer. */ 28 | void glfwKillTimer(); 29 | 30 | /** Set the callback that should be called on timeout scheduled by glfwRescheduleTimer. */ 31 | void glfwSetTimerCallback(GLFWtimerfun cbfun); 32 | 33 | #endif // GLFW_EXTRA_H 34 | -------------------------------------------------------------------------------- /Demo/platform/glfw_extra_linux.cpp: -------------------------------------------------------------------------------- 1 | #include "tb_system.h" 2 | 3 | #if defined(TB_SYSTEM_LINUX) || defined(TB_SYSTEM_MACOSX) 4 | 5 | #include "glfw_extra.h" 6 | #include "tb_msg.h" 7 | #include 8 | 9 | //#include 10 | 11 | //#define GLX_GLXEXT_LEGACY 12 | //#include 13 | 14 | //#define GLFW_EXPOSE_NATIVE_X11_GLX 15 | //#include "GLFW/glfw3native.h" 16 | 17 | //#include "GLFW/glfw3.h" 18 | 19 | // ## NOTE ############################################ 20 | // FIX: Implement message loop and timer on linux! 21 | // For now, just poll using glfwPollEvents and 22 | // always call timer callback, so we keep spinning 23 | // and can at least run our code. 24 | 25 | GLFWtimerfun timerCallback; 26 | 27 | void glfwWakeUpMsgLoop(GLFWwindow *window) 28 | { 29 | } 30 | 31 | void glfwWaitMsgLoop(GLFWwindow *window) 32 | { 33 | glfwPollEvents(); 34 | if (timerCallback) 35 | timerCallback(); 36 | } 37 | 38 | void glfwPollMsgLoop(GLFWwindow *window) 39 | { 40 | glfwPollEvents(); 41 | if (timerCallback) 42 | timerCallback(); 43 | } 44 | 45 | void glfwRescheduleTimer(unsigned int delay_ms) 46 | { 47 | } 48 | 49 | void glfwKillTimer() 50 | { 51 | } 52 | 53 | void glfwSetTimerCallback(GLFWtimerfun cbfun) 54 | { 55 | timerCallback = cbfun; 56 | } 57 | 58 | #endif // defined(TB_SYSTEM_LINUX) || defined(TB_SYSTEM_MACOSX) 59 | -------------------------------------------------------------------------------- /Demo/platform/port_glfw.hpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- 2 | #include "Application.h" 3 | 4 | #ifdef TB_BACKEND_GLFW 5 | #include "glfw_extra.h" 6 | #include "tb_widgets.h" 7 | #include "renderers/tb_renderer_gl.h" 8 | 9 | using namespace tb; 10 | 11 | class AppBackendGLFW : public AppBackend 12 | { 13 | public: 14 | bool Init(App *app); 15 | AppBackendGLFW() : m_app(nullptr) 16 | , m_renderer(nullptr) 17 | , mainWindow(0) 18 | , m_cursor_i_beam(nullptr) 19 | , m_has_pending_update(false) 20 | , m_quit_requested(false) {} 21 | ~AppBackendGLFW(); 22 | 23 | virtual void EventLoop(); 24 | virtual void OnAppEvent(const EVENT &ev); 25 | 26 | TBWidget *GetRoot() const { return m_app->GetRoot(); } 27 | int GetWidth() const { return m_app->GetWidth(); } 28 | int GetHeight() const { return m_app->GetHeight(); } 29 | 30 | App *m_app; 31 | TBRendererGL *m_renderer; 32 | GLFWwindow *mainWindow; 33 | GLFWcursor *m_cursor_i_beam; 34 | bool m_has_pending_update; 35 | bool m_quit_requested; 36 | }; 37 | 38 | #endif // TB_BACKEND_GLFW 39 | -------------------------------------------------------------------------------- /Demo/platform/port_sdl2.hpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- 2 | #include "Application.h" 3 | 4 | #ifdef TB_BACKEND_SDL2 5 | 6 | #include "tb_widgets.h" 7 | #include "renderers/tb_renderer_gl.h" 8 | 9 | #ifdef __APPLE__ 10 | #include 11 | #endif 12 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 13 | #include "SDL2/SDL.h" 14 | #else 15 | #ifdef _WIN32 16 | #include 17 | #endif 18 | #include "SDL.h" 19 | #endif 20 | 21 | using namespace tb; 22 | 23 | class AppBackendSDL2 : public AppBackend 24 | { 25 | public: 26 | bool Init(App *app); 27 | AppBackendSDL2() : m_quit_requested(false) 28 | , m_app(nullptr) 29 | , m_renderer(nullptr) 30 | , mainWindow(0) 31 | , m_has_pending_update(false) 32 | , m_xscale(1) 33 | , m_yscale(1) {} 34 | ~AppBackendSDL2(); 35 | 36 | virtual void EventLoop(); 37 | virtual void OnAppEvent(const EVENT &ev); 38 | 39 | TBWidget *GetRoot() const { return m_app->GetRoot(); } 40 | int GetWidth() const { return m_app->GetWidth(); } 41 | int GetHeight() const { return m_app->GetHeight(); } 42 | 43 | bool HandleSDLEvent(SDL_Event & event); 44 | bool m_quit_requested; 45 | private: 46 | bool InvokeKey(unsigned int key, SPECIAL_KEY special_key, 47 | MODIFIER_KEYS modifierkeys, bool down); 48 | void QueueUserEvent(Sint32 code, void * data1 = NULL, void * data2 = NULL); 49 | 50 | App *m_app; 51 | TBRendererGL *m_renderer; 52 | SDL_Window *mainWindow; 53 | SDL_GLContext glContext; 54 | bool m_has_pending_update; 55 | float m_xscale, m_yscale; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Demo/screenshot/screenshot_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/Demo/screenshot/screenshot_01.png -------------------------------------------------------------------------------- /DemoAndroid/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | //buildToolsVersion "28.0.3" 6 | 7 | defaultConfig { 8 | applicationId "org.hastybadger.demo" 9 | minSdkVersion 14 10 | targetSdkVersion 29 11 | versionCode 19 // internal code, integer, must monotonically increase 12 | versionName "1.0.0" // string shown to users 13 | externalNativeBuild { 14 | cmake { 15 | arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", 16 | "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON", "-DSKIP_INSTALL_ALL=ON", 17 | "-DTB_RENDERER=GLES_1", "-DTB_ALWAYS_SHOW_EDIT_FOCUS:BOOL=ON", 18 | "-DTB_BUILD_DEMO=ANDROID", "-DANDROID_ARM_MODE=arm", 19 | '-DTB_RUNTIME_DEBUG_INFO:BOOL=ON' 20 | targets "TurboBadger" 21 | } 22 | } 23 | 24 | ndk { 25 | abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', "x86_64" 26 | moduleName "libTurboBadger" 27 | } 28 | 29 | } 30 | 31 | buildTypes { 32 | release { 33 | minifyEnabled false 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 35 | } 36 | } 37 | externalNativeBuild { 38 | cmake { 39 | version "3.10.2+" 40 | path "../../CMakeLists.txt" 41 | } 42 | } 43 | lintOptions { 44 | //checkReleaseBuilds false 45 | // Or, if you prefer, you can continue to check for errors in release builds, 46 | // but continue the build even when errors are found: 47 | abortOnError false 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 29 | 30 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/assets/images/image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/assets/images/image_1.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/assets/images/tb_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/assets/images/tb_logo.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/java/org/hastybadger/demo/TBActivity.java: -------------------------------------------------------------------------------- 1 | package org.hastybadger.demo; 2 | 3 | import android.app.Activity; 4 | import android.content.res.AssetManager; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | 9 | 10 | public class TBActivity extends Activity 11 | { 12 | static AssetManager sAssetManager; 13 | TBView mView; 14 | 15 | // On applications creation 16 | @Override protected void onCreate(Bundle savedInstanceState) 17 | { 18 | super.onCreate(savedInstanceState); 19 | 20 | // Pass the asset manager to the native code 21 | sAssetManager = getAssets(); 22 | TBLib.createAssetManager(sAssetManager); 23 | 24 | // Create our view for OpenGL rendering 25 | mView = new TBView(getApplication()); 26 | 27 | setContentView(mView); 28 | } 29 | 30 | @Override protected void onPause() 31 | { 32 | super.onPause(); 33 | mView.onPause(); 34 | } 35 | 36 | @Override protected void onResume() 37 | { 38 | super.onResume(); 39 | mView.onResume(); 40 | } 41 | 42 | @Override public void onBackPressed () 43 | { 44 | // FIX: Queue event to correct thread but wait for return value! 45 | // if (TBLib.OnBackKey() == 0) 46 | super.onBackPressed(); 47 | } 48 | 49 | @Override public boolean onCreateOptionsMenu(Menu menu) 50 | { 51 | /*if (mInitiated) 52 | { 53 | mView.queueEvent(new Runnable() { 54 | public void run() { 55 | TBLib.OnMenuKey(); 56 | }}); 57 | } 58 | return false; */ 59 | menu.add("Exit"); 60 | return super.onCreateOptionsMenu(menu); 61 | } 62 | 63 | @Override public boolean onOptionsItemSelected(MenuItem item) 64 | { 65 | // Exit 66 | mView.queueEvent(new Runnable() { 67 | public void run() { 68 | TBLib.ShutDownApp(); 69 | }}); 70 | return false; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/java/org/hastybadger/demo/TBLib.java: -------------------------------------------------------------------------------- 1 | package org.hastybadger.demo; 2 | 3 | import android.content.res.AssetManager; 4 | 5 | public class TBLib 6 | { 7 | static 8 | { 9 | System.loadLibrary("TurboBadger"); 10 | } 11 | static boolean sInitiated = false; 12 | 13 | public static native void createAssetManager(AssetManager assetManager); 14 | 15 | public static native void InitApp(int width, int height, String settings_path, String custom_data_path); 16 | public static native void ShutDownApp(); 17 | 18 | public static native void OnPauseApp(); 19 | public static native void OnResumeApp(); 20 | 21 | public static native void OnPointer(float x, float y, int down); 22 | public static native void OnPointer2(float x, float y, int down); 23 | public static native void OnPointerMove(float x, float y, float x2, float y2); 24 | 25 | public static native int OnBackKey(); 26 | public static native int OnMenuKey(); 27 | 28 | public static native void OnContextLost(); 29 | public static native void OnContextRestored(); 30 | public static native void OnSurfaceResized(int width, int height); 31 | 32 | public static native void RunSlice(); 33 | 34 | // Methods called from the C++ code 35 | public static void ShowKeyboard(int show) { 36 | TBView.ShowKeyboard(show); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/jni/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | // == CALLS FROM NATIVE TO JAVA ========================================================= 5 | void ShowKeyboard(bool show); 6 | 7 | // == CALLS FROM JAVA TO NATIVE ========================================================= 8 | void Init(unsigned int width, unsigned int height); 9 | void Resize(unsigned int width, unsigned int height); 10 | void Update(); 11 | void Render(); 12 | void Shutdown(); 13 | 14 | #endif // APP_H 15 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi armeabi-v7a x86 2 | #APP_ABI := armeabi-v7a 3 | 4 | APP_OPTIM := release 5 | -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Turbo Badger Demo 4 | 5 | -------------------------------------------------------------------------------- /DemoAndroid/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | google() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:4.0.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | google() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DemoAndroid/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/DemoAndroid/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /DemoAndroid/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jul 27 00:16:07 CDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /DemoAndroid/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | $(MAKE) glfw sdl2 lib 4 | [ `uname` != 'Darwin' ] || $(MAKE) osx ios 5 | [ ! -d ~/.android ] || $(MAKE) and 6 | [ ! -f ~/.emscripten ] || $(MAKE) em em-glfw 7 | 8 | glfw: 9 | [ -f Build-glfw/Makefile ] || cmake . -BBuild-glfw -DTB_RENDERER=GL -DTB_BUILD_DEMO=GLFW 10 | cd Build-glfw && $(MAKE) package 11 | 12 | sdl2: 13 | [ -f Build-sdl2/Makefile ] || cmake . -BBuild-sdl2 -DTB_RENDERER=GL3 -DTB_BUILD_DEMO=SDL2 14 | cd Build-sdl2 && $(MAKE) package 15 | 16 | Build-emsc/Makefile: 17 | # source ${HOME}/local/emsdk/emsdk_env.sh ; 18 | emcmake cmake . -BBuild-emsc -DTB_BUILD_DEMO=SDL2 -DCMAKE_BUILD_TYPE=Debug 19 | 20 | em-sdl2: Build-emsc/Makefile 21 | cd Build-emsc && $(MAKE) 22 | 23 | Build-emscgl/Makefile: 24 | # source ${HOME}/local/emsdk/emsdk_env.sh ; 25 | emcmake cmake . -BBuild-emscgl -DTB_BUILD_DEMO=GLFW -DCMAKE_BUILD_TYPE=Debug 26 | 27 | em-glfw: Build-emscgl/Makefile 28 | cd Build-emscgl && $(MAKE) 29 | 30 | em: em-sdl2 # em-glfw 31 | 32 | emrun: 33 | cd Build-emsc && emrun TurboBadgerDemo.html 34 | 35 | Build-osx/TurboBadger.xcodeproj: 36 | cmake . -G Xcode -BBuild-osx -DTB_RENDERER=GL3 -DTB_BUILD_DEMO=SDL2 37 | 38 | osx: Build-osx/TurboBadger.xcodeproj 39 | cd Build-osx && cmake --build . -j 8 --target package --config Debug 40 | 41 | osxr: Build-osx/TurboBadger.xcodeproj 42 | cd Build-osx && cmake --build . --target package --config Release 43 | 44 | Build-ios/TurboBadger.xcodeproj: 45 | cmake . -G Xcode -BBuild-ios -DCMAKE_TOOLCHAIN_FILE=cmake/iOS.cmake -DTB_BUILD_DEMO=SDL2 46 | 47 | ios: Build-ios/TurboBadger.xcodeproj 48 | cd Build-ios && cmake --build . --target package --config Debug 49 | 50 | iosr: Build-ios/TurboBadger.xcodeproj 51 | cd Build-ios && cmake --build . --target package --config Release 52 | 53 | lib: 54 | [ -d Build-lib ] || cmake . -BBuild-lib -DTB_BACKEND=GLFW -DTB_BUILD_GLFW=ON 55 | # [ -d Build-lib ] || cmake . -BBuild-lib -DTB_BACKEND=SDL2 -DTB_BUILD_SDL2=ON 56 | cd Build-lib && cmake --build . --config Release 57 | 58 | and: 59 | cd DemoAndroid && ./gradlew build 60 | 61 | website: em-sdl2 62 | ./doc/ghpages.sh 63 | 64 | distclean: 65 | rm -rf Build-* 66 | 67 | #%: 68 | # cd Build && $(MAKE) $@ 69 | # 70 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/ghpages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Generage the gh-pages branch from this doxygen 4 | # 5 | set -xe 6 | 7 | SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" 8 | 9 | # make sure we're in the right place 10 | cd "${SRC_DIR}" 11 | [ -d DemoAndroid/app ] || exit 1 12 | [ -d Demo/demo01 ] || exit 1 13 | [ -f doc/Doxyfile.in ] || exit 1 14 | [ "${SRC_DIR}/Build-emsc/doc/Doxyfile" ] || exit 1 15 | EMSCRIPTEN_FILES=" 16 | TurboBadgerDemo.html 17 | TurboBadgerDemo.data 18 | TurboBadgerDemo.wasm 19 | TurboBadgerDemo.js" 20 | for F in ${EMSCRIPTEN_FILES} ; do 21 | if ! [ -f "Build-emsc/${F}" ]; then 22 | echo "Unable to find 'Build-emsc/${F}', did you build the Emscripten Demo?" 23 | exit 1 24 | fi 25 | done 26 | 27 | # should already be configured 28 | cd "${SRC_DIR}/Build-emsc" 29 | make TurboBadgerDemo 30 | 31 | # get a new tb 32 | if [ ! -f "doc/html/index.html" ]; then 33 | # cleanup old doc location 34 | rm -rf "doc/html" 35 | mkdir -p "doc/html" 36 | cd "doc/html" 37 | git clone --depth 1 --branch gh-pages git@github.com:tesch1/turbobadger.git . 38 | fi 39 | 40 | cd "${SRC_DIR}/Build-emsc/doc/html" 41 | echo "Removing old doxygen'd docs..." 42 | git rm -rf * 43 | 44 | # make the docs 45 | cd "${SRC_DIR}/Build-emsc" 46 | make docs 47 | [ -f doc/html/index.html ] || exit 1 48 | 49 | # copy the demo files 50 | for F in ${EMSCRIPTEN_FILES} ; do 51 | cp "${SRC_DIR}/Build-emsc/${F}" "${SRC_DIR}/Build-emsc/doc/html/" 52 | done 53 | 54 | # check the docs in 55 | cd "${SRC_DIR}/Build-emsc/doc/html" 56 | git add . 57 | git commit . -m 'updated doxygen docs' --amend 58 | 59 | set +x 60 | echo "to commit to github:" 61 | echo "cd ${SRC_DIR}/Build-emsc/doc/html && git push -f --set-upstream origin gh-pages" 62 | echo "or to view:" 63 | echo "xdg-open ${SRC_DIR}/Build-emsc/doc/html/index.html" 64 | # git push -f --set-upstream origin gh-pages 65 | -------------------------------------------------------------------------------- /doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | $treeview 14 | $search 15 | $mathjax 16 | 17 | $extrastylesheet 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
34 | 35 |
$projectname 36 |  $projectnumber 37 |
38 |
39 |
$projectbrief
40 |
45 |
$projectbrief
46 |
$searchbox
57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /doc/skindoc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # 4 | # generate a doc file from a skin file/path 5 | # 6 | 7 | from __future__ import print_function, division 8 | import os, sys 9 | import re 10 | 11 | if __name__ == "__main__": 12 | if len(sys.argv) != 2: 13 | print('usage:',sys.argv[0],' ') 14 | exit(1) 15 | 16 | skinfile = sys.argv[1] 17 | skindir = os.path.dirname(skinfile) 18 | skindoc = skindir+'/skin.h' 19 | skin_name = os.path.basename(skindir) 20 | pngs = [] 21 | 22 | # get the image file names from the skin file 23 | regex = re.compile('\w+\.svg|\w+\.png') 24 | with open(skinfile, 'r') as f: 25 | for line in f: 26 | #print(line) 27 | pngs += regex.findall(line) 28 | 29 | # dump a doxygen-file with the images & image names 30 | with open(skindoc, 'w') as f: 31 | print('/** @page skin_%s Skin %s' % (skin_name, skin_name), file=f) 32 | 33 | i = 0 34 | print('', file=f) 35 | print('Skin "%s"' % (skin_name), file=f) 36 | print('', file=f) 37 | print('https://github.com/tesch1/turbobadger/blob/hastybadger/resources/%s' 38 | % (os.path.basename(skinfile)), file=f) 39 | print('', file=f) 40 | f.write('\n') 41 | for img in pngs: 42 | if i == 0: 43 | f.write(' \n') 44 | #print(' \image ',img, img.split('.')[0]) 45 | f.write('
\image html %s %s\n' % (img, img.split('.')[0])) 46 | #print('', file=f) 47 | #f.write(' ![%s](%s)' % (img.split('.')[0], img) ) 48 | i = i + 1 49 | if i == 4: 50 | i = 0 51 | f.write('
') 52 | 53 | print('*/', file=f) 54 | 55 | print('wrote',skindoc) 56 | -------------------------------------------------------------------------------- /ide_extensions/VisualStudio/install.bat: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | 4 | REM set the current directory to where the bat file is 5 | cd /d %~dp0 6 | 7 | copy turbobadger.natvis "%USERPROFILE%\Documents\Visual Studio 11\Visualizers\" 8 | -------------------------------------------------------------------------------- /ide_extensions/VisualStudio/turbobadger.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {s} 5 | s 6 | 7 | 8 | {{x={x} y={y} w={w} h={h}}} 9 | 10 | 11 | Unspecified font (inherit) 12 | Test dummy font, size: {m_packed.size} 13 | {m_id.debug_string.s}, size: {m_packed.size} 14 | 15 | 16 | NULL 17 | {val_str} 18 | {val_float} 19 | {val_int} 20 | array {val_arr} 21 | 22 | 23 | {m_list} 24 | 25 | 26 | length = {m_data->num} 27 | length = 0 28 | 29 | 30 | type={type} 31 | 32 | 33 | -------------------------------------------------------------------------------- /resources/default_font/license.txt: -------------------------------------------------------------------------------- 1 | This folder has some default fonts for demo purposes. 2 | 3 | The license of the files in this folder is Public Domain, however 4 | i can't guarantee that using rasterized graphics from copyrighted 5 | fonts as a bitmap font is ok. Use at your own risk! 6 | -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow.tb.txt: -------------------------------------------------------------------------------- 1 | info 2 | glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ 3 | name Segoe 4 | size 14 5 | bitmap segoe_white_with_shadow_14.png 6 | ascent 15 7 | descent 5 8 | advance_delta -3 9 | space_advance 5 10 | size 28 11 | bitmap segoe_white_with_shadow_28.png 12 | ascent 31 13 | descent 10 14 | advance_delta -7 15 | space_advance 10 16 | -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_font/segoe_white_with_shadow_14.png -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow_14.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_font/segoe_white_with_shadow_14.psd -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_font/segoe_white_with_shadow_28.png -------------------------------------------------------------------------------- /resources/default_skin/TBSectionContainer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/TBSectionContainer.png -------------------------------------------------------------------------------- /resources/default_skin/TBSectionContainer.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/TBSectionContainer.psd -------------------------------------------------------------------------------- /resources/default_skin/TBSectionHeader.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/TBSectionHeader.psd -------------------------------------------------------------------------------- /resources/default_skin/arrow.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow.psd -------------------------------------------------------------------------------- /resources/default_skin/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_down.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_down@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_down@240.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_down@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_down@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_left.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_left@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_left@240.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_left@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_left@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_right.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_right@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_right@240.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_right@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_right@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_up.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_up@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_up@240.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_up@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/arrow_up@384.png -------------------------------------------------------------------------------- /resources/default_skin/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button.png -------------------------------------------------------------------------------- /resources/default_skin/button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button.psd -------------------------------------------------------------------------------- /resources/default_skin/button_flat.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_flat.psd -------------------------------------------------------------------------------- /resources/default_skin/button_flat_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_flat_outline.png -------------------------------------------------------------------------------- /resources/default_skin/button_flat_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_flat_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped.psd -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_first_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_first_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_first_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_first_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_last_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_last_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_last_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_last_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_middle_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_middle_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_middle_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_grouped_x_middle_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/button_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox@240.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_mark.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_mark@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_mark@240.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_mark@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_mark@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_pressed@240.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkbox_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkradio.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/checkradio.psd -------------------------------------------------------------------------------- /resources/default_skin/container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/container.png -------------------------------------------------------------------------------- /resources/default_skin/container.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/container.psd -------------------------------------------------------------------------------- /resources/default_skin/dropdown_button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/dropdown_button.psd -------------------------------------------------------------------------------- /resources/default_skin/editfield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/editfield.png -------------------------------------------------------------------------------- /resources/default_skin/editfield.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/editfield.psd -------------------------------------------------------------------------------- /resources/default_skin/fadeout.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/fadeout.psd -------------------------------------------------------------------------------- /resources/default_skin/fadeout_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/fadeout_x.png -------------------------------------------------------------------------------- /resources/default_skin/fadeout_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/fadeout_y.png -------------------------------------------------------------------------------- /resources/default_skin/focus.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/focus.psd -------------------------------------------------------------------------------- /resources/default_skin/focus_r4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/focus_r4.png -------------------------------------------------------------------------------- /resources/default_skin/focus_tabbutton_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/focus_tabbutton_left.png -------------------------------------------------------------------------------- /resources/default_skin/focus_tabbutton_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/focus_tabbutton_top.png -------------------------------------------------------------------------------- /resources/default_skin/hover.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/hover.psd -------------------------------------------------------------------------------- /resources/default_skin/item.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/item.psd -------------------------------------------------------------------------------- /resources/default_skin/item_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/item_hover.png -------------------------------------------------------------------------------- /resources/default_skin/item_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/item_selected.png -------------------------------------------------------------------------------- /resources/default_skin/item_separator_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/item_separator_x.png -------------------------------------------------------------------------------- /resources/default_skin/item_separator_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/item_separator_y.png -------------------------------------------------------------------------------- /resources/default_skin/license.txt: -------------------------------------------------------------------------------- 1 | This is the default skin of Turbo Badger. 2 | The license of the skin is Public Domain. 3 | 4 | For more information about Turbo Badger and its license, 5 | see tb_core.h. 6 | -------------------------------------------------------------------------------- /resources/default_skin/messageicon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/messageicon.psd -------------------------------------------------------------------------------- /resources/default_skin/mover_tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/mover_tile.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_gear.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/progress_spinner_gear.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_strip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/progress_spinner_strip.png -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_strip@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/progress_spinner_strip@192.png -------------------------------------------------------------------------------- /resources/default_skin/progress_x.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/progress_x.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_y.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/progress_y.psd -------------------------------------------------------------------------------- /resources/default_skin/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio.png -------------------------------------------------------------------------------- /resources/default_skin/radio@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio@240.png -------------------------------------------------------------------------------- /resources/default_skin/radio@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio@384.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_mark.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_mark@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_mark@240.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_mark@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_mark@384.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_pressed@240.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/radio_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/resizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer.png -------------------------------------------------------------------------------- /resources/default_skin/resizer.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer.psd -------------------------------------------------------------------------------- /resources/default_skin/resizer@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer@192.png -------------------------------------------------------------------------------- /resources/default_skin/resizer@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer@240.png -------------------------------------------------------------------------------- /resources/default_skin/resizer@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer@288.png -------------------------------------------------------------------------------- /resources/default_skin/resizer@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/resizer@384.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_bg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/scroll_bg_x.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_bg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/scroll_bg_y.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_fg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/scroll_fg_x.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_fg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/scroll_fg_y.png -------------------------------------------------------------------------------- /resources/default_skin/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search.png -------------------------------------------------------------------------------- /resources/default_skin/search.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search.psd -------------------------------------------------------------------------------- /resources/default_skin/search@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search@192.png -------------------------------------------------------------------------------- /resources/default_skin/search@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search@240.png -------------------------------------------------------------------------------- /resources/default_skin/search@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search@288.png -------------------------------------------------------------------------------- /resources/default_skin/search@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/search@384.png -------------------------------------------------------------------------------- /resources/default_skin/selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/selection.png -------------------------------------------------------------------------------- /resources/default_skin/selection.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/selection.psd -------------------------------------------------------------------------------- /resources/default_skin/slider.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_bg.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_x.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_x@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_x@240.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_x@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_x@384.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_y.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_y@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_y@240.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_y@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_bg_y@384.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle@240.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/slider_handle@384.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_bottom_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_bottom_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_bottom_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_bottom_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_left_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_left_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_left_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_left_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_right_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_right_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_right_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_right_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_top_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_top_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_top_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_button_top_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_section_work.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tab_section_work.psd -------------------------------------------------------------------------------- /resources/default_skin/tabbutton.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tabbutton.psd -------------------------------------------------------------------------------- /resources/default_skin/tabbutton_left_right.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/tabbutton_left_right.psd -------------------------------------------------------------------------------- /resources/default_skin/teststuff.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/teststuff.psd -------------------------------------------------------------------------------- /resources/default_skin/testtabbuttons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/testtabbuttons.psd -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/toggle_section_icon.psd -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/toggle_section_icon_down.png -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_middle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/toggle_section_icon_middle.png -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/toggle_section_icon_up.png -------------------------------------------------------------------------------- /resources/default_skin/window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window.png -------------------------------------------------------------------------------- /resources/default_skin/window.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window.psd -------------------------------------------------------------------------------- /resources/default_skin/window_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_active.png -------------------------------------------------------------------------------- /resources/default_skin/window_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close.png -------------------------------------------------------------------------------- /resources/default_skin/window_close.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close.psd -------------------------------------------------------------------------------- /resources/default_skin/window_close@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_close@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close@240.png -------------------------------------------------------------------------------- /resources/default_skin/window_close@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_close@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close_pressed@240.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_close_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover.psd -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_bg_tile.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_bg_tile@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_bg_tile@240.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_bg_tile@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_bg_tile@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/default_skin/window_mover_overlay.png -------------------------------------------------------------------------------- /resources/icon/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/icon/icon.psd -------------------------------------------------------------------------------- /resources/icon/icon114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/icon/icon114.png -------------------------------------------------------------------------------- /resources/icon/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/icon/icon128.png -------------------------------------------------------------------------------- /resources/icon/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/icon/icon48.png -------------------------------------------------------------------------------- /resources/icon/icon_large.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/icon/icon_large.psd -------------------------------------------------------------------------------- /resources/language/lng_en.tb.txt: -------------------------------------------------------------------------------- 1 | cut Cut 2 | copy Copy 3 | paste Paste 4 | delete Delete 5 | selectall Select all 6 | undo Undo 7 | redo Redo 8 | TBMessageWindow.ok Ok 9 | TBMessageWindow.cancel Cancel 10 | TBMessageWindow.yes Yes 11 | TBMessageWindow.no No 12 | TBList.header Showing %d of %d 13 | new New 14 | save Save 15 | close Close 16 | search Search 17 | -------------------------------------------------------------------------------- /resources/language/lng_sv.tb.txt: -------------------------------------------------------------------------------- 1 | cut Klipp ut 2 | copy Kopiera 3 | paste Klistra in 4 | delete Ta bort 5 | selectall Markera all 6 | undo Ångra 7 | redo Gör om 8 | TBMessageWindow.ok Ok 9 | TBMessageWindow.cancel Avbryt 10 | TBMessageWindow.yes Ja 11 | TBMessageWindow.no Nej 12 | TBList.header Visar %d av %d 13 | new Ny 14 | save Spara 15 | close Stäng 16 | search Sök 17 | -------------------------------------------------------------------------------- /resources/vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tesch1/turbobadger/fcbc9dad867d2320c582ae9d663bb516f7c6e342/resources/vera.ttf -------------------------------------------------------------------------------- /src/tb/animation/tb_animation_utils.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_ANIMATION_UTILS_H 7 | #define TB_ANIMATION_UTILS_H 8 | 9 | #include "animation/tb_animation.h" 10 | 11 | namespace tb { 12 | 13 | // TBAnimatedFloat - A animated float value 14 | 15 | class TBAnimatedFloat : public TBAnimationObject 16 | { 17 | public: 18 | float src_val; 19 | float dst_val; 20 | float current_progress; 21 | public: 22 | // For safe typecasting 23 | TBOBJECT_SUBCLASS(TBAnimatedFloat, TBAnimationObject); 24 | 25 | TBAnimatedFloat( float initial_value, 26 | ANIMATION_CURVE animation_curve = ANIMATION_DEFAULT_CURVE, 27 | double animation_duration = ANIMATION_DEFAULT_DURATION) 28 | : src_val(initial_value), dst_val(initial_value), current_progress(0) 29 | { 30 | TBAnimationObject::animation_curve = animation_curve; 31 | TBAnimationObject::animation_duration = animation_duration; 32 | } 33 | 34 | float GetValue() const { return src_val + (dst_val - src_val) * current_progress; } 35 | void SetValueAnimated(float value) { src_val = GetValue(); dst_val = value; TBAnimationManager::StartAnimation(this, animation_curve, animation_duration); } 36 | void SetValueImmediately(float value) { TBAnimationManager::AbortAnimation(this, false); src_val = dst_val = value; OnAnimationUpdate(1.0f); } 37 | 38 | virtual void OnAnimationStart() { current_progress = 0; } 39 | virtual void OnAnimationUpdate(float progress) { current_progress = progress; } 40 | virtual void OnAnimationStop(bool aborted) {} 41 | }; 42 | 43 | // TBFloatAnimator - Animates a external float value, which address is given in the constructor. 44 | 45 | class TBFloatAnimator : public TBAnimatedFloat 46 | { 47 | public: 48 | float *target_value; 49 | public: 50 | // For safe typecasting 51 | TBOBJECT_SUBCLASS(TBFloatAnimator, TBAnimationObject); 52 | 53 | TBFloatAnimator( float *target_value, 54 | ANIMATION_CURVE animation_curve = ANIMATION_DEFAULT_CURVE, 55 | double animation_duration = ANIMATION_DEFAULT_DURATION) 56 | : TBAnimatedFloat(*target_value), target_value(target_value) {} 57 | 58 | virtual void OnAnimationStart() { TBAnimatedFloat::OnAnimationStart(); *target_value = GetValue(); } 59 | virtual void OnAnimationUpdate(float progress) { TBAnimatedFloat::OnAnimationUpdate(progress); *target_value = GetValue(); } 60 | }; 61 | 62 | } // namespace tb 63 | 64 | #endif // TB_ANIMATION_UTILS_H 65 | -------------------------------------------------------------------------------- /src/tb/image/tb_image_widget.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "image/tb_image_widget.h" 7 | #include "tb_widgets_reader.h" 8 | #include "tb_node_tree.h" 9 | #include "tb_system.h" 10 | 11 | #ifdef TB_IMAGE 12 | 13 | namespace tb { 14 | 15 | PreferredSize TBImageWidget::OnCalculatePreferredContentSize(const SizeConstraints & /*constraints*/) 16 | { 17 | //TBDebugPrint("PCS: %d x %d\n", m_image.Width(), m_image.Height()); 18 | return PreferredSize(m_image.Width(), m_image.Height()); 19 | } 20 | 21 | void TBImageWidget::OnPaint(const PaintProps &paint_props) 22 | { 23 | if (TBBitmapFragment *fragment = m_image.GetBitmap()) { 24 | if (m_adapt_text_color) 25 | g_renderer->DrawBitmapColored(GetPaddingRect(), 26 | TBRect(0, 0, m_image.Width(), m_image.Height()), 27 | paint_props.text_color, fragment); 28 | else 29 | g_renderer->DrawBitmap(GetPaddingRect(), 30 | TBRect(0, 0, m_image.Width(), m_image.Height()), fragment); 31 | } 32 | } 33 | 34 | 35 | } // namespace tb 36 | 37 | #endif // TB_IMAGE 38 | -------------------------------------------------------------------------------- /src/tb/image/tb_image_widget.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_IMAGE_WIDGET_H 7 | #define TB_IMAGE_WIDGET_H 8 | 9 | #include "tb_widgets.h" 10 | 11 | #ifdef TB_IMAGE 12 | 13 | #include "image/tb_image_manager.h" 14 | 15 | namespace tb { 16 | 17 | /** TBImageWidget is a widget showing a image loaded by TBImageManager, 18 | constrained in size to its skin. 19 | If you need to show a image from the skin, you can use TBSkinImage. */ 20 | 21 | class TBImageWidget : public TBWidget 22 | { 23 | public: 24 | // For safe typecasting 25 | TBOBJECT_SUBCLASS(TBImageWidget, TBWidget); 26 | 27 | TBImageWidget() {} 28 | 29 | void SetImage(const TBImage &image) { m_image = image; } 30 | void SetImage(const TBStr &filename) { m_image = g_image_manager->GetImage(filename); } 31 | 32 | void SetAdaptTextColor(bool adapt) { m_adapt_text_color = adapt; } 33 | virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints); 34 | 35 | virtual void OnInflate(const INFLATE_INFO &info); 36 | virtual void OnPaint(const PaintProps &paint_props); 37 | private: 38 | TBImage m_image; 39 | bool m_adapt_text_color; 40 | }; 41 | 42 | } // namespace tb 43 | 44 | #endif // TB_IMAGE 45 | #endif // TB_IMAGE_WIDGET_H 46 | -------------------------------------------------------------------------------- /src/tb/parser/tb_parser.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_PARSER_H 7 | #define TB_PARSER_H 8 | 9 | #include "tb_value.h" 10 | #include "tb_tempbuffer.h" 11 | #include "tb_str.h" 12 | 13 | namespace tb { 14 | 15 | /** Unescape backslash codes. This is done in place using the string both as source 16 | and destination. */ 17 | void UnescapeString(char *str); 18 | 19 | /** Check if buf is pointing at an end quote. It may need to iterate 20 | buf backwards toward buf_start to check if any preceding backslashes 21 | make it a escaped quote (which should not be the end quote) */ 22 | bool IsEndQuote(const char *buf_start, const char *buf, const char quote_type); 23 | 24 | class TBParserTarget 25 | { 26 | public: 27 | virtual ~TBParserTarget() {} 28 | virtual void OnError(int line_nr, const TBStr & error) = 0; 29 | virtual void OnComment(int line_nr, const TBStr & comment) = 0; 30 | virtual void OnToken(int line_nr, const char *name, TBValue &value) = 0; 31 | virtual void Enter() = 0; 32 | virtual void Leave() = 0; 33 | }; 34 | 35 | class TBParserStream 36 | { 37 | public: 38 | virtual ~TBParserStream() {} 39 | virtual int GetMoreData(char *buf, int buf_len) = 0; 40 | }; 41 | 42 | class TBParser 43 | { 44 | public: 45 | enum STATUS { 46 | STATUS_OK, 47 | STATUS_OUT_OF_MEMORY, 48 | STATUS_PARSE_ERROR 49 | }; 50 | TBParser() {} 51 | STATUS Read(TBParserStream *stream, TBParserTarget *target); 52 | private: 53 | int current_indent; 54 | int current_line_nr; 55 | TBStr multi_line_token; 56 | TBTempBuffer multi_line_value; 57 | int multi_line_sub_level; 58 | bool pending_multiline; 59 | void OnLine(char *line, TBParserTarget *target); 60 | void OnCompactLine(char *line, TBParserTarget *target); 61 | void OnMultiline(char *line, TBParserTarget *target); 62 | void ConsumeValue(TBValue &dst_value, char *&line); 63 | }; 64 | 65 | } // namespace tb 66 | 67 | #endif // TB_PARSER_H 68 | -------------------------------------------------------------------------------- /src/tb/tb_clipboard_dummy.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_CLIPBOARD_DUMMY 9 | 10 | namespace tb { 11 | 12 | // == TBClipboard ===================================== 13 | 14 | TBStr clipboard; ///< Obviosly not a full implementation since it ignores the OS :) 15 | 16 | void TBClipboard::Empty() 17 | { 18 | clipboard.Clear(); 19 | } 20 | 21 | bool TBClipboard::HasText() 22 | { 23 | return !clipboard.IsEmpty(); 24 | } 25 | 26 | bool TBClipboard::SetText(const TBStr & text) 27 | { 28 | return clipboard.Set(text); 29 | } 30 | 31 | bool TBClipboard::GetText(TBStr &text) 32 | { 33 | return text.Set(clipboard); 34 | } 35 | 36 | } // namespace tb 37 | 38 | #endif // TB_CLIPBOARD_DUMMY 39 | -------------------------------------------------------------------------------- /src/tb/tb_clipboard_glfw.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_CLIPBOARD_GLFW 9 | 10 | #include "GLFW/glfw3.h" 11 | 12 | namespace tb { 13 | 14 | // == TBClipboard ===================================== 15 | 16 | void TBClipboard::Empty() 17 | { 18 | SetText(""); 19 | } 20 | 21 | bool TBClipboard::HasText() 22 | { 23 | if (GLFWwindow *window = glfwGetCurrentContext()) 24 | { 25 | const char *str = glfwGetClipboardString(window); 26 | if (str && *str) 27 | return true; 28 | } 29 | return false; 30 | } 31 | 32 | bool TBClipboard::SetText(const TBStr & text) 33 | { 34 | if (GLFWwindow *window = glfwGetCurrentContext()) 35 | { 36 | glfwSetClipboardString(window, (const char *)text); 37 | return true; 38 | } 39 | return false; 40 | } 41 | 42 | bool TBClipboard::GetText(TBStr &text) 43 | { 44 | if (GLFWwindow *window = glfwGetCurrentContext()) 45 | { 46 | if (const char *str = glfwGetClipboardString(window)) 47 | return text.Set(str); 48 | } 49 | return false; 50 | } 51 | 52 | } // namespace tb 53 | 54 | #endif // TB_CLIPBOARD_GLFW 55 | -------------------------------------------------------------------------------- /src/tb/tb_clipboard_sdl2.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_CLIPBOARD_SDL2 9 | 10 | #define GL_GLEXT_PROTOTYPES 1 11 | 12 | #ifdef SDL_FRAMEWORK 13 | #include "SDL2/SDL.h" 14 | #else 15 | #include "SDL.h" 16 | #endif 17 | 18 | namespace tb { 19 | 20 | // == TBClipboard ===================================== 21 | 22 | void TBClipboard::Empty() 23 | { 24 | SetText(""); 25 | } 26 | 27 | bool TBClipboard::HasText() 28 | { 29 | return SDL_HasClipboardText(); 30 | } 31 | 32 | bool TBClipboard::SetText(const TBStr & text) 33 | { 34 | return (0 == SDL_SetClipboardText((const char *)text)); 35 | } 36 | 37 | bool TBClipboard::GetText(TBStr &text) 38 | { 39 | if (const char *str = SDL_GetClipboardText()) 40 | return text.Set(str); 41 | return false; 42 | } 43 | 44 | } // namespace tb 45 | 46 | #endif // TB_CLIPBOARD_SDL2 47 | -------------------------------------------------------------------------------- /src/tb/tb_clipboard_win.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_CLIPBOARD_WINDOWS 9 | 10 | #include 11 | #include 12 | 13 | namespace tb { 14 | 15 | // == TBClipboard ===================================== 16 | 17 | void TBClipboard::Empty() 18 | { 19 | if (OpenClipboard(NULL)) 20 | { 21 | EmptyClipboard(); 22 | CloseClipboard(); 23 | } 24 | } 25 | 26 | bool TBClipboard::HasText() 27 | { 28 | bool has_text = false; 29 | if (OpenClipboard(NULL)) 30 | { 31 | has_text = IsClipboardFormatAvailable(CF_TEXT) || 32 | IsClipboardFormatAvailable(CF_OEMTEXT) || 33 | IsClipboardFormatAvailable(CF_UNICODETEXT); 34 | CloseClipboard(); 35 | } 36 | return has_text; 37 | } 38 | 39 | bool TBClipboard::SetText(const TBStr & text) 40 | { 41 | if (OpenClipboard(NULL)) 42 | { 43 | int num_wide_chars_needed = MultiByteToWideChar(CP_UTF8, 0, (const char*)text, -1, NULL, 0); 44 | if (HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, num_wide_chars_needed * sizeof(wchar_t))) 45 | { 46 | LPWSTR pchData = (LPWSTR) GlobalLock(hClipboardData); 47 | MultiByteToWideChar(CP_UTF8, 0, (const char *)text, -1, pchData, num_wide_chars_needed); 48 | GlobalUnlock(hClipboardData); 49 | 50 | EmptyClipboard(); 51 | SetClipboardData(CF_UNICODETEXT, hClipboardData); 52 | } 53 | 54 | CloseClipboard(); 55 | return true; 56 | } 57 | return false; 58 | } 59 | 60 | bool TBClipboard::GetText(TBStr &text) 61 | { 62 | bool success = false; 63 | if (HasText() && OpenClipboard(NULL)) 64 | { 65 | if (HANDLE hClipboardData = GetClipboardData(CF_UNICODETEXT)) 66 | { 67 | wchar_t *pchData = (wchar_t*) GlobalLock(hClipboardData); 68 | int len = WideCharToMultiByte(CP_UTF8, 0, pchData, -1, NULL, 0, NULL, NULL); 69 | if (char *utf8 = new char[len]) 70 | { 71 | WideCharToMultiByte(CP_UTF8, 0, pchData, -1, utf8, len, NULL, NULL); 72 | success = text.Set(utf8); 73 | delete [] utf8; 74 | } 75 | GlobalUnlock(hClipboardData); 76 | } 77 | CloseClipboard(); 78 | } 79 | return success; 80 | } 81 | 82 | } // namespace tb 83 | 84 | #endif // TB_CLIPBOARD_WINDOWS 85 | -------------------------------------------------------------------------------- /src/tb/tb_color.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_COLOR_H 7 | #define TB_COLOR_H 8 | 9 | #include "tb_types.h" 10 | #include "tb_str.h" 11 | #include "tb_id.h" 12 | #include 13 | 14 | namespace tb { 15 | 16 | class TBNode; 17 | class TBSkin; 18 | 19 | /** TBColor contains a 32bit color. */ 20 | 21 | class TBColor 22 | { 23 | public: 24 | TBColor() : b(0), g(0), r(0), a(255) {} 25 | TBColor(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ = 255) : b(b_), g(g_), r(r_), a(a_) {} 26 | TBColor(uint32_t bgra_) : bgra(bgra_) {} 27 | 28 | union { 29 | struct { uint8_t b, g, r, a; }; 30 | uint32_t bgra; 31 | }; 32 | 33 | void Set(const TBColor &color) { *this = color; } 34 | 35 | /** Set the color from string in any of the following formats: 36 | "#rrggbbaa", "#rrggbb", "#rgba", "#rgb" */ 37 | void SetFromString(const TBStr & str); 38 | 39 | /** Write color to string with format #rrggbbaa */ 40 | void GetString(TBStr & str) const; 41 | 42 | operator uint32_t () const { return bgra; } 43 | //bool operator == (const TBColor &c) const { return bgra == (uint32_t)c; } 44 | //bool operator != (const TBColor &c) const { return bgra != (uint32_t)c; } 45 | }; 46 | 47 | /** TBColorManager contains a map of global color names. */ 48 | 49 | class TBColorManager 50 | { 51 | public: 52 | 53 | /** Load a list of colors from a node. */ 54 | void Load(TBNode *n, TBSkin *skin); 55 | 56 | /** Define a color, if not already defined. */ 57 | bool Define(const TBStr & cid, TBColor color); 58 | 59 | /** Is the color defined? */ 60 | bool IsDefined(const TBStr & cid) { return 0 != _id2color.count(cid); } 61 | 62 | /** Is the color defined? */ 63 | bool IsDefined(const TBColor & color) { return 0 != _color2id.count(color); } 64 | 65 | /** (Re)Define a color, no matter what. */ 66 | void ReDefine(const TBStr & cid, TBColor color); 67 | 68 | /** Clear the list of colors. */ 69 | void Clear(); 70 | 71 | /** Return the color with the given id. 72 | * If there is no color with that id, 0 will be returned. 73 | */ 74 | TBColor GetColor(const TBStr & cid) const; 75 | 76 | /** Return the id of the given color, or 0. 77 | * If there is no color with that id, an empty TBStr() will be returned. 78 | */ 79 | TBStr GetColorID(const TBColor & color) const; 80 | 81 | /** Return the cid of the given color, or 0. 82 | * If there is no color with that cid, 0 will be returned. 83 | */ 84 | const std::map GetColorMap() const { return _id2color; } 85 | 86 | /** Dump the current color map */ 87 | void Dump(const TBStr & filename); 88 | 89 | private: 90 | std::map _id2color; 91 | std::map _color2id; 92 | }; 93 | 94 | } // namespace tb 95 | 96 | #endif // TB_COLOR_H 97 | -------------------------------------------------------------------------------- /src/tb/tb_core.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_core.h" 7 | #include "tb_skin.h" 8 | #include "tb_widgets_reader.h" 9 | #include "tb_language.h" 10 | #include "tb_font_renderer.h" 11 | #include "tb_system.h" 12 | #include "animation/tb_animation.h" 13 | #include "image/tb_image_manager.h" 14 | 15 | namespace tb { 16 | 17 | TBRenderer *g_renderer; 18 | TBSkin *g_tb_skin; 19 | TBWidgetsReader *g_widgets_reader; 20 | TBLanguage *g_tb_lng; 21 | TBFontManager *g_font_manager; 22 | TBColorManager *g_color_manager; 23 | 24 | bool tb_core_init(TBRenderer *renderer) 25 | { 26 | //TBDebugPrint("Initiating Turbo Badger - version %s\n", TB_VERSION_STR); 27 | g_renderer = renderer; 28 | g_tb_lng = new TBLanguage; 29 | g_font_manager = new TBFontManager(); 30 | g_color_manager = new TBColorManager(); 31 | g_tb_skin = new TBSkin(); 32 | g_widgets_reader = TBWidgetsReader::Create(); 33 | #ifdef TB_IMAGE 34 | g_image_manager = new TBImageManager(); 35 | #endif 36 | return renderer && g_tb_lng && g_font_manager && g_tb_skin 37 | && g_widgets_reader 38 | #ifdef TB_IMAGE 39 | && g_image_manager 40 | #endif 41 | ; 42 | } 43 | 44 | void tb_core_shutdown() 45 | { 46 | TBAnimationManager::AbortAllAnimations(); 47 | #ifdef TB_IMAGE 48 | delete g_image_manager; 49 | g_image_manager = nullptr; 50 | #endif 51 | delete g_widgets_reader; 52 | g_widgets_reader = nullptr; 53 | delete g_tb_skin; 54 | g_tb_skin = nullptr; 55 | delete g_color_manager; 56 | g_color_manager = nullptr; 57 | delete g_font_manager; 58 | g_font_manager = nullptr; 59 | delete g_tb_lng; 60 | g_tb_lng = nullptr; 61 | } 62 | 63 | bool tb_core_is_initialized() 64 | { 65 | return g_widgets_reader ? true : false; 66 | } 67 | 68 | } // namespace tb 69 | -------------------------------------------------------------------------------- /src/tb/tb_core.h: -------------------------------------------------------------------------------- 1 | /** @page page_license License 2 | 3 | Turbo Badger 4 | Copyright (C) 2011-2014 Emil Segerås 5 | 6 | License: 7 | 8 | This software is provided 'as-is', without any express or implied 9 | warranty. In no event will the authors be held liable for any damages 10 | arising from the use of this software. 11 | 12 | Permission is granted to anyone to use this software for any purpose, 13 | including commercial applications, and to alter it and redistribute it 14 | freely, subject to the following restrictions: 15 | 16 | 1. The origin of this software must not be misrepresented; you must not 17 | claim that you wrote the original software. If you use this software 18 | in a product, an acknowledgment in the product documentation would be 19 | appreciated but is not required. 20 | 21 | 2. Altered source versions must be plainly marked as such, and must not be 22 | misrepresented as being the original software. 23 | 24 | 3. This notice may not be removed or altered from any source 25 | distribution. 26 | */ 27 | 28 | #ifndef TB_CORE_H 29 | #define TB_CORE_H 30 | 31 | #include "tb_types.h" 32 | #include "tb_hash.h" 33 | #include "tb_debug.h" 34 | 35 | namespace tb { 36 | 37 | class TBRenderer; 38 | class TBSkin; 39 | class TBWidgetsReader; 40 | class TBLanguage; 41 | class TBFontManager; 42 | class TBColorManager; 43 | 44 | extern TBRenderer *g_renderer; 45 | extern TBSkin *g_tb_skin; 46 | extern TBWidgetsReader *g_widgets_reader; 47 | extern TBLanguage *g_tb_lng; 48 | extern TBFontManager *g_font_manager; 49 | extern TBColorManager *g_color_manager; 50 | 51 | /** Initialize turbo badger. Call this before using any turbo badger API. */ 52 | bool tb_core_init(TBRenderer *renderer); 53 | 54 | /** Shutdown turbo badger. Call this after deleting the last widget, to free turbo badger internals. */ 55 | void tb_core_shutdown(); 56 | 57 | /** Returns true if turbo badger is initialized. */ 58 | bool tb_core_is_initialized(); 59 | 60 | } // namespace tb 61 | 62 | #endif // TB_CORE_H 63 | -------------------------------------------------------------------------------- /src/tb/tb_debug.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_DEBUG_H 7 | #define TB_DEBUG_H 8 | 9 | #include "tb_types.h" 10 | 11 | #ifdef TB_RUNTIME_DEBUG_INFO 12 | #define TB_IF_DEBUG(debug) debug 13 | #else 14 | #define TB_IF_DEBUG(debug) 15 | #endif 16 | 17 | namespace tb { 18 | 19 | #ifdef TB_RUNTIME_DEBUG_INFO 20 | 21 | class TBDebugInfo 22 | { 23 | public: 24 | TBDebugInfo(); 25 | 26 | enum SETTING { 27 | /** Show widgets bounds */ 28 | LAYOUT_BOUNDS, 29 | /** Show child widget clipping set by some widgets. */ 30 | LAYOUT_CLIPPING, 31 | /** Show highlights on widgets that recalculate their preferred 32 | size, and those who recalculate their layout. */ 33 | LAYOUT_PS_DEBUGGING, 34 | /** Show render batch info and log batch info in the debug 35 | output. It depends on the renderer backend if this is available. */ 36 | RENDER_BATCHES, 37 | /** Render the bitmap fragments of the skin. */ 38 | RENDER_SKIN_BITMAP_FRAGMENTS, 39 | /** Render the bitmap fragments of the font that's set on the hovered 40 | or focused widget. */ 41 | RENDER_FONT_BITMAP_FRAGMENTS, 42 | 43 | NUM_SETTINGS 44 | }; 45 | long settings[NUM_SETTINGS]; 46 | }; 47 | 48 | extern TBDebugInfo g_tb_debug; 49 | 50 | /** Show a window containing runtime debugging settings. */ 51 | void ShowDebugInfoSettingsWindow(class TBWidget *root); 52 | 53 | #define TB_DEBUG_SETTING(setting) g_tb_debug.settings[TBDebugInfo::setting] 54 | #define TB_IF_DEBUG_SETTING(setting, code) if (TB_DEBUG_SETTING(setting)) { code; } 55 | 56 | #else // TB_RUNTIME_DEBUG_INFO 57 | 58 | /** Show a window containing runtime debugging settings. */ 59 | #define ShowDebugInfoSettingsWindow(root) ((void)0) 60 | 61 | #define TB_DEBUG_SETTING(setting) false 62 | #define TB_IF_DEBUG_SETTING(setting, code) 63 | 64 | #endif // TB_RUNTIME_DEBUG_INFO 65 | 66 | } // namespace tb 67 | 68 | #if defined(TB_RUNTIME_DEBUG_INFO) 69 | 70 | namespace tb { class TBStr; } 71 | void TBDebugOut(const tb::TBStr & str); 72 | #define TBDebugPrint(...) do { \ 73 | tb::TBStr tmpxxx; \ 74 | tmpxxx.SetFormatted(__VA_ARGS__); \ 75 | TBDebugOut(tmpxxx); \ 76 | } while (0) 77 | 78 | #else 79 | 80 | #define TBDebugOut(str) do { } while (0) 81 | #define TBDebugPrint(...) do { } while (0) 82 | 83 | #endif // TB_RUNTIME_DEBUG_INFO 84 | 85 | #endif // TB_DEBUG_H 86 | -------------------------------------------------------------------------------- /src/tb/tb_dimension.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_dimension.h" 7 | #include "tb_types.h" 8 | #include "tb_system.h" 9 | #include "tb_tempbuffer.h" 10 | #include "tb_value.h" 11 | #include 12 | #include 13 | 14 | namespace tb { 15 | 16 | // == TBDimensionConverter ================================================================================== 17 | 18 | void TBDimensionConverter::SetDPI(int src_dpi, int dst_dpi) 19 | { 20 | m_src_dpi = src_dpi; 21 | m_dst_dpi = dst_dpi; 22 | m_dst_dpi_str.Clear(); 23 | if (NeedConversion()) 24 | m_dst_dpi_str.SetFormatted("@%d", m_dst_dpi); 25 | } 26 | 27 | void TBDimensionConverter::GetDstDPIFilename(const TBStr &filename, TBTempBuffer *tempbuf) const 28 | { 29 | int dot_pos = 0; 30 | for (dot_pos = filename.Length() - 1; dot_pos > 0; dot_pos--) 31 | if (filename[dot_pos] == '.') 32 | break; 33 | tempbuf->ResetAppendPos(); 34 | tempbuf->Append(filename.CStr(), dot_pos); 35 | tempbuf->AppendString(GetDstDPIStr()); 36 | tempbuf->AppendString(filename.CStr() + dot_pos); 37 | } 38 | 39 | int TBDimensionConverter::DpToPx(int dp) const 40 | { 41 | if (dp <= TB_INVALID_DIMENSION || dp == 0 || !NeedConversion()) 42 | return dp; 43 | if (dp > 0) 44 | { 45 | dp = (dp * m_dst_dpi + m_src_dpi / 2) / m_src_dpi; 46 | return MAX(dp, 1); 47 | } 48 | else 49 | { 50 | dp = (dp * m_dst_dpi - m_src_dpi / 2 + 1) / m_src_dpi; 51 | return MIN(dp, -1); 52 | } 53 | } 54 | 55 | int TBDimensionConverter::MmToPx(int mm) const 56 | { 57 | if (mm <= TB_INVALID_DIMENSION || mm == 0) 58 | return mm; 59 | 60 | return (int) (mm * TBSystem::GetDPI() / 25.4f + 0.5f); 61 | } 62 | 63 | int TBDimensionConverter::GetPxFromString(const TBStr & str, int def_value) const 64 | { 65 | if (!str || !is_start_of_number((const char *)str)) 66 | return def_value; 67 | int len = str.Length(); 68 | int val = str.atoi(); 69 | // "dp" and unspecified unit is dp. 70 | if ((len > 0 && isdigit(str[len - 1])) || 71 | (len > 2 && strcmp((const char *)str + len - 2, "dp") == 0)) 72 | return DpToPx(val); 73 | else if (len > 2 && strcmp((const char *)str + len - 2, "mm") == 0) 74 | return MmToPx(val); 75 | else 76 | return val; 77 | } 78 | 79 | int TBDimensionConverter::GetPxFromValue(TBValue *value, int def_value) const 80 | { 81 | if (!value) 82 | return def_value; 83 | if (value->GetType() == TBValue::TYPE_INT) 84 | return DpToPx((int)value->GetInt()); 85 | else if (value->GetType() == TBValue::TYPE_FLOAT) 86 | // FIX: We might want float versions of all dimension functions. 87 | return DpToPx((int)value->GetFloat()); 88 | return GetPxFromString(value->GetString(), def_value); 89 | } 90 | 91 | } // namespace tb 92 | -------------------------------------------------------------------------------- /src/tb/tb_file_android.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_FILE_ANDROID 9 | 10 | #include "tb_debug.h" 11 | #include "tb_str.h" 12 | 13 | #include 14 | #include 15 | 16 | // for native asset manager 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // in tb_system_android 23 | extern AAssetManager *g_pManager; 24 | 25 | namespace tb { 26 | 27 | // == TBFile ===================================== 28 | 29 | class TBAndroidFile : public TBFile 30 | { 31 | public: 32 | TBAndroidFile(AAsset* f) : file(f) {} 33 | virtual ~TBAndroidFile() { AAsset_close(file); } 34 | 35 | virtual long Size() 36 | { 37 | return AAsset_getLength(file); 38 | } 39 | virtual size_t Read(void *buf, size_t elemSize, size_t count) 40 | { 41 | return AAsset_read(file, buf, elemSize * count); 42 | } 43 | virtual size_t Write(const void *buf, size_t elemSize, size_t count) {return 0;} 44 | virtual size_t Write(const TBStr & str) {return 0;} 45 | 46 | private: 47 | AAsset *file; 48 | }; 49 | 50 | TBFile *TBFile::Open(const TBStr & filename, TBFileMode mode) 51 | { 52 | AAsset *f = nullptr; 53 | switch (mode) 54 | { 55 | case MODE_READ: 56 | f = AAssetManager_open(g_pManager, (const char *)filename, AASSET_MODE_UNKNOWN); 57 | break; 58 | default: 59 | break; 60 | } 61 | if (!f) 62 | return nullptr; 63 | TBAndroidFile *tbf = new TBAndroidFile(f); 64 | if (!tbf) 65 | AAsset_close(f); 66 | return tbf; 67 | } 68 | 69 | } // namespace tb 70 | 71 | #endif // TB_FILE_ANDROID 72 | -------------------------------------------------------------------------------- /src/tb/tb_file_posix.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_FILE_POSIX 9 | 10 | #include 11 | #ifndef _WIN32 12 | #include 13 | #else 14 | /* This is intended as a drop-in replacement for unistd.h on Windows. 15 | * Please add functionality as neeeded. 16 | * https://stackoverflow.com/a/826027/1202830 17 | */ 18 | #include 19 | #include 20 | //#include /* getopt at: https://gist.github.com/ashelly/7776712 */ 21 | #include /* for getpid() and the exec..() family */ 22 | #include /* for _getcwd() and _chdir() */ 23 | #define getcwd _getcwd 24 | /* -- cut -- */ 25 | #endif 26 | 27 | namespace tb { 28 | 29 | class TBPosixFile : public TBFile 30 | { 31 | public: 32 | TBPosixFile(FILE *f) : file(f) {} 33 | virtual ~TBPosixFile() { fclose(file); } 34 | 35 | virtual long Size() 36 | { 37 | long oldpos = ftell(file); 38 | fseek(file, 0, SEEK_END); 39 | long num_bytes = ftell(file); 40 | fseek(file, oldpos, SEEK_SET); 41 | return num_bytes; 42 | } 43 | virtual size_t Read(void *buf, size_t elemSize, size_t count) 44 | { 45 | return fread(buf, elemSize, count, file); 46 | } 47 | virtual size_t Write(const void *buf, size_t elemSize, size_t count) 48 | { 49 | return fwrite(buf, elemSize, count, file); 50 | } 51 | virtual size_t Write(const TBStr & str) 52 | { 53 | return Write(str.CStr(), 1, str.Length()); 54 | } 55 | private: 56 | FILE *file; 57 | }; 58 | 59 | // static 60 | TBFile *TBFile::Open(const TBStr & filename, TBFileMode mode) 61 | { 62 | FILE *f = nullptr; 63 | switch (mode) 64 | { 65 | case MODE_READ: 66 | f = fopen(filename.CStr(), "rb"); 67 | break; 68 | case MODE_WRITETRUNC: 69 | f = fopen(filename.CStr(), "w"); 70 | break; 71 | default: 72 | break; 73 | } 74 | #if defined(TB_RUNTIME_DEBUG_INFO) && 1 75 | if (!f) { 76 | //char tmp[256]; 77 | //TBDebugPrint("Cwd: '%s'\n", getcwd(tmp, sizeof(tmp))); 78 | //TBDebugPrint("TBFile::Open, unable to open file '%s'\n", filename.CStr()); 79 | } 80 | #endif 81 | if (!f) 82 | return nullptr; 83 | TBPosixFile *tbf = new TBPosixFile(f); 84 | if (!tbf) 85 | fclose(f); 86 | return tbf; 87 | } 88 | 89 | } // namespace tb 90 | 91 | #endif // TB_FILE_POSIX 92 | -------------------------------------------------------------------------------- /src/tb/tb_file_sdl2.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_FILE_SDL2 9 | 10 | #ifdef SDL_FRAMEWORK 11 | #include "SDL2/SDL.h" 12 | #else 13 | #include "SDL.h" 14 | #endif 15 | 16 | namespace tb { 17 | 18 | class TBFileSDL2 : public TBFile 19 | { 20 | public: 21 | TBFileSDL2(SDL_RWops *f) : _file(f) {} 22 | virtual ~TBFileSDL2() { SDL_RWclose(_file); } 23 | 24 | virtual long Size() 25 | { 26 | return (long)SDL_RWsize(_file); 27 | } 28 | virtual size_t Read(void *buf, size_t elemSize, size_t count) 29 | { 30 | return SDL_RWread(_file, buf, elemSize, count); 31 | } 32 | virtual size_t Write(const void *buf, size_t elemSize, size_t count) 33 | { 34 | return SDL_RWwrite(_file, buf, elemSize, count); 35 | } 36 | virtual size_t Write(const TBStr & str) 37 | { 38 | return Write(str.CStr(), str.Length(), 1); 39 | } 40 | private: 41 | SDL_RWops *_file; 42 | }; 43 | 44 | // static 45 | TBFile *TBFile::Open(const TBStr & filename, TBFileMode mode) 46 | { 47 | SDL_RWops *f = nullptr; 48 | switch (mode) 49 | { 50 | case MODE_READ: 51 | f = SDL_RWFromFile(filename.CStr(), "rb"); 52 | break; 53 | case MODE_WRITETRUNC: 54 | f = SDL_RWFromFile(filename.CStr(), "w"); 55 | break; 56 | default: 57 | break; 58 | } 59 | #if defined(TB_RUNTIME_DEBUG_INFO) && 1 60 | if (!f) { 61 | //char tmp[256]; 62 | //TBDebugPrint("Cwd: '%s'\n", getcwd(tmp, sizeof(tmp))); 63 | //TBDebugPrint("TBFile::Open, unable to open file '%s'\n", filename.CStr()); 64 | } 65 | #endif 66 | if (!f) 67 | return nullptr; 68 | TBFileSDL2 *tbf = new TBFileSDL2(f); 69 | if (!tbf) 70 | SDL_RWclose(f); 71 | return tbf; 72 | } 73 | 74 | } // namespace tb 75 | 76 | #endif // TB_FILE_POSIX 77 | -------------------------------------------------------------------------------- /src/tb/tb_hash.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_hash.h" 7 | 8 | namespace tb { 9 | 10 | #if 0 11 | #ifndef TB_SUPPORT_CONSTEXPR 12 | 13 | uint32_t TBGetHash(const char *str) 14 | { 15 | if (!str || !*str) 16 | return 0; 17 | // FNV hash 18 | uint32_t hash = 2166136261U; 19 | int i = 0; 20 | while (str[i]) 21 | { 22 | char c = str[i++]; 23 | hash = (16777619U * hash) ^ c; 24 | } 25 | return hash; 26 | } 27 | 28 | #endif // !TB_SUPPORT_CONSTEXPR 29 | #endif 30 | 31 | } // namespace tb 32 | -------------------------------------------------------------------------------- /src/tb/tb_hash.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_HASH_H 7 | #define TB_HASH_H 8 | 9 | #include "tb_types.h" 10 | #include "tb_str.h" 11 | 12 | namespace tb { 13 | 14 | // FNV constants 15 | static constexpr uint32_t basis = 2166136261U; 16 | static constexpr uint32_t prime = 16777619U; 17 | 18 | // compile-time hash helper function 19 | constexpr uint32_t TBGetHash_one(char c, const char* remain, uint32_t value) 20 | { 21 | return c == 0 ? value : TBGetHash_one(remain[0], remain + 1, (value ^ c) * prime); 22 | } 23 | 24 | // compile-time hash 25 | constexpr uint32_t TBGetHash(const char* str) 26 | { 27 | return (str && *str) ? TBGetHash_one(str[0], str + 1, basis) : 0; 28 | } 29 | 30 | #define TBIDC(str) tb::TBGetHash(str) 31 | 32 | } // namespace tb 33 | 34 | #endif // TB_HASH_H 35 | 36 | -------------------------------------------------------------------------------- /src/tb/tb_id.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_id.h" 7 | #include "tb_system.h" 8 | #include "tb_hashtable.h" 9 | 10 | namespace tb { 11 | 12 | // == TBID ============================================================================== 13 | 14 | #ifdef TB_RUNTIME_DEBUG_INFO 15 | 16 | // Hash table for checking if we get any collisions (same hash value for TBID's created 17 | // from different strings) 18 | static TBHashTableAutoDeleteOf all_id_hash; 19 | static bool is_adding = false; 20 | 21 | void TBID::Set(uint32_t newid) 22 | { 23 | id = newid; 24 | debug_string.Clear(); 25 | if (!is_adding && tb_core_is_initialized()) 26 | { 27 | if (!all_id_hash.Get(id) && debug_string.Length()) 28 | { 29 | is_adding = true; 30 | all_id_hash.Add(id, new TBID(*this)); 31 | is_adding = false; 32 | } 33 | if (TBID *other_id = all_id_hash.Get(id)) 34 | if (!debug_string.Length()) 35 | debug_string = other_id->debug_string; 36 | } 37 | } 38 | 39 | void TBID::Set(const TBID &newid) 40 | { 41 | id = newid; 42 | TB_IF_DEBUG(debug_string.Set(newid.debug_string)); 43 | if (!is_adding && tb_core_is_initialized()) 44 | { 45 | if (TBID *other_id = all_id_hash.Get(id)) 46 | { 47 | // If this happens, 2 different strings result in the same hash. 48 | // It might be a good idea to change one of them, but it might not matter. 49 | if (!debug_string.IsEmpty() && !other_id->debug_string.IsEmpty()) 50 | assert(other_id->debug_string == debug_string); 51 | // Otherwise copy the debug string 52 | if (debug_string.IsEmpty() && !other_id->debug_string.IsEmpty()) 53 | debug_string = other_id->debug_string; 54 | } 55 | else if (debug_string.Length()) 56 | { 57 | is_adding = true; 58 | all_id_hash.Add(id, new TBID(*this)); 59 | is_adding = false; 60 | } 61 | } 62 | } 63 | 64 | void TBID::Set(const char *string) 65 | { 66 | id = TBGetHash(string); 67 | TB_IF_DEBUG(debug_string.Set(string)); 68 | if (!is_adding && tb_core_is_initialized()) 69 | { 70 | if (TBID *other_id = all_id_hash.Get(id)) 71 | { 72 | #ifndef NDEBUG 73 | if (other_id->debug_string != debug_string) { 74 | TBDebugPrint("ID collision btw '%s' and '%s'\n", 75 | other_id->debug_string.CStr(), debug_string.CStr()); 76 | } 77 | #endif 78 | assert(other_id->debug_string == debug_string); 79 | } 80 | else if (debug_string.Length()) 81 | { 82 | assert(debug_string.Length()); 83 | is_adding = true; 84 | all_id_hash.Add(id, new TBID(*this)); 85 | is_adding = false; 86 | } 87 | } 88 | } 89 | 90 | const char * TBID::c_str() const 91 | { 92 | if (debug_string.IsEmpty()) 93 | debug_string.SetFormatted("%d",id); 94 | return debug_string.CStr(); 95 | } 96 | #endif // TB_RUNTIME_DEBUG_INFO 97 | 98 | } // namespace tb 99 | -------------------------------------------------------------------------------- /src/tb/tb_id.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_ID_H 7 | #define TB_ID_H 8 | 9 | #include "tb_types.h" 10 | #include "tb_hash.h" 11 | #include "tb_str.h" 12 | 13 | namespace tb { 14 | 15 | /** TBID is a wrapper for a uint32_t to be used as ID. 16 | The uint32_t can be set directly to any uint32_t, or it can be 17 | set from a string which will be hashed into the uint32_t. */ 18 | class TBID 19 | { 20 | public: 21 | TBID(uint32_t id_ = 0) { Set(id_); } 22 | TBID(const char *string) { Set(string); } 23 | TBID(const TBID &id_) { Set(id_); } 24 | TBID(const TBStr &id_) { Set((const char *)id_); } 25 | #ifdef TB_LIBSTD 26 | TBID(const std::string & str) { Set(str.c_str()); } 27 | #endif 28 | 29 | #ifdef TB_RUNTIME_DEBUG_INFO 30 | void Set(uint32_t newid); 31 | void Set(const char *string); 32 | void Set(const TBID &newid); 33 | void Set(const TBStr &str) { Set((const char *)str); } 34 | #else 35 | void Set(uint32_t newid) { id = newid; } 36 | void Set(const char *string) { id = TBGetHash(string); } 37 | void Set(const TBID &newid) { id = newid; } 38 | void Set(const TBStr &str) { id = TBGetHash((const char *)str); } 39 | #endif 40 | 41 | operator uint32_t () const { return id; } 42 | const TBID& operator = (const TBID &id) { Set(id); return *this; } 43 | private: 44 | uint32_t id; 45 | public: 46 | /** This string is here to aid debugging (Only in debug builds!) 47 | It should not to be used in your code! */ 48 | #ifdef TB_RUNTIME_DEBUG_INFO 49 | friend class TBLanguage; 50 | const char * c_str() const; 51 | mutable TBStr debug_string; 52 | #endif 53 | }; 54 | 55 | } // namespace tb 56 | 57 | #endif // TB_ID_H 58 | -------------------------------------------------------------------------------- /src/tb/tb_inline_select.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_INLINE_SELECT_H 7 | #define TB_INLINE_SELECT_H 8 | 9 | #include "tb_widgets_listener.h" 10 | #include "tb_select_item.h" 11 | #include "tb_editfield.h" 12 | 13 | namespace tb { 14 | 15 | /** TBSelectList is a select widget with no popups. Instead it has two 16 | arrow buttons that cycle between the choices. 17 | By default it is a number widget. 18 | 19 | FIX: Should also be possible to set a list of strings that will be 20 | shown instead of numbers. 21 | */ 22 | class TBInlineSelect : public TBWidget 23 | { 24 | public: 25 | // For safe typecasting 26 | TBOBJECT_SUBCLASS(TBInlineSelect, TBWidget); 27 | 28 | TBInlineSelect(); 29 | ~TBInlineSelect(); 30 | 31 | /** Set along which axis the content should layouted. */ 32 | virtual void SetAxis(AXIS axis) { m_layout.SetAxis(axis); } 33 | virtual AXIS GetAxis() const { return m_layout.GetAxis(); } 34 | 35 | void SetLimits(long min, long max); 36 | long GetMinValue() const { return m_min; } 37 | long GetMaxValue() const { return m_max; } 38 | 39 | virtual void SetValue(long value) { SetValueInternal(value, true); } 40 | virtual long GetValue() const { return m_value; } 41 | 42 | virtual void OnInflate(const INFLATE_INFO &info); 43 | virtual void OnSkinChanged(); 44 | virtual bool OnEvent(const TBWidgetEvent &ev); 45 | protected: 46 | TBButton m_buttons[2]; 47 | TBLayout m_layout; 48 | TBEditField m_editfield; 49 | long m_value; 50 | long m_min, m_max; 51 | void SetValueInternal(long value, bool update_text); 52 | }; 53 | 54 | } // namespace tb 55 | 56 | #endif // TB_INLINE_SELECT_H 57 | -------------------------------------------------------------------------------- /src/tb/tb_language.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_language.h" 7 | #include "tb_system.h" 8 | #include "tb_node_tree.h" 9 | 10 | namespace tb { 11 | 12 | TBLanguage::~TBLanguage() 13 | { 14 | Clear(); 15 | } 16 | 17 | bool TBLanguage::Load(const TBStr & filename) 18 | { 19 | // Read the file into a node tree (even though it's only a flat list) 20 | TBNode node; 21 | if (!node.ReadFile(filename)) 22 | return false; 23 | 24 | // Go through all nodes and add to the strings hash table 25 | TBNode *n = node.GetFirstChild(); 26 | while (n) 27 | { 28 | TBStr *new_str = new TBStr(n->GetValue().GetString()); 29 | if (!new_str || !strings.Add(TBID(n->GetName()), new_str)) 30 | { 31 | delete new_str; 32 | return false; 33 | } 34 | n = n->GetNext(); 35 | } 36 | return true; 37 | } 38 | 39 | void TBLanguage::Clear() 40 | { 41 | strings.DeleteAll(); 42 | } 43 | 44 | TBStr TBLanguage::GetString(const TBID &id) 45 | { 46 | if (TBStr *str = strings.Get(id)) 47 | return *str; 48 | #ifdef TB_RUNTIME_DEBUG_INFO 49 | static TBStr tmp; 50 | tmp.SetFormatted("", id.debug_string.CStr()); 51 | return tmp; 52 | #else 53 | return ""; 54 | #endif 55 | } 56 | 57 | } // namespace tb 58 | -------------------------------------------------------------------------------- /src/tb/tb_language.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_LANGUAGE_H 7 | #define TB_LANGUAGE_H 8 | 9 | #include "tb_core.h" 10 | #include "tb_hashtable.h" 11 | #include "tb_id.h" 12 | 13 | namespace tb { 14 | 15 | /** TBLanguage is a basic language string manager. 16 | Strings read into it can be looked up from a TBID, so either by a number 17 | or the hash number from a string (done by TBID). 18 | 19 | Ex: GetString(10) (Get the string with id 10) 20 | Ex: GetString("new") (Get the string with id new) 21 | 22 | In UI resources, you can refer to strings from language lookup by preceding a string with @. 23 | 24 | Ex: TBButton: text: @close (Create a button with text from lookup of "close") 25 | */ 26 | 27 | class TBLanguage 28 | { 29 | public: 30 | ~TBLanguage(); 31 | 32 | /** Load a file into this language manager. 33 | Note: This *adds* strings read from the file, without clearing any existing 34 | strings first. */ 35 | bool Load(const TBStr & filename); 36 | 37 | /** Clear the list of strings. */ 38 | void Clear(); 39 | 40 | /** Return the string with the given id. 41 | If there is no string with that id, "" will be returned 42 | in release builds, and "" (populated with the id) will 43 | be returned in debug builds. */ 44 | TBStr GetString(const TBID &id); 45 | private: 46 | TBHashTableOf strings; 47 | }; 48 | 49 | }; 50 | 51 | #endif // TB_LANGUAGE_H 52 | -------------------------------------------------------------------------------- /src/tb/tb_menu_window.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_menu_window.h" 7 | #include "tb_widgets_listener.h" 8 | 9 | namespace tb { 10 | 11 | // == TBMenuWindow ========================================== 12 | 13 | TBMenuWindow::TBMenuWindow(TBWidget *target, TBID id) 14 | : TBPopupWindow(target) 15 | { 16 | SetID(id); 17 | SetSkinBg(TBIDC("TBMenuWindow"), WIDGET_INVOKE_INFO_NO_CALLBACKS); 18 | m_select_list.GetScrollContainer()->SetAdaptToContentSize(true); 19 | m_select_list.SetIsFocusable(false); ///< Avoid it autoclosing its window on click 20 | m_select_list.SetSkinBg(""); 21 | m_select_list.SetRect(GetPaddingRect()); 22 | m_select_list.SetGravity(WIDGET_GRAVITY_ALL); 23 | AddChild(&m_select_list); 24 | } 25 | 26 | TBMenuWindow::~TBMenuWindow() 27 | { 28 | RemoveChild(&m_select_list); 29 | } 30 | 31 | void TBMenuWindow::OnDie() 32 | { 33 | m_select_list.SetSource(nullptr); 34 | } 35 | 36 | bool TBMenuWindow::Show(TBSelectItemSource *source, const TBPopupAlignment &alignment, int initial_value) 37 | { 38 | m_select_list.SetValue(initial_value); 39 | m_select_list.SetSource(source); 40 | m_select_list.ValidateList(); 41 | 42 | return TBPopupWindow::Show(alignment); 43 | } 44 | 45 | bool TBMenuWindow::OnEvent(const TBWidgetEvent &ev) 46 | { 47 | if (ev.type == EVENT_TYPE_CLICK && &m_select_list == ev.target) 48 | { 49 | TBWidgetSafePointer this_widget(this); 50 | 51 | // Invoke the click on the target 52 | TBWidgetEvent target_ev(EVENT_TYPE_CLICK); 53 | target_ev.ref_id = ev.ref_id; 54 | InvokeEvent(target_ev); 55 | 56 | // If target didn't already delete this, close this 57 | if (this_widget.Get()) 58 | Close(); 59 | return true; 60 | } 61 | return TBPopupWindow::OnEvent(ev); 62 | } 63 | 64 | } // namespace tb 65 | -------------------------------------------------------------------------------- /src/tb/tb_menu_window.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_MENU_WINDOW_H 7 | #define TB_MENU_WINDOW_H 8 | 9 | #include "tb_select.h" 10 | #include "tb_popup_window.h" 11 | 12 | namespace tb { 13 | 14 | /** TBMenuWindow is a popup window that shows a list of items (TBSelectList). 15 | 16 | When selected it will invoke a click with the id given to the menu, 17 | and the id of the clicked item as ref_id, and then close itself. 18 | 19 | It may open sub items as new windows at the same time as this window is open.*/ 20 | 21 | class TBMenuWindow : public TBPopupWindow 22 | { 23 | public: 24 | // For safe typecasting 25 | TBOBJECT_SUBCLASS(TBMenuWindow, TBPopupWindow); 26 | 27 | TBMenuWindow(TBWidget *target, TBID id); 28 | ~TBMenuWindow(); 29 | 30 | bool Show(TBSelectItemSource *source, const TBPopupAlignment &alignment, int initial_value = -1); 31 | 32 | TBSelectList *GetList() { return &m_select_list; } 33 | 34 | virtual bool OnEvent(const TBWidgetEvent &ev); 35 | virtual void OnDie(); 36 | private: 37 | TBSelectList m_select_list; 38 | }; 39 | 40 | } // namespace tb 41 | 42 | #endif // TB_MENU_WINDOW_H 43 | -------------------------------------------------------------------------------- /src/tb/tb_message_window.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_MESSAGE_WINDOW_H 7 | #define TB_MESSAGE_WINDOW_H 8 | 9 | #include "tb_window.h" 10 | #include "tb_widgets_listener.h" 11 | 12 | namespace tb { 13 | 14 | enum TB_MSG { 15 | TB_MSG_OK, 16 | TB_MSG_OK_CANCEL, 17 | TB_MSG_YES_NO, 18 | TB_MSG_YES_NO_CANCEL, 19 | }; 20 | 21 | /** TBMessageWindowSettings contains additional settings for TBMessageWindow. */ 22 | class TBMessageWindowSettings 23 | { 24 | public: 25 | TBMessageWindowSettings() : msg(TB_MSG_OK), dimmer(false), styling(false) {} 26 | TBMessageWindowSettings(TB_MSG msg, TBID icon_skin) : msg(msg), icon_skin(icon_skin), dimmer(false), styling(false), align(TB_TEXT_ALIGN_LEFT) {} 27 | public: 28 | TB_MSG msg; ///< The type of response for the message. 29 | TBID icon_skin; ///< The icon skin (0 for no icon) 30 | bool dimmer; ///< Set to true to dim background widgets by a TBDimmer. 31 | bool styling; ///< Enable styling in the textfield. 32 | TB_TEXT_ALIGN align; ///< Text alignment in message box. 33 | }; 34 | 35 | /** TBMessageWindow is a window for showing simple messages. 36 | Events invoked in this window will travel up through the target widget. 37 | 38 | When the user click any of its buttons, it will invoke a click event 39 | (with the window ID), with the clicked buttons id as ref_id. 40 | Then it will delete itself. 41 | 42 | If the target widget is deleted while this window is alive, the 43 | window will delete itself. */ 44 | class TBMessageWindow : public TBWindow, private TBWidgetListener 45 | { 46 | public: 47 | // For safe typecasting 48 | TBOBJECT_SUBCLASS(TBMessageWindow, TBWindow); 49 | 50 | TBMessageWindow(TBWidget *target, TBID id); 51 | virtual ~TBMessageWindow(); 52 | 53 | bool Show(const TBStr & title, const TBStr & message, TBMessageWindowSettings *settings = nullptr); 54 | 55 | virtual TBWidget *GetEventDestination() const { return m_target.Get(); } 56 | 57 | virtual bool OnEvent(const TBWidgetEvent &ev); 58 | virtual void OnDie(); 59 | private: 60 | void AddButton(TBID id, bool focused); 61 | // TBWidgetListener 62 | virtual void OnWidgetDelete(TBWidget *widget); 63 | virtual bool OnWidgetDying(TBWidget *widget); 64 | TBWidgetSafePointer m_dimmer; 65 | TBWidgetSafePointer m_target; 66 | }; 67 | 68 | } // namespace tb 69 | 70 | #endif // TB_MESSAGE_WINDOW_H 71 | -------------------------------------------------------------------------------- /src/tb/tb_object.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_object.h" 7 | #include 8 | 9 | namespace tb { 10 | 11 | } // namespace tb 12 | -------------------------------------------------------------------------------- /src/tb/tb_object.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_OBJECT_H 7 | #define TB_OBJECT_H 8 | 9 | #include "tb_core.h" 10 | #include "tb_linklist.h" 11 | 12 | namespace tb { 13 | 14 | typedef void* TB_TYPE_ID; 15 | 16 | /* TBTypedObject implements custom RTTI so we can get type safe casts, 17 | and the class name at runtime. 18 | 19 | Each subclass is expected to define TBOBJECT_SUBCLASS to get the 20 | necessary implementations, instead of implementing those manually. */ 21 | class TBTypedObject 22 | { 23 | public: 24 | virtual ~TBTypedObject() {} 25 | 26 | /** A static template method that returns a unique id for each type. */ 27 | template static TB_TYPE_ID GetTypeId() { static char type_id; return &type_id; } 28 | 29 | /** Returns true if the class or the base class matches the type id */ 30 | virtual bool IsOfTypeId(const TB_TYPE_ID type_id) const { return type_id == GetTypeId(); } 31 | 32 | /** Returns this object as the given type or nullptr if it's not that type. */ 33 | template T *SafeCastTo() const { return (T*) (IsOfTypeId(GetTypeId()) ? this : nullptr); } 34 | 35 | /** Return true if this object can safely be casted to the given type. */ 36 | template bool IsOfType() const { return SafeCastTo() ? true : false; } 37 | 38 | /** Get the classname of the object. */ 39 | virtual const char *GetClassName() const { return "TBTypedObject"; } 40 | }; 41 | 42 | /** Returns the given object as the given type, or nullptr if it's not that type 43 | or if the object is nullptr. */ 44 | template T *TBSafeCast(TBTypedObject *obj) { 45 | return obj ? obj->SafeCastTo() : nullptr; 46 | } 47 | 48 | /** Returns the given object as the given type, or nullptr if it's not that type 49 | or if the object is nullptr. */ 50 | template const T *TBSafeCast(const TBTypedObject *obj) { 51 | return obj ? obj->SafeCastTo() : nullptr; 52 | } 53 | 54 | /** Implement the methods for safe typecasting without requiring RTTI. */ 55 | #define TBOBJECT_SUBCLASS(clazz, baseclazz) \ 56 | virtual const char *GetClassName() const { return #clazz; } \ 57 | virtual bool IsOfTypeId(const tb::TB_TYPE_ID type_id) const \ 58 | { return GetTypeId() == type_id ? true : baseclazz::IsOfTypeId(type_id); } 59 | 60 | } // namespace tb 61 | 62 | #endif // TB_OBJECT_H 63 | -------------------------------------------------------------------------------- /src/tb/tb_renderer.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_renderer.h" 7 | 8 | namespace tb { 9 | 10 | // == TBRenderer ======================================================================== 11 | 12 | void TBRenderer::InvokeContextLost() 13 | { 14 | TBLinkListOf::Iterator iter = m_listeners.IterateForward(); 15 | while (TBRendererListener *listener = iter.GetAndStep()) 16 | listener->OnContextLost(); 17 | } 18 | 19 | void TBRenderer::InvokeContextRestored() 20 | { 21 | TBLinkListOf::Iterator iter = m_listeners.IterateForward(); 22 | while (TBRendererListener *listener = iter.GetAndStep()) 23 | listener->OnContextRestored(); 24 | } 25 | 26 | } // namespace tb 27 | -------------------------------------------------------------------------------- /src/tb/tb_skin_util.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_skin_util.h" 7 | 8 | namespace tb { 9 | 10 | static int GetFadeoutSize(int scrolled_distance, int fadeout_length) 11 | { 12 | // Make it appear gradually 13 | //float factor = scrolled_distance / 10.f; 14 | //factor = CLAMP(factor, 0.5f, 1); 15 | //return (int)(fadeout_length * factor); 16 | return scrolled_distance > 0 ? fadeout_length : 0; 17 | } 18 | 19 | void DrawEdgeFadeout(const TBRect &dst_rect, TBID skin_x, TBID skin_y, 20 | int left, int top, int right, int bottom) 21 | { 22 | if (TBSkinElement *skin = g_tb_skin->GetSkinElement(skin_x)) 23 | { 24 | if (skin->bitmap) 25 | { 26 | int bw = skin->bitmap->Width(); 27 | int bh = skin->bitmap->Height(); 28 | int dw; 29 | if ((dw = GetFadeoutSize(left, bw)) > 0) 30 | g_renderer->DrawBitmap(TBRect(dst_rect.x, dst_rect.y, dw, dst_rect.h), TBRect(0, 0, bw, bh), skin->bitmap); 31 | if ((dw = GetFadeoutSize(right, bw)) > 0) 32 | g_renderer->DrawBitmap(TBRect(dst_rect.x + dst_rect.w - dw, dst_rect.y, dw, dst_rect.h), TBRect(bw, 0, -bw, bh), skin->bitmap); 33 | } 34 | } 35 | if (TBSkinElement *skin = g_tb_skin->GetSkinElement(skin_y)) 36 | { 37 | if (skin->bitmap) 38 | { 39 | int bw = skin->bitmap->Width(); 40 | int bh = skin->bitmap->Height(); 41 | int dh; 42 | if ((dh = GetFadeoutSize(top, bh)) > 0) 43 | g_renderer->DrawBitmap(TBRect(dst_rect.x, dst_rect.y, dst_rect.w, dh), TBRect(0, 0, bw, bh), skin->bitmap); 44 | if ((dh = GetFadeoutSize(bottom, bh)) > 0) 45 | g_renderer->DrawBitmap(TBRect(dst_rect.x, dst_rect.y + dst_rect.h - dh, dst_rect.w, dh), TBRect(0, bh, bw, -bh), skin->bitmap); 46 | } 47 | } 48 | } 49 | 50 | } // namespace tb 51 | -------------------------------------------------------------------------------- /src/tb/tb_skin_util.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_SKIN_UTIL_H 7 | #define TB_SKIN_UTIL_H 8 | 9 | #include "tb_skin.h" 10 | 11 | namespace tb { 12 | 13 | /** Draw fade out skin elements at the edges of dst_rect if needed. 14 | It indicates to the user that there is hidden content. 15 | left, top, right, bottom specifies the (positive) distance scrolled 16 | from the limit. */ 17 | void DrawEdgeFadeout(const TBRect &dst_rect, TBID skin_x, TBID skin_y, 18 | int left, int top, int right, int bottom); 19 | 20 | } // namespace tb 21 | 22 | #endif // TB_SKIN_UTIL_H 23 | -------------------------------------------------------------------------------- /src/tb/tb_sort.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_SORT_H 7 | #define TB_SORT_H 8 | 9 | namespace tb { 10 | 11 | template 12 | static void insertion_sort(TYPE *elements, size_t element_count, CONTEXT context, int(*cmp)(CONTEXT context, const TYPE *a, const TYPE *b)) 13 | { 14 | size_t i, j; 15 | for (i = 1; i < element_count; i++) 16 | { 17 | TYPE value = elements[i]; 18 | for (j = i; j > 0 && cmp(context, &value, &elements[j - 1]) < 0; j--) 19 | elements[j] = elements[j - 1]; 20 | elements[j] = value; 21 | } 22 | } 23 | 24 | } // namespace tb 25 | 26 | #endif // TB_SORT_H 27 | -------------------------------------------------------------------------------- /src/tb/tb_system.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_SYSTEM_H 7 | #define TB_SYSTEM_H 8 | 9 | #include "tb_core.h" 10 | #include "tb_str.h" 11 | 12 | namespace tb { 13 | 14 | // == Platform interface =================================================== 15 | 16 | /** TBSystem is porting interface for the underlaying OS. */ 17 | class TBSystem 18 | { 19 | public: 20 | /** Get the system time in milliseconds since some undefined epoch. */ 21 | static double GetTimeMS(); 22 | 23 | /** Called when the need to call TBMessageHandler::ProcessMessages has changed due to changes in the 24 | message queue. fire_time is the new time is needs to be called. 25 | It may be 0 which means that ProcessMessages should be called asap (but NOT from this call!) 26 | It may also be TB_NOT_SOON which means that ProcessMessages doesn't need to be called. */ 27 | static void RescheduleTimer(double fire_time); 28 | 29 | /** Get how many milliseconds it should take after a touch down event should generate a long click 30 | event. */ 31 | static int GetLongClickDelayMS(); 32 | 33 | /** Get how many pixels of dragging should start panning scrollable widgets. */ 34 | static int GetPanThreshold(); 35 | 36 | /** Get how many pixels a typical line is: The length that should be scrolled when turning a mouse 37 | wheel one notch. */ 38 | static int GetPixelsPerLine(); 39 | 40 | /** Get Dots Per Inch for the main screen. */ 41 | static int GetDPI(); 42 | 43 | /** Set Dots Per Inch for the main screen. */ 44 | static void SetDPI(int dpi); 45 | 46 | private: 47 | static int _dpi; //< the current dpi value 48 | }; 49 | 50 | /** TBClipboard is a portable interface for the clipboard. */ 51 | class TBClipboard 52 | { 53 | public: 54 | /** Empty the contents of the clipboard. */ 55 | static void Empty(); 56 | 57 | /** Return true if the clipboard currently contains text. */ 58 | static bool HasText(); 59 | 60 | /** Set the text of the clipboard in UTF-8 format. */ 61 | static bool SetText(const TBStr & text); 62 | 63 | /** Get the text from the clipboard in UTF-8 format. 64 | Returns true on success. */ 65 | static bool GetText(TBStr &text); 66 | }; 67 | 68 | /** TBFile is a portable interface for file access. */ 69 | class TBFile 70 | { 71 | public: 72 | enum TBFileMode { MODE_READ, MODE_WRITETRUNC }; 73 | static TBFile *Open(const TBStr & filename, TBFileMode mode); 74 | 75 | virtual ~TBFile() {} 76 | virtual long Size() = 0; 77 | virtual size_t Read(void *buf, size_t elemSize, size_t count) = 0; 78 | virtual size_t Write(const void *buf, size_t elemSize, size_t count) = 0; 79 | virtual size_t Write(const TBStr & str) = 0; 80 | }; 81 | 82 | } // namespace tb 83 | 84 | #endif // TB_SYSTEM_H 85 | -------------------------------------------------------------------------------- /src/tb/tb_system_android.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_SYSTEM_ANDROID 9 | #ifndef TB_BACKEND_SDL2 10 | 11 | #include "tb_debug.h" 12 | #include "tb_str.h" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // for native asset manager 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(TB_RUNTIME_DEBUG_INFO) 25 | 26 | #define LOG_TAG "TB" 27 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 28 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 29 | 30 | void TBDebugOut(const tb::TBStr & str) 31 | { 32 | LOGI("%s", str.CStr()); 33 | } 34 | 35 | #endif // TB_RUNTIME_DEBUG_INFO 36 | 37 | AAssetManager *g_pManager; 38 | 39 | void SetAssetManager(AAssetManager *pManager) 40 | { 41 | g_pManager = pManager; 42 | } 43 | 44 | namespace tb { 45 | 46 | // == TBSystem ======================================== 47 | 48 | double TBSystem::GetTimeMS() 49 | { 50 | struct timeval now; 51 | gettimeofday(&now, NULL); 52 | return now.tv_usec / 1000 + now.tv_sec * 1000; 53 | } 54 | 55 | void TBSystem::RescheduleTimer(double fire_time) 56 | { 57 | } 58 | 59 | int TBSystem::GetLongClickDelayMS() 60 | { 61 | return 500; 62 | } 63 | 64 | int TBSystem::GetPanThreshold() 65 | { 66 | return 5 * GetDPI() / 120; 67 | } 68 | 69 | int TBSystem::GetPixelsPerLine() 70 | { 71 | return 40 * GetDPI() / 120; 72 | } 73 | 74 | int TBSystem::GetDPI() 75 | { 76 | AConfiguration *config = AConfiguration_new(); 77 | AConfiguration_fromAssetManager(config, g_pManager); 78 | int32_t density = AConfiguration_getDensity(config); 79 | AConfiguration_delete(config); 80 | if (density == 0 || density == ACONFIGURATION_DENSITY_NONE) 81 | return 120; 82 | return density; 83 | } 84 | 85 | } // namespace tb 86 | 87 | #endif // !TB_SYSTEM_SDL2 88 | #endif // TB_SYSTEM_ANDROID 89 | -------------------------------------------------------------------------------- /src/tb/tb_system_linux.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | #include "tb_str.h" 8 | 9 | #if (defined(TB_SYSTEM_IOS) || defined(TB_SYSTEM_MACOSX) || defined(TB_SYSTEM_LINUX)) && !defined(TB_BACKEND_SDL2) 10 | 11 | #include 12 | #include 13 | 14 | #ifdef TB_RUNTIME_DEBUG_INFO 15 | 16 | void TBDebugOut(const tb::TBStr & str) 17 | { 18 | printf("%s", (const char *)str); 19 | } 20 | 21 | #endif // TB_RUNTIME_DEBUG_INFO 22 | 23 | namespace tb { 24 | 25 | // == TBSystem ======================================== 26 | 27 | double TBSystem::GetTimeMS() 28 | { 29 | struct timeval now; 30 | gettimeofday( &now, NULL ); 31 | return now.tv_usec/1000 + now.tv_sec*1000; 32 | } 33 | 34 | // Implementation currently done in port_glfw.cpp. 35 | // FIX: Implement here for linux-desktop/android/macos? 36 | //void TBSystem::RescheduleTimer(double fire_time) 37 | //{ 38 | //} 39 | 40 | int TBSystem::GetLongClickDelayMS() 41 | { 42 | return 500; 43 | } 44 | 45 | int TBSystem::GetPanThreshold() 46 | { 47 | return 5 * GetDPI() / 96; 48 | } 49 | 50 | int TBSystem::GetPixelsPerLine() 51 | { 52 | return 40 * GetDPI() / 96; 53 | } 54 | 55 | int TBSystem::GetDPI() 56 | { 57 | // FIX: Implement! 58 | return 96; 59 | } 60 | 61 | } // namespace tb 62 | 63 | #endif // TB_SYSTEM_LINUX 64 | -------------------------------------------------------------------------------- /src/tb/tb_system_win.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_system.h" 7 | 8 | #ifdef TB_SYSTEM_WINDOWS 9 | #ifdef TB_BACKEND_GLFW 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "tb_debug.h" 16 | 17 | #ifdef TB_RUNTIME_DEBUG_INFO 18 | 19 | void TBDebugOut(const tb::TBStr & str) 20 | { 21 | OutputDebugString(str.CStr()); 22 | } 23 | 24 | #endif // TB_RUNTIME_DEBUG_INFO 25 | 26 | namespace tb { 27 | 28 | // == TBSystem ======================================== 29 | 30 | double TBSystem::GetTimeMS() 31 | { 32 | return timeGetTime(); 33 | } 34 | 35 | // Implementation currently done in port_glfw.cpp. 36 | // Windows timer suck. Glut timers suck too (can't be canceled) but that will do for now. 37 | //void TBSystem::RescheduleTimer(double fire_time) 38 | //{ 39 | //} 40 | 41 | int TBSystem::GetLongClickDelayMS() 42 | { 43 | return 500; 44 | } 45 | 46 | int TBSystem::GetPanThreshold() 47 | { 48 | return 5 * GetDPI() / 96; 49 | } 50 | 51 | int TBSystem::GetPixelsPerLine() 52 | { 53 | return 40 * GetDPI() / 96; 54 | } 55 | 56 | int TBSystem::GetDPI() 57 | { 58 | HDC hdc = GetDC(nullptr); 59 | int DPI_x = GetDeviceCaps(hdc, LOGPIXELSX); 60 | ReleaseDC(nullptr, hdc); 61 | #if 0 // TEST CODE! 62 | DPI_x *= 2; 63 | #endif 64 | return DPI_x; 65 | } 66 | 67 | } // namespace tb 68 | 69 | #endif // TB_BACKEND_GLFW 70 | #endif // TB_SYSTEM_WINDOWS 71 | -------------------------------------------------------------------------------- /src/tb/tb_tab_container.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_TAB_CONTAINER_H 7 | #define TB_TAB_CONTAINER_H 8 | 9 | #include "tb_widgets_common.h" 10 | 11 | namespace tb { 12 | 13 | /** TBTabLayout is a TBLayout used in TBTabContainer to apply some 14 | default properties on any TBButton added to it. The buttons are 15 | the tab labels / switchers. */ 16 | class TBTabLayout : public TBLayout 17 | { 18 | public: 19 | // For safe typecasting 20 | TBOBJECT_SUBCLASS(TBTabLayout, TBLayout); 21 | 22 | virtual void OnChildAdded(TBWidget *child); 23 | virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints); 24 | }; 25 | 26 | /** TBTabContainer - A container with tabs for multiple pages. */ 27 | 28 | class TBTabContainer : public TBWidget 29 | { 30 | public: 31 | // For safe typecasting 32 | TBOBJECT_SUBCLASS(TBTabContainer, TBWidget); 33 | 34 | TBTabContainer(); 35 | ~TBTabContainer(); 36 | 37 | /** Set along which axis the content should layouted. 38 | Use SetAlignment instead for more choice! Also, calling 39 | SetAxis directly does not update the current alignment. */ 40 | virtual void SetAxis(AXIS axis); 41 | virtual AXIS GetAxis() const { return m_root_layout.GetAxis(); } 42 | 43 | /** Set alignment of the tabs. */ 44 | void SetAlignment(TB_ALIGN align); 45 | TB_ALIGN GetAlignment() const { return m_align; } 46 | 47 | /** Set which page should be selected and visible. */ 48 | virtual void SetValue(long value); 49 | virtual long GetValue() const { return m_current_page; } 50 | 51 | /** Set which page should be selected and visible. */ 52 | void SetCurrentPage(int index) { SetValue(index); } 53 | int GetCurrentPage() { return GetValue(); } 54 | int GetNumPages(); 55 | 56 | /** Return the widget that is the current page, or nullptr if none is active. */ 57 | TBWidget *GetCurrentPageWidget() const; 58 | 59 | virtual void OnInflate(const INFLATE_INFO &info); 60 | virtual bool OnEvent(const TBWidgetEvent &ev); 61 | virtual void OnProcess(); 62 | 63 | virtual TBWidget *GetContentRoot() { return &m_content_root; } 64 | TBLayout *GetTabLayout() { return &m_tab_layout; } 65 | protected: 66 | TBLayout m_root_layout; 67 | TBTabLayout m_tab_layout; 68 | TBWidget m_content_root; 69 | bool m_need_page_update; 70 | int m_current_page; 71 | TB_ALIGN m_align; 72 | }; 73 | 74 | }; 75 | 76 | #endif // TB_TAB_CONTAINER_H 77 | -------------------------------------------------------------------------------- /src/tb/tb_widget_skin_condition_context.h: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #ifndef TB_WIDGET_SKIN_CONDITION_CONTEXT_H 7 | #define TB_WIDGET_SKIN_CONDITION_CONTEXT_H 8 | 9 | #include "tb_widgets.h" 10 | #include "tb_skin.h" 11 | 12 | namespace tb { 13 | 14 | /** Check if a condition is true for a widget when painting a skin. */ 15 | 16 | class TBWidgetSkinConditionContext : public TBSkinConditionContext 17 | { 18 | public: 19 | TBWidgetSkinConditionContext(TBWidget *widget) : m_widget(widget) {} 20 | virtual bool GetCondition(TBSkinCondition::TARGET target, const TBSkinCondition::CONDITION_INFO &info); 21 | private: 22 | bool GetCondition(TBWidget *widget, const TBSkinCondition::CONDITION_INFO &info); 23 | TBWidget *m_widget; 24 | }; 25 | 26 | } // namespace tb 27 | 28 | #endif // TB_WIDGET_SKIN_CONDITION_CONTEXT_H 29 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_color.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | #include "tb_color.h" 8 | #include "tb_core.h" 9 | 10 | #ifdef TB_UNIT_TESTING 11 | 12 | using namespace tb; 13 | 14 | TB_TEST_GROUP(tb_color) 15 | { 16 | TB_TEST(set_from_string_rrggbbaa) 17 | { 18 | TBColor col; 19 | col.SetFromString(TBStr("#11223344", 9)); 20 | TB_VERIFY(col.r == 0x11); 21 | TB_VERIFY(col.g == 0x22); 22 | TB_VERIFY(col.b == 0x33); 23 | TB_VERIFY(col.a == 0x44); 24 | } 25 | TB_TEST(set_from_string_rrggbb) 26 | { 27 | TBColor col; 28 | col.SetFromString(TBStr("#112233", 7)); 29 | TB_VERIFY(col.r == 0x11); 30 | TB_VERIFY(col.g == 0x22); 31 | TB_VERIFY(col.b == 0x33); 32 | TB_VERIFY(col.a == 0xff); 33 | } 34 | TB_TEST(set_from_string_rgba) 35 | { 36 | TBColor col; 37 | col.SetFromString(TBStr("#1234", 5)); 38 | TB_VERIFY(col.r == 0x11); 39 | TB_VERIFY(col.g == 0x22); 40 | TB_VERIFY(col.b == 0x33); 41 | TB_VERIFY(col.a == 0x44); 42 | } 43 | TB_TEST(set_from_string_rgb) 44 | { 45 | TBColor col; 46 | col.SetFromString(TBStr("#123", 4)); 47 | TB_VERIFY(col.r == 0x11); 48 | TB_VERIFY(col.g == 0x22); 49 | TB_VERIFY(col.b == 0x33); 50 | TB_VERIFY(col.a == 0xff); 51 | } 52 | TB_TEST(set_from_string_invalid) 53 | { 54 | TBColor col; 55 | col.SetFromString(TBStr("123", 3)); 56 | TB_VERIFY(col.r == 0x0); 57 | TB_VERIFY(col.g == 0x0); 58 | TB_VERIFY(col.b == 0x0); 59 | TB_VERIFY(col.a == 0xff); 60 | } 61 | } 62 | 63 | #endif // TB_UNIT_TESTING 64 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_dimension.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | #include "tb_dimension.h" 8 | #include "tb_core.h" 9 | 10 | #ifdef TB_UNIT_TESTING 11 | 12 | using namespace tb; 13 | 14 | TB_TEST_GROUP(tb_dimension_converter) 15 | { 16 | TBDimensionConverter dim_conv; 17 | 18 | TB_TEST(Init) 19 | { 20 | dim_conv.SetDPI(100, 200); 21 | } 22 | 23 | TB_TEST(set_from_string_unspecified) 24 | { 25 | int px = dim_conv.GetPxFromString("50", 0); 26 | TB_VERIFY(px == 50 * 2); 27 | } 28 | 29 | TB_TEST(set_from_string_px) 30 | { 31 | int px = dim_conv.GetPxFromString("50px", 0); 32 | TB_VERIFY(px == 50); 33 | } 34 | 35 | TB_TEST(set_from_string_dp) 36 | { 37 | int px = dim_conv.GetPxFromString("50dp", 0); 38 | TB_VERIFY(px == 50 * 2); 39 | } 40 | } 41 | 42 | #endif // TB_UNIT_TESTING 43 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_object.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | #include "tb_object.h" 8 | 9 | #ifdef TB_UNIT_TESTING 10 | 11 | using namespace tb; 12 | 13 | TB_TEST_GROUP(tb_object) 14 | { 15 | class Car : public TBTypedObject 16 | { 17 | public: 18 | TBOBJECT_SUBCLASS(Car, TBTypedObject); 19 | }; 20 | 21 | class Fruit : public TBTypedObject 22 | { 23 | public: 24 | TBOBJECT_SUBCLASS(Fruit, TBTypedObject); 25 | }; 26 | 27 | class Apple : public Fruit 28 | { 29 | public: 30 | TBOBJECT_SUBCLASS(Apple, Fruit); 31 | }; 32 | 33 | TB_TEST(safe_cast) 34 | { 35 | Fruit fruit; 36 | Apple apple; 37 | Car car; 38 | 39 | TB_VERIFY(TBSafeCast(&fruit)); 40 | TB_VERIFY(TBSafeCast(&apple)); 41 | TB_VERIFY(TBSafeCast(&car)); 42 | 43 | TB_VERIFY(TBSafeCast(&fruit)); 44 | TB_VERIFY(TBSafeCast(&apple)); 45 | TB_VERIFY(!TBSafeCast(&car)); 46 | 47 | TB_VERIFY(!TBSafeCast(&fruit)); 48 | TB_VERIFY(TBSafeCast(&apple)); 49 | TB_VERIFY(!TBSafeCast(&car)); 50 | 51 | TB_VERIFY(!TBSafeCast(&fruit)); 52 | TB_VERIFY(!TBSafeCast(&apple)); 53 | TB_VERIFY(TBSafeCast(&car)); 54 | } 55 | } 56 | 57 | #endif // TB_UNIT_TESTING 58 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_parser_definitions.tb.txt: -------------------------------------------------------------------------------- 1 | 2 | # This test file will be included from test_tb_parser.tb.txt 3 | 4 | styles 5 | Chocolate 6 | skin: "DarkSkin" 7 | Vanilla 8 | skin: "LightSkin" 9 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_parser_included.tb.txt: -------------------------------------------------------------------------------- 1 | 2 | # This test file will be included from test_tb_parser.tb.txt 3 | 4 | something1: "Chocolate" 5 | something2: "Cake" 6 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_tempbuffer.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | #include "tb_tempbuffer.h" 8 | 9 | #ifdef TB_UNIT_TESTING 10 | 11 | using namespace tb; 12 | 13 | TB_TEST_GROUP(tb_tempbuffer) 14 | { 15 | TB_TEST(append_path_1) 16 | { 17 | TBTempBuffer buf; 18 | buf.AppendPath("foo.txt"); 19 | TB_VERIFY_STR(buf.GetData(), "./"); 20 | } 21 | TB_TEST(append_path_2) 22 | { 23 | TBTempBuffer buf; 24 | buf.AppendPath("Path/subpath/foo.txt"); 25 | TB_VERIFY_STR(buf.GetData(), "Path/subpath/"); 26 | } 27 | TB_TEST(append_path_3) 28 | { 29 | TBTempBuffer buf; 30 | buf.AppendPath("C:\\test\\foo.txt"); 31 | TB_VERIFY_STR(buf.GetData(), "C:\\test\\"); 32 | } 33 | TB_TEST(append_string) 34 | { 35 | TBTempBuffer buf; 36 | buf.AppendString("xxxxxxxxxx"); 37 | TB_VERIFY(buf.GetAppendPos() == 10); 38 | TB_VERIFY_STR(buf.GetData(), "xxxxxxxxxx"); 39 | 40 | buf.SetAppendPos(0); 41 | buf.AppendString("Foo"); 42 | buf.AppendString("Bar"); 43 | TB_VERIFY_STR(buf.GetData(), "FooBar"); 44 | } 45 | } 46 | 47 | #endif // TB_UNIT_TESTING 48 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_test.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | 8 | #ifdef TB_UNIT_TESTING 9 | 10 | using namespace tb; 11 | 12 | TB_TEST_GROUP(tb_test) 13 | { 14 | TB_TEST(single_test) 15 | { 16 | TB_PASS(); 17 | } 18 | } 19 | 20 | TB_TEST_GROUP(tb_test_multiple_calls) 21 | { 22 | int setup_calls; 23 | int test_calls; 24 | 25 | TB_TEST(Setup) 26 | { 27 | setup_calls++; 28 | } 29 | TB_TEST(test_1) 30 | { 31 | TB_VERIFY(setup_calls == 1); 32 | test_calls++; 33 | } 34 | TB_TEST(test_2) 35 | { 36 | TB_VERIFY(setup_calls == 2); 37 | test_calls++; 38 | } 39 | TB_TEST(Cleanup) 40 | { 41 | TB_VERIFY(test_calls > 0); 42 | } 43 | } 44 | 45 | #endif // TB_UNIT_TESTING 46 | -------------------------------------------------------------------------------- /src/tb/tests/test_tb_value.cpp: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == 3 | // == See tb_core.h for more information. == 4 | // ================================================================================ 5 | 6 | #include "tb_test.h" 7 | #include "tb_node_tree.h" 8 | 9 | #ifdef TB_UNIT_TESTING 10 | 11 | using namespace tb; 12 | 13 | TB_TEST_GROUP(tb_value) 14 | { 15 | TB_TEST(node_create_on_get) 16 | { 17 | TBNode node; 18 | TB_VERIFY(node.GetNode("foo>bar>funky") == nullptr); 19 | TB_VERIFY(node.GetNode("foo>bar>funky", TBNode::GET_MISS_POLICY_CREATE) != nullptr); 20 | TB_VERIFY(node.GetNode("foo>bar>funky") != nullptr); 21 | } 22 | 23 | // More coverage in test_tb_parser.cpp... 24 | } 25 | 26 | #endif // TB_UNIT_TESTING 27 | -------------------------------------------------------------------------------- /src/tb/utf8/utf8.h: -------------------------------------------------------------------------------- 1 | #ifndef BASIC_UTF8_H 2 | #define BASIC_UTF8_H 3 | 4 | typedef unsigned int UCS4; 5 | 6 | namespace utf8 { 7 | 8 | /** Decodes UTF-8 from a string input to a UCS4 character. 9 | @param src buffer in UTF-8 that should be decoded. If the buffer represent 10 | a valid character, the pointer will be incremented to the next character. 11 | @param src_end The end of the string. 12 | @return a UCS4 character, or 0xFFFF if the buffer didn't represent a valid character. 13 | */ 14 | UCS4 decode(const char *&src, const char *src_end); 15 | 16 | /** Encodes a UCS4 character to UTF-8. 17 | @param ch UCS-4 value. 18 | @param dst buffer to receive UTF-8 encoding (must be at least 8 bytes!) 19 | @return number of bytes needed to represent character 20 | */ 21 | int encode(UCS4 ch, char *dst); 22 | 23 | /** Decode the next UCS4 character from a UTF-8 string, and update the index variable. 24 | @param str The UTF-8 string. 25 | @param i The index of the current position. This will be increased to the next position. 26 | @param i_max The last position (size of str). 27 | */ 28 | UCS4 decode_next(const char *str, int *i, int i_max); 29 | 30 | /** Move to the next character in a UTF-8 string. 31 | @param str The UTF-8 string. 32 | @param i The index of the current position. This will be increased to the next position. 33 | @param i_max The last position (size of str). 34 | */ 35 | void move_inc(const char *str, int *i, int i_max); 36 | 37 | /** Move to the previous character in a UTF-8 string. 38 | @param str The UTF-8 string. 39 | @param i The index of the current position. This will be decreased to the previous position. 40 | */ 41 | void move_dec(const char *str, int *i); 42 | 43 | /** Count characters before null termination in a UTF-8 string. 44 | Node: Does not include the null termination! 45 | @param str The UTF-8 string. 46 | @param i_max The last position (size of str). 47 | */ 48 | int count_characters(const char *str, int i_max); 49 | 50 | } // namespace utf8 51 | 52 | #endif // BASIC_UTF8_H 53 | --------------------------------------------------------------------------------