├── .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 │ └── port_glfw.cpp └── screenshot │ └── screenshot_01.png ├── DemoAndroid ├── AndroidManifest.xml ├── ant.properties ├── assets │ ├── images │ │ ├── image_1.png │ │ └── tb_logo.png │ └── layout │ │ └── main_layout.tb.txt ├── build.bat ├── build.xml ├── jni │ ├── Android.mk │ ├── App.cpp │ ├── App.h │ ├── Application.mk │ └── jni_glue.cpp ├── proguard-project.txt ├── proguard.cfg ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ └── values │ │ └── strings.xml ├── src │ └── com │ │ └── fiffigt │ │ └── tb │ │ └── demo │ │ ├── TBActivity.java │ │ ├── TBLib.java │ │ └── TBView.java ├── turbobadger_android.sublime-project └── update_assets.bat ├── 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@288.png │ ├── arrow_down@384.png │ ├── arrow_left.png │ ├── arrow_left@192.png │ ├── arrow_left@288.png │ ├── arrow_left@384.png │ ├── arrow_right.png │ ├── arrow_right@192.png │ ├── arrow_right@288.png │ ├── arrow_right@384.png │ ├── arrow_up.png │ ├── arrow_up@192.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@288.png │ ├── checkbox@384.png │ ├── checkbox_mark.png │ ├── checkbox_mark@192.png │ ├── checkbox_mark@288.png │ ├── checkbox_mark@384.png │ ├── checkbox_pressed.png │ ├── checkbox_pressed@192.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@288.png │ ├── radio@384.png │ ├── radio_mark.png │ ├── radio_mark@192.png │ ├── radio_mark@288.png │ ├── radio_mark@384.png │ ├── radio_pressed.png │ ├── radio_pressed@192.png │ ├── radio_pressed@288.png │ ├── radio_pressed@384.png │ ├── resizer.png │ ├── resizer.psd │ ├── resizer@192.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@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@288.png │ ├── slider_bg_x@384.png │ ├── slider_bg_y.png │ ├── slider_bg_y@192.png │ ├── slider_bg_y@288.png │ ├── slider_bg_y@384.png │ ├── slider_handle.png │ ├── slider_handle.psd │ ├── slider_handle@192.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@288.png │ ├── window_close@384.png │ ├── window_close_pressed.png │ ├── window_close_pressed@192.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@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_win.cpp │ ├── tb_color.cpp │ ├── tb_color.h │ ├── tb_config.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_posix.cpp │ ├── tb_font_desc.h │ ├── tb_font_renderer.cpp │ ├── tb_font_renderer.h │ ├── tb_font_renderer_freetype.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_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_hashtable.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 │ ├── 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 └── turbobadger.sublime-project /.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 | 36 | DemoAndroid/libs 37 | DemoAndroid/assets/demo_skin 38 | DemoAndroid/assets/font 39 | DemoAndroid/assets/language 40 | DemoAndroid/assets/skin 41 | Demo.exe 42 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Demo/thirdparty/glfw"] 2 | path = Demo/thirdparty/glfw 3 | url = https://github.com/glfw/glfw.git 4 | -------------------------------------------------------------------------------- /Demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Use project source dir for demo output. We have to set 2 | # the release and debug specific defines too, for MSVC. 3 | if(TB_DEMO_IN_SRC) 4 | SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) 5 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}) 6 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}) 7 | endif() 8 | 9 | if(CMAKE_SYSTEM MATCHES "Windows") 10 | add_definitions(-DGLFW_EXPOSE_NATIVE_WIN32) 11 | add_definitions(-DGLFW_EXPOSE_NATIVE_WGL) 12 | set(EXTRA_LIBS ${EXTRA_LIBS} winmm) 13 | endif(CMAKE_SYSTEM MATCHES "Windows") 14 | 15 | # Configure glfw 16 | set(GLFW_BUILD_EXAMPLES OFF) 17 | set(GLFW_BUILD_TESTS OFF) 18 | set(GLFW_INSTALL OFF) 19 | #set(GLFW_USE_OPTIMUS_HPG ON) 20 | 21 | # Add sources 22 | set(LOCAL_SRCS "") 23 | aux_source_directory(./demo01 LOCAL_SRCS) 24 | aux_source_directory(./platform LOCAL_SRCS) 25 | include_directories(".") 26 | 27 | # Add glfw project 28 | target_include_directories(TurboBadgerLib PUBLIC "thirdparty/glfw/include") 29 | include_directories("thirdparty/glfw/include") 30 | add_subdirectory(thirdparty/glfw) 31 | 32 | # Platform specific 33 | if(CMAKE_COMPILER_IS_MINGW) 34 | # Avoid dll dependencies by linking statically. 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static") 36 | endif(CMAKE_COMPILER_IS_MINGW) 37 | 38 | add_executable(TurboBadgerDemo WIN32 ${LOCAL_SRCS}) 39 | target_link_libraries(TurboBadgerDemo TurboBadgerLib ${EXTRA_LIBS} glfw ${GLFW_LIBRARIES}) 40 | install(TARGETS TurboBadgerDemo 41 | RUNTIME DESTINATION bin 42 | LIBRARY DESTINATION lib 43 | ARCHIVE DESTINATION lib) 44 | -------------------------------------------------------------------------------- /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 char *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 char *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 char *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 char *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 char *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 char *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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_1.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_2.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_3.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_4.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_5.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_6.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_7.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_8.png -------------------------------------------------------------------------------- /Demo/demo01/images/image_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/images/image_9.png -------------------------------------------------------------------------------- /Demo/demo01/skin/bg_tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/bg_tile.png -------------------------------------------------------------------------------- /Demo/demo01/skin/bg_tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/bg_tile.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/focus_r8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/focus_r8.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/icon128.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/icon16.png -------------------------------------------------------------------------------- /Demo/demo01/skin/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/icon48.png -------------------------------------------------------------------------------- /Demo/demo01/skin/image_frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/image_frame.png -------------------------------------------------------------------------------- /Demo/demo01/skin/image_frame.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/image_frame.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/special_button.png -------------------------------------------------------------------------------- /Demo/demo01/skin/special_button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/special_button.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/special_button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/special_button_pressed.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star.psd -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gold.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gold@192.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gold@288.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gold@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gold@384.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gray.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gray@192.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/demo01/skin/star_gray@288.png -------------------------------------------------------------------------------- /Demo/demo01/skin/star_gray@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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: "Demo/demo01/images/image_1.png", skin: ImageFrame 13 | TBButton: skin: "Remove", id: "remove", gravity: right 14 | TBImageWidget: filename: "Demo/demo01/images/image_2.png", skin: ImageFrame 15 | TBButton: skin: "Remove", id: "remove", gravity: right 16 | TBImageWidget: filename: "Demo/demo01/images/image_3.png", skin: ImageFrame 17 | TBButton: skin: "Remove", id: "remove", gravity: right 18 | TBImageWidget: filename: "Demo/demo01/images/image_4.png", skin: ImageFrame 19 | TBButton: skin: "Remove", id: "remove", gravity: right 20 | TBImageWidget: filename: "Demo/demo01/images/image_5.png", skin: ImageFrame 21 | TBButton: skin: "Remove", id: "remove", gravity: right 22 | TBImageWidget: filename: "Demo/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: "Demo/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: "Demo/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: "Demo/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/fonts/neon_42.png -------------------------------------------------------------------------------- /Demo/fonts/orange.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/fonts/orange_30.png -------------------------------------------------------------------------------- /Demo/fonts/orangutang.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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 | // == App ========================================================================================= 15 | 16 | App::App(int width, int height) 17 | : m_backend(nullptr) 18 | , m_root(this) 19 | { 20 | // Set initial size which suggest to the backend which size we want the window to be. 21 | m_root.SetRect(TBRect(0, 0, width, height)); 22 | } 23 | 24 | void App::OnBackendAttached(AppBackend *backend, int width, int height) 25 | { 26 | m_backend = backend; 27 | OnResized(width, height); 28 | } 29 | 30 | void App::OnResized(int width, int height) 31 | { 32 | m_root.SetRect(TBRect(0, 0, width, height)); 33 | } 34 | 35 | bool App::Init() 36 | { 37 | TBWidgetsAnimationManager::Init(); 38 | return true; 39 | } 40 | 41 | void App::ShutDown() 42 | { 43 | TBWidgetsAnimationManager::Shutdown(); 44 | } 45 | 46 | void App::Process() 47 | { 48 | TBAnimationManager::Update(); 49 | m_root.InvokeProcessStates(); 50 | m_root.InvokeProcess(); 51 | } 52 | 53 | void App::RenderFrame() 54 | { 55 | g_renderer->BeginPaint(m_root.GetRect().w, m_root.GetRect().h); 56 | m_root.InvokePaint(TBWidget::PaintProps()); 57 | g_renderer->EndPaint(); 58 | 59 | // If animations are running, reinvalidate immediately 60 | if (TBAnimationManager::HasAnimationsRunning()) 61 | GetRoot()->Invalidate(); 62 | } 63 | -------------------------------------------------------------------------------- /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 | 24 | App *GetApp() { return m_app; } 25 | private: 26 | App *m_app; 27 | }; 28 | 29 | /** Backend interface that handles platform window & creating the renderer. */ 30 | class AppBackend 31 | { 32 | public: 33 | enum EVENT { 34 | EVENT_PAINT_REQUEST, 35 | EVENT_QUIT_REQUEST, 36 | EVENT_TITLE_CHANGED 37 | }; 38 | virtual ~AppBackend() {} 39 | virtual void OnAppEvent(const EVENT &ev) = 0; 40 | }; 41 | 42 | /** Application interface, for setting up the application using turbo badger. */ 43 | class App 44 | { 45 | public: 46 | App(int width, int height); 47 | virtual ~App() {} 48 | 49 | virtual const char *GetTitle() const { return ""; } 50 | int GetWidth() const { return m_root.GetRect().w; } 51 | int GetHeight() const { return m_root.GetRect().h; } 52 | 53 | tb::TBWidget *GetRoot() { return &m_root; } 54 | AppBackend *GetBackend() { return m_backend; } 55 | 56 | virtual void OnBackendAttached(AppBackend *backend, int width, int height); 57 | virtual void OnBackendDetached() { m_backend = nullptr; } 58 | virtual void OnResized(int width, int height); 59 | 60 | virtual bool Init(); 61 | virtual void ShutDown(); 62 | virtual void Process(); 63 | virtual void RenderFrame(); 64 | protected: 65 | AppBackend *m_backend; 66 | AppRootWidget m_root; 67 | }; 68 | 69 | /** Should return new instance of App. */ 70 | App *app_create(); 71 | 72 | #endif // APPLICATION_H 73 | -------------------------------------------------------------------------------- /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 | #endif 7 | #include "GLFW/glfw3.h" 8 | 9 | /* Function pointer types */ 10 | typedef void (* GLFWtimerfun)(); 11 | 12 | /** Do something (like posting a dummy message) to get the message loop to stop waiting 13 | in glfwWaitMsgLoop. */ 14 | void glfwWakeUpMsgLoop(GLFWwindow *window); 15 | 16 | /** Wait for a new message in the message loop. Should stop waiting if glfwWakeUpMsgLoop is called. */ 17 | void glfwWaitMsgLoop(GLFWwindow *window); 18 | 19 | /** Handle message(s) waiting in the message loop, or return immediately if there are none. */ 20 | void glfwPollMsgLoop(GLFWwindow *window); 21 | 22 | /** Start a timer that after the delay will call the callback set by glfwSetTimerCallback. 23 | Calling this should cancel any previously scheduled time out that has not yet happened. */ 24 | void glfwRescheduleTimer(unsigned int delay_ms); 25 | 26 | /** Kill the timer started by glfwRescheduleTimer. */ 27 | void glfwKillTimer(); 28 | 29 | /** Set the callback that should be called on timeout scheduled by glfwRescheduleTimer. */ 30 | void glfwSetTimerCallback(GLFWtimerfun cbfun); 31 | 32 | #endif // GLFW_EXTRA_H 33 | -------------------------------------------------------------------------------- /Demo/platform/glfw_extra_linux.cpp: -------------------------------------------------------------------------------- 1 | #include "tb_system.h" 2 | 3 | #if defined(TB_TARGET_LINUX) || defined(TB_TARGET_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_TARGET_LINUX) || defined(TB_TARGET_MACOSX) 59 | -------------------------------------------------------------------------------- /Demo/platform/glfw_extra_win.cpp: -------------------------------------------------------------------------------- 1 | #include "tb_system.h" 2 | 3 | #ifdef TB_TARGET_WINDOWS 4 | #include "glfw_extra.h" 5 | #include "tb_msg.h" 6 | #include "GLFW/glfw3native.h" 7 | 8 | GLFWtimerfun timerCallback; 9 | UINT_PTR timer_id; 10 | HWND timer_hwnd; 11 | WNDCLASS wndclass; 12 | bool prevent_starvation; 13 | 14 | #define GLFW_EXTRA_MSG_NULL WM_USER + 1 15 | #define FAKE_WM_TIMER WM_USER + 2 16 | 17 | LRESULT PASCAL TimerProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 18 | { 19 | if ((message == WM_TIMER || message == FAKE_WM_TIMER) && timerCallback) 20 | timerCallback(); 21 | return DefWindowProc(hwnd, message, wParam, lParam); 22 | } 23 | 24 | void CreateTimerWindow() 25 | { 26 | // Set up and register window class 27 | memset(&wndclass, 0, sizeof(WNDCLASS)); 28 | wndclass.lpfnWndProc = TimerProc; 29 | wndclass.lpszMenuName = "TB_TIMER_WINDOW"; 30 | wndclass.lpszClassName = "TB_TIMER_WINDOW"; 31 | RegisterClass((WNDCLASS*)&wndclass); 32 | 33 | timer_hwnd = CreateWindow("TB_TIMER_WINDOW", "TB_TIMER_WINDOW", 0, 34 | 10, 10, 100, 100, 35 | HWND_MESSAGE, (HMENU)NULL, NULL, NULL); 36 | } 37 | 38 | void glfwWakeUpMsgLoop(GLFWwindow *window) 39 | { 40 | prevent_starvation = true; 41 | PostMessage(glfwGetWin32Window(window), GLFW_EXTRA_MSG_NULL, 0, 0); 42 | } 43 | 44 | void glfwWaitMsgLoop(GLFWwindow *window) 45 | { 46 | glfwWaitEvents(); 47 | prevent_starvation = false; 48 | } 49 | 50 | void glfwPollMsgLoop(GLFWwindow *window) 51 | { 52 | glfwPollEvents(); 53 | prevent_starvation = false; 54 | } 55 | 56 | void glfwRescheduleTimer(unsigned int delay_ms) 57 | { 58 | if (!timer_hwnd) 59 | CreateTimerWindow(); 60 | 61 | if (delay_ms == 0) 62 | { 63 | // Some hackery: 64 | // If we're supposed to handle messages ASAP, we can't use SetTimer since 65 | // it's capped at 10ms minimum delay. Instead post the FAKE_WM_TIMER 66 | // message immediately. This will however starve the message loop 67 | // completely (freeze input) if we have a lot to do since posting 68 | // messages have higher priority in windows. To prevent this, we'll take 69 | // the 10ms penalty if we have any other messages in the queue or 70 | // glfwWakeUpMsgLoop was called (prevent_starvation is true). 71 | 72 | // Warning: Windows may actually *deliver* certain messages during this 73 | // call which may be unexpected with our current stack. This should 74 | // hopefully not be a problem in this demo app :) 75 | 76 | MSG msg; 77 | if (!prevent_starvation && !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) 78 | { 79 | glfwKillTimer(); 80 | PostMessage(timer_hwnd, FAKE_WM_TIMER, 0, 0); 81 | return; 82 | } 83 | } 84 | timer_id = SetTimer(timer_hwnd, 1, delay_ms, 0); 85 | } 86 | 87 | void glfwKillTimer() 88 | { 89 | if (timer_id) 90 | { 91 | KillTimer(timer_hwnd, timer_id); 92 | timer_id = 0; 93 | } 94 | } 95 | 96 | void glfwSetTimerCallback(GLFWtimerfun cbfun) 97 | { 98 | timerCallback = cbfun; 99 | } 100 | 101 | #endif // TB_TARGET_WINDOWS 102 | -------------------------------------------------------------------------------- /Demo/screenshot/screenshot_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/Demo/screenshot/screenshot_01.png -------------------------------------------------------------------------------- /DemoAndroid/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 25 | 30 | 31 | -------------------------------------------------------------------------------- /DemoAndroid/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked in Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /DemoAndroid/assets/images/image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/assets/images/image_1.png -------------------------------------------------------------------------------- /DemoAndroid/assets/images/tb_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/assets/images/tb_logo.png -------------------------------------------------------------------------------- /DemoAndroid/build.bat: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | 4 | call update_assets.bat 5 | 6 | set INSTALL=adb install -r bin/TBDemo-debug.apk 7 | set RUN=adb shell am start -n com.fiffigt.tb.demo/.TBActivity 8 | 9 | ndk-build -j 4 && ant debug && %INSTALL% && %RUN% 10 | -------------------------------------------------------------------------------- /DemoAndroid/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/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi armeabi-v7a x86 2 | #APP_ABI := armeabi-v7a 3 | 4 | APP_OPTIM := release 5 | -------------------------------------------------------------------------------- /DemoAndroid/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /DemoAndroid/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /DemoAndroid/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-19 12 | -------------------------------------------------------------------------------- /DemoAndroid/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/DemoAndroid/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoAndroid/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Turbo Badger Demo 4 | 5 | -------------------------------------------------------------------------------- /DemoAndroid/src/com/fiffigt/tb/demo/TBActivity.java: -------------------------------------------------------------------------------- 1 | package com.fiffigt.tb.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/src/com/fiffigt/tb/demo/TBLib.java: -------------------------------------------------------------------------------- 1 | package com.fiffigt.tb.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/turbobadger_android.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "./", 6 | "folder_exclude_patterns": ["bin", "gen", "obj", "libs"], 7 | "file_exclude_patterns": ["RunDemo", "*.png"] 8 | }, 9 | { 10 | "path": "../src/", 11 | "folder_exclude_patterns": ["icon"], 12 | "file_exclude_patterns": ["*.png"] 13 | } 14 | ], 15 | "settings": 16 | { 17 | "tab_size": 4, 18 | "trim_trailing_white_space_on_save": true 19 | }, 20 | "build_systems": 21 | [ 22 | { 23 | "name": "Android build and deploy DEBUG", 24 | "working_dir": "${project_path:${folder}}", 25 | "windows": 26 | { 27 | "cmd": ["build.bat"], 28 | "shell": ["cmd.exe"] 29 | } 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /DemoAndroid/update_assets.bat: -------------------------------------------------------------------------------- 1 | 2 | mkdir assets\language 3 | mkdir assets\font 4 | mkdir assets\skin 5 | mkdir assets\demo_skin 6 | copy /Y "..\resources\language\*.txt" "assets\language\*" 7 | copy /Y "..\resources\default_font\*" "assets\font\*" 8 | copy /Y "..\resources\default_skin\*.png" "assets\skin\*" 9 | copy /Y "..\resources\default_skin\*.txt" "assets\skin\*" 10 | copy /Y "..\Demo\demo01\skin\*.png" "assets\demo_skin\*" 11 | copy /Y "..\Demo\demo01\skin\*.txt" "assets\demo_skin\*" 12 | -------------------------------------------------------------------------------- /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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_font/segoe_white_with_shadow_14.png -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow_14.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_font/segoe_white_with_shadow_14.psd -------------------------------------------------------------------------------- /resources/default_font/segoe_white_with_shadow_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_font/segoe_white_with_shadow_28.png -------------------------------------------------------------------------------- /resources/default_skin/TBSectionContainer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/TBSectionContainer.png -------------------------------------------------------------------------------- /resources/default_skin/TBSectionContainer.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/TBSectionContainer.psd -------------------------------------------------------------------------------- /resources/default_skin/TBSectionHeader.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/TBSectionHeader.psd -------------------------------------------------------------------------------- /resources/default_skin/arrow.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow.psd -------------------------------------------------------------------------------- /resources/default_skin/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_down.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_down@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_down@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_down@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_down@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_left.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_left@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_left@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_left@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_left@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_right.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_right@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_right@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_right@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_right@384.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_up.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_up@192.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_up@288.png -------------------------------------------------------------------------------- /resources/default_skin/arrow_up@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/arrow_up@384.png -------------------------------------------------------------------------------- /resources/default_skin/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button.png -------------------------------------------------------------------------------- /resources/default_skin/button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button.psd -------------------------------------------------------------------------------- /resources/default_skin/button_flat.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_flat.psd -------------------------------------------------------------------------------- /resources/default_skin/button_flat_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_flat_outline.png -------------------------------------------------------------------------------- /resources/default_skin/button_flat_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_flat_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped.psd -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_first_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_first_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_first_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_first_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_last_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_last_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_last_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_last_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_middle_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_middle_down.png -------------------------------------------------------------------------------- /resources/default_skin/button_grouped_x_middle_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_grouped_x_middle_up.png -------------------------------------------------------------------------------- /resources/default_skin/button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/button_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_mark.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_mark@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_mark@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_mark@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_mark@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/checkbox_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkbox_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/checkradio.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/checkradio.psd -------------------------------------------------------------------------------- /resources/default_skin/container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/container.png -------------------------------------------------------------------------------- /resources/default_skin/container.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/container.psd -------------------------------------------------------------------------------- /resources/default_skin/dropdown_button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/dropdown_button.psd -------------------------------------------------------------------------------- /resources/default_skin/editfield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/editfield.png -------------------------------------------------------------------------------- /resources/default_skin/editfield.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/editfield.psd -------------------------------------------------------------------------------- /resources/default_skin/fadeout.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/fadeout.psd -------------------------------------------------------------------------------- /resources/default_skin/fadeout_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/fadeout_x.png -------------------------------------------------------------------------------- /resources/default_skin/fadeout_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/fadeout_y.png -------------------------------------------------------------------------------- /resources/default_skin/focus.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/focus.psd -------------------------------------------------------------------------------- /resources/default_skin/focus_r4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/focus_r4.png -------------------------------------------------------------------------------- /resources/default_skin/focus_tabbutton_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/focus_tabbutton_left.png -------------------------------------------------------------------------------- /resources/default_skin/focus_tabbutton_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/focus_tabbutton_top.png -------------------------------------------------------------------------------- /resources/default_skin/hover.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/hover.psd -------------------------------------------------------------------------------- /resources/default_skin/item.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/item.psd -------------------------------------------------------------------------------- /resources/default_skin/item_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/item_hover.png -------------------------------------------------------------------------------- /resources/default_skin/item_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/item_selected.png -------------------------------------------------------------------------------- /resources/default_skin/item_separator_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/item_separator_x.png -------------------------------------------------------------------------------- /resources/default_skin/item_separator_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/messageicon.psd -------------------------------------------------------------------------------- /resources/default_skin/mover_tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/mover_tile.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_gear.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/progress_spinner_gear.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_strip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/progress_spinner_strip.png -------------------------------------------------------------------------------- /resources/default_skin/progress_spinner_strip@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/progress_spinner_strip@192.png -------------------------------------------------------------------------------- /resources/default_skin/progress_x.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/progress_x.psd -------------------------------------------------------------------------------- /resources/default_skin/progress_y.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/progress_y.psd -------------------------------------------------------------------------------- /resources/default_skin/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio.png -------------------------------------------------------------------------------- /resources/default_skin/radio@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio@384.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_mark.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_mark@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_mark@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio_mark@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_mark@384.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/radio_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/radio_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/resizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/resizer.png -------------------------------------------------------------------------------- /resources/default_skin/resizer.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/resizer.psd -------------------------------------------------------------------------------- /resources/default_skin/resizer@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/resizer@192.png -------------------------------------------------------------------------------- /resources/default_skin/resizer@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/resizer@288.png -------------------------------------------------------------------------------- /resources/default_skin/resizer@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/resizer@384.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_bg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/scroll_bg_x.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_bg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/scroll_bg_y.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_fg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/scroll_fg_x.png -------------------------------------------------------------------------------- /resources/default_skin/scroll_fg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/scroll_fg_y.png -------------------------------------------------------------------------------- /resources/default_skin/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/search.png -------------------------------------------------------------------------------- /resources/default_skin/search.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/search.psd -------------------------------------------------------------------------------- /resources/default_skin/search@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/search@192.png -------------------------------------------------------------------------------- /resources/default_skin/search@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/search@288.png -------------------------------------------------------------------------------- /resources/default_skin/search@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/search@384.png -------------------------------------------------------------------------------- /resources/default_skin/selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/selection.png -------------------------------------------------------------------------------- /resources/default_skin/selection.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/selection.psd -------------------------------------------------------------------------------- /resources/default_skin/slider.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_bg.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_x.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_x@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_x@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_x@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_x@384.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_y.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_y@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_y@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_bg_y@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_bg_y@384.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_handle.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_handle.psd -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_handle@192.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_handle@288.png -------------------------------------------------------------------------------- /resources/default_skin/slider_handle@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/slider_handle@384.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_bottom_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_bottom_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_bottom_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_bottom_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_left_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_left_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_left_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_left_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_right_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_right_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_right_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_right_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_top_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_top_active.png -------------------------------------------------------------------------------- /resources/default_skin/tab_button_top_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_button_top_inactive.png -------------------------------------------------------------------------------- /resources/default_skin/tab_section_work.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tab_section_work.psd -------------------------------------------------------------------------------- /resources/default_skin/tabbutton.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tabbutton.psd -------------------------------------------------------------------------------- /resources/default_skin/tabbutton_left_right.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/tabbutton_left_right.psd -------------------------------------------------------------------------------- /resources/default_skin/teststuff.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/teststuff.psd -------------------------------------------------------------------------------- /resources/default_skin/testtabbuttons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/testtabbuttons.psd -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/toggle_section_icon.psd -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/toggle_section_icon_down.png -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_middle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/toggle_section_icon_middle.png -------------------------------------------------------------------------------- /resources/default_skin/toggle_section_icon_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/toggle_section_icon_up.png -------------------------------------------------------------------------------- /resources/default_skin/window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window.png -------------------------------------------------------------------------------- /resources/default_skin/window.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window.psd -------------------------------------------------------------------------------- /resources/default_skin/window_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_active.png -------------------------------------------------------------------------------- /resources/default_skin/window_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close.png -------------------------------------------------------------------------------- /resources/default_skin/window_close.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close.psd -------------------------------------------------------------------------------- /resources/default_skin/window_close@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_close@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_close@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close_pressed.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close_pressed@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close_pressed@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_close_pressed@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_close_pressed@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover.psd -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover_bg_tile.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover_bg_tile@192.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@288.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover_bg_tile@288.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_bg_tile@384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover_bg_tile@384.png -------------------------------------------------------------------------------- /resources/default_skin/window_mover_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/default_skin/window_mover_overlay.png -------------------------------------------------------------------------------- /resources/icon/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/icon/icon.psd -------------------------------------------------------------------------------- /resources/icon/icon114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/icon/icon114.png -------------------------------------------------------------------------------- /resources/icon/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/icon/icon128.png -------------------------------------------------------------------------------- /resources/icon/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/icon/icon48.png -------------------------------------------------------------------------------- /resources/icon/icon_large.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/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/metadata/tb_widgets_attr.tb.txt: -------------------------------------------------------------------------------- 1 | # 2 | # List of supported resource attributes for all default widgets in Turbo Badger. 3 | # All widgets of course support the attributes read by the classes they inherit (such as TBWidget). 4 | # 5 | # - 0 or 1 6 | # - number 7 | # - number or string. Read into an TBID 8 | # - numbers with optional unit (default is dp). F.ex 10mm 9 | # - string 10 | # - string or language string (f.ex "@search") 11 | # - child widgets or attributes 12 | # foo, bar - either foo or bar. 13 | # foo | bar - flag combo of foo and bar. 14 | # 15 | # Note: As all node based resources, nodes/values may reference other node trees, 16 | # use conditions and local & file includes. 17 | # 18 | 19 | TBWidget 20 | id 21 | group-id 22 | value 23 | data 24 | is-group-root 25 | is-focusable 26 | want-long-click 27 | ignore-input 28 | opacity (0-1) 29 | text 30 | connection 31 | axis x, y 32 | gravity left | top | right | bottom | all 33 | visibility visible, invisible, gone 34 | state disabled 35 | skin 36 | lp 37 | width 38 | height 39 | min-width 40 | min-height 41 | max-width 42 | max-height 43 | pref-width 44 | pref-height 45 | font 46 | name 47 | size 48 | rect 49 | autofocus 50 | 51 | TBClickLabel 52 | TBEditField 53 | multiline 54 | styling 55 | readonly 56 | wrap 57 | adapt-to-content 58 | virtual-width 59 | placeholder 60 | type text, search, password, email, phone, url, number 61 | text-align left, center, right 62 | TBTextField 63 | text-align left, center, right 64 | TBLayout 65 | spacing 66 | size preferred, available, gravity 67 | position center, left, top, right, bottom, gravity 68 | overflow clip, scroll 69 | distribution preferred, available, gravity 70 | distribution-position center, left, top, right, bottom 71 | TBScrollContainer 72 | adapt-content 73 | adapt-to-content 74 | scroll-mode xy, y, y-auto, auto, off 75 | TBTabContainer 76 | align left, top, right, bottom 77 | tabs 78 | 79 | content 80 | 81 | root 82 | 83 | TBButton 84 | squeezable 85 | auto-repeat 86 | toggle-mode 87 | TBScrollBar 88 | TBSlider 89 | min 90 | max 91 | TBInlineSelect 92 | min 93 | max 94 | TBSelectList 95 | items 96 | item 97 | text 98 | id 99 | TBSelectDropdown 100 | items 101 | item 102 | text 103 | id 104 | TBCheckBox 105 | TBRadioButton 106 | TBSkinImage 107 | TBSeparator 108 | TBProgressSpinner 109 | TBContainer 110 | TBSectionHeader 111 | TBSection 112 | TBToggleContainer 113 | toggle enabled, opacity, expanded 114 | invert 115 | TBImageWidget 116 | filename 117 | -------------------------------------------------------------------------------- /resources/vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/resources/vera.ttf -------------------------------------------------------------------------------- /src/tb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(LOCAL_SRCS "") 4 | aux_source_directory(. LOCAL_SRCS) 5 | aux_source_directory(image LOCAL_SRCS) 6 | aux_source_directory(animation LOCAL_SRCS) 7 | aux_source_directory(parser LOCAL_SRCS) 8 | aux_source_directory(renderers LOCAL_SRCS) 9 | aux_source_directory(tests LOCAL_SRCS) 10 | aux_source_directory(utf8 LOCAL_SRCS) 11 | 12 | add_library(TurboBadgerLib ${LOCAL_SRCS}) 13 | 14 | install(TARGETS TurboBadgerLib 15 | RUNTIME DESTINATION bin 16 | LIBRARY DESTINATION lib 17 | ARCHIVE DESTINATION lib) 18 | -------------------------------------------------------------------------------- /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() { 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 | 10 | #ifdef TB_IMAGE 11 | 12 | namespace tb { 13 | 14 | PreferredSize TBImageWidget::OnCalculatePreferredContentSize(const SizeConstraints &constraints) 15 | { 16 | return PreferredSize(m_image.Width(), m_image.Height()); 17 | } 18 | 19 | void TBImageWidget::OnPaint(const PaintProps &paint_props) 20 | { 21 | if (TBBitmapFragment *fragment = m_image.GetBitmap()) 22 | g_renderer->DrawBitmap(GetPaddingRect(), TBRect(0, 0, m_image.Width(), m_image.Height()), fragment); 23 | } 24 | 25 | } // namespace tb 26 | 27 | #endif // TB_IMAGE 28 | -------------------------------------------------------------------------------- /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 char *filename) { m_image = g_image_manager->GetImage(filename); } 31 | 32 | virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints); 33 | 34 | virtual void OnInflate(const INFLATE_INFO &info); 35 | virtual void OnPaint(const PaintProps &paint_props); 36 | private: 37 | TBImage m_image; 38 | }; 39 | 40 | } // namespace tb 41 | 42 | #endif // TB_IMAGE 43 | #endif // TB_IMAGE_WIDGET_H 44 | -------------------------------------------------------------------------------- /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 a 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 char *error) = 0; 29 | virtual void OnComment(int line_nr, const char *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/renderers/tb_renderer_gl.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_RENDERER_GL_H 7 | #define TB_RENDERER_GL_H 8 | 9 | #include "tb_types.h" 10 | 11 | #ifdef TB_RENDERER_GL 12 | 13 | #ifdef TB_RENDERER_GLES_1 14 | #include 15 | #include 16 | #elif defined(_WIN32) 17 | #include // make gl.h compile 18 | #include 19 | #elif defined(MACOSX) 20 | #include 21 | #elif defined(ANDROID) || defined(__ANDROID__) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #include "renderers/tb_renderer_batcher.h" 28 | 29 | namespace tb { 30 | 31 | class TBRendererGL; 32 | 33 | class TBBitmapGL : public TBBitmap 34 | { 35 | public: 36 | TBBitmapGL(TBRendererGL *renderer); 37 | ~TBBitmapGL(); 38 | bool Init(int width, int height, uint32 *data); 39 | virtual int Width() { return m_w; } 40 | virtual int Height() { return m_h; } 41 | virtual void SetData(uint32 *data); 42 | public: 43 | TBRendererGL *m_renderer; 44 | int m_w, m_h; 45 | GLuint m_texture; 46 | }; 47 | 48 | class TBRendererGL : public TBRendererBatcher 49 | { 50 | public: 51 | TBRendererGL(); 52 | 53 | // == TBRenderer ==================================================================== 54 | 55 | virtual void BeginPaint(int render_target_w, int render_target_h); 56 | virtual void EndPaint(); 57 | 58 | virtual TBBitmap *CreateBitmap(int width, int height, uint32 *data); 59 | 60 | // == TBRendererBatcher =============================================================== 61 | 62 | virtual void RenderBatch(Batch *batch); 63 | virtual void SetClipRect(const TBRect &rect); 64 | }; 65 | 66 | } // namespace tb 67 | 68 | #endif // TB_RENDERER_GL 69 | #endif // TB_RENDERER_GL_H 70 | -------------------------------------------------------------------------------- /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 | #include 11 | #include 12 | 13 | namespace tb { 14 | 15 | // == TBClipboard ===================================== 16 | 17 | TBStr clipboard; ///< Obviosly not a full implementation since it ignores the OS :) 18 | 19 | void TBClipboard::Empty() 20 | { 21 | clipboard.Clear(); 22 | } 23 | 24 | bool TBClipboard::HasText() 25 | { 26 | return !clipboard.IsEmpty(); 27 | } 28 | 29 | bool TBClipboard::SetText(const char *text) 30 | { 31 | return clipboard.Set(text); 32 | } 33 | 34 | bool TBClipboard::GetText(TBStr &text) 35 | { 36 | return text.Set(clipboard); 37 | } 38 | 39 | } // namespace tb 40 | 41 | #endif // TB_CLIPBOARD_DUMMY 42 | -------------------------------------------------------------------------------- /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 char *text) 33 | { 34 | if (GLFWwindow *window = glfwGetCurrentContext()) 35 | { 36 | glfwSetClipboardString(window, 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_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 char *text) 40 | { 41 | if (OpenClipboard(NULL)) 42 | { 43 | int num_wide_chars_needed = MultiByteToWideChar(CP_UTF8, 0, 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, 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.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_color.h" 7 | #include 8 | 9 | namespace tb { 10 | 11 | // == TBColor =============================================================================== 12 | 13 | void TBColor::SetFromString(const char *str, int len) 14 | { 15 | int r, g, b, a; 16 | if (len == 9 && sscanf(str, "#%2x%2x%2x%2x", &r, &g, &b, &a) == 4) // rrggbbaa 17 | Set(TBColor(r, g, b, a)); 18 | else if (len == 7 && sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3) // rrggbb 19 | Set(TBColor(r, g, b)); 20 | else if (len == 5 && sscanf(str, "#%1x%1x%1x%1x", &r, &g, &b, &a) == 4) // rgba 21 | Set(TBColor(r + (r << 4), g + (g << 4), b + (b << 4), a + (a << 4))); 22 | else if (len == 4 && sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3) // rgb 23 | Set(TBColor(r + (r << 4), g + (g << 4), b + (b << 4))); 24 | else 25 | Set(TBColor()); 26 | } 27 | 28 | } // namespace tb 29 | -------------------------------------------------------------------------------- /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 | 11 | namespace tb { 12 | 13 | /** TBColor contains a 32bit color. */ 14 | 15 | class TBColor 16 | { 17 | public: 18 | TBColor() : b(0), g(0), r(0), a(255) {} 19 | TBColor(int r, int g, int b, int a = 255) : b(b), g(g), r(r), a(a) {} 20 | 21 | uint8 b, g, r, a; 22 | 23 | void Set(const TBColor &color) { *this = color; } 24 | 25 | /** Set the color from string in any of the following formats: 26 | "#rrggbbaa", "#rrggbb", "#rgba", "#rgb" */ 27 | void SetFromString(const char *str, int len); 28 | 29 | inline operator uint32 () const { return *((uint32*)this); } 30 | inline bool operator == (const TBColor &c) const { return *this == (uint32)c; } 31 | inline bool operator != (const TBColor &c) const { return !(*this == c); } 32 | 33 | /** Premultiply alpha on the r, g, b components */ 34 | inline void Premultiply() { 35 | const uint32 a32 = a; 36 | r = (r * a32 + 1) >> 8; 37 | g = (g * a32 + 1) >> 8; 38 | b = (b * a32 + 1) >> 8; 39 | } 40 | 41 | /** Unpremultiply alpha on the r, g, b components */ 42 | inline void Unpremultiply() { 43 | const uint32 a32 = a; 44 | if (a32) { 45 | r = r * 255 / a32; 46 | g = g * 255 / a32; 47 | b = b * 255 / a32; 48 | } 49 | } 50 | }; 51 | 52 | } // namespace tb 53 | 54 | #endif // TB_COLOR_H 55 | -------------------------------------------------------------------------------- /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 = nullptr; 18 | TBSkin *g_tb_skin = nullptr; 19 | TBWidgetsReader *g_widgets_reader = nullptr; 20 | TBLanguage *g_tb_lng = nullptr; 21 | TBFontManager *g_font_manager = nullptr; 22 | 23 | bool tb_core_init(TBRenderer *renderer) 24 | { 25 | TBDebugPrint("Initiating Turbo Badger - version %s\n", TB_VERSION_STR); 26 | g_renderer = renderer; 27 | g_tb_lng = new TBLanguage; 28 | g_font_manager = new TBFontManager(); 29 | g_tb_skin = new TBSkin(); 30 | g_widgets_reader = TBWidgetsReader::Create(); 31 | #ifdef TB_IMAGE 32 | g_image_manager = new TBImageManager(); 33 | #endif 34 | return true; 35 | } 36 | 37 | void tb_core_shutdown() 38 | { 39 | TBAnimationManager::AbortAllAnimations(); 40 | #ifdef TB_IMAGE 41 | delete g_image_manager; 42 | #endif 43 | delete g_widgets_reader; 44 | delete g_tb_skin; 45 | delete g_font_manager; 46 | delete g_tb_lng; 47 | } 48 | 49 | bool tb_core_is_initialized() 50 | { 51 | return g_widgets_reader ? true : false; 52 | } 53 | 54 | } // namespace tb 55 | -------------------------------------------------------------------------------- /src/tb/tb_core.h: -------------------------------------------------------------------------------- 1 | /** @mainpage Turbo Badger - Fast UI toolkit 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 | #define TB_VERSION_MAJOR 0 36 | #define TB_VERSION_MINOR 1 37 | #define TB_VERSION_REVISION 1 38 | #define TB_VERSION_STR "0.1.1" 39 | 40 | namespace tb { 41 | 42 | class TBRenderer; 43 | class TBSkin; 44 | class TBWidgetsReader; 45 | class TBLanguage; 46 | class TBFontManager; 47 | 48 | extern TBRenderer *g_renderer; 49 | extern TBSkin *g_tb_skin; 50 | extern TBWidgetsReader *g_widgets_reader; 51 | extern TBLanguage *g_tb_lng; 52 | extern TBFontManager *g_font_manager; 53 | 54 | /** Initialize turbo badger. Call this before using any turbo badger API. */ 55 | bool tb_core_init(TBRenderer *renderer); 56 | 57 | /** Shutdown turbo badger. Call this after deleting the last widget, to free turbo badger internals. */ 58 | void tb_core_shutdown(); 59 | 60 | /** Returns true if turbo badger is initialized. */ 61 | bool tb_core_is_initialized(); 62 | 63 | } // namespace tb 64 | 65 | #endif // TB_CORE_H 66 | -------------------------------------------------------------------------------- /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 | int 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 | #endif // TB_DEBUG_H 69 | -------------------------------------------------------------------------------- /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 | 12 | namespace tb { 13 | 14 | class TBPosixFile : public TBFile 15 | { 16 | public: 17 | TBPosixFile(FILE *f) : file(f) {} 18 | virtual ~TBPosixFile() { fclose(file); } 19 | 20 | virtual long Size() 21 | { 22 | long oldpos = ftell(file); 23 | fseek(file, 0, SEEK_END); 24 | long num_bytes = ftell(file); 25 | fseek(file, oldpos, SEEK_SET); 26 | return num_bytes; 27 | } 28 | virtual size_t Read(void *buf, size_t elemSize, size_t count) 29 | { 30 | return fread(buf, elemSize, count, file); 31 | } 32 | private: 33 | FILE *file; 34 | }; 35 | 36 | // static 37 | TBFile *TBFile::Open(const char *filename, TBFileMode mode) 38 | { 39 | FILE *f = nullptr; 40 | switch (mode) 41 | { 42 | case MODE_READ: 43 | f = fopen(filename, "rb"); 44 | break; 45 | default: 46 | break; 47 | } 48 | if (!f) 49 | return nullptr; 50 | TBPosixFile *tbf = new TBPosixFile(f); 51 | if (!tbf) 52 | fclose(f); 53 | return tbf; 54 | } 55 | 56 | } // namespace tb 57 | 58 | #endif // TB_FILE_POSIX 59 | -------------------------------------------------------------------------------- /src/tb/tb_font_desc.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_FONT_DESC_H 7 | #define TB_FONT_DESC_H 8 | 9 | #include "tb_types.h" 10 | #include "tb_id.h" 11 | 12 | namespace tb { 13 | 14 | /** TBFontDescription describes a font. 15 | By default when nothing is set, the font is unspecified and means it should be inherited 16 | from a parent widget that specifies a font, or use the default font if no parent does. */ 17 | 18 | class TBFontDescription 19 | { 20 | public: 21 | /** Set the font ID of the font to use. 22 | This ID maps to the font names in TBFontInfo, which is managed from 23 | TBFontManager::AddFontInfo, TBFontManager::GetFontInfo. 24 | 25 | Example: 26 | If a font was added to the font manager with the name "Vera", you can 27 | do font_description.SetID(TBIDC("Vera")). 28 | */ 29 | void SetID(const TBID &id) { m_id = id; } 30 | 31 | /** Get the TBID for the font name (See SetID). */ 32 | TBID GetID() const { return m_id; } 33 | 34 | /** Get the TBID for the TBFontFace that matches this font description. 35 | This is a ID combining both the font file, and variation (such as size and style), 36 | and should be used to identify a certain font face. 37 | 38 | If this is 0, the font description is unspecified. For a widget, that means that the font 39 | should be inherited from the parent widget. */ 40 | TBID GetFontFaceID() const { return m_id + m_packed_init; } 41 | 42 | void SetSize(uint32 size) { m_packed.size = MIN(size, 0x8000u); } 43 | uint32 GetSize() const { return m_packed.size; } 44 | 45 | //not connected to anything yet 46 | //void SetBold(bool bold) { m_packed.bold = bold; } 47 | //bool GetBold() const { return m_packed.bold; } 48 | 49 | //not connected to anything yet 50 | //void SetItalic(bool italic) { m_packed.italic = italic; } 51 | //bool GetItalic() const { return m_packed.italic; } 52 | 53 | TBFontDescription() : m_packed_init(0) {} 54 | TBFontDescription(const TBFontDescription &src) { m_packed_init = src.m_packed_init; m_id = src.m_id; } 55 | const TBFontDescription& operator = (const TBFontDescription &src) { m_packed_init = src.m_packed_init; m_id = src.m_id; return *this; } 56 | bool operator == (const TBFontDescription &fd) const { return m_packed_init == fd.m_packed_init && m_id == fd.m_id; } 57 | bool operator != (const TBFontDescription &fd) const { return !(*this == fd); } 58 | private: 59 | TBID m_id; 60 | union { 61 | struct { 62 | uint32 size : 15; 63 | uint32 italic : 1; 64 | uint32 bold : 1; 65 | } m_packed; 66 | uint32 m_packed_init; 67 | }; 68 | }; 69 | 70 | } // namespace tb 71 | 72 | #endif // TB_FONT_DESC_H 73 | -------------------------------------------------------------------------------- /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 | #ifndef TB_SUPPORT_CONSTEXPR 11 | 12 | uint32 TBGetHash(const char *str) 13 | { 14 | if (!str || !*str) 15 | return 0; 16 | // FNV hash 17 | uint32 hash = 2166136261U; 18 | int i = 0; 19 | while (str[i]) 20 | { 21 | char c = str[i++]; 22 | hash = (16777619U * hash) ^ c; 23 | } 24 | return hash; 25 | } 26 | 27 | #endif // !TB_SUPPORT_CONSTEXPR 28 | 29 | } // namespace tb 30 | -------------------------------------------------------------------------------- /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 | 11 | namespace tb { 12 | 13 | // On C++ compilers that support it, use const expr for hash so that 14 | // TBID comparisions turn into simple uint32 comparisions compiletime. 15 | // Disabled for TB_RUNTIME_DEBUG_INFO builds, so TBID string debugging 16 | // is available. 17 | // 18 | // Note: GCC may need -std=c++0x or -std=c++11 to enable this feature. 19 | 20 | #ifndef TB_RUNTIME_DEBUG_INFO 21 | #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || _MSC_VER >= 1900 22 | #define TB_SUPPORT_CONSTEXPR 23 | #endif 24 | #endif 25 | 26 | #ifdef TB_SUPPORT_CONSTEXPR 27 | 28 | // FNV constants 29 | static constexpr uint32 basis = 2166136261U; 30 | static constexpr uint32 prime = 16777619U; 31 | 32 | // compile-time hash helper function 33 | constexpr uint32 TBGetHash_one(char c, const char* remain, uint32 value) 34 | { 35 | return c == 0 ? value : TBGetHash_one(remain[0], remain + 1, (value ^ c) * prime); 36 | } 37 | 38 | // compile-time hash 39 | constexpr uint32 TBGetHash(const char* str) 40 | { 41 | return (str && *str) ? TBGetHash_one(str[0], str + 1, basis) : 0; 42 | } 43 | 44 | #define TBIDC(str) tb::TBGetHash(str) 45 | 46 | #else // TB_SUPPORT_CONSTEXPR 47 | 48 | #define TBIDC(str) tb::TBID(str) 49 | 50 | /** Get hash value from string */ 51 | uint32 TBGetHash(const char *str); 52 | 53 | #endif // !TB_SUPPORT_CONSTEXPR 54 | 55 | } // namespace tb 56 | 57 | #endif // TB_HASH_H 58 | 59 | -------------------------------------------------------------------------------- /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_hashtable.h" 8 | 9 | namespace tb { 10 | 11 | // == TBID ============================================================================== 12 | 13 | #ifdef TB_RUNTIME_DEBUG_INFO 14 | 15 | // Hash table for checking if we get any collisions (same hash value for TBID's created 16 | // from different strings) 17 | static TBHashTableAutoDeleteOf all_id_hash; 18 | static bool is_adding = false; 19 | 20 | void TBID::Set(uint32 newid) 21 | { 22 | id = newid; 23 | debug_string.Clear(); 24 | if (!is_adding && tb_core_is_initialized()) 25 | { 26 | if (!all_id_hash.Get(id)) 27 | { 28 | is_adding = true; 29 | all_id_hash.Add(id, new TBID(*this)); 30 | is_adding = false; 31 | } 32 | } 33 | } 34 | 35 | void TBID::Set(const TBID &newid) 36 | { 37 | id = newid; 38 | TB_IF_DEBUG(debug_string.Set(newid.debug_string)); 39 | if (!is_adding && tb_core_is_initialized()) 40 | { 41 | if (TBID *other_id = all_id_hash.Get(id)) 42 | { 43 | // If this happens, 2 different strings result in the same hash. 44 | // It might be a good idea to change one of them, but it might not matter. 45 | assert(other_id->debug_string.Equals(debug_string)); 46 | } 47 | else 48 | { 49 | is_adding = true; 50 | all_id_hash.Add(id, new TBID(*this)); 51 | is_adding = false; 52 | } 53 | } 54 | } 55 | 56 | void TBID::Set(const char *string) 57 | { 58 | id = TBGetHash(string); 59 | TB_IF_DEBUG(debug_string.Set(string)); 60 | if (!is_adding && tb_core_is_initialized()) 61 | { 62 | if (TBID *other_id = all_id_hash.Get(id)) 63 | { 64 | assert(other_id->debug_string.Equals(debug_string)); 65 | } 66 | else 67 | { 68 | is_adding = true; 69 | all_id_hash.Add(id, new TBID(*this)); 70 | is_adding = false; 71 | } 72 | } 73 | } 74 | 75 | #endif // TB_RUNTIME_DEBUG_INFO 76 | 77 | } // namespace tb 78 | -------------------------------------------------------------------------------- /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 to be used as ID. 16 | The uint32 can be set directly to any uint32, or it can be 17 | set from a string which will be hashed into the uint32. */ 18 | class TBID 19 | { 20 | public: 21 | TBID(uint32 id = 0) { Set(id); } 22 | TBID(const char *string) { Set(string); } 23 | TBID(const TBID &id) { Set(id); } 24 | 25 | #ifdef TB_RUNTIME_DEBUG_INFO 26 | void Set(uint32 newid); 27 | void Set(const TBID &newid); 28 | void Set(const char *string); 29 | #else 30 | void Set(uint32 newid) { id = newid; } 31 | void Set(const TBID &newid) { id = newid; } 32 | void Set(const char *string) { id = TBGetHash(string); } 33 | #endif 34 | 35 | operator uint32 () const { return id; } 36 | const TBID& operator = (const TBID &id) { Set(id); return *this; } 37 | private: 38 | uint32 id; 39 | public: 40 | /** This string is here to aid debugging (Only in debug builds!) 41 | It should not to be used in your code! */ 42 | #ifdef TB_RUNTIME_DEBUG_INFO 43 | friend class TBLanguage; 44 | TBStr debug_string; 45 | #endif 46 | }; 47 | 48 | } // namespace tb 49 | 50 | #endif // TB_ID_H 51 | -------------------------------------------------------------------------------- /src/tb/tb_image_loader_stb.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_bitmap_fragment.h" 7 | #include "tb_system.h" 8 | #include "tb_tempbuffer.h" 9 | 10 | #ifdef TB_IMAGE_LOADER_STB 11 | 12 | // Configure stb image and remove some features we don't use to reduce binary size. 13 | #define STB_IMAGE_STATIC 14 | #define STB_IMAGE_IMPLEMENTATION 15 | //#define STBI_SIMD 16 | #define STBI_NO_STDIO 17 | #define STBI_NO_FAILURE_STRINGS 18 | #define STBI_NO_HDR 19 | 20 | // Disable unused function warnings for stb_image.h. Since STB_IMAGE_STATIC is 21 | // defined, it will contain a couple of unused static functions. 22 | #pragma GCC diagnostic push 23 | #pragma GCC diagnostic ignored "-Wunused-function" 24 | 25 | // Include stb image - Tiny portable and reasonable fast image loader from http://nothings.org/ 26 | // Should not be used for content not distributed with your app (May not be secure and doesn't 27 | // support all formats fully) 28 | #include "thirdparty/stb_image.h" 29 | 30 | #pragma GCC diagnostic pop 31 | 32 | namespace tb { 33 | 34 | class STBI_Loader : public TBImageLoader 35 | { 36 | public: 37 | int width, height; 38 | unsigned char *data; 39 | 40 | STBI_Loader() : width(0), height(0), data(nullptr) {} 41 | ~STBI_Loader() { stbi_image_free(data); } 42 | 43 | virtual int Width() { return width; } 44 | virtual int Height() { return height; } 45 | virtual uint32 *Data() { return (uint32*)data; } 46 | }; 47 | 48 | TBImageLoader *TBImageLoader::CreateFromFile(const char *filename) 49 | { 50 | TBTempBuffer buf; 51 | if (buf.AppendFile(filename)) 52 | { 53 | int w, h, comp; 54 | if (unsigned char *img_data = stbi_load_from_memory( 55 | (unsigned char*) buf.GetData(), buf.GetAppendPos(), &w, &h, &comp, 4)) 56 | { 57 | if (STBI_Loader *img = new STBI_Loader()) 58 | { 59 | img->width = w; 60 | img->height = h; 61 | img->data = img_data; 62 | return img; 63 | } 64 | else 65 | stbi_image_free(img_data); 66 | } 67 | } 68 | return nullptr; 69 | } 70 | 71 | } // namespace tb 72 | 73 | #endif // TB_IMAGE_LOADER_STB 74 | -------------------------------------------------------------------------------- /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(int min, int max); 36 | int GetMinValue() const { return m_min; } 37 | int GetMaxValue() const { return m_max; } 38 | 39 | virtual void SetValue(int value) { SetValueInternal(value, true); } 40 | virtual int GetValue() { 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 | int m_value; 50 | int m_min, m_max; 51 | void SetValueInternal(int 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 char *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 | const char *str = n->GetValue().GetString(); 29 | TBStr *new_str = new TBStr(str); 30 | if (!new_str || !strings.Add(TBID(n->GetName()), new_str)) 31 | { 32 | delete new_str; 33 | return false; 34 | } 35 | n = n->GetNext(); 36 | } 37 | return true; 38 | } 39 | 40 | void TBLanguage::Clear() 41 | { 42 | strings.DeleteAll(); 43 | } 44 | 45 | const char *TBLanguage::GetString(const TBID &id) 46 | { 47 | if (TBStr *str = strings.Get(id)) 48 | return *str; 49 | #ifdef TB_RUNTIME_DEBUG_INFO 50 | static TBStr tmp; 51 | tmp.SetFormatted("", id.debug_string.CStr()); 52 | return tmp; 53 | #else 54 | return ""; 55 | #endif 56 | } 57 | 58 | } // namespace tb 59 | -------------------------------------------------------------------------------- /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 char *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 | const char *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 | bool TBMenuWindow::Show(TBSelectItemSource *source, const TBPopupAlignment &alignment, int initial_value) 32 | { 33 | m_select_list.SetValue(initial_value); 34 | m_select_list.SetSource(source); 35 | m_select_list.ValidateList(); 36 | 37 | return TBPopupWindow::Show(alignment); 38 | } 39 | 40 | bool TBMenuWindow::OnEvent(const TBWidgetEvent &ev) 41 | { 42 | if (ev.type == EVENT_TYPE_CLICK && &m_select_list == ev.target) 43 | { 44 | TBWidgetSafePointer this_widget(this); 45 | 46 | // Invoke the click on the target 47 | TBWidgetEvent target_ev(EVENT_TYPE_CLICK); 48 | target_ev.ref_id = ev.ref_id; 49 | InvokeEvent(target_ev); 50 | 51 | // If target got deleted, close 52 | if (this_widget.Get()) 53 | Close(); 54 | return true; 55 | } 56 | return TBPopupWindow::OnEvent(ev); 57 | } 58 | 59 | } // namespace tb 60 | -------------------------------------------------------------------------------- /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 | private: 36 | TBSelectList m_select_list; 37 | }; 38 | 39 | } // namespace tb 40 | 41 | #endif // TB_MENU_WINDOW_H 42 | -------------------------------------------------------------------------------- /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 | }; 19 | 20 | /** TBMessageWindowSettings contains additional settings for TBMessageWindow. */ 21 | class TBMessageWindowSettings 22 | { 23 | public: 24 | TBMessageWindowSettings() : msg(TB_MSG_OK), dimmer(false), styling(false) {} 25 | TBMessageWindowSettings(TB_MSG msg, TBID icon_skin) : msg(msg), icon_skin(icon_skin), dimmer(false), styling(false) {} 26 | public: 27 | TB_MSG msg; ///< The type of response for the message. 28 | TBID icon_skin; ///< The icon skin (0 for no icon) 29 | bool dimmer; ///< Set to true to dim background widgets by a TBDimmer. 30 | bool styling; ///< Enable styling in the textfield. 31 | }; 32 | 33 | /** TBMessageWindow is a window for showing simple messages. 34 | Events invoked in this window will travel up through the target widget. 35 | 36 | When the user click any of its buttons, it will invoke a click event 37 | (with the window ID), with the clicked buttons id as ref_id. 38 | Then it will delete itself. 39 | 40 | If the target widget is deleted while this window is alive, the 41 | window will delete itself. */ 42 | class TBMessageWindow : public TBWindow, private TBWidgetListener 43 | { 44 | public: 45 | // For safe typecasting 46 | TBOBJECT_SUBCLASS(TBMessageWindow, TBWindow); 47 | 48 | TBMessageWindow(TBWidget *target, TBID id); 49 | virtual ~TBMessageWindow(); 50 | 51 | bool Show(const char *title, const char *message, TBMessageWindowSettings *settings = nullptr); 52 | 53 | virtual TBWidget *GetEventDestination() { return m_target.Get(); } 54 | 55 | virtual bool OnEvent(const TBWidgetEvent &ev); 56 | virtual void OnDie(); 57 | private: 58 | void AddButton(TBID id, bool focused); 59 | // TBWidgetListener 60 | virtual void OnWidgetDelete(TBWidget *widget); 61 | virtual bool OnWidgetDying(TBWidget *widget); 62 | TBWidgetSafePointer m_dimmer; 63 | TBWidgetSafePointer m_target; 64 | }; 65 | 66 | } // namespace tb 67 | 68 | #endif // TB_MESSAGE_WINDOW_H 69 | -------------------------------------------------------------------------------- /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 override { return #clazz; } \ 57 | virtual bool IsOfTypeId(const tb::TB_TYPE_ID type_id) const override \ 58 | { return GetTypeId() == type_id ? true : baseclazz::IsOfTypeId(type_id); } 59 | 60 | } // namespace tb 61 | 62 | #endif // TB_OBJECT_H 63 | -------------------------------------------------------------------------------- /src/tb/tb_popup_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_POPUP_WINDOW_H 7 | #define TB_POPUP_WINDOW_H 8 | 9 | #include "tb_window.h" 10 | #include "tb_widgets_listener.h" 11 | 12 | namespace tb { 13 | 14 | /** TBPopupAlignment describes the preferred alignment of a popup 15 | relative to a target widget or a given point. 16 | 17 | It calculates the rect to be used to match these preferences 18 | for any given popup and target. */ 19 | class TBPopupAlignment 20 | { 21 | public: 22 | static const int UNSPECIFIED = TB_INVALID_DIMENSION; 23 | 24 | /** Align relative to the target widget. */ 25 | TBPopupAlignment(TB_ALIGN align = TB_ALIGN_BOTTOM) 26 | : pos_in_root(UNSPECIFIED, UNSPECIFIED) 27 | , align(align) 28 | , expand_to_target_width(true) {} 29 | 30 | /** Align relative to the given position (coordinates relative to the root widget). */ 31 | TBPopupAlignment(const TBPoint &pos_in_root, TB_ALIGN align = TB_ALIGN_BOTTOM) 32 | : pos_in_root(pos_in_root) 33 | , align(align) 34 | , expand_to_target_width(true) {} 35 | 36 | /** Align relative to the given position (coordinates relative to the root widget). 37 | Applies an additional offset. */ 38 | TBPopupAlignment(const TBPoint &pos_in_root, const TBPoint &pos_offset) 39 | : pos_in_root(pos_in_root) 40 | , pos_offset(pos_offset) 41 | , align(TB_ALIGN_BOTTOM) 42 | , expand_to_target_width(true) {} 43 | 44 | /** Calculate a good rect for the given popup window using its preferred size and 45 | the preferred alignment information stored in this class. */ 46 | TBRect GetAlignedRect(TBWidget *popup, TBWidget *target) const; 47 | 48 | TBPoint pos_in_root; 49 | TBPoint pos_offset; 50 | 51 | TB_ALIGN align; 52 | /** If true, the width of the popup will be at least the same as the target widget 53 | if the alignment is TB_ALIGN_TOP or TB_ALIGN_BOTTOM. */ 54 | bool expand_to_target_width; 55 | }; 56 | 57 | /** TBPopupWindow is a popup window that redirects any child widgets events 58 | through the given target. It will automatically close on click events that 59 | are not sent through this popup. */ 60 | 61 | class TBPopupWindow : public TBWindow, private TBWidgetListener 62 | { 63 | public: 64 | // For safe typecasting 65 | TBOBJECT_SUBCLASS(TBPopupWindow, TBWindow); 66 | 67 | TBPopupWindow(TBWidget *target); 68 | ~TBPopupWindow(); 69 | 70 | bool Show(const TBPopupAlignment &alignment); 71 | 72 | virtual TBWidget *GetEventDestination() { return m_target.Get(); } 73 | 74 | virtual bool OnEvent(const TBWidgetEvent &ev); 75 | private: 76 | TBWidgetSafePointer m_target; 77 | // TBWidgetListener 78 | virtual void OnWidgetFocusChanged(TBWidget *widget, bool focused); 79 | virtual bool OnWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev); 80 | virtual void OnWidgetDelete(TBWidget *widget); 81 | virtual bool OnWidgetDying(TBWidget *widget); 82 | }; 83 | 84 | } // namespace tb 85 | 86 | #endif // TB_POPUP_WINDOW_H 87 | -------------------------------------------------------------------------------- /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_str.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_STR_H 7 | #define TB_STR_H 8 | 9 | #include "tb_types.h" 10 | #include 11 | 12 | namespace tb { 13 | 14 | /** Use as parameter for string length if you know the string is null terminated. 15 | Can be used in functions that support it. */ 16 | #define TB_ALL_TO_TERMINATION 2147483647 17 | 18 | /** Some useful C-like functions that's missing in the standard. */ 19 | const char *stristr(const char *arg1, const char *arg2); 20 | 21 | /** Simple string class that doesn't own or change the string pointer. */ 22 | 23 | class TBStrC 24 | { 25 | protected: 26 | char *s; 27 | public: 28 | TBStrC(const char *str) : s(const_cast(str)) {} 29 | 30 | inline int Length() const { return strlen(s); } 31 | inline bool IsEmpty() const { return s[0] == 0; } 32 | 33 | inline int Compare(const char* str) const { return strcmp(s, str); } 34 | inline bool Equals(const char* str) const { return !strcmp(s, str); } 35 | 36 | inline char operator[](int n) const { return s[n]; } 37 | inline operator const char *() const { return s; } 38 | const char *CStr() const { return s; } 39 | }; 40 | 41 | /** TBStr is a simple string class. 42 | It's a compact wrapper for a char array, and doesn't do any storage magic to 43 | avoid buffer copying or remember its length. It is intended as "final storage" 44 | of strings since its buffer is compact. 45 | 46 | Serious work on strings is better done using TBTempBuffer and then set on a TBStr for 47 | final storage (since TBTempBuffer is optimized for speed rather than being compact). 48 | 49 | It is guaranteed to have a valid pointer at all times. If uninitialized, emptied or on 50 | out of memory, its storage will be a empty ("") const string. 51 | */ 52 | 53 | class TBStr : public TBStrC 54 | { 55 | public: 56 | ~TBStr(); 57 | TBStr(); 58 | TBStr(const TBStr &str); 59 | TBStr(const char* str); 60 | TBStr(const char* str, int len); 61 | 62 | bool Set(const char* str, int len = TB_ALL_TO_TERMINATION); 63 | bool SetFormatted(const char* format, ...); 64 | 65 | void Clear(); 66 | 67 | void Remove(int ofs, int len); 68 | bool Insert(int ofs, const char *ins, int ins_len = TB_ALL_TO_TERMINATION); 69 | bool Append(const char *ins, int ins_len = TB_ALL_TO_TERMINATION) { return Insert(strlen(s), ins, ins_len); } 70 | 71 | inline operator char *() const { return s; } 72 | char *CStr() const { return s; } 73 | const TBStr& operator = (const TBStr &str) { Set(str); return *this; } 74 | }; 75 | 76 | } // namespace tb 77 | 78 | #endif // TB_STR_H 79 | -------------------------------------------------------------------------------- /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 | #ifdef TB_RUNTIME_DEBUG_INFO 13 | void TBDebugOut(const char *str); 14 | #define TBDebugPrint(str, ...) { tb::TBStr tmp; tmp.SetFormatted(str, __VA_ARGS__); TBDebugOut(tmp); } 15 | #else 16 | #define TBDebugOut(str) ((void)0) 17 | #define TBDebugPrint(str, ...) ((void)0) 18 | #endif 19 | 20 | namespace tb { 21 | 22 | // == Platform interface =================================================== 23 | 24 | /** TBSystem is porting interface for the underlaying OS. */ 25 | class TBSystem 26 | { 27 | public: 28 | /** Get the system time in milliseconds since some undefined epoch. */ 29 | static double GetTimeMS(); 30 | 31 | /** Called when the need to call TBMessageHandler::ProcessMessages has changed due to changes in the 32 | message queue. fire_time is the new time is needs to be called. 33 | It may be 0 which means that ProcessMessages should be called asap (but NOT from this call!) 34 | It may also be TB_NOT_SOON which means that ProcessMessages doesn't need to be called. */ 35 | static void RescheduleTimer(double fire_time); 36 | 37 | /** Get how many milliseconds it should take after a touch down event should generate a long click 38 | event. */ 39 | static int GetLongClickDelayMS(); 40 | 41 | /** Get how many pixels of dragging should start panning scrollable widgets. */ 42 | static int GetPanThreshold(); 43 | 44 | /** Get how many pixels a typical line is: The length that should be scrolled when turning a mouse 45 | wheel one notch. */ 46 | static int GetPixelsPerLine(); 47 | 48 | /** Get Dots Per Inch for the main screen. */ 49 | static int GetDPI(); 50 | }; 51 | 52 | /** TBClipboard is a porting interface for the clipboard. */ 53 | class TBClipboard 54 | { 55 | public: 56 | /** Empty the contents of the clipboard. */ 57 | static void Empty(); 58 | 59 | /** Return true if the clipboard currently contains text. */ 60 | static bool HasText(); 61 | 62 | /** Set the text of the clipboard in UTF-8 format. */ 63 | static bool SetText(const char *text); 64 | 65 | /** Get the text from the clipboard in UTF-8 format. 66 | Returns true on success. */ 67 | static bool GetText(TBStr &text); 68 | }; 69 | 70 | /** TBFile is a porting interface for file access. */ 71 | class TBFile 72 | { 73 | public: 74 | enum TBFileMode { MODE_READ }; 75 | static TBFile *Open(const char *filename, TBFileMode mode); 76 | 77 | virtual ~TBFile() {} 78 | virtual long Size() = 0; 79 | virtual size_t Read(void *buf, size_t elemSize, size_t count) = 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 | 10 | #include 11 | #include 12 | #include 13 | 14 | // for native asset manager 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef TB_RUNTIME_DEBUG_INFO 21 | 22 | #define LOG_TAG "TB" 23 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 24 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 25 | 26 | void TBDebugOut(const char *str) 27 | { 28 | LOGI("%s", str); 29 | } 30 | 31 | #endif // TB_RUNTIME_DEBUG_INFO 32 | 33 | AAssetManager *g_pManager = NULL; 34 | 35 | void SetAssetManager(AAssetManager *pManager) 36 | { 37 | g_pManager = pManager; 38 | } 39 | 40 | namespace tb { 41 | 42 | // == TBSystem ======================================== 43 | 44 | double TBSystem::GetTimeMS() 45 | { 46 | struct timeval now; 47 | gettimeofday(&now, NULL); 48 | return now.tv_usec / 1000 + now.tv_sec * 1000; 49 | } 50 | 51 | void TBSystem::RescheduleTimer(double fire_time) 52 | { 53 | } 54 | 55 | int TBSystem::GetLongClickDelayMS() 56 | { 57 | return 500; 58 | } 59 | 60 | int TBSystem::GetPanThreshold() 61 | { 62 | return 5 * GetDPI() / 120; 63 | } 64 | 65 | int TBSystem::GetPixelsPerLine() 66 | { 67 | return 40 * GetDPI() / 120; 68 | } 69 | 70 | int TBSystem::GetDPI() 71 | { 72 | AConfiguration *config = AConfiguration_new(); 73 | AConfiguration_fromAssetManager(config, g_pManager); 74 | int32_t density = AConfiguration_getDensity(config); 75 | AConfiguration_delete(config); 76 | if (density == 0 || density == ACONFIGURATION_DENSITY_NONE) 77 | return 120; 78 | return density; 79 | } 80 | 81 | // == TBFile ===================================== 82 | 83 | class TBAndroidFile : public TBFile 84 | { 85 | public: 86 | TBAndroidFile(AAsset* f) : file(f) {} 87 | virtual ~TBAndroidFile() { AAsset_close(file); } 88 | 89 | virtual long Size() 90 | { 91 | return AAsset_getLength(file); 92 | } 93 | virtual size_t Read(void *buf, size_t elemSize, size_t count) 94 | { 95 | return AAsset_read(file, buf, elemSize * count); 96 | } 97 | private: 98 | AAsset *file; 99 | }; 100 | 101 | TBFile *TBFile::Open(const char *filename, TBFileMode mode) 102 | { 103 | AAsset *f = nullptr; 104 | switch (mode) 105 | { 106 | case MODE_READ: 107 | f = AAssetManager_open(g_pManager, filename, AASSET_MODE_UNKNOWN); 108 | break; 109 | default: 110 | break; 111 | } 112 | if (!f) 113 | return nullptr; 114 | TBAndroidFile *tbf = new TBAndroidFile(f); 115 | if (!tbf) 116 | AAsset_close(f); 117 | return tbf; 118 | } 119 | 120 | } // namespace tb 121 | 122 | #endif // TB_SYSTEM_ANDROID 123 | -------------------------------------------------------------------------------- /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 | 8 | #ifdef TB_SYSTEM_LINUX 9 | 10 | #include 11 | #include 12 | 13 | #ifdef TB_RUNTIME_DEBUG_INFO 14 | 15 | void TBDebugOut(const char *str) 16 | { 17 | printf("%s", str); 18 | } 19 | 20 | #endif // TB_RUNTIME_DEBUG_INFO 21 | 22 | namespace tb { 23 | 24 | // == TBSystem ======================================== 25 | 26 | double TBSystem::GetTimeMS() 27 | { 28 | struct timeval now; 29 | gettimeofday( &now, nullptr ); 30 | return now.tv_usec/1000 + now.tv_sec*1000; 31 | } 32 | 33 | // Implementation currently done in port_glfw.cpp. 34 | // FIX: Implement here for linux-desktop/android/macos? 35 | //void TBSystem::RescheduleTimer(double fire_time) 36 | //{ 37 | //} 38 | 39 | int TBSystem::GetLongClickDelayMS() 40 | { 41 | return 500; 42 | } 43 | 44 | int TBSystem::GetPanThreshold() 45 | { 46 | return 5 * GetDPI() / 96; 47 | } 48 | 49 | int TBSystem::GetPixelsPerLine() 50 | { 51 | return 40 * GetDPI() / 96; 52 | } 53 | 54 | int TBSystem::GetDPI() 55 | { 56 | // FIX: Implement! 57 | return 96; 58 | } 59 | 60 | } // namespace tb 61 | 62 | #endif // TB_SYSTEM_LINUX 63 | -------------------------------------------------------------------------------- /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 | 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef TB_RUNTIME_DEBUG_INFO 15 | 16 | void TBDebugOut(const char *str) 17 | { 18 | OutputDebugString(str); 19 | } 20 | 21 | #endif // TB_RUNTIME_DEBUG_INFO 22 | 23 | namespace tb { 24 | 25 | // == TBSystem ======================================== 26 | 27 | double TBSystem::GetTimeMS() 28 | { 29 | return timeGetTime(); 30 | } 31 | 32 | // Implementation currently done in port_glfw.cpp. 33 | // Windows timer suck. Glut timers suck too (can't be canceled) but that will do for now. 34 | //void TBSystem::RescheduleTimer(double fire_time) 35 | //{ 36 | //} 37 | 38 | int TBSystem::GetLongClickDelayMS() 39 | { 40 | return 500; 41 | } 42 | 43 | int TBSystem::GetPanThreshold() 44 | { 45 | return 5 * GetDPI() / 96; 46 | } 47 | 48 | int TBSystem::GetPixelsPerLine() 49 | { 50 | return 40 * GetDPI() / 96; 51 | } 52 | 53 | int TBSystem::GetDPI() 54 | { 55 | HDC hdc = GetDC(nullptr); 56 | int DPI_x = GetDeviceCaps(hdc, LOGPIXELSX); 57 | ReleaseDC(nullptr, hdc); 58 | #if 0 // TEST CODE! 59 | DPI_x *= 2; 60 | #endif 61 | return DPI_x; 62 | } 63 | 64 | } // namespace tb 65 | 66 | #endif // TB_SYSTEM_WINDOWS 67 | -------------------------------------------------------------------------------- /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 14 | some default properties on any TBButton added to it. */ 15 | class TBTabLayout : public TBLayout 16 | { 17 | public: 18 | // For safe typecasting 19 | TBOBJECT_SUBCLASS(TBTabLayout, TBLayout); 20 | 21 | virtual void OnChildAdded(TBWidget *child); 22 | virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints); 23 | }; 24 | 25 | /** TBTabContainer - A container with tabs for multiple pages. */ 26 | 27 | class TBTabContainer : public TBWidget 28 | { 29 | public: 30 | // For safe typecasting 31 | TBOBJECT_SUBCLASS(TBTabContainer, TBWidget); 32 | 33 | TBTabContainer(); 34 | ~TBTabContainer(); 35 | 36 | /** Set along which axis the content should layouted. 37 | Use SetAlignment instead for more choice! Also, calling 38 | SetAxis directly does not update the current alignment. */ 39 | virtual void SetAxis(AXIS axis); 40 | virtual AXIS GetAxis() const { return m_root_layout.GetAxis(); } 41 | 42 | /** Set alignment of the tabs. */ 43 | void SetAlignment(TB_ALIGN align); 44 | TB_ALIGN GetAlignment() const { return m_align; } 45 | 46 | /** Set which page should be selected and visible. */ 47 | virtual void SetValue(int value); 48 | virtual int GetValue() { return m_current_page; } 49 | 50 | /** Set which page should be selected and visible. */ 51 | void SetCurrentPage(int index) { SetValue(index); } 52 | int GetCurrentPage() { return GetValue(); } 53 | int GetNumPages(); 54 | 55 | /** Return the widget that is the current page, or nullptr if none is active. */ 56 | TBWidget *GetCurrentPageWidget() const; 57 | 58 | virtual void OnInflate(const INFLATE_INFO &info); 59 | virtual bool OnEvent(const TBWidgetEvent &ev); 60 | virtual void OnProcess(); 61 | 62 | virtual TBWidget *GetContentRoot() { return &m_content_root; } 63 | TBLayout *GetTabLayout() { return &m_tab_layout; } 64 | protected: 65 | TBLayout m_root_layout; 66 | TBTabLayout m_tab_layout; 67 | TBWidget m_content_root; 68 | bool m_need_page_update; 69 | int m_current_page; 70 | TB_ALIGN m_align; 71 | }; 72 | 73 | }; 74 | 75 | #endif // TB_TAB_CONTAINER_H 76 | -------------------------------------------------------------------------------- /src/tb/tb_tempbuffer.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_TEMP_BUFFER_H 7 | #define TB_TEMP_BUFFER_H 8 | 9 | namespace tb { 10 | 11 | /** TBTempBuffer manages a buffer that will be deleted on destruction. 12 | 13 | The buffer size can grow by calling Reserve or Append, but it 14 | will never shrink during the lifetime of the object. 15 | */ 16 | class TBTempBuffer 17 | { 18 | public: 19 | TBTempBuffer(); 20 | ~TBTempBuffer(); 21 | 22 | /** Make sure the buffer has at least size bytes. 23 | Returns false on OOM. */ 24 | bool Reserve(int size); 25 | 26 | /** Get a pointer to the buffer data. */ 27 | char *GetData() const { return m_data; } 28 | 29 | /** Return the size of the buffer in bytes. */ 30 | int GetCapacity() const { return m_data_size; } 31 | 32 | /** Append data with size bytes at the end of the buffer and 33 | increase the append position with the same amount. 34 | Returns false on OOM. */ 35 | bool Append(const char *data, int size); 36 | 37 | /** Increase the append position with size bytes without 38 | writing any data. This is useful if you want to write 39 | the data later and want to make sure space is reserved. 40 | Returns false on OOM. */ 41 | bool AppendSpace(int size); 42 | 43 | /** Append a null terminated string (including the null termination) 44 | at the end of the buffer. The append position will be increased 45 | with the length of the text (excluding the null termination) so 46 | multiple calls will produce a concatenated null terminated string. 47 | Returns false on OOM. */ 48 | bool AppendString(const char *str); 49 | 50 | /** Append a path without the ending filename. 51 | The buffer will be null terminated and the append position will be 52 | increased with the length of the path (excluding the null termination). */ 53 | bool AppendPath(const char *full_path_and_filename); 54 | 55 | /** Append file content at the end of the buffer. The append position will 56 | be increased by the size of the file. It will always append null 57 | termination (not included in append position). 58 | Returns false of OOM or if loading failed. 59 | */ 60 | bool AppendFile(const char *filename); 61 | 62 | /** Set the position (in bytes) in the buffer where Append should write. */ 63 | void SetAppendPos(int append_pos); 64 | 65 | /** Reset the append position to 0. */ 66 | void ResetAppendPos() { m_append_pos = 0; } 67 | 68 | /** Return the current append position in in bytes. */ 69 | int GetAppendPos() const { return m_append_pos; } 70 | private: 71 | int GetAppendReserveSize(int needed_size) const; 72 | char *m_data; 73 | int m_data_size; 74 | int m_append_pos; 75 | }; 76 | 77 | } // namespace tb 78 | 79 | #endif // TB_TEMP_BUFFER_H 80 | -------------------------------------------------------------------------------- /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("#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("#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("#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("#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("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_hashtable.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fruxo/turbobadger/389baa6946986d6d5afead50c90dc6b55e23b976/src/tb/tests/test_tb_hashtable.cpp -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /turbobadger.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "build_systems": 3 | [ 4 | { 5 | "cmd": 6 | [ 7 | "make", 8 | "DEBUG=YES" 9 | ], 10 | "name": "Make DEBUG=YES", 11 | "working_dir": "${project_path:${folder}}" 12 | } 13 | ], 14 | "folders": 15 | [ 16 | { 17 | "file_exclude_patterns": 18 | [ 19 | "*~", 20 | "RunDemo", 21 | "*.png", 22 | "*.o.d" 23 | ], 24 | "folder_exclude_patterns": 25 | [ 26 | "VisualStudio" 27 | ], 28 | "follow_symlinks": true, 29 | "path": "." 30 | } 31 | ], 32 | "settings": 33 | { 34 | "sublimegdb_commandline": "gdb --interpreter=mi ./RunDemo", 35 | "sublimegdb_workingdir": "${folder:${project_path:RunDemo}}", 36 | "tab_size": 4, 37 | "trim_trailing_white_space_on_save": true 38 | } 39 | } 40 | --------------------------------------------------------------------------------