diff --git a/authors.txt b/authors.txt index 4dd0147cb..2cd3889d5 100644 --- a/authors.txt +++ b/authors.txt @@ -4,4 +4,5 @@ Radon Labs GmbH, Berlin/Germany Johannes Hirche Gustav Sterbrant -Fredrik Lindahl \ No newline at end of file +Fredrik Lindahl +Robert Campbell \ No newline at end of file diff --git a/code/addons/CMakeLists.txt b/code/addons/CMakeLists.txt index 60db45de3..4818d8c46 100644 --- a/code/addons/CMakeLists.txt +++ b/code/addons/CMakeLists.txt @@ -11,3 +11,4 @@ add_subdirectory(scripting) #add_subdirectory(staticui) add_subdirectory(tinyxml) add_subdirectory(nsharp) +add_subdirectory(tbui) diff --git a/code/addons/graphicsfeature/CMakeLists.txt b/code/addons/graphicsfeature/CMakeLists.txt index a55f1fb0e..646a0cdf2 100644 --- a/code/addons/graphicsfeature/CMakeLists.txt +++ b/code/addons/graphicsfeature/CMakeLists.txt @@ -1,6 +1,6 @@ nebula_begin_module(graphicsfeature) nebula_flatc(SYSTEM graphicsfeature/graphicsfeatureschema.fbs graphicsfeature/terrainschema.fbs graphicsfeature/vegetationschema.fbs) -fips_deps(render application dynui nflatbuffer) +fips_deps(render application dynui tbui nflatbuffer) target_precompile_headers(graphicsfeature PRIVATE ) fips_ide_group(features) fips_files( diff --git a/code/addons/graphicsfeature/graphicsfeatureunit.cc b/code/addons/graphicsfeature/graphicsfeatureunit.cc index 7f37241fd..3c6c8547c 100644 --- a/code/addons/graphicsfeature/graphicsfeatureunit.cc +++ b/code/addons/graphicsfeature/graphicsfeatureunit.cc @@ -9,6 +9,7 @@ #include "graphics/cameracontext.h" #include "visibility/visibilitycontext.h" #include "dynui/imguicontext.h" +#include "tbui/tbuicontext.h" #include "characters/charactercontext.h" #include "dynui/im3d/im3dcontext.h" #include "appgame/gameapplication.h" @@ -159,6 +160,7 @@ GraphicsFeatureUnit::OnActivate() Im3d::Im3dContext::Create(); Dynui::ImguiContext::Create(); //StaticUI::StaticUIContext::Create(); + TBUI::TBUIContext::Create(); CameraContext::Create(); ModelContext::Create(); @@ -290,6 +292,7 @@ GraphicsFeatureUnit::OnActivate() Util::Array preLogicCalls = { Dynui::ImguiContext::NewFrame, + TBUI::TBUIContext::FrameUpdate, CameraContext::UpdateCameras, ModelContext::UpdateTransforms, Characters::CharacterContext::UpdateAnimations, @@ -380,6 +383,7 @@ GraphicsFeatureUnit::OnDeactivate() Raytracing::RaytracingContext::Discard(); Im3d::Im3dContext::Discard(); Dynui::ImguiContext::Discard(); + TBUI::TBUIContext::Discard(); FeatureUnit::OnDeactivate(); DestroyWindow(this->wnd); this->gfxServer->DiscardStage(this->defaultStage); diff --git a/code/addons/tbui/CMakeLists.txt b/code/addons/tbui/CMakeLists.txt new file mode 100644 index 000000000..561f762a2 --- /dev/null +++ b/code/addons/tbui/CMakeLists.txt @@ -0,0 +1,37 @@ +#------------------------------------------------------------------------------- +# tbui module +#------------------------------------------------------------------------------- + +nebula_begin_module(tbui) +fips_ide_group(addons) + +fips_deps(render turbobadger) +target_precompile_headers(tbui PRIVATE ) +target_include_directories(tbui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +fips_files( + tbuicontext.cc + tbuicontext.h + tbuiinputhandler.cc + tbuiinputhandler.h + tbuiview.cc + tbuiview.h +) + +add_shaders(tbui.fx) + +fips_dir(backend) + fips_files( + tbuibatch.h + tbuibitmap.cc + tbuibitmap.h + tbuiclipboard.cc + tbuifile.cc + tbuifile.h + tbuirenderer.cc + tbuirenderer.h + tbuisystem.cc + tbuivertex.h + ) + +nebula_end_module() diff --git a/code/addons/tbui/backend/tbuibatch.h b/code/addons/tbui/backend/tbuibatch.h new file mode 100644 index 000000000..6c75deb5a --- /dev/null +++ b/code/addons/tbui/backend/tbuibatch.h @@ -0,0 +1,25 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI Batch + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "coregraphics/buffer.h" +#include "coregraphics/texture.h" +#include "util/array.h" +#include "math/rectangle.h" +#include "tbuivertex.h" + +//------------------------------------------------------------------------------ +namespace TBUI +{ +struct TBUIBatch +{ + CoreGraphics::TextureId texture; + Util::Array vertices; + Math::intRectangle clipRect; +}; +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuibitmap.cc b/code/addons/tbui/backend/tbuibitmap.cc new file mode 100644 index 000000000..05171ffcf --- /dev/null +++ b/code/addons/tbui/backend/tbuibitmap.cc @@ -0,0 +1,85 @@ +//------------------------------------------------------------------------------ +// backend/tbuibitmap.cc +// (C) 2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "tbuibitmap.h" +#include "tbuirenderer.h" + + +namespace TBUI +{ + +//------------------------------------------------------------------------------ +/* +*/ +TBUIBitmap::TBUIBitmap(TBUIRenderer* renderer) + : renderer(renderer), + texture(CoreGraphics::InvalidTextureId) +{ +} + +//------------------------------------------------------------------------------ +/* +*/ +TBUIBitmap::~TBUIBitmap() +{ + this->renderer->FlushBitmap(this); + CoreGraphics::DestroyTexture(this->texture); + this->texture = CoreGraphics::InvalidTextureId; +} + +//------------------------------------------------------------------------------ +/* +*/ +bool +TBUIBitmap::Init(int width, int height, unsigned int* data) +{ + this->width = width; + this->height = height; + + CoreGraphics::TextureCreateInfo texInfo; + texInfo.name = "tbui_generated_texture"_atm; + texInfo.usage = CoreGraphics::TextureUsage::SampleTexture; + texInfo.tag = "tbui"_atm; + texInfo.data = data; + texInfo.dataSize = width * height * CoreGraphics::PixelFormat::ToSize(CoreGraphics::PixelFormat::SRGBA8); + texInfo.type = CoreGraphics::TextureType::Texture2D; + texInfo.format = CoreGraphics::PixelFormat::SRGBA8; + texInfo.width = width; + texInfo.height = height; + + this->texture = CoreGraphics::CreateTexture(texInfo); + + //SetData(data); + return true; +} + +//------------------------------------------------------------------------------ +/* +*/ +int +TBUIBitmap::Width() +{ + return this->width; +} + +//------------------------------------------------------------------------------ +/* +*/ +int +TBUIBitmap::Height() +{ + return this->height; +} + +//------------------------------------------------------------------------------ +/* +*/ +void +TBUIBitmap::SetData(unsigned int* data) +{ + const SizeT dataSize = this->width * this->height * CoreGraphics::PixelFormat::ToSize(CoreGraphics::PixelFormat::SRGBA8); + CoreGraphics::TextureUpdate(this->renderer->GetCmdBufferId(), this->texture, this->width, this->height, 0, 0, data, dataSize); +} +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuibitmap.h b/code/addons/tbui/backend/tbuibitmap.h new file mode 100644 index 000000000..2218ff6e0 --- /dev/null +++ b/code/addons/tbui/backend/tbuibitmap.h @@ -0,0 +1,62 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI Bitmap + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "coregraphics/texture.h" +#include "tb_renderer.h" + +//------------------------------------------------------------------------------ +namespace TBUI +{ + +class TBUIRenderer; + +//------------------------------------------------------------------------------ +class TBUIBitmap : public tb::TBBitmap +{ +public: + + /// + TBUIBitmap(TBUIRenderer* renderer); + + /** Note: Implementations for batched renderers should call TBRenderer::FlushBitmap + to make sure any active batch is being flushed before the bitmap is deleted. */ + ~TBUIBitmap() override; + + /// + bool Init(int width, int height, unsigned int* data); + + /// + int Width() override; + /// + int Height() override; + + /** Update the bitmap with the given data (in BGRA32 format). + Note: Implementations for batched renderers should call TBRenderer::FlushBitmap + to make sure any active batch is being flushed before the bitmap is changed. */ + void SetData(unsigned int* data) override; + + /// + CoreGraphics::TextureId GetTexture() const; + +private: + TBUIRenderer* renderer; + int width = 0; + int height = 0; + CoreGraphics::TextureId texture; +}; + +//------------------------------------------------------------------------------ +/* +*/ +inline CoreGraphics::TextureId +TBUIBitmap::GetTexture() const +{ + return this->texture; +} +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuiclipboard.cc b/code/addons/tbui/backend/tbuiclipboard.cc new file mode 100644 index 000000000..32aa6a688 --- /dev/null +++ b/code/addons/tbui/backend/tbuiclipboard.cc @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// backend/tbuiclipboard.cc +// (C) 2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "tb_system.h" + +namespace tb +{ + +// == TBClipboard ===================================== + +TBStr clipboard; ///< Obviosly not a full implementation since it ignores the OS :) + +void +TBClipboard::Empty() +{ + clipboard.Clear(); +} + +bool +TBClipboard::HasText() +{ + return !clipboard.IsEmpty(); +} + +bool +TBClipboard::SetText(const char* text) +{ + return clipboard.Set(text); +} + +bool +TBClipboard::GetText(TBStr& text) +{ + return text.Set(clipboard); +} + +} // namespace tb diff --git a/code/addons/tbui/backend/tbuifile.cc b/code/addons/tbui/backend/tbuifile.cc new file mode 100644 index 000000000..70b1e9f6b --- /dev/null +++ b/code/addons/tbui/backend/tbuifile.cc @@ -0,0 +1,76 @@ +//------------------------------------------------------------------------------ +// backend/tbuifile.cc +// (C) 2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "io/ioserver.h" +#include "io/stream.h" +#include "tbuifile.h" +#include "tb_system.h" + +namespace tb +{ +//------------------------------------------------------------------------------ +/** +*/ +TBFile* +TBFile::Open(const char* filename, TBFileMode mode) +{ + if (mode != TBFileMode::MODE_READ) + return nullptr; + + TBUI::TBUIFile* file = new ::TBUI::TBUIFile(filename, IO::Stream::AccessMode::ReadAccess); + if (!file->IsOpen()) + { + file = nullptr; + } + + return file; +} +} // namespace tb + +namespace TBUI +{ +//------------------------------------------------------------------------------ +/** +*/ +TBUIFile::TBUIFile(const Util::String& filePath, IO::Stream::AccessMode accessMode) + : fileStream(nullptr) +{ + this->fileStream = IO::IoServer::Instance()->CreateStream(filePath).downcast(); + this->fileStream->SetAccessMode(accessMode); + if (!this->fileStream->Open()) + { + this->fileStream = nullptr; + } +} + +//------------------------------------------------------------------------------ +/** +*/ +TBUIFile::~TBUIFile() +{ + if (this->fileStream->IsOpen()) + { + this->fileStream->Close(); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +long +TBUIFile::Size() +{ + return this->fileStream->GetSize(); +} + +//------------------------------------------------------------------------------ +/** +*/ +size_t +TBUIFile::Read(void* buf, size_t elemSize, size_t count) +{ + return this->fileStream->Read(buf, count); +} +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuifile.h b/code/addons/tbui/backend/tbuifile.h new file mode 100644 index 000000000..4e63882d1 --- /dev/null +++ b/code/addons/tbui/backend/tbuifile.h @@ -0,0 +1,46 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI File interface + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ + +#include "io/filestream.h" +#include "util/string.h" +#include "tb_system.h" + +//------------------------------------------------------------------------------ +namespace TBUI +{ +class TBUIFile : public tb::TBFile +{ +public: + /// + TBUIFile(const Util::String& filepath, IO::Stream::AccessMode accessMode); + /// + ~TBUIFile(); + + /// + long Size() override; + /// + size_t Read(void* buf, size_t elemSize, size_t count) override; + /// + bool IsOpen() const; + +private: + Ptr fileStream; +}; + +//------------------------------------------------------------------------------ +/* +*/ +inline bool +TBUIFile::IsOpen() const +{ + return fileStream && fileStream->IsOpen(); +} + +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuirenderer.cc b/code/addons/tbui/backend/tbuirenderer.cc new file mode 100644 index 000000000..0a61ce3d3 --- /dev/null +++ b/code/addons/tbui/backend/tbuirenderer.cc @@ -0,0 +1,104 @@ +//------------------------------------------------------------------------------ +// backend/tbuirenderer.cc +// (C) 2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "coregraphics/texture.h" +#include "tbuirenderer.h" +#include "tbuibitmap.h" + +namespace TBUI +{ + +//------------------------------------------------------------------------------ +/** +*/ +tb::TBBitmap* +TBUIRenderer::CreateBitmap(int width, int height, uint32* data) +{ + TBUIBitmap* bitmap = new TBUIBitmap(this); + if (!bitmap->Init(width, height, data)) + { + delete bitmap; + return nullptr; + } + + return bitmap; +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIRenderer::RenderBatch(Batch* tbBatch) +{ + CoreGraphics::TextureId texture = CoreGraphics::InvalidTextureId; + TBUIBitmap* bitmap = (TBUIBitmap*)tbBatch->bitmap; + if (bitmap) + { + texture = bitmap->GetTexture(); + } + + TBUIBatch batch; + batch.texture = texture; + batch.clipRect = this->clipRect; + + for (int i = 0; i < tbBatch->vertex_count; i++) + { + tb::TBRendererBatcher::Vertex tbVertex = tbBatch->vertex[i]; + TBUIVertex vertex = { + .position = {tbVertex.x, tbVertex.y}, + .uv = {tbVertex.u, tbVertex.v}, + .color = {.v = tbVertex.col}, + }; + + batch.vertices.Append(vertex); + } + + this->batches.Append(batch); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIRenderer::SetClipRect(const tb::TBRect& rect) +{ + this->clipRect = Math::intRectangle(rect.x, rect.y, rect.x + rect.w, rect.y + rect.h); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIRenderer::SetCmdBufferId(const CoreGraphics::CmdBufferId& cmdBufferId) +{ + this->cmdBufferId = cmdBufferId; +} + +//------------------------------------------------------------------------------ +/** +*/ +const CoreGraphics::CmdBufferId& +TBUIRenderer::GetCmdBufferId() const +{ + return this->cmdBufferId; +} + +//------------------------------------------------------------------------------ +/** +*/ +Util::Array +TBUIRenderer::RenderView(TBUIView* view, int32_t width, int32_t height) +{ + this->batches.Clear(); + + this->clipRect = {0, 0, (int32_t)width, (int32_t)height}; + + BeginPaint(width, height); + view->InvokePaint(tb::TBWidget::PaintProps()); + EndPaint(); + + return this->batches; +} +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuirenderer.h b/code/addons/tbui/backend/tbuirenderer.h new file mode 100644 index 000000000..49af464c3 --- /dev/null +++ b/code/addons/tbui/backend/tbuirenderer.h @@ -0,0 +1,42 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI Renderer + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ + +#include "math/rectangle.h" +#include "renderers/tb_renderer_batcher.h" +#include "tbuibatch.h" +#include "tbui/tbuiview.h" + +namespace TBUI +{ +class TBUIRenderer : public tb::TBRendererBatcher +{ +public: + /// + tb::TBBitmap* CreateBitmap(int width, int height, uint32* data) override; + /// + void RenderBatch(Batch* batch) override; + /// + void SetClipRect(const tb::TBRect& rect) override; + + /// + void SetCmdBufferId(const CoreGraphics::CmdBufferId& cmdBufferId); + /// + const CoreGraphics::CmdBufferId& GetCmdBufferId() const; + + /// + Util::Array RenderView(TBUIView* view, int32_t width, int32_t height); + +private: + Math::intRectangle clipRect; + Util::Array batches; + + CoreGraphics::CmdBufferId cmdBufferId; +}; +} // namespace TBUI diff --git a/code/addons/tbui/backend/tbuisystem.cc b/code/addons/tbui/backend/tbuisystem.cc new file mode 100644 index 000000000..1c801aa29 --- /dev/null +++ b/code/addons/tbui/backend/tbuisystem.cc @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// backend/tbuisystem.cc +// (C) 2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "core/sysfunc.h" +#include "timing/calendartime.h" +#include "tbuicontext.h" +#include "tb_system.h" + +#ifdef TB_RUNTIME_DEBUG_INFO + +//------------------------------------------------------------------------------ +/** +*/ +void +TBDebugOut(const char* str) +{ + Core::SysFunc::DebugOut(str); +} + +#endif // TB_RUNTIME_DEBUG_INFO + +namespace tb +{ +namespace +{ + +// hopefully we dont need this, leaving it for now +#if 0 +//------------------------------------------------------------------------------ +/** +*/ +static double +GetMillisecondsSinceEpoch(Timing::CalendarTime calendarTime) +{ + int year = calendarTime.GetYear(); + int month = calendarTime.GetMonth(); + int day = calendarTime.GetDay(); + int hour = calendarTime.GetHour(); + int minute = calendarTime.GetMinute(); + int second = calendarTime.GetSecond(); + int millisecond = calendarTime.GetMilliSecond(); + + // Validate input (basic checks) + if (month < 1 || month > 12 || day < 1 || day > 31 || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || + second > 59 || millisecond < 0 || millisecond > 999) + { + return -1.0; // Failure + } + + // Construct a tm structure + std::tm timeinfo = {}; + timeinfo.tm_year = year - 1900; // tm_year is years since 1900 + timeinfo.tm_mon = month - 1; // tm_mon is 0-based + timeinfo.tm_mday = day; + timeinfo.tm_hour = hour; + timeinfo.tm_min = minute; + timeinfo.tm_sec = second; + + // Convert to time_t (seconds since epoch) + std::time_t time_since_epoch = std::mktime(&timeinfo); + + // Check for invalid time conversion + if (time_since_epoch == -1) + { + return -1.0; // Failure + } + + // Convert to milliseconds as double + return static_cast(time_since_epoch) * 1000.0 + static_cast(millisecond); +} +#endif +} + +//------------------------------------------------------------------------------ +/** + Get the system time in milliseconds since some undefined epoch. +*/ +double +TBSystem::GetTimeMS() +{ + n_assert(TBUI::TBUIContext::state.timer.isvalid()); + return TBUI::TBUIContext::state.timer->GetTime(); +} + +//------------------------------------------------------------------------------ +/** + Called when the need to call TBMessageHandler::ProcessMessages has changed + due to changes in the message queue. fire_time is the new time is needs to be + called. + It may be 0 which means that ProcessMessages should be called asap (but NOT + from this call!) It may also be TB_NOT_SOON which means that ProcessMessages + doesn't need to be called. +*/ +void +TBSystem::RescheduleTimer(double fire_time) +{ +} + +//------------------------------------------------------------------------------ +/** + Get how many milliseconds it should take after a touch down event should + generate a long click event. +*/ +int +TBSystem::GetLongClickDelayMS() +{ + return 500; +} + +//------------------------------------------------------------------------------ +/** + Get how many pixels of dragging should start panning scrollable widgets. +*/ +int +TBSystem::GetPanThreshold() +{ + return 40; +} + +//------------------------------------------------------------------------------ +/** + Get how many pixels a typical line is: The length that should be scrolled + when turning a mouse wheel one notch. +*/ +int +TBSystem::GetPixelsPerLine() +{ + return 40; +} + +//------------------------------------------------------------------------------ +/** + Get Dots Per Inch for the main screen. +*/ +int +TBSystem::GetDPI() +{ + return 96; +} +} // namespace tb diff --git a/code/addons/tbui/backend/tbuivertex.h b/code/addons/tbui/backend/tbuivertex.h new file mode 100644 index 000000000..41b22dee8 --- /dev/null +++ b/code/addons/tbui/backend/tbuivertex.h @@ -0,0 +1,23 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI Vertex + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ + +#include "math/scalar.h" + +namespace TBUI +{ +#pragma pack(push, 1) +struct TBUIVertex +{ + float position[2]; + float uv[2]; + Math::byte4u color; +}; +#pragma pack(pop) +} diff --git a/code/addons/tbui/tbui.fx b/code/addons/tbui/tbui.fx new file mode 100644 index 000000000..521bcb0c4 --- /dev/null +++ b/code/addons/tbui/tbui.fx @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------------ +// tbui.fx +// +// Shader for Turbobadger rendering +// +// (C) 2013 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ + +#include "lib/std.fxh" +#include "lib/techniques.fxh" +#include "lib/shared.fxh" +#include "lib/defaultsamplers.fxh" + +// put variables in push-constant block +push constant TBUI [ string Visibility = "PS|VS"; ] +{ + mat4 TextProjectionModel; + uint Texture; +}; + +group(BATCH_GROUP) sampler_state TextureSampler +{ + Filter = Linear; +}; + +render_state TextState +{ + BlendEnabled[0] = true; + SrcBlend[0] = SrcAlpha; + DstBlend[0] = OneMinusSrcAlpha; + DepthWrite = false; + DepthEnabled = false; + CullMode = None; + ScissorEnabled = true; +}; + +//------------------------------------------------------------------------------ +/** +*/ +shader +void +vsMain( + [slot=0] in vec2 position, + [slot=1] in vec2 uv, + [slot=2] in vec4 color, + out vec2 UV, + out vec4 Color) +{ + vec4 pos = vec4(position, 0, 1); + gl_Position = TBUI.TextProjectionModel * pos; + Color = color; + UV = uv; +} + +//------------------------------------------------------------------------------ +/** +*/ +shader +void +psMain( + in vec2 UV, + in vec4 Color, + [color0] out vec4 FinalColor) +{ + vec4 texColor = sample2D(TBUI.Texture, TextureSampler, UV); + + // Since we are using sRGB output, remember to degamma + FinalColor = Color * texColor; +} + + +//------------------------------------------------------------------------------ +/** +*/ +SimpleTechnique(Default, "Static", vsMain(), psMain(), TextState); diff --git a/code/addons/tbui/tbuibatch.cc b/code/addons/tbui/tbuibatch.cc new file mode 100644 index 000000000..2ba53f688 --- /dev/null +++ b/code/addons/tbui/tbuibatch.cc @@ -0,0 +1 @@ +#include "tbuibatch.h" diff --git a/code/addons/tbui/tbuicontext.cc b/code/addons/tbui/tbuicontext.cc new file mode 100644 index 000000000..230842417 --- /dev/null +++ b/code/addons/tbui/tbuicontext.cc @@ -0,0 +1,578 @@ +//------------------------------------------------------------------------------ +// @file tbuicontext.cc +// @copyright (C) 2021 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "math/mat4.h" +#include "input/inputserver.h" +#include "frame/default.h" +#include "io/assignregistry.h" +#include "input/keyboard.h" + +#include +#include "tbuicontext.h" +#include "tbuiview.h" +#include "backend/tbuibatch.h" +#include "backend/tbuirenderer.h" +#include "tb_core.h" +#include "tb_language.h" +#include "tb_font_renderer.h" +#include "animation/tb_widget_animation.h" +#include "tb_window.h" +#include "tb_node_tree.h" +#include "tb_widgets_reader.h" + +#ifdef TB_FONT_RENDERER_TBBF +void register_tbbf_font_renderer(); +#endif +#ifdef TB_FONT_RENDERER_STB +void register_stb_font_renderer(); +#endif +#ifdef TB_FONT_RENDERER_FREETYPE +void register_freetype_font_renderer(); +#endif + +namespace TBUI +{ +namespace +{ + +//------------------------------------------------------------------------------ +/** +*/ +tb::MODIFIER_KEYS +GetModifierKeys() +{ + tb::MODIFIER_KEYS modifiers = tb::TB_MODIFIER_NONE; + auto& kb = Input::InputServer::Instance()->GetDefaultKeyboard(); + if (kb->KeyDown(Input::Key::Shift)) + { + modifiers |= tb::MODIFIER_KEYS::TB_SHIFT; + } + if (kb->KeyDown(Input::Key::Control)) + { + modifiers |= tb::MODIFIER_KEYS::TB_CTRL; + } + if (kb->KeyDown(Input::Key::Menu)) + { + modifiers |= tb::MODIFIER_KEYS::TB_ALT; + } + if (kb->KeyDown(Input::Key::LeftWindows) || kb->KeyDown(Input::Key::RightWindows)) + { + modifiers |= tb::MODIFIER_KEYS::TB_SUPER; + } + + return modifiers; +} + +//------------------------------------------------------------------------------ +/** +*/ +tb::SPECIAL_KEY +GetSpecialKey(Input::Key::Code code) +{ + tb::SPECIAL_KEY key = tb::SPECIAL_KEY::TB_KEY_UNDEFINED; + + switch (code) + { + case Input::Key::Code::InvalidKey: + return tb::TB_KEY_UNDEFINED; + case Input::Key::Code::Up: + return tb::TB_KEY_UP; + case Input::Key::Code::Down: + return tb::TB_KEY_DOWN; + case Input::Key::Code::Left: + return tb::TB_KEY_LEFT; + case Input::Key::Code::Right: + return tb::TB_KEY_RIGHT; + case Input::Key::Code::PageUp: + return tb::TB_KEY_PAGE_UP; + case Input::Key::Code::PageDown: + return tb::TB_KEY_PAGE_DOWN; + case Input::Key::Code::Home: + return tb::TB_KEY_HOME; + case Input::Key::Code::End: + return tb::TB_KEY_END; + case Input::Key::Code::Tab: + return tb::TB_KEY_TAB; + case Input::Key::Code::Back: + return tb::TB_KEY_BACKSPACE; + case Input::Key::Code::Insert: + return tb::TB_KEY_INSERT; + case Input::Key::Code::Delete: + return tb::TB_KEY_DELETE; + case Input::Key::Code::Return: + return tb::TB_KEY_ENTER; + case Input::Key::Code::Escape: + return tb::TB_KEY_ESC; + case Input::Key::Code::F1: + return tb::TB_KEY_F1; + case Input::Key::Code::F2: + return tb::TB_KEY_F2; + case Input::Key::Code::F3: + return tb::TB_KEY_F3; + case Input::Key::Code::F4: + return tb::TB_KEY_F4; + case Input::Key::Code::F5: + return tb::TB_KEY_F5; + case Input::Key::Code::F6: + return tb::TB_KEY_F6; + case Input::Key::Code::F7: + return tb::TB_KEY_F7; + case Input::Key::Code::F8: + return tb::TB_KEY_F8; + case Input::Key::Code::F9: + return tb::TB_KEY_F9; + case Input::Key::Code::F10: + return tb::TB_KEY_F10; + case Input::Key::Code::F11: + return tb::TB_KEY_F11; + case Input::Key::Code::F12: + return tb::TB_KEY_F12; + } + + return key; +} + +//------------------------------------------------------------------------------ +/** +*/ +static int32_t +GetTBKey(const Input::InputEvent& inputEvent) +{ + return (int32_t)Input::Key::ToChar(inputEvent.GetKey()); +} +} // namespace + +TBUIRenderer* TBUIContext::renderer = nullptr; +Util::Array TBUIContext::views; +TBUIContext::TBUIState TBUIContext::state; +static constexpr size_t TBUI_VERTEX_MAX_SIZE = VERTEX_BATCH_SIZE * sizeof(TBUIVertex); + +__ImplementPluginContext(TBUIContext) + //------------------------------------------------------------------------------ + /** +*/ + TBUIContext::TBUIContext() +{ +} + +//------------------------------------------------------------------------------ +/** +*/ +TBUIContext::~TBUIContext() +{ +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::Create() +{ + n_assert(FrameSync::FrameSyncTimer::HasInstance()); + __bundle.OnWindowResized = TBUIContext::OnWindowResized; + Graphics::GraphicsServer::Instance()->RegisterGraphicsContext(&__bundle, &__state); + if (!tb::tb_core_is_initialized()) + { + renderer = new TBUIRenderer(); + if (!tb::tb_core_init(renderer)) + { + delete renderer; + return; + } + IO::AssignRegistry::Instance()->SetAssign(IO::Assign("tb", "root:work/turbobadger")); + + // Load language file + tb::g_tb_lng->Load("tb:resources/language/lng_en.tb.txt"); + + // Load the default skin + tb::g_tb_skin->Load("tb:resources/default_skin/skin.tb.txt", "tb:demo/skin/skin.tb.txt"); + + // Register font renderers. +#ifdef TB_FONT_RENDERER_TBBF + register_tbbf_font_renderer(); +#endif + +#ifdef TB_FONT_RENDERER_STB + register_stb_font_renderer(); +#endif +#ifdef TB_FONT_RENDERER_FREETYPE + register_freetype_font_renderer(); +#endif + + // Add fonts we can use to the font manager. +#if defined(TB_FONT_RENDERER_STB) || defined(TB_FONT_RENDERER_FREETYPE) + tb::g_font_manager->AddFontInfo("tb:resources/vera.ttf", "Vera"); +#endif +#ifdef TB_FONT_RENDERER_TBBF + tb::g_font_manager->AddFontInfo("tb:resources/default_font/segoe_white_with_shadow.tb.txt", "Segoe"); + tb::g_font_manager->AddFontInfo("tb:demo/fonts/neon.tb.txt", "Neon"); + tb::g_font_manager->AddFontInfo("tb:demo/fonts/orangutang.tb.txt", "Orangutang"); + tb::g_font_manager->AddFontInfo("tb:demo/fonts/orange.tb.txt", "Orange"); +#endif + + // Set the default font description for widgets to one of the fonts we just added + tb::TBFontDescription fd; +#ifdef TB_FONT_RENDERER_TBBF + fd.SetID(TBIDC("Segoe")); +#else + fd.SetID(TBIDC("Vera")); +#endif + fd.SetSize(tb::g_tb_skin->GetDimensionConverter()->DpToPx(14)); + tb::g_font_manager->SetDefaultFontDescription(fd); + + // Create the font now. + tb::TBFontFace* font = tb::g_font_manager->CreateFontFace(tb::g_font_manager->GetDefaultFontDescription()); + + // Render some glyphs in one go now since we know we are going to use them. It would work fine + // without this since glyphs are rendered when needed, but with some extra updating of the glyph bitmap. + if (font) + font->RenderGlyphs(" !\"#$%&'()*+,-./" + "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + + tb::TBWidgetsAnimationManager::Init(); + + // setup state + { + // allocate shader + state.shader = CoreGraphics::ShaderGet("shd:tbui.fxb"); + state.shaderProgram = CoreGraphics::ShaderGetProgram(state.shader, CoreGraphics::ShaderFeatureMask("Static")); + + state.resourceTable = CoreGraphics::ShaderCreateResourceTable(state.shader, NEBULA_BATCH_GROUP); + + state.textProjectionConstant = CoreGraphics::ShaderGetConstantBinding(state.shader, "TextProjectionModel"); + state.textureConstant = CoreGraphics::ShaderGetConstantBinding(state.shader, "Texture"); + + // create vertex buffer + Util::Array components; + components.Append(CoreGraphics::VertexComponent(0, CoreGraphics::VertexComponent::Float2, 0)); + components.Append(CoreGraphics::VertexComponent(1, CoreGraphics::VertexComponent::Float2, 0)); + components.Append(CoreGraphics::VertexComponent(2, CoreGraphics::VertexComponent::UByte4N, 0)); + state.vertexLayout = CoreGraphics::CreateVertexLayout({.name = "TBUI Vertex Layout", .comps = components}); + + FrameScript_default::RegisterSubgraphPipelines_StaticUIToBackbuffer_Pass( + [](const CoreGraphics::PassId pass, uint subpass) + { + CoreGraphics::InputAssemblyKey inputAssembly {CoreGraphics::PrimitiveTopology::TriangleList, false}; + if (state.pipeline != CoreGraphics::InvalidPipelineId) + CoreGraphics::DestroyGraphicsPipeline(state.pipeline); + state.pipeline = CoreGraphics::CreateGraphicsPipeline({state.shaderProgram, pass, subpass, inputAssembly}); + } + ); + + FrameScript_default::RegisterSubgraph_StaticUIToBackbuffer_Pass( + [](const CoreGraphics::CmdBufferId cmdBuf, + const Math::rectangle& viewport, + const IndexT frame, + const IndexT bufferIndex) + { + //TBUI::TBUIContext::FrameUpdate({}); + TBUIContext::Render(cmdBuf, viewport, frame, bufferIndex); + } + ); + + SizeT numBuffers = CoreGraphics::GetNumBufferedFrames(); + + CoreGraphics::BufferCreateInfo vboInfo; + vboInfo.name = "TBUI VBO"_atm; + vboInfo.size = 1; + vboInfo.elementSize = CoreGraphics::VertexLayoutGetSize(state.vertexLayout); + vboInfo.mode = CoreGraphics::HostCached; + vboInfo.usageFlags = CoreGraphics::VertexBuffer; + vboInfo.data = nullptr; + vboInfo.dataSize = 0; + state.vbos.Resize(numBuffers); + IndexT i; + for (i = 0; i < numBuffers; i++) + { + state.vbos[i] = CoreGraphics::CreateBuffer(vboInfo); + } + + // map buffer + state.vertexPtrs.Resize(numBuffers); + for (i = 0; i < numBuffers; i++) + { + state.vertexPtrs[i] = (byte*)CoreGraphics::BufferMap(state.vbos[i]); + } + + state.inputHandler = TBUIInputHandler::Create(); + Input::InputServer::Instance()->AttachInputHandler( + Input::InputPriority::Gui, state.inputHandler.upcast() + ); + + state.timer = FrameSync::FrameSyncTimer::Instance(); + } + } +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::Discard() +{ + if (tb::tb_core_is_initialized()) + { + tb::TBWidgetsAnimationManager::Shutdown(); + tb::tb_core_shutdown(); + + Input::InputServer::Instance()->RemoveInputHandler(state.inputHandler.upcast()); + state.inputHandler = nullptr; + + IndexT i; + for (i = 0; i < state.vbos.Size(); i++) + { + CoreGraphics::BufferUnmap(state.vbos[i]); + + CoreGraphics::DestroyBuffer(state.vbos[i]); + + state.vertexPtrs[i] = nullptr; + } + + delete renderer; + + IO::AssignRegistry::Instance()->ClearAssign("tb"); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::FrameUpdate(const Graphics::FrameContext& ctx) +{ + tb::TBMessageHandler::ProcessMessages(); + tb::TBAnimationManager::Update(); + + for (auto& view : views) + { + view->InvokeProcessStates(); + view->InvokeProcess(); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::OnWindowResized(const CoreGraphics::WindowId windowId, SizeT width, SizeT height) +{ + for (auto& view : views) + { + //view->SetSize(width, height); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +TBUIView* +TBUIContext::CreateView(int32_t width, int32_t height) +{ + TBUIView* view = new TBUIView(); + { + view->Invalidate(); + view->SetSize(width, height); + view->InvalidateLayout(tb::TBWidget::INVALIDATE_LAYOUT_RECURSIVE); + + // Set gravity all so we resize correctly + view->SetGravity(tb::WIDGET_GRAVITY_ALL); + + view->SetFocus(tb::WIDGET_FOCUS_REASON_UNKNOWN); + } + views.Append(view); + return view; +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::DestroyView(const TBUIView* view) +{ + if (auto it = views.Find(const_cast(view))) + { + views.Erase(it); + (*it)->Die(); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +bool +TBUIContext::ProcessInput(const Input::InputEvent& inputEvent) +{ + TBUIView* view = views.Back(); + if (!view) + return false; + + tb::MODIFIER_KEYS modifiers = GetModifierKeys(); + + switch (inputEvent.GetType()) + { + case Input::InputEvent::KeyUp: + { + return view->InvokeKey(/*GetTBKey(inputEvent)*/0, GetSpecialKey(inputEvent.GetKey()), modifiers, false); + } + break; + case Input::InputEvent::KeyDown: { + return view->InvokeKey(/*GetTBKey(inputEvent)*/0, GetSpecialKey(inputEvent.GetKey()), modifiers, true); + } + case Input::InputEvent::Character: { + int c = (int)inputEvent.GetChar(); + tb::SPECIAL_KEY key = GetSpecialKey(inputEvent.GetKey()); + view->InvokeKey(c, key, modifiers, false); + return view->InvokeKey(c, key, modifiers, true); + } + break; + + case Input::InputEvent::MouseButtonDown: { + inputEvent.GetMouseButton(); + Math::vec2 pos = inputEvent.GetAbsMousePos(); + return view->InvokePointerDown(pos.x, pos.y, 1, modifiers, false); + } + case Input::InputEvent::MouseButtonUp: { + inputEvent.GetMouseButton(); + Math::vec2 pos = inputEvent.GetAbsMousePos(); + return view->InvokePointerUp(pos.x, pos.y, modifiers, false); + } + case Input::InputEvent::MouseMove: { + Math::vec2 pos = inputEvent.GetAbsMousePos(); + view->InvokePointerMove(pos.x, pos.y, modifiers, false); + } + break; + case Input::InputEvent::MouseWheelForward: { + Math::vec2 pos = inputEvent.GetAbsMousePos(); + view->InvokeWheel(pos.x, pos.y, 0, 1, modifiers); + } + break; + case Input::InputEvent::MouseWheelBackward: { + Math::vec2 pos = inputEvent.GetAbsMousePos(); + view->InvokeWheel(pos.x, pos.y, 0, -1, modifiers); + } + break; + default: + break; + { + } + } + + return false; +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIContext::Render(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle& viewport, const IndexT frame, const IndexT bufferIndex) +{ + Util::Array batches; + + // todo: Maybe render only the top view? + renderer->SetCmdBufferId(cmdBuf); + + for (const auto& view : views) + { + batches = renderer->RenderView(view, viewport.width(), viewport.height()); + } + + IndexT currentBuffer = CoreGraphics::GetBufferedFrameIndex(); + CoreGraphics::BufferId vbo = TBUIContext::state.vbos[currentBuffer]; + + N_CMD_SCOPE(cmdBuf, NEBULA_MARKER_GRAPHICS, "TBUI"); + + // create orthogonal matrix +#if __VULKAN__ + Math::mat4 proj = Math::orthooffcenterrh(0.0f, viewport.width(), viewport.height(), 0.0f, -1.0f, +1.0f); +#else + Math::mat4 proj = Math::orthooffcenterrh(0.0f, viewport.width(), 0.0f, viewport.height(), -1.0f, +1.0f); +#endif + + Math::mat4 transform = Math::mat4::identity; + + proj = proj * transform; + + size_t requiredVertexBufferSize = 0; + + for (const auto& batch : batches) + { + requiredVertexBufferSize += sizeof(TBUIVertex) * batch.vertices.Size(); + } + + // if buffers are too small, create new buffers + if (requiredVertexBufferSize > CoreGraphics::BufferGetByteSize(TBUIContext::state.vbos[currentBuffer])) + { + CoreGraphics::BufferUnmap(TBUIContext::state.vbos[currentBuffer]); + CoreGraphics::DestroyBuffer(TBUIContext::state.vbos[currentBuffer]); + + CoreGraphics::BufferCreateInfo vboInfo; + vboInfo.name = "TBUI VBO"_atm; + vboInfo.size = 0; + vboInfo.elementSize = CoreGraphics::VertexLayoutGetSize(TBUIContext::state.vertexLayout); + vboInfo.byteSize = requiredVertexBufferSize; + vboInfo.mode = CoreGraphics::HostCached; + vboInfo.usageFlags = CoreGraphics::VertexBuffer; + vboInfo.data = nullptr; + vboInfo.dataSize = 0; + TBUIContext::state.vbos[currentBuffer] = CoreGraphics::CreateBuffer(vboInfo); + TBUIContext::state.vertexPtrs[currentBuffer] = (byte*)CoreGraphics::BufferMap(TBUIContext::state.vbos[currentBuffer]); + } + + CoreGraphics::CmdSetGraphicsPipeline(cmdBuf, state.pipeline); + CoreGraphics::CmdSetVertexLayout(cmdBuf, state.vertexLayout); + CoreGraphics::CmdSetResourceTable(cmdBuf, state.resourceTable, NEBULA_BATCH_GROUP, CoreGraphics::GraphicsPipeline, nullptr); + CoreGraphics::CmdSetVertexBuffer(cmdBuf, 0, TBUIContext::state.vbos[currentBuffer], 0); + CoreGraphics::CmdSetPrimitiveTopology(cmdBuf, CoreGraphics::PrimitiveTopology::TriangleList); + CoreGraphics::CmdSetViewport(cmdBuf, viewport, 0); + CoreGraphics::CmdSetScissorRect(cmdBuf, viewport, 0); + + // set projection + CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, state.textProjectionConstant, sizeof(proj), (byte*)&proj); + + IndexT vertexOffset = 0; + IndexT vertexBufferOffset = 0; + + for (IndexT i = 0; i < batches.Size(); i++) + { + const auto& batch = batches[i]; + const unsigned char* vertexBuffer = (unsigned char*)&batch.vertices.Front(); + const SizeT vertexBufferSize = + batch.vertices.Size() * sizeof(TBUIVertex); // 2 for position, 2 for uvs, 1 int for color + + // if we render too many vertices, we will simply assert, but should never happen really + n_assert( + vertexBufferOffset + (IndexT)batch.vertices.Size() < + CoreGraphics::BufferGetByteSize(TBUIContext::state.vbos[currentBuffer]) + ); + + // wait for previous draws to finish... + Memory::Copy(vertexBuffer, TBUIContext::state.vertexPtrs[currentBuffer] + vertexBufferOffset, vertexBufferSize); + + CoreGraphics::CmdSetScissorRect(cmdBuf, batch.clipRect, 0); + + IndexT textureId = CoreGraphics::TextureGetBindlessHandle(batch.texture); + + CoreGraphics::CmdPushConstants(cmdBuf, CoreGraphics::GraphicsPipeline, state.textureConstant, sizeof(IndexT), &textureId); + + // setup primitive + CoreGraphics::PrimitiveGroup primitive; + primitive.SetNumIndices(0); + primitive.SetBaseIndex(0); + primitive.SetBaseVertex(vertexOffset); + primitive.SetNumVertices(batch.vertices.Size()); + + // prepare render device and draw + CoreGraphics::CmdDraw(cmdBuf, primitive); + + // bump vertices + vertexOffset += batch.vertices.Size(); + + // lock buffers + vertexBufferOffset += vertexBufferSize; + } + CoreGraphics::BufferFlush(TBUIContext::state.vbos[currentBuffer]); +} + +} // namespace TBUI diff --git a/code/addons/tbui/tbuicontext.h b/code/addons/tbui/tbuicontext.h new file mode 100644 index 000000000..c8b42b3da --- /dev/null +++ b/code/addons/tbui/tbuicontext.h @@ -0,0 +1,78 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Turbobadger UI Context + + @copyright + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "graphics/graphicscontext.h" +#include "coregraphics/vertexlayout.h" +#include "coregraphics/shader.h" +#include "coregraphics/pipeline.h" +#include "tbuiinputhandler.h" +#include "threading/spinlock.h" +#include "framesync/framesynctimer.h" + +namespace TBUI +{ +class TBUIRenderer; +class TBUIView; + +class TBUIContext : public Graphics::GraphicsContext +{ + __DeclarePluginContext(); + +public: + /// constructor + TBUIContext(); + /// destructor + virtual ~TBUIContext(); + + /// Create context + static void Create(); + /// Discard context + static void Discard(); + /// + static void FrameUpdate(const Graphics::FrameContext& ctx); + /// + static TBUIView* CreateView(int32_t width, int32_t height); + /// + static void DestroyView(const TBUIView* view); + /// + static bool ProcessInput(const Input::InputEvent& inputEvent); + + //static void LoadViewResource(); + +public: + struct TBUIState + { + CoreGraphics::ShaderId shader; + CoreGraphics::ShaderProgramId shaderProgram; + CoreGraphics::PipelineId pipeline; + Util::FixedArray vbos; + CoreGraphics::VertexLayoutId vertexLayout; + + IndexT textProjectionConstant; + IndexT textureConstant; + CoreGraphics::ResourceTableId resourceTable; + Util::FixedArray vertexPtrs; + + Ptr inputHandler; + Ptr timer; + }; + static TBUIState state; + +private: + /// + static void Render(const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle& viewport, const IndexT frame, const IndexT bufferIndex ); + + /// called if the window size has changed + static void OnWindowResized(const CoreGraphics::WindowId windowId, SizeT width, SizeT height); + + static TBUIRenderer* renderer; + static Util::Array views; +}; + +} // namespace TBUI diff --git a/code/addons/tbui/tbuiinputhandler.cc b/code/addons/tbui/tbuiinputhandler.cc new file mode 100644 index 000000000..8cdea4920 --- /dev/null +++ b/code/addons/tbui/tbuiinputhandler.cc @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------ +// TBUIinputhandler.cc +// (C) 2012-2020 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "render/stdneb.h" +#include "tbuiinputhandler.h" +#include "input/inputserver.h" +#include "tbuicontext.h" + +namespace TBUI +{ +__ImplementClass(TBUI::TBUIInputHandler, 'TBIH', Input::InputHandler); + +//------------------------------------------------------------------------------ +/** +*/ +TBUIInputHandler::TBUIInputHandler() +{ + // empty +} + +//------------------------------------------------------------------------------ +/** +*/ +TBUIInputHandler::~TBUIInputHandler() +{ + // empty +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIInputHandler::BeginCapture() +{ + Input::InputServer::Instance()->ObtainMouseCapture(this); + Input::InputServer::Instance()->ObtainKeyboardCapture(this); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIInputHandler::EndCapture() +{ + Input::InputServer::Instance()->ReleaseMouseCapture(this); + Input::InputServer::Instance()->ReleaseKeyboardCapture(this); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIInputHandler::OnBeginFrame() +{ +} + +//------------------------------------------------------------------------------ +/** +*/ +bool +TBUIInputHandler::OnEvent(const Input::InputEvent& inputEvent) +{ + switch (inputEvent.GetType()) + { +#ifndef _DEBUG + case Input::InputEvent::AppObtainFocus: + case Input::InputEvent::AppLoseFocus: +#endif + case Input::InputEvent::Reset: + this->OnReset(); + break; + + default: + return TBUIContext::ProcessInput(inputEvent); + } + return false; +} + +} // namespace TBUI diff --git a/code/addons/tbui/tbuiinputhandler.h b/code/addons/tbui/tbuiinputhandler.h new file mode 100644 index 000000000..4bac3fe65 --- /dev/null +++ b/code/addons/tbui/tbuiinputhandler.h @@ -0,0 +1,42 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + @class TBUI::TBUIInputHandler + + This input handler passes input events to Turbobadger. + + @copyright + (C) 2012-2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "core/refcounted.h" +#include "input/inputhandler.h" + +namespace TBUI +{ +class TBUIInputHandler : public Input::InputHandler +{ + __DeclareClass(TBUIInputHandler); +public: + /// constructor + TBUIInputHandler(); + /// destructor + virtual ~TBUIInputHandler(); + + /// capture input to this event handler + virtual void BeginCapture(); + /// end input capturing to this event handler + virtual void EndCapture(); + + /// reset key inputs + void OnBeginFrame() override; + +protected: + + /// called when an input event should be processed + virtual bool OnEvent(const Input::InputEvent& inputEvent); + +private: + Util::Array inputEvents; +}; +} // namespace TBUI \ No newline at end of file diff --git a/code/addons/tbui/tbuiview.cc b/code/addons/tbui/tbuiview.cc new file mode 100644 index 000000000..d99e28997 --- /dev/null +++ b/code/addons/tbui/tbuiview.cc @@ -0,0 +1 @@ +#include "tbuiview.h" diff --git a/code/addons/tbui/tbuiview.h b/code/addons/tbui/tbuiview.h new file mode 100644 index 000000000..56adc724b --- /dev/null +++ b/code/addons/tbui/tbuiview.h @@ -0,0 +1,17 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + TBUI::TBUIView + + (C) 2024 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "tb_widgets.h" + +namespace TBUI +{ + class TBUIView : public tb::TBWidget + { + + }; +} diff --git a/fips-files/configs/vulkan-linux-ninja-debug.yml b/fips-files/configs/vulkan-linux-ninja-debug.yml index d9681d1ee..d4ddf288b 100644 --- a/fips-files/configs/vulkan-linux-ninja-debug.yml +++ b/fips-files/configs/vulkan-linux-ninja-debug.yml @@ -7,3 +7,4 @@ defines: N_USE_VULKAN: ON FIPS_RTTI: ON FIPS_EXCEPTIONS: ON + TB_ENABLE_RTTI: ON diff --git a/fips.yml b/fips.yml index 7a8f3efe3..93a77a52f 100644 --- a/fips.yml +++ b/fips.yml @@ -45,6 +45,8 @@ imports: #fixme, make this configurable or put it into its own fips module entirely #fips-ultralight: # git: https://github.com/gscept/fips-ultralight.git + fips-turbobadger: + git: https://github.com/gscept/fips-turbobadger.git exports: header-dirs : - . diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 953fbec65..b539d0714 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,3 +18,4 @@ add_subdirectory(testviewer) add_subdirectory(testscript) add_subdirectory(testaddon) add_subdirectory(testnsharp) +add_subdirectory(testtbui) diff --git a/tests/testtbui/CMakeLists.txt b/tests/testtbui/CMakeLists.txt new file mode 100644 index 000000000..ceee12577 --- /dev/null +++ b/tests/testtbui/CMakeLists.txt @@ -0,0 +1,25 @@ + +nebula_begin_app(testtbui windowed) +fips_src(. *.* EXCEPT work/* GROUP test) + +fips_files( + main.cc + tbuifeatureunit.h + tbuifeatureunit.cc + gamestatemanager.h + gamestatemanager.cc + ListWindow.cc + ListWindow.h + ResourceEditWindow.cc + ResourceEditWindow.h +) + +fips_dir(managers) + fips_files( + inputmanager.h + inputmanager.cc + ) + +fips_deps(foundation application graphicsfeature render resource dynui turbobadger tbui editor) +target_precompile_headers(testtbui PRIVATE [["stdneb.h"]] [["foundation/stdneb.h"]] [["render/stdneb.h"]]) +nebula_end_app() diff --git a/tests/testtbui/ListWindow.cc b/tests/testtbui/ListWindow.cc new file mode 100644 index 000000000..51543ade0 --- /dev/null +++ b/tests/testtbui/ListWindow.cc @@ -0,0 +1,124 @@ +#include "ListWindow.h" +#include "tb_widgets_reader.h" + +using namespace Tests; + +// == AdvancedItemWidget ====================================================== + +AdvancedItemWidget::AdvancedItemWidget(AdvancedItem *item, AdvancedItemSource *source, + TBSelectItemViewer *source_viewer, int index) + : m_source(source) + , m_source_viewer(source_viewer) + , m_index(index) +{ + SetSkinBg(TBIDC("TBSelectItem")); + SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY); + SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP); + SetPaintOverflowFadeout(false); + + tb::g_widgets_reader->LoadFile(GetContentRoot(), "tb:demo/ui_resources/test_list_item.tb.txt"); + TBCheckBox *checkbox = GetWidgetByIDAndType(TBIDC("check")); + TBTextField *name = GetWidgetByIDAndType(TBIDC("name")); + TBTextField *info = GetWidgetByIDAndType(TBIDC("info")); + checkbox->SetValue(item->GetChecked() ? true : false); + name->SetText(item->str); + info->SetText(item->GetMale() ? "Male" : "Female"); +} + +bool AdvancedItemWidget::OnEvent(const TBWidgetEvent &ev) +{ + if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("check")) + { + AdvancedItem *item = m_source->GetItem(m_index); + item->SetChecked(ev.target->GetValue() ? true : false); + + m_source->InvokeItemChanged(m_index, m_source_viewer); + return true; + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("delete")) + { + m_source->DeleteItem(m_index); + return true; + } + return TBLayout::OnEvent(ev); +} + +// == AdvancedItemSource ====================================================== + +bool AdvancedItemSource::Filter(int index, const char *filter) +{ + // Override this method so we can return hits for our extra data too. + + if (TBSelectItemSource::Filter(index, filter)) + return true; + + AdvancedItem *item = GetItem(index); + return stristr(item->GetMale() ? "Male" : "Female", filter) ? true : false; +} + +TBWidget *AdvancedItemSource::CreateItemWidget(int index, TBSelectItemViewer *viewer) +{ + if (TBLayout *layout = new AdvancedItemWidget(GetItem(index), this, viewer, index)) + return layout; + return nullptr; +} + +// == ListWindow ============================================================== + +ListWindow::ListWindow(TBWidget *root, TBSelectItemSource *source) : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_select.tb.txt"); + if (TBSelectList *select = GetWidgetByIDAndType("list")) + { + select->SetSource(source); + select->GetScrollContainer()->SetScrollMode(SCROLL_MODE_Y_AUTO); + } +} + +bool ListWindow::OnEvent(const TBWidgetEvent &ev) +{ + if (ev.type == EVENT_TYPE_CHANGED && ev.target->GetID() == TBIDC("filter")) + { + if (TBSelectList *select = GetWidgetByIDAndType("list")) + select->SetFilter(ev.target->GetText()); + return true; + } + return DemoWindow::OnEvent(ev); +} + +// == AdvancedListWindow ============================================================== + +AdvancedListWindow::AdvancedListWindow(TBWidget *root, AdvancedItemSource *source) + : DemoWindow(root) + , m_source(source) +{ + LoadResourceFile("tb:demo/ui_resources/test_select_advanced.tb.txt"); + if (TBSelectList *select = GetWidgetByIDAndType("list")) + { + select->SetSource(source); + select->GetScrollContainer()->SetScrollMode(SCROLL_MODE_X_AUTO_Y_AUTO); + } +} + +bool AdvancedListWindow::OnEvent(const TBWidgetEvent &ev) +{ + TBSelectList *select = GetWidgetByIDAndType("list"); + if (select && ev.type == EVENT_TYPE_CHANGED && ev.target->GetID() == TBIDC("filter")) + { + select->SetFilter(ev.target->GetText()); + return true; + } + else if (select && ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("add")) + { + TBStr name = GetTextByID(TBIDC("add_name")); + if (!name.IsEmpty()) + m_source->AddItem(new AdvancedItem(name, TBIDC("boy_item"), true)); + return true; + } + else if (select && ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("delete all")) + { + m_source->DeleteAllItems(); + return true; + } + return DemoWindow::OnEvent(ev); +} diff --git a/tests/testtbui/ListWindow.h b/tests/testtbui/ListWindow.h new file mode 100644 index 000000000..5f0a41c48 --- /dev/null +++ b/tests/testtbui/ListWindow.h @@ -0,0 +1,99 @@ +#ifndef LISTWINDOW_DEMO_H +#define LISTWINDOW_DEMO_H + +#include "tb_select.h" + +using namespace tb; + +namespace Tests +{ + +class AdvancedItemSource; + +class DemoWindow : public TBWindow +{ +public: + DemoWindow(TBWidget* root); + bool LoadResourceFile(const char* filename); + void LoadResourceData(const char* data); + void LoadResource(TBNode& node); + + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +/** Shows a list of items from *any* type of source. */ +class ListWindow : public DemoWindow +{ +public: + ListWindow(TBWidget* root, TBSelectItemSource* source); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +/** Shows a list of items from a source of type AdvancedItemSource. */ +class AdvancedListWindow : public DemoWindow +{ +public: + AdvancedListWindow(TBWidget* root, AdvancedItemSource* source); + virtual bool OnEvent(const TBWidgetEvent& ev); + +private: + AdvancedItemSource* m_source; +}; + +/** AdvancedItem adds extra info to a string item. */ +class AdvancedItem : public TBGenericStringItem +{ +public: + AdvancedItem(const char* str, const TBID& id, bool male) + : TBGenericStringItem(str, id), + m_checked(false), + m_male(male) + { + } + void + SetChecked(bool checked) + { + m_checked = checked; + } + bool + GetChecked() const + { + return m_checked; + } + bool + GetMale() const + { + return m_male; + } + +private: + TBStr m_info; + bool m_checked; + bool m_male; +}; + +/** AdvancedItemSource provides items of type AdvancedItem and makes sure + the viewer is populated with the customized widget for each item. */ +class AdvancedItemSource : public TBSelectItemSourceList +{ +public: + virtual bool Filter(int index, const char* filter); + virtual TBWidget* CreateItemWidget(int index, TBSelectItemViewer* viewer); +}; + +/** AdvancedItemWidget is the widget representing a AdvancedItem. + On changes to the item, it calls InvokeItemChanged on the source, so that all + viewers of the source are updated to reflect the change. */ +class AdvancedItemWidget : public TBLayout +{ +public: + AdvancedItemWidget(AdvancedItem* item, AdvancedItemSource* source, TBSelectItemViewer* source_viewer, int index); + virtual bool OnEvent(const TBWidgetEvent& ev); + +private: + AdvancedItemSource* m_source; + TBSelectItemViewer* m_source_viewer; + int m_index; +}; +} // namespace Tests +#endif // LISTWINDOW_DEMO_H diff --git a/tests/testtbui/ResourceEditWindow.cc b/tests/testtbui/ResourceEditWindow.cc new file mode 100644 index 000000000..000f06893 --- /dev/null +++ b/tests/testtbui/ResourceEditWindow.cc @@ -0,0 +1,249 @@ +#include + +#include "ResourceEditWindow.h" +#include "tb_widgets_reader.h" +#include "tb_message_window.h" +#include "tb_system.h" +#include "tb_select.h" +#include "tb_editfield.h" +#include "tb_tempbuffer.h" +#include "tb_scroll_container.h" + +// == ResourceItem ==================================================================================== + +using namespace Tests; + +ResourceItem::ResourceItem(TBWidget *widget, const char *str) + : TBGenericStringItem(str) + , m_widget(widget) +{ +} + +// == ResourceEditWindow ============================================================================== + +ResourceEditWindow::ResourceEditWindow() + : m_widget_list(nullptr) + , m_scroll_container(nullptr) + , m_build_container(nullptr) + , m_source_edit(nullptr) +{ + // Register as global listener to intercept events in the build container + TBWidgetListener::AddGlobalListener(this); + + g_widgets_reader->LoadFile(this, "tb:demo/ui_resources/resource_edit_window.tb.txt"); + + m_scroll_container = GetWidgetByIDAndType(TBIDC("scroll_container")); + m_build_container = m_scroll_container->GetContentRoot(); + m_source_edit = GetWidgetByIDAndType(TBIDC("source_edit")); + + m_widget_list = GetWidgetByIDAndType(TBIDC("widget_list")); + m_widget_list->SetSource(&m_widget_list_source); + + SetRect(TBRect(100, 50, 900, 600)); +} + +ResourceEditWindow::~ResourceEditWindow() +{ + TBWidgetListener::RemoveGlobalListener(this); + + // avoid assert + m_widget_list->SetSource(nullptr); +} + +void ResourceEditWindow::Load(const char *resource_file) +{ + m_resource_filename.Set(resource_file); + SetText(resource_file); + + TBTempBuffer buffer; + if (buffer.AppendFile(m_resource_filename)) + m_source_edit->SetText(buffer.GetData(), buffer.GetAppendPos()); + else // Error, clear and show message + { + m_source_edit->SetText(""); + TBStr text; + text.SetFormatted("Could not load file %s", resource_file); + if (TBMessageWindow *msg_win = new TBMessageWindow(GetParentRoot(), TBIDC(""))) + msg_win->Show("Error loading resource", text); + } + + RefreshFromSource(); +} + +void ResourceEditWindow::RefreshFromSource() +{ + // Clear old widgets + while (TBWidget *child = m_build_container->GetFirstChild()) + { + m_build_container->RemoveChild(child); + delete child; + } + + // Create new widgets from source + g_widgets_reader->LoadData(m_build_container, m_source_edit->GetText()); + + // Force focus back in case the edited resource has autofocus. + // FIX: It would be better to prevent the focus change instead! + m_source_edit->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN); +} + +void ResourceEditWindow::UpdateWidgetList(bool immediately) +{ + if (!immediately) + { + TBID id = TBIDC("update_widget_list"); + if (!GetMessageByID(id)) + this->PostMessage(id, nullptr); + } + else + { + m_widget_list_source.DeleteAllItems(); + AddWidgetListItemsRecursive(m_build_container, 0); + + m_widget_list->InvalidateList(); + } +} + +void ResourceEditWindow::AddWidgetListItemsRecursive(TBWidget *widget, int depth) +{ + if (depth > 0) // Ignore the root + { + // Add a new ResourceItem for this widget + TBStr str; + const char *classname = widget->GetClassName(); + if (!*classname) + classname = ""; + str.SetFormatted("% *s%s", depth - 1, "", classname); + + if (ResourceItem *item = new ResourceItem(widget, str)) + m_widget_list_source.AddItem(item); + } + + for (TBWidget *child = widget->GetFirstChild(); child; child = child->GetNext()) + AddWidgetListItemsRecursive(child, depth + 1); +} + +ResourceEditWindow::ITEM_INFO ResourceEditWindow::GetItemFromWidget(TBWidget *widget) +{ + ITEM_INFO item_info = { nullptr, -1 }; + for (int i = 0; i < m_widget_list_source.GetNumItems(); i++) + if (m_widget_list_source.GetItem(i)->GetWidget() == widget) + { + item_info.index = i; + item_info.item = m_widget_list_source.GetItem(i); + break; + } + return item_info; +} + +void ResourceEditWindow::SetSelectedWidget(TBWidget *widget) +{ + m_selected_widget.Set(widget); + ITEM_INFO item_info = GetItemFromWidget(widget); + if (item_info.item) + m_widget_list->SetValue(item_info.index); +} + +bool ResourceEditWindow::OnEvent(const TBWidgetEvent &ev) +{ + if (ev.type == EVENT_TYPE_CHANGED && ev.target->GetID() == TBIDC("widget_list_search")) + { + m_widget_list->SetFilter(ev.target->GetText()); + return true; + } + else if (ev.type == EVENT_TYPE_CHANGED && ev.target == m_widget_list) + { + if (m_widget_list->GetValue() >= 0 && m_widget_list->GetValue() < m_widget_list_source.GetNumItems()) + if (ResourceItem *item = m_widget_list_source.GetItem(m_widget_list->GetValue())) + SetSelectedWidget(item->GetWidget()); + } + else if (ev.type == EVENT_TYPE_CHANGED && ev.target == m_source_edit) + { + RefreshFromSource(); + return true; + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("test")) + { + // Create a window containing the current layout, resize and center it. + if (TBWindow *win = new TBWindow()) + { + win->SetText("Test window"); + g_widgets_reader->LoadData(win->GetContentRoot(), m_source_edit->GetText()); + TBRect bounds(0, 0, GetParent()->GetRect().w, GetParent()->GetRect().h); + win->SetRect(win->GetResizeToFitContentRect().CenterIn(bounds).MoveIn(bounds).Clip(bounds)); + GetParent()->AddChild(win); + } + return true; + } + else if (ev.target->GetID() == TBIDC("constrained")) + { + m_scroll_container->SetAdaptContentSize(ev.target->GetValue() ? true : false); + return true; + } + else if (ev.type == EVENT_TYPE_FILE_DROP) + { + return OnDropFileEvent(ev); + } + return TBWindow::OnEvent(ev); +} + +void ResourceEditWindow::OnPaintChildren(const PaintProps &paint_props) +{ + TBWindow::OnPaintChildren(paint_props); + + // Paint the selection of the selected widget + if (TBWidget *selected_widget = GetSelectedWidget()) + { + TBRect widget_rect(0, 0, selected_widget->GetRect().w, selected_widget->GetRect().h); + selected_widget->ConvertToRoot(widget_rect.x, widget_rect.y); + ConvertFromRoot(widget_rect.x, widget_rect.y); + g_tb_skin->PaintRect(widget_rect, TBColor(255, 205, 0), 1); + } +} + +void ResourceEditWindow::OnMessageReceived(TBMessage *msg) +{ + if (msg->message == TBIDC("update_widget_list")) + UpdateWidgetList(true); +} + +bool ResourceEditWindow::OnWidgetInvokeEvent(TBWidget *widget, const TBWidgetEvent &ev) +{ + // Intercept all events to widgets in the build container + if (m_build_container->IsAncestorOf(ev.target)) + { + // Let events through if alt is pressed so we can test some + // functionality right in the editor (like toggle hidden UI). + if (ev.modifierkeys & TB_ALT) + return false; + + // Select widget when clicking + if (ev.type == EVENT_TYPE_POINTER_DOWN) + SetSelectedWidget(ev.target); + + if (ev.type == EVENT_TYPE_FILE_DROP) + OnDropFileEvent(ev); + return true; + } + return false; +} + +void ResourceEditWindow::OnWidgetAdded(TBWidget *parent, TBWidget *child) +{ + if (m_build_container && m_build_container->IsAncestorOf(child)) + UpdateWidgetList(false); +} + +void ResourceEditWindow::OnWidgetRemove(TBWidget *parent, TBWidget *child) +{ + if (m_build_container && m_build_container->IsAncestorOf(child)) + UpdateWidgetList(false); +} + +bool ResourceEditWindow::OnDropFileEvent(const TBWidgetEvent &ev) +{ + const TBWidgetEventFileDrop *fd_event = TBSafeCast(&ev); + if (fd_event->files.GetNumItems() > 0) + Load(*fd_event->files.Get(0)); + return true; +} diff --git a/tests/testtbui/ResourceEditWindow.h b/tests/testtbui/ResourceEditWindow.h new file mode 100644 index 000000000..f07a75ac8 --- /dev/null +++ b/tests/testtbui/ResourceEditWindow.h @@ -0,0 +1,81 @@ +#ifndef ResourceEditWindow_H +#define ResourceEditWindow_H + +#include "tb_widgets.h" +#include "tb_select.h" +#include "tb_widgets_common.h" +#include "tb_widgets_listener.h" +#include "tb_editfield.h" +#include "tb_msg.h" + +using namespace tb; + +namespace Tests +{ + +class ResourceItem : public TBGenericStringItem +{ +public: + ResourceItem(TBWidget* widget, const char* str); + TBWidget* + GetWidget() + { + return m_widget; + } + +private: + TBWidget* m_widget; +}; + +class ResourceEditWindow : public TBWindow, public TBMessageHandler, public TBWidgetListener +{ +public: + // For safe typecasting + TBOBJECT_SUBCLASS(ResourceEditWindow, TBWindow); + + ResourceEditWindow(); + ~ResourceEditWindow(); + + void UpdateWidgetList(bool immediately); + + struct ITEM_INFO + { + ResourceItem* item; + int index; + }; + ITEM_INFO GetItemFromWidget(TBWidget* widget); + TBWidget* + GetSelectedWidget() + { + return m_selected_widget.Get(); + } + void SetSelectedWidget(TBWidget* widget); + + void Load(const char* resource_file); + void RefreshFromSource(); + + // == TBWindow ====================================================================== + virtual bool OnEvent(const TBWidgetEvent& ev); + virtual void OnPaintChildren(const PaintProps& paint_props); + + // == TBMessageHandler ============================================================== + virtual void OnMessageReceived(TBMessage* msg); + + // == TBWidgetListener ======================================================== + virtual bool OnWidgetInvokeEvent(TBWidget* widget, const TBWidgetEvent& ev); + virtual void OnWidgetAdded(TBWidget* parent, TBWidget* child); + virtual void OnWidgetRemove(TBWidget* parent, TBWidget* child); + +private: + TBSelectList* m_widget_list; + TBSelectItemSourceList m_widget_list_source; + TBScrollContainer* m_scroll_container; + TBWidget* m_build_container; + TBEditField* m_source_edit; + TBStr m_resource_filename; + TBWidgetSafePointer m_selected_widget; + void AddWidgetListItemsRecursive(TBWidget* widget, int depth); + bool OnDropFileEvent(const TBWidgetEvent& ev); +}; +} // namespace Tests +#endif // ResourceEditWindow_H diff --git a/tests/testtbui/gamestatemanager.cc b/tests/testtbui/gamestatemanager.cc new file mode 100644 index 000000000..c83f4948f --- /dev/null +++ b/tests/testtbui/gamestatemanager.cc @@ -0,0 +1,959 @@ +//------------------------------------------------------------------------------ +// gamestatemanager.cc +// (C) 2020-2024 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ + +#include "application/stdneb.h" +#include "gamestatemanager.h" +#include "models/modelcontext.h" +#include "graphics/graphicsentity.h" +#include "visibility/visibilitycontext.h" +#include "graphicsfeature/graphicsfeatureunit.h" +#include "basegamefeature/components/basegamefeature.h" +#include "basegamefeature/components/position.h" +#include "basegamefeature/components/orientation.h" +#include "basegamefeature/components/velocity.h" +#include "physicsfeature/components/physicsfeature.h" +#include "physicsfeature/managers/physicsmanager.h" +#include "physics/actorcontext.h" +#include "input/inputserver.h" +#include "input/keyboard.h" +#include "dynui/im3d/im3dcontext.h" +#include "imgui.h" +#include "util/random.h" +#include "characters/charactercontext.h" +#include "models/nodes/shaderstatenode.h" +#include "dynui/im3d/im3d.h" +#include "lighting/lightcontext.h" +#include "decals/decalcontext.h" +#include "resources/resourceserver.h" +#include "terrain/terraincontext.h" +#include "coregraphics/legacy/nvx2streamreader.h" +#include "coregraphics/primitivegroup.h" +#include "basegamefeature/level.h" + +#include "graphicsfeature/managers/graphicsmanager.h" +#include "game/gameserver.h" +#include "game/api.h" + +#ifdef __WIN32__ +#include +#elif __LINUX__ + +#endif + +#include "tbui/tbuicontext.h" +#include "ListWindow.h" +#include "ResourceEditWindow.h" +#include "animation/tb_animation.h" +#include "tests/tb_test.h" +#include "tb_system.h" +#include "tb_language.h" +#include "tb_inline_select.h" +#include "tb_select.h" +#include "tb_menu_window.h" +#include "tb_editfield.h" +#include "tb_tab_container.h" +#include "tb_bitmap_fragment.h" +#include "animation/tb_widget_animation.h" +#include "tb_node_tree.h" +#include "tb_tempbuffer.h" +#include "tb_font_renderer.h" + +namespace Tests +{ + +// ====================================================== + +int fps = 0; +uint32 frame_counter_total = 0; +uint32 frame_counter = 0; +double frame_counter_reset_time = 0; + +const char* girl_names[] = {"Maja", "Alice", "Julia", "Linnéa", "Wilma", "Ella", "Elsa", "Emma", "Alva", + "Olivia", "Molly", "Ebba", "Klara", "Nellie", "Agnes", "Isabelle", "Ida", "Elin", + "Ellen", "Moa", "Emilia", "Nova", "Alma", "Saga", "Amanda", "Isabella", "Lilly", + "Alicia", "Astrid", "Matilda", "Tuva", "Tilde", "Stella", "Felicia", "Elvira", "Tyra", + "Hanna", "Sara", "Vera", "Thea", "Freja", "Lova", "Selma", "Meja", "Signe", + "Ester", "Lovisa", "Ellie", "Lea", "Tilda", "Tindra", "Sofia", "Nora", "Nathalie", + "Leia", "Filippa", "Siri", "Emelie", "Inez", "Edith", "Stina", "Liv", "Lisa", + "Linn", "Tove", "Emmy", "Livia", "Jasmine", "Evelina", "Cornelia", "Märta", "Svea", + "Ingrid", "My", "Rebecca", "Joline", "Mira", "Ronja", "Hilda", "Melissa", "Anna", + "Frida", "Maria", "Iris", "Josefine", "Elise", "Elina", "Greta", "Vilda", "Minna", + "Lina", "Hedda", "Nicole", "Kajsa", "Majken", "Sofie", "Annie", "Juni", "Novalie", + "Hedvig", nullptr}; +const char* boy_names[] = {"Oscar", "William", "Lucas", "Elias", "Alexander", "Hugo", "Oliver", "Theo", + "Liam", "Leo", "Viktor", "Erik", "Emil", "Isak", "Axel", "Filip", + "Anton", "Gustav", "Edvin", "Vincent", "Arvid", "Albin", "Ludvig", "Melvin", + "Noah", "Charlie", "Max", "Elliot", "Viggo", "Alvin", "Alfred", "Theodor", + "Adam", "Olle", "Wilmer", "Benjamin", "Simon", "Nils", "Noel", "Jacob", + "Leon", "Rasmus", "Kevin", "Linus", "Casper", "Gabriel", "Jonathan", "Milo", + "Melker", "Felix", "Love", "Ville", "Sebastian", "Sixten", "Carl", "Malte", + "Neo", "David", "Joel", "Adrian", "Valter", "Josef", "Jack", "Hampus", + "Samuel", "Mohammed", "Alex", "Tim", "Daniel", "Vilgot", "Wilhelm", "Harry", + "Milton", "Maximilian", "Robin", "Sigge", "Måns", "Eddie", "Elton", "Vidar", + "Hjalmar", "Loke", "Elis", "August", "John", "Hannes", "Sam", "Frank", + "Svante", "Marcus", "Mio", "Otto", "Ali", "Johannes", "Fabian", "Ebbe", + "Aron", "Julian", "Elvin", "Ivar", nullptr}; + +AdvancedItemSource advanced_source; +tb::TBGenericStringItemSource name_source; +tb::TBGenericStringItemSource popup_menu_source; + +// == DemoWindow ============================================================== + +DemoWindow::DemoWindow(TBWidget* root) +{ + root->AddChild(this); +} + +bool +DemoWindow::LoadResourceFile(const char* filename) +{ + // We could do g_widgets_reader->LoadFile(this, filename) but we want + // some extra data we store under "WindowInfo", so read into node tree. + TBNode node; + if (!node.ReadFile(filename)) + return false; + LoadResource(node); + return true; +} + +void +DemoWindow::LoadResourceData(const char* data) +{ + // We could do g_widgets_reader->LoadData(this, filename) but we want + // some extra data we store under "WindowInfo", so read into node tree. + TBNode node; + node.ReadData(data); + LoadResource(node); +} + +void +DemoWindow::LoadResource(TBNode& node) +{ + g_widgets_reader->LoadNodeTree(this, &node); + + // Get title from the WindowInfo section (or use "" if not specified) + SetText(node.GetValueString("WindowInfo>title", "")); + + const TBRect parent_rect(0, 0, GetParent()->GetRect().w, GetParent()->GetRect().h); + const TBDimensionConverter* dc = tb::g_tb_skin->GetDimensionConverter(); + TBRect window_rect = GetResizeToFitContentRect(); + + // Use specified size or adapt to the preferred content size. + TBNode* tmp = node.GetNode("WindowInfo>size"); + if (tmp && tmp->GetValue().GetArrayLength() == 2) + { + window_rect.w = dc->GetPxFromString(tmp->GetValue().GetArray()->GetValue(0)->GetString(), window_rect.w); + window_rect.h = dc->GetPxFromString(tmp->GetValue().GetArray()->GetValue(1)->GetString(), window_rect.h); + } + + // Use the specified position or center in parent. + tmp = node.GetNode("WindowInfo>position"); + if (tmp && tmp->GetValue().GetArrayLength() == 2) + { + window_rect.x = dc->GetPxFromString(tmp->GetValue().GetArray()->GetValue(0)->GetString(), window_rect.x); + window_rect.y = dc->GetPxFromString(tmp->GetValue().GetArray()->GetValue(1)->GetString(), window_rect.y); + } + else + window_rect = window_rect.CenterIn(parent_rect); + + // Make sure the window is inside the parent, and not larger. + window_rect = window_rect.MoveIn(parent_rect).Clip(parent_rect); + + SetRect(window_rect); + + // Ensure we have focus - now that we've filled the window with possible focusable + // widgets. EnsureFocus was automatically called when the window was activated (by + // adding the window to the root), but then we had nothing to focus. + // Alternatively, we could add the window after setting it up properly. + EnsureFocus(); +} + +bool +DemoWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_KEY_DOWN && ev.special_key == TB_KEY_ESC) + { + // We could call Die() to fade away and die, but click the close button instead. + // That way the window has a chance of intercepting the close and f.ex ask if it really should be closed. + TBWidgetEvent click_ev(EVENT_TYPE_CLICK); + m_close_button.InvokeEvent(click_ev); + return true; + } + return TBWindow::OnEvent(ev); +} + +// == LayoutWindow ============================================================ + +LayoutWindow::LayoutWindow(TBWidget* root, const char* filename) + : DemoWindow(root) +{ + LoadResourceFile(filename); +} + +bool +LayoutWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CHANGED && ev.target->GetID() == TBIDC("select position")) + { + LAYOUT_POSITION pos = LAYOUT_POSITION_CENTER; + if (TBSelectDropdown* select = GetWidgetByIDAndType(TBIDC("select position"))) + pos = static_cast(select->GetValue()); + for (int i = 0; i < 3; i++) + if (TBLayout* layout = GetWidgetByIDAndType(i + 1)) + layout->SetLayoutPosition(pos); + return true; + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("toggle axis")) + { + static AXIS axis = AXIS_Y; + for (int i = 0; i < 3; i++) + if (TBLayout* layout = GetWidgetByIDAndType(i + 1)) + layout->SetAxis(axis); + axis = axis == AXIS_X ? AXIS_Y : AXIS_X; + if (TBLayout* layout = GetWidgetByIDAndType(TBIDC("switch_layout"))) + layout->SetAxis(axis); + ResizeToFitContent(RESIZE_FIT_CURRENT_OR_NEEDED); + return true; + } + return DemoWindow::OnEvent(ev); +} + +// == TabContainerWindow ============================================================ + +TabContainerWindow::TabContainerWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_tabcontainer01.tb.txt"); +} + +bool +TabContainerWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("set_align")) + { + if (TBTabContainer* tc = GetWidgetByIDAndType(TBIDC("tabcontainer"))) + tc->SetAlignment(static_cast(ev.target->data.GetInt())); + ResizeToFitContent(RESIZE_FIT_CURRENT_OR_NEEDED); + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("toggle_tab_axis")) + { + static AXIS axis = AXIS_X; + axis = axis == AXIS_X ? AXIS_Y : AXIS_X; + if (TBTabContainer* tc = GetWidgetByIDAndType(TBIDC("tabcontainer"))) + { + for (TBWidget* child = tc->GetTabLayout()->GetFirstChild(); child; child = child->GetNext()) + { + if (TBButton* button = TBSafeCast(child)) + button->SetAxis(axis); + } + } + ResizeToFitContent(RESIZE_FIT_CURRENT_OR_NEEDED); + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("start_spinner")) + { + if (TBProgressSpinner* spinner = GetWidgetByIDAndType(TBIDC("spinner"))) + spinner->SetValue(1); + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("stop_spinner")) + { + if (TBProgressSpinner* spinner = GetWidgetByIDAndType(TBIDC("spinner"))) + spinner->SetValue(0); + } + return DemoWindow::OnEvent(ev); +} + +// == ConnectionWindow ========================================================= + +ConnectionWindow::ConnectionWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_connections.tb.txt"); +} + +bool +ConnectionWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("reset-master-volume")) + { + if (TBWidgetValue* val = g_value_group.GetValue(TBIDC("master-volume"))) + val->SetInt(50); + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("reset-user-name")) + { + if (TBWidgetValue* val = g_value_group.GetValue(TBIDC("user-name"))) + val->SetText(""); + } + return DemoWindow::OnEvent(ev); +} + +// == ScrollContainerWindow =================================================== + +ScrollContainerWindow::ScrollContainerWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_scrollcontainer.tb.txt"); + + if (TBSelectDropdown* select = GetWidgetByIDAndType(TBIDC("name dropdown"))) + select->SetSource(&name_source); + + if (TBSelectDropdown* select = GetWidgetByIDAndType(TBIDC("advanced dropdown"))) + select->SetSource(&advanced_source); +} + +bool +ScrollContainerWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK) + { + if (ev.target->GetID() == TBIDC("add img")) + { + TBButton* button = TBSafeCast(ev.target); + TBSkinImage* skin_image = new TBSkinImage; + skin_image->SetSkinBg(TBIDC("Icon16")); + button->GetContentRoot()->AddChild(skin_image, WIDGET_Z_BOTTOM); + return true; + } + else if (ev.target->GetID() == TBIDC("new buttons")) + { + for (int i = 0; i < ev.target->data.GetInt(); i++) + { + TBStr str; + str.SetFormatted("Remove %d", i); + TBButton* button = new TBButton; + button->SetID(TBIDC("remove button")); + button->SetText(str); + ev.target->GetParent()->AddChild(button); + } + return true; + } + else if (ev.target->GetID() == TBIDC("new buttons delayed")) + { + for (int i = 0; i < ev.target->data.GetInt(); i++) + { + TBMessageData* data = new TBMessageData(); + data->id1 = ev.target->GetParent()->GetID(); + data->v1.SetInt(i); + PostMessageDelayed(TBIDC("new button"), data, 100 + i * 500); + } + return true; + } + else if (ev.target->GetID() == TBIDC("remove button")) + { + ev.target->GetParent()->RemoveChild(ev.target); + delete ev.target; + return true; + } + else if (ev.target->GetID() == TBIDC("showpopupmenu1")) + { + if (TBMenuWindow* menu = new TBMenuWindow(ev.target, TBIDC("popupmenu1"))) + menu->Show(&popup_menu_source, TBPopupAlignment()); + return true; + } + else if (ev.target->GetID() == TBIDC("popupmenu1")) + { + TBStr str; + str.SetFormatted("Menu event received!\nref_id: %d", (int)ev.ref_id); + TBMessageWindow* msg_win = new TBMessageWindow(this, TBIDC("popup_dialog")); + msg_win->Show("Info", str); + return true; + } + } + return DemoWindow::OnEvent(ev); +} + +void +ScrollContainerWindow::OnMessageReceived(TBMessage* msg) +{ + if (msg->message == TBIDC("new button") && msg->data) + { + if (TBWidget* target = GetWidgetByID(msg->data->id1)) + { + TBStr str; + str.SetFormatted("Remove %d", msg->data->v1.GetInt()); + TBButton* button = new TBButton; + button->SetID(TBIDC("remove button")); + button->SetText(str); + target->AddChild(button); + } + } +} + +// == ImageWindow ============================================================= + +ImageWindow::ImageWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_image_widget.tb.txt"); +} + +bool +ImageWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("remove")) + { + TBWidget* image = ev.target->GetParent(); + image->GetParent()->RemoveChild(image); + delete image; + return true; + } + return DemoWindow::OnEvent(ev); +} + +// == PageWindow ============================================================= + +PageWindow::PageWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_scroller_snap.tb.txt"); + + // Listen to the pagers scroller + if (TBWidget* pager = GetWidgetByID(TBIDC("page-scroller"))) + pager->GetScroller()->SetSnapListener(this); +} + +bool +PageWindow::OnEvent(const TBWidgetEvent& ev) +{ + return DemoWindow::OnEvent(ev); +} + +void +PageWindow::OnScrollSnap(TBWidget* target_widget, int& target_x, int& target_y) +{ + int page_w = target_widget->GetPaddingRect().w; + int target_page = (target_x + page_w / 2) / page_w; + target_x = target_page * page_w; +} + +// == AnimationsWindow ======================================================== + +AnimationsWindow::AnimationsWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_animations.tb.txt"); + Animate(); +} + +void +AnimationsWindow::Animate() +{ + // Abort any still unfinished animations. + TBWidgetsAnimationManager::AbortAnimations(this); + + ANIMATION_CURVE curve = ANIMATION_CURVE_SLOW_DOWN; + double duration = 500; + bool fade = true; + + if (TBSelectList* curve_select = GetWidgetByIDAndType("curve")) + curve = static_cast(curve_select->GetValue()); + if (TBInlineSelect* duration_select = GetWidgetByIDAndType("duration")) + duration = duration_select->GetValueDouble(); + if (TBCheckBox* fade_check = GetWidgetByIDAndType("fade")) + fade = fade_check->GetValue() ? true : false; + + // Start move animation + if (TBAnimationObject* anim = new TBWidgetAnimationRect(this, GetRect().Offset(-GetRect().x - GetRect().w, 0), GetRect())) + TBAnimationManager::StartAnimation(anim, curve, duration); + // Start fade animation + if (fade) + { + if (TBAnimationObject* anim = new TBWidgetAnimationOpacity(this, TB_ALMOST_ZERO_OPACITY, 1, false)) + TBAnimationManager::StartAnimation(anim, ANIMATION_CURVE_SLOW_DOWN, duration); + } +} + +bool +AnimationsWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("Animate!")) + Animate(); + return DemoWindow::OnEvent(ev); +} + +// == MainWindow ============================================================== + +MainWindow::MainWindow(TBWidget* root) + : DemoWindow(root) +{ + LoadResourceFile("tb:demo/ui_resources/test_ui.tb.txt"); + + SetOpacity(0.97f); +} + +void +MainWindow::OnMessageReceived(TBMessage* msg) +{ + if (msg->message == TBIDC("instantmsg")) + { + TBMessageWindow* msg_win = new TBMessageWindow(this, TBIDC("test_dialog")); + msg_win->Show("Message window", "Instant message received!"); + } + else if (msg->message == TBIDC("busy")) + { + // Keep the message queue busy by posting another "busy" message. + this->PostMessage(TBIDC("busy"), nullptr); + } + else if (msg->message == TBIDC("delayedmsg")) + { + TBStr text; + text.SetFormatted( + "Delayed message received!\n\n" + "It was received %d ms after its intended fire time.", + (int)(TBSystem::GetTimeMS() - msg->GetFireTime()) + ); + TBMessageWindow* msg_win = new TBMessageWindow(this, TBIDC("")); + msg_win->Show("Message window", text); + } +} + +bool +MainWindow::OnEvent(const TBWidgetEvent& ev) +{ + if (ev.type == EVENT_TYPE_CLICK) + { + if (ev.target->GetID() == TBIDC("new")) + { + new MainWindow(GetParentRoot()); + return true; + } + if (ev.target->GetID() == TBIDC("msg")) + { + this->PostMessage(TBIDC("instantmsg"), nullptr); + return true; + } + else if (ev.target->GetID() == TBIDC("busymsg")) + { + if (ev.target->GetValue() == 1) + { + // Post the first "busy" message when we check the checkbox. + assert(!GetMessageByID(TBIDC("busy"))); + if (!GetMessageByID(TBIDC("busy"))) + { + this->PostMessage(TBIDC("busy"), nullptr); + TBMessageWindow* msg_win = new TBMessageWindow(this, TBIDC("test_dialog")); + msg_win->Show( + "Message window", + "The message loop is now constantly busy with messages to process.\n\n" + "The main thread should be working hard, but input & animations should still be running smoothly." + ); + } + } + else + { + // Remove any pending "busy" message when we uncheck the checkbox. + assert(GetMessageByID(TBIDC("busy"))); + if (TBMessage* busymsg = GetMessageByID(TBIDC("busy"))) + DeleteMessage(busymsg); + } + return true; + } + else if (ev.target->GetID() == TBIDC("delayedmsg")) + { + PostMessageDelayed(TBIDC("delayedmsg"), nullptr, 2000); + return true; + } + else if (ev.target->GetID() == TBIDC("TBWindow.close")) + { + // Intercept the TBWindow.close message and stop it from bubbling + // to TBWindow (prevent the window from closing) + TBMessageWindow* msg_win = new TBMessageWindow(this, TBIDC("confirm_close_dialog")); + TBMessageWindowSettings settings(TB_MSG_YES_NO, TBIDC("Icon48")); + settings.dimmer = true; + settings.styling = true; + msg_win->Show("Are you sure?", "Really close the window?", &settings); + return true; + } + else if (ev.target->GetID() == TBIDC("confirm_close_dialog")) + { + if (ev.ref_id == TBIDC("TBMessageWindow.yes")) + Close(); + return true; + } + else if (ev.target->GetID() == TBIDC("reload skin bitmaps")) + { + int reload_count = 10; + double t1 = TBSystem::GetTimeMS(); + for (int i = 0; i < reload_count; i++) + tb::g_tb_skin->ReloadBitmaps(); + double t2 = TBSystem::GetTimeMS(); + + TBStr message; + message.SetFormatted("Reloading the skin graphics %d times took %dms", reload_count, (int)(t2 - t1)); + TBMessageWindow* msg_win = new TBMessageWindow(ev.target, TBID()); + msg_win->Show("GFX load performance", message); + return true; + } + else if (ev.target->GetID() == TBIDC("test context lost")) + { + g_renderer->InvokeContextLost(); + g_renderer->InvokeContextRestored(); + TBMessageWindow* msg_win = new TBMessageWindow(ev.target, TBID()); + msg_win->Show( + "Context lost & restore", + "Called InvokeContextLost and InvokeContextRestored.\n\n" + "Does everything look fine?" + ); + return true; + } + else if (ev.target->GetID() == TBIDC("test-layout")) + { + TBStr resource_file("tb:demo/ui_resources/"); + resource_file.Append(ev.target->data.GetString()); + new LayoutWindow(GetParentRoot(), resource_file); + return true; + } + else if (ev.target->GetID() == TBIDC("test-connections")) + { + new ConnectionWindow(GetParentRoot()); + return true; + } + else if (ev.target->GetID() == TBIDC("test-list")) + { + new AdvancedListWindow(GetParentRoot(), &advanced_source); + return true; + } + else if (ev.target->GetID() == TBIDC("test-image")) + { + new ImageWindow(GetParentRoot()); + return true; + } + else if (ev.target->GetID() == TBIDC("test-page")) + { + new PageWindow(GetParentRoot()); + return true; + } + else if (ev.target->GetID() == TBIDC("test-animations")) + { + new AnimationsWindow(GetParentRoot()); + return true; + } + else if (ev.target->GetID() == TBIDC("test-scroll-container")) + { + new ScrollContainerWindow(GetParentRoot()); + return true; + } + else if (ev.target->GetID() == TBIDC("test-skin-conditions")) + { + (new DemoWindow(GetParentRoot()))->LoadResourceFile("tb:demo/ui_resources/test_skin_conditions01.tb.txt"); + (new DemoWindow(GetParentRoot()))->LoadResourceFile("tb:demo/ui_resources/test_skin_conditions02.tb.txt"); + return true; + } + else if (ev.target->GetID() == TBIDC("test-resource-edit")) + { + ResourceEditWindow* res_edit_win = new ResourceEditWindow(); + res_edit_win->Load("tb:demo/ui_resources/resource_edit_test.tb.txt"); + GetParent()->AddChild(res_edit_win); + return true; + } + else if (ev.type == EVENT_TYPE_CLICK && ev.target->GetID() == TBIDC("debug settings")) + { +#ifdef TB_RUNTIME_DEBUG_INFO + ShowDebugInfoSettingsWindow(GetParentRoot()); +#else + TBMessageWindow* msg_win = new TBMessageWindow(ev.target, TBID()); + msg_win->Show( + "Debug settings", + "Debug settings is only available in builds " + "compiled with TB_RUNTIME_DEBUG_INFO defined.\n\n" + "Debug builds enable this by default." + ); +#endif + return true; + } + } + return DemoWindow::OnEvent(ev); +} + +// == EditWindow ============================================================== + +class EditWindow : public DemoWindow +{ +public: + EditWindow(TBWidget* root) + : DemoWindow(root) + { + LoadResourceFile("tb:demo/ui_resources/test_textwindow.tb.txt"); + } + virtual void + OnProcessStates() + { + // Update the disabled state of undo/redo buttons, and caret info. + + if (TBEditField* edit = GetWidgetByIDAndType(TBIDC("editfield"))) + { + if (TBWidget* undo = GetWidgetByID("undo")) + undo->SetState(WIDGET_STATE_DISABLED, !edit->GetStyleEdit()->CanUndo()); + if (TBWidget* redo = GetWidgetByID("redo")) + redo->SetState(WIDGET_STATE_DISABLED, !edit->GetStyleEdit()->CanRedo()); + if (TBTextField* info = GetWidgetByIDAndType(TBIDC("info"))) + { + TBStr text; + text.SetFormatted("Caret ofs: %d", edit->GetStyleEdit()->caret.GetGlobalOfs()); + info->SetText(text); + } + } + } + virtual bool + OnEvent(const TBWidgetEvent& ev) + { + if (ev.type == EVENT_TYPE_CLICK) + { + TBEditField* edit = GetWidgetByIDAndType(TBIDC("editfield")); + if (!edit) + return false; + + if (ev.target->GetID() == TBIDC("clear")) + { + edit->SetText(""); + return true; + } + else if (ev.target->GetID() == TBIDC("undo")) + { + edit->GetStyleEdit()->Undo(); + return true; + } + else if (ev.target->GetID() == TBIDC("redo")) + { + edit->GetStyleEdit()->Redo(); + return true; + } + else if (ev.target->GetID() == TBIDC("menu")) + { + static TBGenericStringItemSource source; + if (!source.GetNumItems()) + { + source.AddItem(new TBGenericStringItem("Default font", TBIDC("default font"))); + source.AddItem(new TBGenericStringItem("Default font (larger)", TBIDC("large font"))); + source.AddItem(new TBGenericStringItem("RGB font (Neon)", TBIDC("rgb font Neon"))); + source.AddItem(new TBGenericStringItem("RGB font (Orangutang)", TBIDC("rgb font Orangutang"))); + source.AddItem(new TBGenericStringItem("RGB font (Orange)", TBIDC("rgb font Orange"))); + source.AddItem(new TBGenericStringItem("-")); + source.AddItem(new TBGenericStringItem("Glyph cache stresstest (CJK)", TBIDC("CJK"))); + source.AddItem(new TBGenericStringItem("-")); + source.AddItem(new TBGenericStringItem("Toggle wrapping", TBIDC("toggle wrapping"))); + source.AddItem(new TBGenericStringItem("-")); + source.AddItem(new TBGenericStringItem("Align left", TBIDC("align left"))); + source.AddItem(new TBGenericStringItem("Align center", TBIDC("align center"))); + source.AddItem(new TBGenericStringItem("Align right", TBIDC("align right"))); + } + + if (TBMenuWindow* menu = new TBMenuWindow(ev.target, TBIDC("popup_menu"))) + menu->Show(&source, TBPopupAlignment()); + return true; + } + else if (ev.target->GetID() == TBIDC("popup_menu")) + { + if (ev.ref_id == TBIDC("default font")) + edit->SetFontDescription(TBFontDescription()); + else if (ev.ref_id == TBIDC("large font")) + { + TBFontDescription fd = tb::g_font_manager->GetDefaultFontDescription(); + fd.SetSize(28); + edit->SetFontDescription(fd); + } + else if (ev.ref_id == TBIDC("rgb font Neon")) + { + TBFontDescription fd = edit->GetCalculatedFontDescription(); + fd.SetID(TBIDC("Neon")); + edit->SetFontDescription(fd); + } + else if (ev.ref_id == TBIDC("rgb font Orangutang")) + { + TBFontDescription fd = edit->GetCalculatedFontDescription(); + fd.SetID(TBIDC("Orangutang")); + edit->SetFontDescription(fd); + } + else if (ev.ref_id == TBIDC("rgb font Orange")) + { + TBFontDescription fd = edit->GetCalculatedFontDescription(); + fd.SetID(TBIDC("Orange")); + edit->SetFontDescription(fd); + } + else if (ev.ref_id == TBIDC("CJK")) + { + TBTempBuffer buf; + for (int i = 0, cp = 0x4E00; cp <= 0x9FCC; cp++, i++) + { + char utf8[8]; + int len = utf8::encode(cp, utf8); + buf.Append(utf8, len); + if (i % 64 == 63) + buf.Append("\n", 1); + } + edit->GetStyleEdit()->SetText(buf.GetData(), buf.GetAppendPos()); + } + else if (ev.ref_id == TBIDC("toggle wrapping")) + edit->SetWrapping(!edit->GetWrapping()); + else if (ev.ref_id == TBIDC("align left")) + edit->SetTextAlign(TB_TEXT_ALIGN_LEFT); + else if (ev.ref_id == TBIDC("align center")) + edit->SetTextAlign(TB_TEXT_ALIGN_CENTER); + else if (ev.ref_id == TBIDC("align right")) + edit->SetTextAlign(TB_TEXT_ALIGN_RIGHT); + return true; + } + } + return DemoWindow::OnEvent(ev); + } +}; + +__ImplementClass(Tests::GameStateManager, 'DGSM', Game::Manager); +__ImplementSingleton(GameStateManager) + + //------------------------------------------------------------------------------ + /** +*/ + GameStateManager::GameStateManager() {__ConstructSingleton} + +//------------------------------------------------------------------------------ +/** +*/ +GameStateManager::~GameStateManager() +{ + __DestructSingleton +} + +//------------------------------------------------------------------------------ +/** +*/ + +void +GameStateManager::OnActivate() +{ + Game::Manager::OnActivate(); + + view = TBUI::TBUIContext::CreateView(2560, 1480); + + { + // Block new animations during Init. + tb::TBAnimationBlocker anim_blocker; + + // Run unit tests + int num_failed_tests = 0; + //TBRunTests(); + + // TBSelectList and TBSelectDropdown widgets have a default item source that are fed with any items + // specified in the resource files. But it is also possible to set any source which can save memory + // and improve performance. Then you don't have to populate each instance with its own set of items, + // for widgets that occur many times in a UI, always with the same items. + // Here we prepare the name source, that is used in a few places. + for (int i = 0; boy_names[i]; i++) + advanced_source.AddItem(new AdvancedItem(boy_names[i++], TBIDC("boy_item"), true)); + for (int i = 0; girl_names[i]; i++) + advanced_source.AddItem(new AdvancedItem(girl_names[i++], TBIDC("girl_item"), false)); + for (int i = 0; girl_names[i]; i++) + name_source.AddItem(new TBGenericStringItem(girl_names[i++], TBIDC("girl_item"))); + for (int i = 0; boy_names[i]; i++) + name_source.AddItem(new TBGenericStringItem(boy_names[i++], TBIDC("boy_item"))); + advanced_source.SetSort(TB_SORT_ASCENDING); + name_source.SetSort(TB_SORT_ASCENDING); + + // Prepare a source with submenus (with eternal recursion) so we can test sub menu support. + popup_menu_source.AddItem(new TBGenericStringItem("Option 1", TBIDC("opt 1"))); + popup_menu_source.AddItem(new TBGenericStringItem("Option 2", TBIDC("opt 2"))); + popup_menu_source.AddItem(new TBGenericStringItem("-")); + popup_menu_source.AddItem(new TBGenericStringItem("Same submenu", &popup_menu_source)); + popup_menu_source.AddItem(new TBGenericStringItem("Long submenu", &name_source)); + // Give the first item a skin image + popup_menu_source.GetItem(0)->SetSkinImage(TBIDC("Icon16")); + + new MainWindow(view); + + new EditWindow(view); + + new ListWindow(view, &name_source); + + new AdvancedListWindow(view, &advanced_source); + + new TabContainerWindow(view); + + if (num_failed_tests) + { + TBStr text; + text.SetFormatted("There is %d failed tests!\nCheck the output for details.", num_failed_tests); + TBMessageWindow* msg_win = new TBMessageWindow(view, TBIDC("")); + msg_win->Show("Testing results", text); + } + } + //view->SetSkinBg(TBIDC("background")); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +GameStateManager::OnDeactivate() +{ + TBUI::TBUIContext::DestroyView(view); + + Game::Manager::OnDeactivate(); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +GameStateManager::OnBeginFrame() +{ + if (Input::InputServer::Instance()->GetDefaultKeyboard()->KeyPressed(Input::Key::Escape)) + { + Core::SysFunc::Exit(0); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +void +GameStateManager::OnFrame() +{ +#if __NEBULA_HTTP__ + if (Input::InputServer::Instance()->GetDefaultKeyboard()->KeyDown(Input::Key::F1)) + { + // Open browser with debug page. + Util::String url = "http://localhost:2100"; +#ifdef __WIN32__ + ShellExecute(0, 0, url.AsCharPtr(), 0, 0, SW_SHOW); +#elif __LINUX__ + Util::String shellCommand = "open "; + shellCommand.Append(url); + system(shellCommand.AsCharPtr()); +#else + n_printf("Cannot open browser. URL is %s\n", url.AsCharPtr()); +#endif + } +#endif + { + frame_counter++; + frame_counter_total++; + + // Update the FPS counter + double time = TBSystem::GetTimeMS(); + if (time > frame_counter_reset_time + 1000) + { + fps = (int)((frame_counter / (time - frame_counter_reset_time)) * 1000); + frame_counter_reset_time = time; + frame_counter = 0; + } + + // Draw FPS + TBWidgetValue* continuous_repaint_val = g_value_group.GetValue(TBIDC("continous-repaint")); + bool continuous_repaint = continuous_repaint_val ? !!continuous_repaint_val->GetInt() : 0; + + TBStr str; + if (continuous_repaint) + str.SetFormatted("FPS: %d Frame %d", fps, frame_counter_total); + else + str.SetFormatted("Frame %d", frame_counter_total); + view->GetFont()->DrawString(5, 5, TBColor(255, 255, 255), str); + + // If we want continous updates or got animations running, reinvalidate immediately + if (continuous_repaint || TBAnimationManager::HasAnimationsRunning()) + view->Invalidate(); + } +} + +} // namespace Tests diff --git a/tests/testtbui/gamestatemanager.h b/tests/testtbui/gamestatemanager.h new file mode 100644 index 000000000..753c5f6bd --- /dev/null +++ b/tests/testtbui/gamestatemanager.h @@ -0,0 +1,121 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + @class Tests::GameStateManager + + (C) 2020 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "core/refcounted.h" +#include "core/singleton.h" +#include "game/manager.h" +#include "renderutil/mouserayutil.h" +#include "input/keyboard.h" +#include "input/mouse.h" +#include "input/inputserver.h" +#include "io/ioserver.h" +#include "graphics/cameracontext.h" +#include "models/nodes/primitivenode.h" +#include "models/modelcontext.h" +#include "imgui.h" +#include "dynui/im3d/im3d.h" +#include "dynui/im3d/im3dcontext.h" +#include "timing/timer.h" +#include "tbui/tbuiview.h" + +#include "tb_widgets.h" +#include "tb_widgets_common.h" +#include "tb_widgets_reader.h" +#include "tb_widgets_listener.h" +#include "tb_message_window.h" +#include "tb_msg.h" +#include "tb_scroller.h" +#include "ListWindow.h" +#include "ResourceEditWindow.h" + +namespace Tests +{ +using namespace tb; + +class MainWindow : public DemoWindow, public TBMessageHandler +{ +public: + MainWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); + + // Implement TBMessageHandler + virtual void OnMessageReceived(TBMessage* msg); +}; + +class ImageWindow : public DemoWindow +{ +public: + ImageWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +class PageWindow : public DemoWindow, public TBScrollerSnapListener +{ +public: + PageWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); + virtual void OnScrollSnap(TBWidget* target_widget, int& target_x, int& target_y); +}; + +class AnimationsWindow : public DemoWindow +{ +public: + AnimationsWindow(TBWidget* root); + void Animate(); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +class LayoutWindow : public DemoWindow +{ +public: + LayoutWindow(TBWidget* root, const char* filename); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +class TabContainerWindow : public DemoWindow +{ +public: + TabContainerWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +class ConnectionWindow : public DemoWindow +{ +public: + ConnectionWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); +}; + +class ScrollContainerWindow : public DemoWindow, public TBMessageHandler +{ +public: + ScrollContainerWindow(TBWidget* root); + virtual bool OnEvent(const TBWidgetEvent& ev); + + // Implement TBMessageHandler + virtual void OnMessageReceived(TBMessage* msg); +}; + +class GameStateManager : public Game::Manager +{ + __DeclareClass(GameStateManager) + __DeclareSingleton(GameStateManager) +public: + GameStateManager(); + virtual ~GameStateManager(); + + void OnActivate() override; + void OnDeactivate() override; + void OnBeginFrame() override; + void OnFrame() override; + + private: + TBUI::TBUIView* view = nullptr; +}; + +} // namespace Demo diff --git a/tests/testtbui/main.cc b/tests/testtbui/main.cc new file mode 100644 index 000000000..b5b684127 --- /dev/null +++ b/tests/testtbui/main.cc @@ -0,0 +1,98 @@ +//------------------------------------------------------------------------------ +// main.cc +// (C) 2020 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#define NEBULA_EDITOR_ENABLED + +#include "application/stdneb.h" +#include "system/appentry.h" +#include "basegamefeature/basegamefeatureunit.h" +#include "graphicsfeature/graphicsfeatureunit.h" +#include "appgame/gameapplication.h" +#include "tbuifeatureunit.h" +#include "gamestatemanager.h" +#include "profiling/profiling.h" + +#ifdef NEBULA_EDITOR_ENABLED +#include "editorfeature/editorfeatureunit.h" +#endif + +#include "nflatbuffer/nebula_flat.h" +#include "nflatbuffer/flatbufferinterface.h" +#include "flat/graphicsfeature/terrainschema.h" + +ImplementNebulaApplication(); + +using namespace Core; + + +class NebulaDemoApplication : public App::GameApplication +{ +private: + /// setup game features + void SetupGameFeatures() + { +#if NEBULA_ENABLE_PROFILING + Profiling::ProfilingRegisterThread(); +#endif + this->graphicsFeature = GraphicsFeature::GraphicsFeatureUnit::Create(); + this->graphicsFeature->SetCmdLineArgs(this->GetCmdLineArgs()); + this->gameServer->AttachGameFeature(this->graphicsFeature); + + this->demoFeatureUnit = Tests::TBUIFeatureUnit::Create(); + this->gameServer->AttachGameFeature(this->demoFeatureUnit); + +#ifdef NEBULA_EDITOR_ENABLED + this->editorFeatureUnit = EditorFeature::EditorFeatureUnit::Create(); + this->gameServer->AttachGameFeature(this->editorFeatureUnit); +#endif + + Flat::FlatbufferInterface::LoadSchema("data:flatbuffer/graphicsfeature/terrainschema.bfbs"_uri); + IO::URI tablePath = "proj:work/data/tables/terrain.json"_uri; + CompileFlatbuffer(GraphicsFeature::TerrainSetup, tablePath, "data:tables/graphicsfeature"); + } + /// cleanup game features + void CleanupGameFeatures() + { + this->gameServer->RemoveGameFeature(this->graphicsFeature); + this->gameServer->RemoveGameFeature(this->demoFeatureUnit); + this->graphicsFeature->Release(); + this->graphicsFeature = nullptr; + this->demoFeatureUnit->Release(); + this->demoFeatureUnit = nullptr; + +#ifdef NEBULA_EDITOR_ENABLED + this->gameServer->RemoveGameFeature(this->editorFeatureUnit); + this->editorFeatureUnit->Release(); + this->editorFeatureUnit = nullptr; +#endif + } + + Ptr graphicsFeature; + Ptr demoFeatureUnit; + +#ifdef NEBULA_EDITOR_ENABLED + Ptr editorFeatureUnit; +#endif +}; + +//------------------------------------------------------------------------------ +/** +*/ +void +NebulaMain(const Util::CommandLineArgs& args) +{ + NebulaDemoApplication gameApp; + gameApp.SetCompanyName("Gscept"); + gameApp.SetAppTitle("Turbobadger demo"); + gameApp.SetCmdLineArgs(args); + + if (!gameApp.Open()) + { + return; + } + + gameApp.Run(); + gameApp.Close(); + Core::SysFunc::Exit(0); +} diff --git a/tests/testtbui/managers/inputmanager.cc b/tests/testtbui/managers/inputmanager.cc new file mode 100644 index 000000000..985e35933 --- /dev/null +++ b/tests/testtbui/managers/inputmanager.cc @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// inputmanager.cc +// (C) 2020 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "application/stdneb.h" +#include "inputmanager.h" +#include "input/inputserver.h" +#include "input/mouse.h" +#include "input/keyboard.h" +#include "game/api.h" +#include "memdb/table.h" +#include "memdb/filterset.h" +#include "memdb/database.h" +#include "game/processor.h" +#include "game/world.h" + +#include "audiofeature/components/audiofeature.h" + +namespace Tests +{ + +__ImplementClass(Tests::InputManager, 'DInM', Game::Manager); +__ImplementSingleton(InputManager) + +//------------------------------------------------------------------------------ +/** +*/ +InputManager::InputManager() +{ + __ConstructSingleton +} + +//------------------------------------------------------------------------------ +/** +*/ +InputManager::~InputManager() +{ + __DestructSingleton +} + +//------------------------------------------------------------------------------ +/** +*/ +void +InputManager::OnActivate() +{ + Game::Manager::OnActivate(); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +InputManager::OnDeactivate() +{ + Game::Manager::OnDeactivate(); +} + + +} // namespace Game + + diff --git a/tests/testtbui/managers/inputmanager.h b/tests/testtbui/managers/inputmanager.h new file mode 100644 index 000000000..3b13914d4 --- /dev/null +++ b/tests/testtbui/managers/inputmanager.h @@ -0,0 +1,28 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + @class Demo::InputManager + + (C) 2020 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "core/refcounted.h" +#include "core/singleton.h" +#include "game/manager.h" + +namespace Tests +{ + +class InputManager : public Game::Manager +{ + __DeclareClass(InputManager) + __DeclareSingleton(InputManager); +public: + InputManager(); + virtual ~InputManager(); + + void OnActivate() override; + void OnDeactivate() override;; +}; + +} // namespace Demo diff --git a/tests/testtbui/tbuifeatureunit.cc b/tests/testtbui/tbuifeatureunit.cc new file mode 100644 index 000000000..f5b4ee2e4 --- /dev/null +++ b/tests/testtbui/tbuifeatureunit.cc @@ -0,0 +1,102 @@ +//------------------------------------------------------------------------------ +// tbuifeatureunit.cc +// (C) 2020 Individual contributors, see AUTHORS file +//------------------------------------------------------------------------------ +#include "foundation/stdneb.h" +#include "tbuifeatureunit.h" +#include "basegamefeature/basegamefeatureunit.h" +#include "gamestatemanager.h" +#include "profiling/profiling.h" +#include "managers/inputmanager.h" +#include "game/api.h" +#include "game/world.h" +#include "appgame/gameapplication.h" +#include "frame/default.h" + +namespace Tests +{ + +__ImplementClass(TBUIFeatureUnit, 'TBFU', Game::FeatureUnit); +__ImplementSingleton(TBUIFeatureUnit); + +//------------------------------------------------------------------------------ +/** +*/ +TBUIFeatureUnit::TBUIFeatureUnit() +{ + __ConstructSingleton; +} + +//------------------------------------------------------------------------------ +/** +*/ +TBUIFeatureUnit::~TBUIFeatureUnit() +{ + __DestructSingleton; +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIFeatureUnit::OnAttach() +{ +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIFeatureUnit::OnActivate() +{ + FeatureUnit::OnActivate(); + + // Setup game state + this->AttachManager(Tests::GameStateManager::Create()); + this->AttachManager(Tests::InputManager::Create()); + +#if WITH_NEBULA_EDITOR + if (!App::GameApplication::IsEditorEnabled()) +#endif + { + Graphics::GraphicsServer::Instance()->AddPostViewCall( + [](IndexT frameIndex, IndexT bufferIndex) + { + Graphics::GraphicsServer::SwapInfo swapInfo; + swapInfo.syncFunc = [](CoreGraphics::CmdBufferId cmdBuf) + { + FrameScript_default::Synchronize( + "Present_Sync", + cmdBuf, + CoreGraphics::GraphicsQueueType, + {{(FrameScript_default::TextureIndex)FrameScript_default::Export_ColorBuffer.index, + CoreGraphics::PipelineStage::TransferRead}}, + nullptr + ); + }; + swapInfo.submission = FrameScript_default::Submission_Scene; + swapInfo.swapSource = FrameScript_default::Export_ColorBuffer.tex; + Graphics::GraphicsServer::Instance()->SetSwapInfo(swapInfo); + } + ); + } +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIFeatureUnit::OnBeginFrame() +{ + FeatureUnit::OnBeginFrame(); +} + +//------------------------------------------------------------------------------ +/** +*/ +void +TBUIFeatureUnit::OnDeactivate() +{ + FeatureUnit::OnDeactivate(); +} +} // namespace Tests diff --git a/tests/testtbui/tbuifeatureunit.h b/tests/testtbui/tbuifeatureunit.h new file mode 100644 index 000000000..fc05a407a --- /dev/null +++ b/tests/testtbui/tbuifeatureunit.h @@ -0,0 +1,41 @@ +#pragma once +//------------------------------------------------------------------------------ +/** + Tests::TBUIFeatureUnit + + (C) 2020 Individual contributors, see AUTHORS file +*/ +//------------------------------------------------------------------------------ +#include "core/refcounted.h" +#include "core/singleton.h" +#include "game/featureunit.h" +#include "game/manager.h" + +namespace Tests +{ + +class TBUIFeatureUnit : public Game::FeatureUnit +{ + __DeclareClass(TBUIFeatureUnit) + __DeclareSingleton(TBUIFeatureUnit) +public: + /// + TBUIFeatureUnit(); + /// + ~TBUIFeatureUnit(); + + /// + void OnAttach() override; + /// + void OnActivate() override; + /// + void OnDeactivate() override; + /// + void OnBeginFrame() override; +}; + +} // namespace Tests + + + + diff --git a/tests/work/turbobadger/demo/fonts/license.txt b/tests/work/turbobadger/demo/fonts/license.txt new file mode 100644 index 000000000..38c53fd1b --- /dev/null +++ b/tests/work/turbobadger/demo/fonts/license.txt @@ -0,0 +1,5 @@ +This folder has some default fonts for demo purposes. + +The license of the files in this folder is Public Domain, however +i can't guarantee that using rasterized graphics from copyrighted +fonts as a bitmap font is ok. Use at your own risk! diff --git a/tests/work/turbobadger/demo/fonts/neon.psd b/tests/work/turbobadger/demo/fonts/neon.psd new file mode 100644 index 000000000..2984237ea Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/neon.psd differ diff --git a/tests/work/turbobadger/demo/fonts/neon.tb.txt b/tests/work/turbobadger/demo/fonts/neon.tb.txt new file mode 100644 index 000000000..2696f5d42 --- /dev/null +++ b/tests/work/turbobadger/demo/fonts/neon.tb.txt @@ -0,0 +1,11 @@ +info + glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€£¥§•·©«»®¶ÅÄÖÆØåäöæø + rgb 1 + name Neon +size 42 + bitmap neon_42.png + ascent 50 + descent 16 + x_ofs -6 + advance_delta -12 + space_advance 12 diff --git a/tests/work/turbobadger/demo/fonts/neon_42.png b/tests/work/turbobadger/demo/fonts/neon_42.png new file mode 100644 index 000000000..1a7f64060 Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/neon_42.png differ diff --git a/tests/work/turbobadger/demo/fonts/orange.psd b/tests/work/turbobadger/demo/fonts/orange.psd new file mode 100644 index 000000000..10bfe26aa Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/orange.psd differ diff --git a/tests/work/turbobadger/demo/fonts/orange.tb.txt b/tests/work/turbobadger/demo/fonts/orange.tb.txt new file mode 100644 index 000000000..e7a8cc291 --- /dev/null +++ b/tests/work/turbobadger/demo/fonts/orange.tb.txt @@ -0,0 +1,11 @@ +info + glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…ˆŠ‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¥¦§¨©«®´µ¶·¸¹º»¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüþÿ + name Orange + rgb 1 +size 30 + bitmap orange_30.png + ascent 62 + descent 25 + x_ofs -7 + advance_delta -20 + space_advance 22 diff --git a/tests/work/turbobadger/demo/fonts/orange_30.png b/tests/work/turbobadger/demo/fonts/orange_30.png new file mode 100644 index 000000000..45da195ec Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/orange_30.png differ diff --git a/tests/work/turbobadger/demo/fonts/orangutang.psd b/tests/work/turbobadger/demo/fonts/orangutang.psd new file mode 100644 index 000000000..cb88e833a Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/orangutang.psd differ diff --git a/tests/work/turbobadger/demo/fonts/orangutang.tb.txt b/tests/work/turbobadger/demo/fonts/orangutang.tb.txt new file mode 100644 index 000000000..86d4fc83b --- /dev/null +++ b/tests/work/turbobadger/demo/fonts/orangutang.tb.txt @@ -0,0 +1,11 @@ +info + glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€£¥§•·©«»®¶ÅÄÖÆØåäöæø + rgb 1 + name Orangutang +size 48 + bitmap orangutang_48.png + ascent 51 + descent 15 + x_ofs -2 + advance_delta -4 + space_advance 12 diff --git a/tests/work/turbobadger/demo/fonts/orangutang_48.png b/tests/work/turbobadger/demo/fonts/orangutang_48.png new file mode 100644 index 000000000..9652ab60a Binary files /dev/null and b/tests/work/turbobadger/demo/fonts/orangutang_48.png differ diff --git a/tests/work/turbobadger/demo/images/image_1.png b/tests/work/turbobadger/demo/images/image_1.png new file mode 100644 index 000000000..1e9ce2efe Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_1.png differ diff --git a/tests/work/turbobadger/demo/images/image_2.png b/tests/work/turbobadger/demo/images/image_2.png new file mode 100644 index 000000000..c784af65c Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_2.png differ diff --git a/tests/work/turbobadger/demo/images/image_3.png b/tests/work/turbobadger/demo/images/image_3.png new file mode 100644 index 000000000..95b0ed5ed Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_3.png differ diff --git a/tests/work/turbobadger/demo/images/image_4.png b/tests/work/turbobadger/demo/images/image_4.png new file mode 100644 index 000000000..fcfbb81b4 Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_4.png differ diff --git a/tests/work/turbobadger/demo/images/image_5.png b/tests/work/turbobadger/demo/images/image_5.png new file mode 100644 index 000000000..7a7a36df7 Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_5.png differ diff --git a/tests/work/turbobadger/demo/images/image_6.png b/tests/work/turbobadger/demo/images/image_6.png new file mode 100644 index 000000000..e363a8dc0 Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_6.png differ diff --git a/tests/work/turbobadger/demo/images/image_7.png b/tests/work/turbobadger/demo/images/image_7.png new file mode 100644 index 000000000..adbbec037 Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_7.png differ diff --git a/tests/work/turbobadger/demo/images/image_8.png b/tests/work/turbobadger/demo/images/image_8.png new file mode 100644 index 000000000..79dba923f Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_8.png differ diff --git a/tests/work/turbobadger/demo/images/image_9.png b/tests/work/turbobadger/demo/images/image_9.png new file mode 100644 index 000000000..ba59ceb67 Binary files /dev/null and b/tests/work/turbobadger/demo/images/image_9.png differ diff --git a/tests/work/turbobadger/demo/skin/bg_tile.png b/tests/work/turbobadger/demo/skin/bg_tile.png new file mode 100644 index 000000000..36c3fca41 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/bg_tile.png differ diff --git a/tests/work/turbobadger/demo/skin/bg_tile.psd b/tests/work/turbobadger/demo/skin/bg_tile.psd new file mode 100644 index 000000000..43b21c298 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/bg_tile.psd differ diff --git a/tests/work/turbobadger/demo/skin/focus_r8.png b/tests/work/turbobadger/demo/skin/focus_r8.png new file mode 100644 index 000000000..bbd923bbc Binary files /dev/null and b/tests/work/turbobadger/demo/skin/focus_r8.png differ diff --git a/tests/work/turbobadger/demo/skin/icon128.png b/tests/work/turbobadger/demo/skin/icon128.png new file mode 100644 index 000000000..02797f3b6 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/icon128.png differ diff --git a/tests/work/turbobadger/demo/skin/icon16.png b/tests/work/turbobadger/demo/skin/icon16.png new file mode 100644 index 000000000..ddaa54fe6 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/icon16.png differ diff --git a/tests/work/turbobadger/demo/skin/icon48.png b/tests/work/turbobadger/demo/skin/icon48.png new file mode 100644 index 000000000..a113662f8 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/icon48.png differ diff --git a/tests/work/turbobadger/demo/skin/image_frame.png b/tests/work/turbobadger/demo/skin/image_frame.png new file mode 100644 index 000000000..af92850e1 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/image_frame.png differ diff --git a/tests/work/turbobadger/demo/skin/image_frame.psd b/tests/work/turbobadger/demo/skin/image_frame.psd new file mode 100644 index 000000000..1ebd69d32 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/image_frame.psd differ diff --git a/tests/work/turbobadger/demo/skin/remove.png b/tests/work/turbobadger/demo/skin/remove.png new file mode 100644 index 000000000..0cc7abca5 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/remove.png differ diff --git a/tests/work/turbobadger/demo/skin/skin.tb.txt b/tests/work/turbobadger/demo/skin/skin.tb.txt new file mode 100644 index 000000000..18f48ff64 --- /dev/null +++ b/tests/work/turbobadger/demo/skin/skin.tb.txt @@ -0,0 +1,74 @@ +# Demo skin override (contains some additions for the demo) +elements + Icon16 + bitmap icon16.png + min-width 16 + min-height 16 + Icon48 + bitmap icon48.png + cut 4 + min-width 20 + min-height 20 + Icon128 + bitmap icon128.png + background + bitmap bg_tile.png + type Tile + background_solid + background-color #3b3b3b + padding 10 + SpecialButton + bitmap special_button.png + cut 17 + expand 7 + padding 6 8 + overrides + element SpecialButton.pressed + state pressed + overlays + element generic_focus_r8 + state focused + element Star + condition: target: ancestors, property: skin, value: "Starry buttons" + SpecialButton.pressed + bitmap special_button_pressed.png + cut 17 + expand 7 + content-ofs-x 1 + content-ofs-y 1 + ImageCaption + background-color #00000066 + ImageFrame + overlays + element ImageFrame.overlay + state all + ImageFrame.overlay + bitmap image_frame.png + cut 22 + expand 15 + Remove + bitmap remove.png + type Image + padding 5 + Star + bitmap star_gray.png + type Image + img-position-x 0 + img-position-y 0 + img-ofs-x -8 + img-ofs-y -12 + overrides + element Star.active + condition: target: this, property: "window active" + condition: target: parent, property: hover + Star.active + bitmap star_gold.png + type Image + img-position-x 0 + img-position-y 0 + img-ofs-x -10 + img-ofs-y -14 + generic_focus_r8 + bitmap focus_r8.png + cut 14 + expand 4 diff --git a/tests/work/turbobadger/demo/skin/special_button.png b/tests/work/turbobadger/demo/skin/special_button.png new file mode 100644 index 000000000..db759f8ff Binary files /dev/null and b/tests/work/turbobadger/demo/skin/special_button.png differ diff --git a/tests/work/turbobadger/demo/skin/special_button.psd b/tests/work/turbobadger/demo/skin/special_button.psd new file mode 100644 index 000000000..11311c8e9 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/special_button.psd differ diff --git a/tests/work/turbobadger/demo/skin/special_button_pressed.png b/tests/work/turbobadger/demo/skin/special_button_pressed.png new file mode 100644 index 000000000..96235c324 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/special_button_pressed.png differ diff --git a/tests/work/turbobadger/demo/skin/star.psd b/tests/work/turbobadger/demo/skin/star.psd new file mode 100644 index 000000000..b7d996388 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star.psd differ diff --git a/tests/work/turbobadger/demo/skin/star_gold.png b/tests/work/turbobadger/demo/skin/star_gold.png new file mode 100644 index 000000000..1c4bebac9 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gold.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gold@192.png b/tests/work/turbobadger/demo/skin/star_gold@192.png new file mode 100644 index 000000000..4591227bb Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gold@192.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gold@288.png b/tests/work/turbobadger/demo/skin/star_gold@288.png new file mode 100644 index 000000000..0941e68b8 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gold@288.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gold@384.png b/tests/work/turbobadger/demo/skin/star_gold@384.png new file mode 100644 index 000000000..3ec2fdb52 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gold@384.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gray.png b/tests/work/turbobadger/demo/skin/star_gray.png new file mode 100644 index 000000000..2266b33f8 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gray.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gray@192.png b/tests/work/turbobadger/demo/skin/star_gray@192.png new file mode 100644 index 000000000..95a5d4537 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gray@192.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gray@288.png b/tests/work/turbobadger/demo/skin/star_gray@288.png new file mode 100644 index 000000000..119f88a29 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gray@288.png differ diff --git a/tests/work/turbobadger/demo/skin/star_gray@384.png b/tests/work/turbobadger/demo/skin/star_gray@384.png new file mode 100644 index 000000000..a6bc66ad2 Binary files /dev/null and b/tests/work/turbobadger/demo/skin/star_gray@384.png differ diff --git a/tests/work/turbobadger/demo/ui_resources/resource_edit_test.tb.txt b/tests/work/turbobadger/demo/ui_resources/resource_edit_test.tb.txt new file mode 100644 index 000000000..8370807b1 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/resource_edit_test.tb.txt @@ -0,0 +1,21 @@ +TBLayout + distribution available + axis y + TBLayout + TBButton + text Button 1 + TBRadioButton + TBCheckBox + @if 1 + TBContainer + TBLayout + TBSlider + value 0.5 + TBScrollBar + TBEditField + multiline 1 + readonly 1 + TBEditField + text Hello world\nHello world + adapt-to-content 1 + multiline 1 diff --git a/tests/work/turbobadger/demo/ui_resources/resource_edit_window.tb.txt b/tests/work/turbobadger/demo/ui_resources/resource_edit_window.tb.txt new file mode 100644 index 000000000..87b84c9a3 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/resource_edit_window.tb.txt @@ -0,0 +1,38 @@ +TBLayout + distribution gravity + size available + TBLayout + gravity top bottom + distribution available + distribution-position top left + size available + axis y + TBLayout + distribution available + TBButton + text @new + state disabled + TBButton + text @save + state disabled + TBButton + text Test + id test + TBEditField + placeholder @search + type search + id widget_list_search + TBSelectList + id widget_list + TBLayout + distribution available + TBEditField + id source_edit + multiline 1 + gravity all + TBLayout: axis: y, distribution: available, position: left + TBScrollContainer + id scroll_container + gravity all + TBClickLabel: text: "Adapt to container" + TBCheckBox: id: "constrained" diff --git a/tests/work/turbobadger/demo/ui_resources/test_animations.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_animations.tb.txt new file mode 100644 index 000000000..e0bc8f5e4 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_animations.tb.txt @@ -0,0 +1,16 @@ +WindowInfo + title Animations +TBLayout: axis: y + TBTextField: text: "Duration (in milliseconds):" + TBInlineSelect: id: "duration", min: 0, max: 100000, value: 500 + TBTextField: text: "Curve:" + TBSelectList: id: "curve", value: 1 + items + item: text: "Linear" + item: text: "Slow down" + item: text: "Speed up" + item: text: "Bezier" + item: text: "Smooth" + TBClickLabel: text: Fade + TBCheckBox: id: fade, value: 1 + TBButton: text: "Animate!", id: "Animate!", skin: "SpecialButton" diff --git a/tests/work/turbobadger/demo/ui_resources/test_batching01.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_batching01.tb.txt new file mode 100644 index 000000000..134368d0d --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_batching01.tb.txt @@ -0,0 +1,381 @@ +TBLayout + axis y + TBTextField: text: "For enabling \"Continuous repaint\" and test batching speed. + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" + TBLayout + TBButton: text: "A" + TBButton: text: "B" + TBButton: text: "C" + TBButton: text: "D" + TBButton: text: "E" + TBButton: text: "F" + TBButton: text: "G" + TBButton: text: "H" + TBButton: text: "I" + TBButton: text: "J" + TBButton: text: "K" + TBButton: text: "L" + TBButton: text: "M" + TBButton: text: "N" + TBButton: text: "O" + TBButton: text: "P" + TBButton: text: "Q" + TBButton: text: "R" + TBButton: text: "S" + TBButton: text: "T" + TBButton: text: "U" + TBButton: text: "V" + TBButton: text: "W" + TBButton: text: "X" + TBButton: text: "Y" + TBButton: text: "Z" diff --git a/tests/work/turbobadger/demo/ui_resources/test_connections.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_connections.tb.txt new file mode 100644 index 000000000..80ce79862 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_connections.tb.txt @@ -0,0 +1,43 @@ +WindowInfo + title TBWidgetValue connections +TBLayout + axis y + TBTextField + text Numeric widgets sharing a connection + TBContainer + gravity all + TBLayout + TBInlineSelect + connection master-volume + min 0 + max 100 + TBSlider + connection master-volume + min 0 + max 100 + TBSlider + axis y + connection master-volume + min 0 + max 100 + TBButton + text Reset + id reset-master-volume + TBTextField + text Text widgets sharing a connection + TBContainer + gravity all + TBLayout + TBEditField + placeholder User name + connection user-name + min 0 + max 100 + TBEditField + placeholder User name + connection user-name + min 0 + max 100 + TBButton + text Reset + id reset-user-name diff --git a/tests/work/turbobadger/demo/ui_resources/test_image_widget.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_image_widget.tb.txt new file mode 100644 index 000000000..2598e9fc2 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_image_widget.tb.txt @@ -0,0 +1,33 @@ +WindowInfo + title TBImageWidget + size 350 500 +TBScrollContainer + adapt-content 1 + TBLayout + axis y + spacing 20 + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 + text: "Some images shown by TBImageWidget. This test requires enabling TB_IMAGE (see tb_config.h).\n" \ + "Images are unloaded when all references are removed (this window is closed)." + TBImageWidget: filename: "tb:demo/images/image_1.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBImageWidget: filename: "tb:demo/images/image_2.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBImageWidget: filename: "tb:demo/images/image_3.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBImageWidget: filename: "tb:demo/images/image_4.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBImageWidget: filename: "tb:demo/images/image_5.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBImageWidget: filename: "tb:demo/images/image_6.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBTextField: skin: "ImageCaption", text: "Öland", gravity: bottom left right + TBImageWidget: filename: "tb:demo/images/image_7.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBTextField: skin: "ImageCaption", text: "Öland", gravity: bottom left right + TBImageWidget: filename: "tb:demo/images/image_8.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBTextField: skin: "ImageCaption", text: "Örebro", gravity: bottom left right + TBImageWidget: filename: "tb:demo/images/image_9.png", skin: ImageFrame + TBButton: skin: "Remove", id: "remove", gravity: right + TBTextField: skin: "ImageCaption", text: "Stockholm", gravity: bottom left right diff --git a/tests/work/turbobadger/demo/ui_resources/test_layout01.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_layout01.tb.txt new file mode 100644 index 000000000..4dc9c7a2c --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_layout01.tb.txt @@ -0,0 +1,55 @@ +WindowInfo + title TBLayout size & gravity +# Declare a branch of layout nodes that is included in all three containers below. +test_layout_content + TBLayout + TBButton + text Default + TBCheckBox + value 1 + TBButton + axis y + text Foo Bar + TBSkinImage + skin Icon16 + TBButton + gravity all + text Gravity all + TBButton + gravity top + text Gravity top + TBButton + gravity bottom + text Gravity bottom +TBLayout + axis y + TBLayout + TBSelectDropdown + text Select position + id select position + items + item: text: "LAYOUT_POSITION_CENTER" + item: text: "LAYOUT_POSITION_LEFT_TOP" + item: text: "LAYOUT_POSITION_RIGHT_BOTTOM" + item: text: "LAYOUT_POSITION_GRAVITY" + TBButton + text Toggle axis + id toggle axis + TBLayout + id switch_layout + axis y + TBTextField: text: "size: preferred" + TBContainer + @include test_layout_content + size preferred + id 1 + TBTextField: text: "size: available" + TBContainer + @include test_layout_content + size available + id 2 + TBTextField: text: "size: gravity" + TBContainer + @include test_layout_content + size gravity + id 3 diff --git a/tests/work/turbobadger/demo/ui_resources/test_layout02.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_layout02.tb.txt new file mode 100644 index 000000000..31e0adc87 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_layout02.tb.txt @@ -0,0 +1,39 @@ +WindowInfo + title TBLayout distribution +TBLayout: position: left top, axis: y + TBTextField: text: "distribution: preferred" + TBLayout: distribution: preferred + TBButton: text: tab 1 + TBButton: text: tab 2 + TBButton: text: tab 3 + TBButton: text: tab 4 + TBEditField: placeholder: @search, gravity: left right, type: "search" + TBTextField: text: "distribution: available" + TBLayout: distribution: available + TBButton: text: tab 1 + TBButton: text: tab 2 + TBButton: text: tab 3 + TBButton: text: tab 4 + TBEditField: placeholder: @search, gravity: left right, type: "search" + TBTextField: text: "distribution: gravity" + TBLayout: distribution: gravity + TBButton: text: tab 1 + TBButton: text: tab 2 + TBButton: text: tab 3 + TBButton: text: tab 4 + TBEditField: placeholder: @search, gravity: left right, type: "search" + TBTextField: text: gravity + trailing layout for right align + TBLayout: distribution: gravity + TBButton: text: tab 1 + TBButton: text: tab 2 + TBButton: text: tab 3 + TBButton: text: tab 4 + TBLayout: gravity: left right, distribution-position: right bottom + TBEditField: placeholder: @search, type: "search" + TBTextField: text: "gravity + mixed gravity" + TBLayout: distribution: gravity + TBButton: text: tab 1 + TBEditField: placeholder: @search, gravity: left right, type: "search" + TBButton: text: tab 3 + TBButton: text: tab 4 + TBEditField: placeholder: @search, gravity: left right, type: "search" diff --git a/tests/work/turbobadger/demo/ui_resources/test_layout03.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_layout03.tb.txt new file mode 100644 index 000000000..590ead2dd --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_layout03.tb.txt @@ -0,0 +1,21 @@ +WindowInfo + title Default TBWidget positioning + size 350 350 +TBLayout: axis: y, distribution: gravity + TBLayout: distribution: available, gravity: left right + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1 + text: "Any widget may contain children and by default applies basic gravity positioning.\n" \ + "To achieve more advanced layout, you would normally wrap a layouting " \ + "widget (f.ex TBLayout) but sometimes the default is enough.\n" \ + "The default preferred size is calculated to the largest child " \ + "(or the skin if there are no children)." + TBContainer: gravity: all + TBTextField: text: "all", gravity: all + TBTextField: text: "top, left, right", gravity: top left right + TBTextField: text: "bottom, left, right", gravity: bottom left right + TBTextField: text: "left, top, bottom", gravity: left top bottom + TBTextField: text: "right, top, bottom", gravity: right top bottom + TBButton: text: Upper left + TBButton: text: Upper right, gravity: right + TBButton: text: Lower left, gravity: bottom + TBButton: text: Lower right, gravity: bottom right diff --git a/tests/work/turbobadger/demo/ui_resources/test_list_item.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_list_item.tb.txt new file mode 100644 index 000000000..65ae1a1bb --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_list_item.tb.txt @@ -0,0 +1,6 @@ +TBCheckBox: id: check +TBSkinImage: id: icon, skin: Icon48, ignore-input: 1 +TBLayout: axis: y, position: left, spacing: 0, ignore-input: 1, size: available, position: left top + TBTextField: id: name, text-align: left + TBTextField: id: info, text-align: left, state: disabled +TBButton: id: delete, skin: TBWindow.close \ No newline at end of file diff --git a/tests/work/turbobadger/demo/ui_resources/test_radio_checkbox.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_radio_checkbox.tb.txt new file mode 100644 index 000000000..f9ef455ca --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_radio_checkbox.tb.txt @@ -0,0 +1,38 @@ +WindowInfo + title Radiobutton & checkbox +TBLayout: position: left top, axis: y + TBTextField: text: "Radiobuttons, anonymous group:" + TBLayout: distribution: preferred + TBRadioButton + TBRadioButton + TBRadioButton: state: disabled + TBTextField: text: "Radiobuttons, group-id: 'R1'": + TBLayout: distribution: preferred + TBRadioButton: group-id: R1 + TBRadioButton: group-id: R1 + TBRadioButton: group-id: R1, state: disabled + TBTextField: text: "Radiobuttons, group-id: 'R2' value set": + TBLayout: distribution: preferred + TBRadioButton: group-id: R2, value: 1 + TBRadioButton: group-id: R2 + TBRadioButton: group-id: R2, state: disabled + TBTextField: text: "Checkboxes" + TBLayout: distribution: preferred + TBCheckBox + TBCheckBox: value: 1 + TBCheckBox: state: disabled + TBCheckBox: state: disabled, value: 1 + TBTextField: text: "TBClickLabel with radio & check" + TBClickLabel: text: Some text to click + TBCheckBox + TBClickLabel: text: Some text to click + TBRadioButton + TBClickLabel: text: Some text to click, state: disabled + TBCheckBox + TBClickLabel: text: Some text to click, state: disabled + TBRadioButton + TBTextField: text: "Regular buttons with group-id: 'R3'": + TBLayout: distribution: preferred + TBButton: text: "A", group-id: "R3", value: 1 + TBButton: text: "B", group-id: "R3" + TBButton: text: "C", group-id: "R3" diff --git a/tests/work/turbobadger/demo/ui_resources/test_scrollcontainer.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_scrollcontainer.tb.txt new file mode 100644 index 000000000..4b97c3d90 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_scrollcontainer.tb.txt @@ -0,0 +1,123 @@ +WindowInfo + title TBScrollContainer with misc widgets + size 500 500 +TBLayout + gravity all + distribution available + axis y + TBScrollContainer + TBLayout + position left top + axis y + TBTextField: text: Buttons with different fonts: + TBLayout + TBButton + text: "Orange" + font: name: Orange + TBButton + text: "Segoe 14" + font: size: 14px + TBButton + text: "Segoe 28" + font: size: 28px + TBTextField: text: TBButton containing TBSkinImage: + TBLayout + TBButton + text Click for image! + id add img + TBSkinImage + skin Icon16 + TBButton + axis y + text Click for image! + id add img + TBSkinImage + skin Icon16 + TBTextField: text: "TBButton containing TBEditField:" + TBLayout + TBButton + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1, styling: 1 + text: "A TBButton with styled text that is able to wrap to multiple lines." + TBTextField: text: "Showing menu manually, and TBSelectDropdown:" + TBLayout + TBButton + text Give me a popup menu! + id showpopupmenu1 + TBSelectDropdown + text Dropdown + id name dropdown + TBSelectDropdown + text Customized items in Dropdown + id advanced dropdown + TBLayout + overflow scroll + TBRadioButton + TBCheckBox + value 1 + TBSkinImage + skin Icon16 + TBSkinImage + skin Icon48 + TBButton + TBButton: toggle-mode: 1 + TBTextField: text: "TBEditField:" + TBLayout + TBEditField + text Edit type text + TBEditField + type search + text Edit type search + TBEditField + type password + text pwd goes here + TBEditField + text In this field, multiple lines are enabled. + multiline 1 + TBTextField: text: "TBSlider:" + TBLayout + TBSlider + TBSlider + min 100 + max 200 + value 150 + TBSlider + axis y + min 0 + max 100 + connection master-volume + TBTextField: text: "TBScrollbar:" + TBLayout + TBScrollBar + TBScrollBar + axis y + TBTextField: text: Horizontal layout: + TBLayout + id horizontal_layout + TBButton + text "1 new button" + id new buttons + data 1 + TBButton + text "100 new buttons!" + id new buttons + data 100 + TBButton + text "10 new with delay!" + id new buttons delayed + data 10 + TBTextField: text: Vertical layout: + TBLayout + id vertical_layout + axis y + TBButton + text "1 new button" + id new buttons + data 1 + TBButton + text "100 new buttons!" + id new buttons + data 100 + TBButton + text "10 new with delay!" + id new buttons delayed + data 10 diff --git a/tests/work/turbobadger/demo/ui_resources/test_scroller_snap.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_scroller_snap.tb.txt new file mode 100644 index 000000000..1ced50c0f --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_scroller_snap.tb.txt @@ -0,0 +1,25 @@ +WindowInfo + title TBScrollerSnapListener +definitions + pagesize + lp: width: 200, height: 300 +TBScrollContainer: id: "page-scroller" + @include definitions>pagesize + scroll-mode off + TBLayout + spacing 0 + TBContainer + @include definitions>pagesize + TBTextField: text: "One - Swipe to next page" + TBContainer + @include definitions>pagesize + TBTextField: text: "Two" + TBContainer + @include definitions>pagesize + TBTextField: text: "Three" + TBContainer + @include definitions>pagesize + TBTextField: text: "Four" + TBContainer + @include definitions>pagesize + TBTextField: text: "Five - Last page" diff --git a/tests/work/turbobadger/demo/ui_resources/test_select.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_select.tb.txt new file mode 100644 index 000000000..d0028516f --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_select.tb.txt @@ -0,0 +1,15 @@ +WindowInfo + title List and filter + position 1100 50 +TBLayout + axis y + distribution gravity + gravity all + TBEditField + id filter + gravity left right + placeholder @search + type search + TBSelectList + id list + gravity all diff --git a/tests/work/turbobadger/demo/ui_resources/test_select_advanced.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_select_advanced.tb.txt new file mode 100644 index 000000000..6f73dc795 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_select_advanced.tb.txt @@ -0,0 +1,30 @@ +WindowInfo + title Customized list items + position 770 50 + size 300 300 +TBLayout + axis y + distribution gravity + gravity all + TBLayout + distribution gravity + TBEditField + id filter + gravity left right + placeholder @search + type search + TBSelectList + id list + gravity all + TBLayout + distribution gravity + TBEditField + id add_name + gravity left right + placeholder Name + TBButton + id add + text Add + TBButton + id delete all + text Delete all diff --git a/tests/work/turbobadger/demo/ui_resources/test_skin_conditions01.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_skin_conditions01.tb.txt new file mode 100644 index 000000000..4439ddf47 --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_skin_conditions01.tb.txt @@ -0,0 +1,18 @@ +WindowInfo + title Skin conditions + position 200 170 +TBLayout: axis: y + TBTextField: text: Normal layout with buttons: + TBContainer + TBLayout + TBButton: text: " A ", skin: "SpecialButton" + TBButton: text: " B ", skin: "SpecialButton" + TBButton: text: " C ", skin: "SpecialButton" + TBTextField: text: Layout with skin "Starry buttons": + TBContainer + TBLayout: skin: Starry buttons + TBButton: text: " A ", skin: "SpecialButton" + TBButton: text: " B ", skin: "SpecialButton" + TBButton: text: " C ", skin: "SpecialButton" + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 + 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. diff --git a/tests/work/turbobadger/demo/ui_resources/test_skin_conditions02.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_skin_conditions02.tb.txt new file mode 100644 index 000000000..f249ae93f --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_skin_conditions02.tb.txt @@ -0,0 +1,44 @@ +WindowInfo + title Skin conditions + position 500 170 +TBLayout + axis y + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 + 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. + TBLayout + TBLayout: skin: button_group + TBButton + text < + TBButton + text > + TBLayout: skin: button_group + TBButton + text 1 + TBButton + text 2 + TBButton + text 3 + TBLayout: skin: button_group + TBButton + text A + TBButton + text B + TBButton + text C + TBLayout: skin: button_group + TBButton + text Hello + TBButton + text World! + TBEditField: gravity: all, skin: 0, multiline: 1, readonly: 1, adapt-to-content: 1 + text The "button_group" skin overrides default layout spacing. It can also be overridden in the UI resource. + TBLayout: skin: button_group + spacing 2 + TBButton + text Group + TBButton + text with + TBButton + text spacing + TBButton + text 2 diff --git a/tests/work/turbobadger/demo/ui_resources/test_tabcontainer01.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_tabcontainer01.tb.txt new file mode 100644 index 000000000..fa7b50a1f --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_tabcontainer01.tb.txt @@ -0,0 +1,38 @@ +WindowInfo + title TBTabContainer & misc tests + position 770 430 +TBTabContainer + gravity all + id tabcontainer + tabs + TBButton: text: "Tab with long text" + TBButton: text: "Skin" + TBButton: text: "Spinner" + TBSkinImage: skin: Icon16 + TBLayout: axis: y + TBTextField: text: "Tab alignment:" + TBLayout + TBClickLabel: text: Left + TBRadioButton: group-id: set_align, id: set_align, data: 0 + TBClickLabel: text: Up + TBRadioButton: group-id: set_align, id: set_align, data: 1, value: 1 + TBClickLabel: text: Right + TBRadioButton: group-id: set_align, id: set_align, data: 2 + TBClickLabel: text: Bottom + TBRadioButton: group-id: set_align, id: set_align, data: 3 + TBButton + text Toggle tab axis + id toggle_tab_axis + TBLayout + TBLayout: axis: y, position: right bottom + TBButton: text: Normal button + TBButton: text: Overridden skin, skin: SpecialButton + TBButton: text: Disabled button, state: disabled + TBEditField + text TBEditField + multiline 1 + TBLayout + axis y + TBButton: id: start_spinner, text: Start spinner + TBButton: id: stop_spinner, text: Stop spinner + TBProgressSpinner: id: spinner diff --git a/tests/work/turbobadger/demo/ui_resources/test_textwindow.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_textwindow.tb.txt new file mode 100644 index 000000000..680499f2b --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_textwindow.tb.txt @@ -0,0 +1,35 @@ +WindowInfo + title Text editing + position 280 50 + size 450 630 +TBLayout: axis: y, distribution: available + TBLayout: distribution: gravity + TBButton: id: undo + TBSkinImage: skin: arrow.left + TBButton: id: redo + TBSkinImage: skin: arrow.right + TBButton: text: Clear, id: clear + TBLayout + gravity left right + distribution-position right bottom + TBTextField: id: info + TBButton: id: menu + TBSkinImage: skin: arrow.down + TBTextField: text: Menu + skin TBButton.flat + TBEditField: multiline: 1, styling: 1, gravity: all, id: editfield, autofocus: 1 + text: "Turbo Badger - Fast UI toolkit\n\n" \ + "Test zone\n" \ + "The menu to the left spawns some examples of features in turbo badger.\n\n" \ + "The code in Demo/* is more like a developers test zone than organized tutorial-like samples. " \ + "This would be good to fix of course (help is welcome! ;)\n\n" \ + "Some things to try out\n" \ + " • All layouts provide panning of content automatically when squashed below the minimal size, so try resizing windows and pan.\n" \ + " • Lines starting with a bullet sequence (like this one) should wrap in a smart way.\n" \ + " • Message windows whose target is removed, are automatically removed. Close the menu window with open messages.\n" \ + " • Keyboard navigation using tab.\n" \ + " • Underline, Red, Green, Blue\n\n" \ + "Good to know\n" \ + " • 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" \ + " • 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" \ + " • All resources are UTF-8.\n" diff --git a/tests/work/turbobadger/demo/ui_resources/test_toggle_containers.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_toggle_containers.tb.txt new file mode 100644 index 000000000..7bd1f05cb --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_toggle_containers.tb.txt @@ -0,0 +1,54 @@ +WindowInfo + title TBToggleContainer +TBLayout: axis: y + TBEditField: gravity: all, adapt-to-content: 1, multiline: 1, readonly: 1, skin: 0, virtual-width: 400 + text: "TBToggleContainer used with TBWidgetValue connections to automatically toggle a group of items (no programming needed)." + + TBLayout: position: top left + TBContainer + TBLayout: axis: y + TBClickLabel: text: "Check to enable stuff:" + TBCheckBox: connection: toggle_demo_1 + + # == Toggle enabled ===================================================== + TBToggleContainer: connection: toggle_demo_1, toggle: enabled + TBLayout: axis: y + TBClickLabel: text: "Option 1" + TBRadioButton: group-id: group1, value: 1 + TBClickLabel: text: "Option 2" + TBRadioButton: group-id: group1 + + TBClickLabel: text: "Check to disable stuff:" + TBCheckBox: connection: toggle_demo_2 + + # == Toggle enabled, with the invert flag set =========================== + TBToggleContainer: connection: toggle_demo_2, toggle: enabled, invert: 1 + TBLayout: axis: y + TBClickLabel: text: "Option 1" + TBRadioButton: group-id: group2, value: 1 + TBClickLabel: text: "Option 2" + TBRadioButton: group-id: group2 + + TBContainer + TBLayout: axis: y + TBClickLabel: text: "Check to show stuff:" + TBCheckBox: connection: toggle_demo_3 + + # == Toggle opacity ===================================================== + TBToggleContainer: connection: toggle_demo_3, toggle: opacity + TBLayout: axis: y + TBClickLabel: text: "Option 1" + TBRadioButton: group-id: group3, value: 1 + TBClickLabel: text: "Option 2" + TBRadioButton: group-id: group3 + + TBClickLabel: text: "Check to expand stuff:" + TBCheckBox: connection: toggle_demo_4 + + # == Toggle expand ====================================================== + TBToggleContainer: connection: toggle_demo_4, toggle: expanded + TBLayout: axis: y + TBClickLabel: text: "Option 1" + TBRadioButton: group-id: group4, value: 1 + TBClickLabel: text: "Option 2" + TBRadioButton: group-id: group4 diff --git a/tests/work/turbobadger/demo/ui_resources/test_ui.tb.txt b/tests/work/turbobadger/demo/ui_resources/test_ui.tb.txt new file mode 100644 index 000000000..944012b4d --- /dev/null +++ b/tests/work/turbobadger/demo/ui_resources/test_ui.tb.txt @@ -0,0 +1,58 @@ +WindowInfo + title Turbo Badger + position 10 50 + size 250 630 + +TBLayout: axis: y, distribution-position: "left top", distribution: "available" + + TBSection: value: 1, text: "Misc features" + TBLayout: axis: y, spacing: 0, size: available + TBButton: skin: "TBButton.flat", text: "Radiobutton & Checkbox" + id: "test-layout" + data: "test_radio_checkbox.tb.txt" + TBButton: skin: "TBButton.flat", text: "TBSelectList", id: "test-list" + TBButton: skin: "TBButton.flat", text: "ScrollContainer & misc.", id: "test-scroll-container" + TBButton: skin: "TBButton.flat", text: "TBWidgetValue connections", id: "test-connections" + TBButton: skin: "TBButton.flat", text: "TBImage", id: "test-image" + TBButton: skin: "TBButton.flat", text: "TBScrollerSnapListener", id: "test-page" + TBButton: skin: "TBButton.flat", text: "Animations", id: "test-animations" + TBButton: skin: "TBButton.flat", text: "Skin conditions", id: "test-skin-conditions" + TBButton: skin: "TBButton.flat", text: "TBToggleContainer" + id: "test-layout" + data: "test_toggle_containers.tb.txt" + TBButton: skin: "TBButton.flat", text: "Close with dim & alert", id: "TBWindow.close" + TBButton: skin: "TBButton.flat", text: "ResourceEditWindow", id: "test-resource-edit" + + TBSection: value: 0, text: "Layout tests" + TBLayout: axis: y, spacing: 0, size: available + TBButton: skin: "TBButton.flat", text: "Size, gravity, position" + id: "test-layout" + data: "test_layout01.tb.txt" + TBButton: skin: "TBButton.flat", text: "Distribution" + id: "test-layout" + data: "test_layout02.tb.txt" + TBButton: skin: "TBButton.flat", text: "TBWidget default" + id: "test-layout" + data: "test_layout03.tb.txt" + + TBSection: value: 0, text: "Graphics tests" + TBLayout: axis: y, spacing: 0, size: available + TBClickLabel: text: "Continous repaint" + lp: max-width: 0 + TBCheckBox: connection: continous-repaint + TBButton: skin: "TBButton.flat", text: "Reload skin bitmaps", id: "reload skin bitmaps" + TBButton: skin: "TBButton.flat", text: "Context lost & restore", id: "test context lost" + + TBSection: value: 0, text: "Message tests" + TBLayout: axis: y, spacing: 0, size: available + TBButton: skin: "TBButton.flat", text: "PostMessage", id: "msg" + TBButton: skin: "TBButton.flat", text: "PostMessageDelayed", id: "delayedmsg" + TBClickLabel: text: "Busy message loop" + lp: max-width: 0 + TBCheckBox: id: "busymsg" + + # We want the debug button at the bottom if there is space over, + # so use an trailing layout which may expand a lot. + TBLayout: axis: y, distribution-position: bottom + lp: max-height: 10000 + TBButton: id: "debug settings", text: "Runtime debug settings..." diff --git a/tests/work/turbobadger/resources/default_font/license.txt b/tests/work/turbobadger/resources/default_font/license.txt new file mode 100644 index 000000000..38c53fd1b --- /dev/null +++ b/tests/work/turbobadger/resources/default_font/license.txt @@ -0,0 +1,5 @@ +This folder has some default fonts for demo purposes. + +The license of the files in this folder is Public Domain, however +i can't guarantee that using rasterized graphics from copyrighted +fonts as a bitmap font is ok. Use at your own risk! diff --git a/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow.tb.txt b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow.tb.txt new file mode 100644 index 000000000..7cf7cc944 --- /dev/null +++ b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow.tb.txt @@ -0,0 +1,15 @@ +info + glyph_str !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ + name Segoe +size 14 + bitmap segoe_white_with_shadow_14.png + ascent 15 + descent 5 + advance_delta -3 + space_advance 5 +size 28 + bitmap segoe_white_with_shadow_28.png + ascent 31 + descent 10 + advance_delta -7 + space_advance 10 diff --git a/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.png b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.png new file mode 100644 index 000000000..f4d6ffe82 Binary files /dev/null and b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.png differ diff --git a/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.psd b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.psd new file mode 100644 index 000000000..a59aac4b4 Binary files /dev/null and b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_14.psd differ diff --git a/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_28.png b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_28.png new file mode 100644 index 000000000..3ea54d26d Binary files /dev/null and b/tests/work/turbobadger/resources/default_font/segoe_white_with_shadow_28.png differ diff --git a/tests/work/turbobadger/resources/default_skin/TBSectionContainer.png b/tests/work/turbobadger/resources/default_skin/TBSectionContainer.png new file mode 100644 index 000000000..646d2015e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/TBSectionContainer.png differ diff --git a/tests/work/turbobadger/resources/default_skin/TBSectionContainer.psd b/tests/work/turbobadger/resources/default_skin/TBSectionContainer.psd new file mode 100644 index 000000000..a28dd4457 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/TBSectionContainer.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/TBSectionHeader.psd b/tests/work/turbobadger/resources/default_skin/TBSectionHeader.psd new file mode 100644 index 000000000..13ae9c1e0 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/TBSectionHeader.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow.psd b/tests/work/turbobadger/resources/default_skin/arrow.psd new file mode 100644 index 000000000..a9fdfbead Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_down.png b/tests/work/turbobadger/resources/default_skin/arrow_down.png new file mode 100644 index 000000000..0ef63ac9a Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_down.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_down@192.png b/tests/work/turbobadger/resources/default_skin/arrow_down@192.png new file mode 100644 index 000000000..35400f615 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_down@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_down@288.png b/tests/work/turbobadger/resources/default_skin/arrow_down@288.png new file mode 100644 index 000000000..c5f7bb76f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_down@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_down@384.png b/tests/work/turbobadger/resources/default_skin/arrow_down@384.png new file mode 100644 index 000000000..3a6865674 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_down@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_left.png b/tests/work/turbobadger/resources/default_skin/arrow_left.png new file mode 100644 index 000000000..90ebb40d2 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_left.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_left@192.png b/tests/work/turbobadger/resources/default_skin/arrow_left@192.png new file mode 100644 index 000000000..2a0cdf8be Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_left@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_left@288.png b/tests/work/turbobadger/resources/default_skin/arrow_left@288.png new file mode 100644 index 000000000..de1e76124 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_left@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_left@384.png b/tests/work/turbobadger/resources/default_skin/arrow_left@384.png new file mode 100644 index 000000000..e62644fd1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_left@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_right.png b/tests/work/turbobadger/resources/default_skin/arrow_right.png new file mode 100644 index 000000000..b303eb8ac Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_right.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_right@192.png b/tests/work/turbobadger/resources/default_skin/arrow_right@192.png new file mode 100644 index 000000000..d9e2ec6c1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_right@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_right@288.png b/tests/work/turbobadger/resources/default_skin/arrow_right@288.png new file mode 100644 index 000000000..3aee572c9 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_right@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_right@384.png b/tests/work/turbobadger/resources/default_skin/arrow_right@384.png new file mode 100644 index 000000000..54b098706 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_right@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_up.png b/tests/work/turbobadger/resources/default_skin/arrow_up.png new file mode 100644 index 000000000..dea45c5b8 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_up.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_up@192.png b/tests/work/turbobadger/resources/default_skin/arrow_up@192.png new file mode 100644 index 000000000..70aaa0547 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_up@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_up@288.png b/tests/work/turbobadger/resources/default_skin/arrow_up@288.png new file mode 100644 index 000000000..821c3145b Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_up@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/arrow_up@384.png b/tests/work/turbobadger/resources/default_skin/arrow_up@384.png new file mode 100644 index 000000000..221a1477b Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/arrow_up@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button.png b/tests/work/turbobadger/resources/default_skin/button.png new file mode 100644 index 000000000..f7bf402fc Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button.psd b/tests/work/turbobadger/resources/default_skin/button.psd new file mode 100644 index 000000000..dabc834a1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/button_flat.psd b/tests/work/turbobadger/resources/default_skin/button_flat.psd new file mode 100644 index 000000000..3d7eb21d1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_flat.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/button_flat_outline.png b/tests/work/turbobadger/resources/default_skin/button_flat_outline.png new file mode 100644 index 000000000..bb17f7f7d Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_flat_outline.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_flat_pressed.png b/tests/work/turbobadger/resources/default_skin/button_flat_pressed.png new file mode 100644 index 000000000..2b29e1b0b Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_flat_pressed.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped.psd b/tests/work/turbobadger/resources/default_skin/button_grouped.psd new file mode 100644 index 000000000..f47504dac Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_down.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_down.png new file mode 100644 index 000000000..056f3f895 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_down.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_up.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_up.png new file mode 100644 index 000000000..d21a107fd Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_first_up.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_down.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_down.png new file mode 100644 index 000000000..ae11e6e00 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_down.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_up.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_up.png new file mode 100644 index 000000000..d01ae9b26 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_last_up.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_down.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_down.png new file mode 100644 index 000000000..99793781e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_down.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_up.png b/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_up.png new file mode 100644 index 000000000..c50de0825 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_grouped_x_middle_up.png differ diff --git a/tests/work/turbobadger/resources/default_skin/button_pressed.png b/tests/work/turbobadger/resources/default_skin/button_pressed.png new file mode 100644 index 000000000..4bf844274 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/button_pressed.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox.png b/tests/work/turbobadger/resources/default_skin/checkbox.png new file mode 100644 index 000000000..0191da62f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox@192.png b/tests/work/turbobadger/resources/default_skin/checkbox@192.png new file mode 100644 index 000000000..e2c0e89e3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox@288.png b/tests/work/turbobadger/resources/default_skin/checkbox@288.png new file mode 100644 index 000000000..0ce5e73f5 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox@384.png b/tests/work/turbobadger/resources/default_skin/checkbox@384.png new file mode 100644 index 000000000..b1f5c8e57 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_mark.png b/tests/work/turbobadger/resources/default_skin/checkbox_mark.png new file mode 100644 index 000000000..b8f07004e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_mark.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_mark@192.png b/tests/work/turbobadger/resources/default_skin/checkbox_mark@192.png new file mode 100644 index 000000000..ee7b6c5cd Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_mark@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_mark@288.png b/tests/work/turbobadger/resources/default_skin/checkbox_mark@288.png new file mode 100644 index 000000000..d31468d47 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_mark@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_mark@384.png b/tests/work/turbobadger/resources/default_skin/checkbox_mark@384.png new file mode 100644 index 000000000..d1392c90f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_mark@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_pressed.png b/tests/work/turbobadger/resources/default_skin/checkbox_pressed.png new file mode 100644 index 000000000..3cfede0fe Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_pressed.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_pressed@192.png b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@192.png new file mode 100644 index 000000000..419378d53 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_pressed@288.png b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@288.png new file mode 100644 index 000000000..dc3cd2958 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkbox_pressed@384.png b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@384.png new file mode 100644 index 000000000..632e3146d Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkbox_pressed@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/checkradio.psd b/tests/work/turbobadger/resources/default_skin/checkradio.psd new file mode 100644 index 000000000..47c37b2e5 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/checkradio.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/container.png b/tests/work/turbobadger/resources/default_skin/container.png new file mode 100644 index 000000000..a3958ad7c Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/container.png differ diff --git a/tests/work/turbobadger/resources/default_skin/container.psd b/tests/work/turbobadger/resources/default_skin/container.psd new file mode 100644 index 000000000..d684b5576 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/container.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/dropdown_button.psd b/tests/work/turbobadger/resources/default_skin/dropdown_button.psd new file mode 100644 index 000000000..2f392500a Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/dropdown_button.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/editfield.png b/tests/work/turbobadger/resources/default_skin/editfield.png new file mode 100644 index 000000000..1f6cb9e9f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/editfield.png differ diff --git a/tests/work/turbobadger/resources/default_skin/editfield.psd b/tests/work/turbobadger/resources/default_skin/editfield.psd new file mode 100644 index 000000000..cf89182c6 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/editfield.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/fadeout.psd b/tests/work/turbobadger/resources/default_skin/fadeout.psd new file mode 100644 index 000000000..8edab630f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/fadeout.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/fadeout_x.png b/tests/work/turbobadger/resources/default_skin/fadeout_x.png new file mode 100644 index 000000000..1001812d2 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/fadeout_x.png differ diff --git a/tests/work/turbobadger/resources/default_skin/fadeout_y.png b/tests/work/turbobadger/resources/default_skin/fadeout_y.png new file mode 100644 index 000000000..178fe3635 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/fadeout_y.png differ diff --git a/tests/work/turbobadger/resources/default_skin/focus.psd b/tests/work/turbobadger/resources/default_skin/focus.psd new file mode 100644 index 000000000..5d3177b3f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/focus.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/focus_r4.png b/tests/work/turbobadger/resources/default_skin/focus_r4.png new file mode 100644 index 000000000..ac8388a9b Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/focus_r4.png differ diff --git a/tests/work/turbobadger/resources/default_skin/focus_tabbutton_left.png b/tests/work/turbobadger/resources/default_skin/focus_tabbutton_left.png new file mode 100644 index 000000000..3cb739b76 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/focus_tabbutton_left.png differ diff --git a/tests/work/turbobadger/resources/default_skin/focus_tabbutton_top.png b/tests/work/turbobadger/resources/default_skin/focus_tabbutton_top.png new file mode 100644 index 000000000..1f579cba7 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/focus_tabbutton_top.png differ diff --git a/tests/work/turbobadger/resources/default_skin/hover.psd b/tests/work/turbobadger/resources/default_skin/hover.psd new file mode 100644 index 000000000..6502fdd84 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/hover.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/item.psd b/tests/work/turbobadger/resources/default_skin/item.psd new file mode 100644 index 000000000..ee471990f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/item.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/item_hover.png b/tests/work/turbobadger/resources/default_skin/item_hover.png new file mode 100644 index 000000000..d4dbd4e05 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/item_hover.png differ diff --git a/tests/work/turbobadger/resources/default_skin/item_selected.png b/tests/work/turbobadger/resources/default_skin/item_selected.png new file mode 100644 index 000000000..e82364135 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/item_selected.png differ diff --git a/tests/work/turbobadger/resources/default_skin/item_separator_x.png b/tests/work/turbobadger/resources/default_skin/item_separator_x.png new file mode 100644 index 000000000..839f98864 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/item_separator_x.png differ diff --git a/tests/work/turbobadger/resources/default_skin/item_separator_y.png b/tests/work/turbobadger/resources/default_skin/item_separator_y.png new file mode 100644 index 000000000..c1ae4c8d8 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/item_separator_y.png differ diff --git a/tests/work/turbobadger/resources/default_skin/license.txt b/tests/work/turbobadger/resources/default_skin/license.txt new file mode 100644 index 000000000..4b726a3c7 --- /dev/null +++ b/tests/work/turbobadger/resources/default_skin/license.txt @@ -0,0 +1,5 @@ +This is the default skin of Turbo Badger. +The license of the skin is Public Domain. + +For more information about Turbo Badger and its license, +see tb_core.h. diff --git a/tests/work/turbobadger/resources/default_skin/messageicon.psd b/tests/work/turbobadger/resources/default_skin/messageicon.psd new file mode 100644 index 000000000..63c6d5d94 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/messageicon.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/mover_tile.psd b/tests/work/turbobadger/resources/default_skin/mover_tile.psd new file mode 100644 index 000000000..e31e95b27 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/mover_tile.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/progress_spinner_gear.psd b/tests/work/turbobadger/resources/default_skin/progress_spinner_gear.psd new file mode 100644 index 000000000..b91aedc7a Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/progress_spinner_gear.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/progress_spinner_strip.png b/tests/work/turbobadger/resources/default_skin/progress_spinner_strip.png new file mode 100644 index 000000000..f5c13d762 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/progress_spinner_strip.png differ diff --git a/tests/work/turbobadger/resources/default_skin/progress_spinner_strip@192.png b/tests/work/turbobadger/resources/default_skin/progress_spinner_strip@192.png new file mode 100644 index 000000000..9c4509525 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/progress_spinner_strip@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/progress_x.psd b/tests/work/turbobadger/resources/default_skin/progress_x.psd new file mode 100644 index 000000000..2c479e009 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/progress_x.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/progress_y.psd b/tests/work/turbobadger/resources/default_skin/progress_y.psd new file mode 100644 index 000000000..97162b198 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/progress_y.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/radio.png b/tests/work/turbobadger/resources/default_skin/radio.png new file mode 100644 index 000000000..a12ec41f3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio@192.png b/tests/work/turbobadger/resources/default_skin/radio@192.png new file mode 100644 index 000000000..5acde6977 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio@288.png b/tests/work/turbobadger/resources/default_skin/radio@288.png new file mode 100644 index 000000000..5f883be2d Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio@384.png b/tests/work/turbobadger/resources/default_skin/radio@384.png new file mode 100644 index 000000000..791fe385e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_mark.png b/tests/work/turbobadger/resources/default_skin/radio_mark.png new file mode 100644 index 000000000..531bbc0b5 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_mark.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_mark@192.png b/tests/work/turbobadger/resources/default_skin/radio_mark@192.png new file mode 100644 index 000000000..dca39096f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_mark@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_mark@288.png b/tests/work/turbobadger/resources/default_skin/radio_mark@288.png new file mode 100644 index 000000000..7c0b05a5e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_mark@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_mark@384.png b/tests/work/turbobadger/resources/default_skin/radio_mark@384.png new file mode 100644 index 000000000..bbf3908b9 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_mark@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_pressed.png b/tests/work/turbobadger/resources/default_skin/radio_pressed.png new file mode 100644 index 000000000..48391c504 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_pressed.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_pressed@192.png b/tests/work/turbobadger/resources/default_skin/radio_pressed@192.png new file mode 100644 index 000000000..dd231e99f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_pressed@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_pressed@288.png b/tests/work/turbobadger/resources/default_skin/radio_pressed@288.png new file mode 100644 index 000000000..ff9cac8d7 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_pressed@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/radio_pressed@384.png b/tests/work/turbobadger/resources/default_skin/radio_pressed@384.png new file mode 100644 index 000000000..cfd268dac Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/radio_pressed@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/resizer.png b/tests/work/turbobadger/resources/default_skin/resizer.png new file mode 100644 index 000000000..50e7a83e3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/resizer.png differ diff --git a/tests/work/turbobadger/resources/default_skin/resizer.psd b/tests/work/turbobadger/resources/default_skin/resizer.psd new file mode 100644 index 000000000..f32e29175 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/resizer.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/resizer@192.png b/tests/work/turbobadger/resources/default_skin/resizer@192.png new file mode 100644 index 000000000..537c222a1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/resizer@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/resizer@288.png b/tests/work/turbobadger/resources/default_skin/resizer@288.png new file mode 100644 index 000000000..f0c6c3988 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/resizer@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/resizer@384.png b/tests/work/turbobadger/resources/default_skin/resizer@384.png new file mode 100644 index 000000000..6a6ca49e7 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/resizer@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/scroll_bg_x.png b/tests/work/turbobadger/resources/default_skin/scroll_bg_x.png new file mode 100644 index 000000000..c001b0b09 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/scroll_bg_x.png differ diff --git a/tests/work/turbobadger/resources/default_skin/scroll_bg_y.png b/tests/work/turbobadger/resources/default_skin/scroll_bg_y.png new file mode 100644 index 000000000..0885f4255 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/scroll_bg_y.png differ diff --git a/tests/work/turbobadger/resources/default_skin/scroll_fg_x.png b/tests/work/turbobadger/resources/default_skin/scroll_fg_x.png new file mode 100644 index 000000000..2d8426e50 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/scroll_fg_x.png differ diff --git a/tests/work/turbobadger/resources/default_skin/scroll_fg_y.png b/tests/work/turbobadger/resources/default_skin/scroll_fg_y.png new file mode 100644 index 000000000..6a5f3cbe8 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/scroll_fg_y.png differ diff --git a/tests/work/turbobadger/resources/default_skin/search.png b/tests/work/turbobadger/resources/default_skin/search.png new file mode 100644 index 000000000..06711fd9a Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/search.png differ diff --git a/tests/work/turbobadger/resources/default_skin/search.psd b/tests/work/turbobadger/resources/default_skin/search.psd new file mode 100644 index 000000000..48aa309bd Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/search.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/search@192.png b/tests/work/turbobadger/resources/default_skin/search@192.png new file mode 100644 index 000000000..b6c3eb658 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/search@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/search@288.png b/tests/work/turbobadger/resources/default_skin/search@288.png new file mode 100644 index 000000000..6889fa87c Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/search@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/search@384.png b/tests/work/turbobadger/resources/default_skin/search@384.png new file mode 100644 index 000000000..85867ffe8 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/search@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/selection.png b/tests/work/turbobadger/resources/default_skin/selection.png new file mode 100644 index 000000000..6fd957ea4 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/selection.png differ diff --git a/tests/work/turbobadger/resources/default_skin/selection.psd b/tests/work/turbobadger/resources/default_skin/selection.psd new file mode 100644 index 000000000..5f29859db Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/selection.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/skin.tb.txt b/tests/work/turbobadger/resources/default_skin/skin.tb.txt new file mode 100644 index 000000000..b7654f62e --- /dev/null +++ b/tests/work/turbobadger/resources/default_skin/skin.tb.txt @@ -0,0 +1,468 @@ +# This is the default skin of Turbo Badger +# The license of the skin is Public Domain. +# +# For more information about Turbo Badger and its license, +# see tb_core.h. +description + name Turbo Badger Default skin + # Dimensions in dp (the default unit for padding and such) and bitmaps are specified for this DPI. + base-dpi 96 + # The skin also has graphics available in these DPI modes + supported-dpi 96 192 288 384 +defaults + spacing 5 + text-color #fefefe + placeholder + opacity 0.2 + disabled + opacity 0.3 +elements + TBButton + text-color #fefefe + bitmap button.png + cut 17 + expand 7 + padding 6 8 + overrides + element TBButtonInGroup + condition: target: parent, property: skin, value: button_group + condition: target: parent, property: axis, value: x + element TBButton.pressed + state pressed + TBButton.pressed + text-color #fefefe + bitmap button_pressed.png + cut 17 + expand 7 + content-ofs-x 1 + content-ofs-y 1 + + TBButton.flat + text-color #fefefe + padding 6 8 + children + element TBButton.flat.hovered + state hovered + element TBButton.flat.pressed + state pressed + TBButton.flat.hovered + bitmap button_flat_outline.png + cut 15 + expand 6 + TBButton.flat.pressed + bitmap button_flat_pressed.png + cut 8 + + # == TBButtonInGroup is not a widget. It's only used as override for TBButton under a "button_group" ==== + TBButtonInGroup + bitmap button_grouped_x_middle_up.png + cut 17 + expand 7 + padding 6 8 + overrides + element TBButtonInGroup.first + condition: target: prev sibling, property: skin, value: TBButton, test: != + element TBButtonInGroup.last + condition: target: next sibling, property: skin, value: TBButton, test: != + element TBButtonInGroup.pressed + state pressed + TBButtonInGroup.pressed + clone TBButtonInGroup + bitmap button_grouped_x_middle_down.png + content-ofs-x 1 + content-ofs-y 1 + overrides + TBButtonInGroup.first + clone TBButtonInGroup + bitmap button_grouped_x_first_up.png + overrides + element TBButtonInGroup.first.pressed + state pressed + TBButtonInGroup.first.pressed + clone TBButtonInGroup.pressed + bitmap button_grouped_x_first_down.png + overrides + TBButtonInGroup.last + clone TBButtonInGroup + bitmap button_grouped_x_last_up.png + overrides + element TBButtonInGroup.last.pressed + state pressed + TBButtonInGroup.last.pressed + clone TBButtonInGroup.pressed + bitmap button_grouped_x_last_down.png + overrides + + # == button_group is not a widget. It's specified on widgets that should group TBButton ======= + button_group + spacing -1px + + # == TBSection skins ========================================================================== + TBSection.layout + spacing -1px + TBSection.container + bitmap TBSectionContainer.png + type StretchBorder + cut 11 + expand 6 + padding 10 + TBSectionHeader + bitmap window_mover_bg_tile.png + type Tile + expand -1 + padding 3 16 + children + element TBSectionHeader.icon_0 + condition: target: this, property: value, value: 0 + condition: target: this, property: capture, test: != + element TBSectionHeader.icon_1 + condition: target: this, property: value, value: 1 + condition: target: this, property: capture, test: != + element TBSectionHeader.icon_pressed + condition: target: this, property: capture + overlays + element TBSectionHeader.overlay + state all + TBSectionHeader.overlay + bitmap window_mover_overlay.png + type StretchBorder + cut 16 + expand 3 + TBSectionHeader.icon_0 + bitmap toggle_section_icon_up.png + type Image + img-position-x 0 + img-ofs-x 4 + TBSectionHeader.icon_1 + bitmap toggle_section_icon_down.png + type Image + img-position-x 0 + img-ofs-x 4 + TBSectionHeader.icon_pressed + bitmap toggle_section_icon_middle.png + type Image + img-position-x 0 + img-ofs-x 4 + + # == TBTabContainer skins - Create strong overrides for the tab buttons four alignments ============ + TBTabContainer.rootlayout + spacing -1px + TBTabContainer.tablayout_x + padding 0 10 + TBTabContainer.tablayout_y + padding 10 0 + TBTabContainer.container + clone TBContainer + TBTabContainer.tab + strong-overrides + element TBTabContainer.tab_top + condition: target: ancestors, property: align, value: top + element TBTabContainer.tab_bottom + condition: target: ancestors, property: align, value: bottom + element TBTabContainer.tab_left + condition: target: ancestors, property: align, value: left + element TBTabContainer.tab_right + condition: target: ancestors, property: align, value: right + # == Top tab button ============================= + TBTabContainer.tab_top + bitmap tab_button_top_inactive.png + cut 12 + expand 6 + padding 6 6 3 6 + min-width 50 + overrides + element TBTabContainer.tab_top.pressed + state pressed + children + element tab_top_focus + state focused + tab_top_focus + type StretchBorder + bitmap focus_tabbutton_top.png + cut 12 + expand 6 + TBTabContainer.tab_top.pressed + bitmap tab_button_top_active.png + cut 13 + expand 6 + # == Bottom tab button ============================= + TBTabContainer.tab_bottom + bitmap tab_button_bottom_inactive.png + cut 12 + expand 6 + padding 3 6 6 6 + min-width 50 + overrides + element TBTabContainer.tab_bottom.pressed + state pressed + children + element tab_bottom_focus + state focused + tab_bottom_focus + clone tab_top_focus + flip-y 1 + TBTabContainer.tab_bottom.pressed + bitmap tab_button_bottom_active.png + cut 13 + expand 6 + # == Left tab button ============================= + TBTabContainer.tab_left + bitmap tab_button_left_inactive.png + cut 12 + expand 6 + padding 6 3 6 6 + min-width 50 + overrides + element TBTabContainer.tab_left.pressed + state pressed + children + element tab_left_focus + state focused + tab_left_focus + type StretchBorder + bitmap focus_tabbutton_left.png + cut 12 + expand 6 + TBTabContainer.tab_left.pressed + bitmap tab_button_left_active.png + cut 13 + expand 6 + # == Right tab button ============================= + TBTabContainer.tab_right + bitmap tab_button_right_inactive.png + cut 12 + expand 6 + padding 6 6 6 3 + min-width 50 + overrides + element TBTabContainer.tab_right.pressed + state pressed + children + element tab_right_focus + state focused + tab_right_focus + clone tab_left_focus + flip-x 1 + TBTabContainer.tab_right.pressed + bitmap tab_button_right_active.png + cut 13 + expand 6 + + # == TBEditField skin. Create strong overrides for the search type to add magnifier glass icon ===== + TBEditField.selection + cut 2 + bitmap selection.png + TBEditField + bitmap editfield.png + cut 12 + expand 4 + padding 4 + strong-overrides + element TBEditField.search + condition: target: this, property: edit-type, value: "search" + + TBEditField.search + clone TBEditField + padding 4 4 4 24 + min-width 50 + children + element TBEditField.search.icon + TBEditField.search.icon + bitmap search.png + type Image + img-position-x 0 + img-ofs-x 5 + + # == TBWindow skin ================================================================================= + TBWindow + bitmap window.png + cut 16 + expand 12 + padding 10 + overrides + element TBWindow.selected + state selected + TBWindow.selected + bitmap window_active.png + cut 16 + expand 12 + TBWindow.close + bitmap window_close.png + type Image + min-width 20 + min-height 20 + children + element TBWindow.close.pressed + state pressed + TBWindow.close.pressed + bitmap window_close_pressed.png + type Image + min-width 20 + min-height 20 + TBWindow.mover + text-color #b8b8b8 + bitmap window_mover_bg_tile.png + type Tile + expand -1 + padding 4 + overrides + element TBWindow.mover.active + state selected + children + element TBWindow.mover.overlay + state all + TBWindow.mover.overlay + bitmap window_mover_overlay.png + cut 12 + expand 3 + TBWindow.mover.active + clone TBWindow.mover + text-color #fefefe + overrides + overlays + children + + # == Misc skins ==================================================================================== + TBContainer + bitmap container.png + type StretchBorder + cut 12 + expand 6 + padding 10 + TBCheckBox + bitmap checkbox.png + cut 19 + expand 7 + children + element TBCheckBox.selected + state selected + element TBCheckBox.pressed + state pressed + TBCheckBox.selected + bitmap checkbox_mark.png + type Image + expand 7 + TBCheckBox.pressed + bitmap checkbox_pressed.png + type Image + TBRadioButton + bitmap radio.png + cut 19 + expand 7 + children + element TBRadioButton.selected + state selected + element TBRadioButton.pressed + state pressed + TBRadioButton.selected + bitmap radio_mark.png + type Image + expand 7 + TBRadioButton.pressed + bitmap radio_pressed.png + type Image + expand 7 + TBLayout.fadeout_x + bitmap fadeout_x.png + TBLayout.fadeout_y + bitmap fadeout_y.png + TBSelectList + clone TBEditField + padding 2 + TBSelectDropdown + clone TBButton + TBSelectDropdown.arrow + clone arrow.down + TBSelectDropdown.window + clone TBPopupWindow + TBPopupWindow + clone TBWindow + padding 2 + TBMenuWindow + clone TBPopupWindow + TBSelectItem + padding 4 10 + children + element TBSelectItem.hovered + state hovered + element TBSelectItem.selected + state selected + TBSelectItem.selected + cut 7 + bitmap item_selected.png + TBSelectItem.hovered + cut 7 + bitmap item_hover.png + TBSelectItem.separator + clone TBSeparator + + TBSeparator + bitmap item_separator_x.png + type Stretch Image + overrides + element TBSeparator.y + condition: target: parent, property: axis, value: x + TBSeparator.y + bitmap item_separator_y.png + type Stretch Image + + TBScrollBarBgX + bitmap scroll_bg_x.png + cut 11 + expand 5 + TBScrollBarFgX + bitmap scroll_fg_x.png + cut 11 + expand 5 + TBScrollBarBgY + bitmap scroll_bg_y.png + cut 11 + expand 5 + TBScrollBarFgY + bitmap scroll_fg_y.png + cut 11 + expand 5 + + TBSliderBgX + bitmap slider_bg_x.png + cut 9 + min-height 19 + max-height 19 + min-width 50 + TBSliderFgX + bitmap slider_handle.png + expand 5 + + TBSliderBgY + bitmap slider_bg_y.png + cut 9 + min-width 19 + max-width 19 + min-height 50 + TBSliderFgY + clone TBSliderFgX + + TBResizer + bitmap resizer.png + TBInlineSelect + max-width 110 + TBDimmer + background-color #00000088 + + TBProgressSpinner + min-width 28 + min-height 28 + TBProgressSpinner.fg + bitmap progress_spinner_strip.png + + # The TBList header is always disabled, thus gets slightly less opacity default. + TBList.header + + arrow.left: type: Image, bitmap: arrow_left.png, min-width: 5, min-height: 10 + arrow.right: type: Image, bitmap: arrow_right.png, min-width: 5, min-height: 10 + arrow.up: type: Image, bitmap: arrow_up.png, min-width: 10, min-height: 5 + arrow.down: type: Image, bitmap: arrow_down.png, min-width: 10, min-height: 5 + generic_focus + bitmap focus_r4.png + cut 11 + expand 4 diff --git a/tests/work/turbobadger/resources/default_skin/slider.psd b/tests/work/turbobadger/resources/default_skin/slider.psd new file mode 100644 index 000000000..64d234254 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg.psd b/tests/work/turbobadger/resources/default_skin/slider_bg.psd new file mode 100644 index 000000000..07fc2059d Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_x.png b/tests/work/turbobadger/resources/default_skin/slider_bg_x.png new file mode 100644 index 000000000..6bc6027c9 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_x.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_x@192.png b/tests/work/turbobadger/resources/default_skin/slider_bg_x@192.png new file mode 100644 index 000000000..110aa28ed Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_x@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_x@288.png b/tests/work/turbobadger/resources/default_skin/slider_bg_x@288.png new file mode 100644 index 000000000..3707f042e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_x@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_x@384.png b/tests/work/turbobadger/resources/default_skin/slider_bg_x@384.png new file mode 100644 index 000000000..decc9c8a2 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_x@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_y.png b/tests/work/turbobadger/resources/default_skin/slider_bg_y.png new file mode 100644 index 000000000..88ca1e0cd Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_y.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_y@192.png b/tests/work/turbobadger/resources/default_skin/slider_bg_y@192.png new file mode 100644 index 000000000..4be78a17f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_y@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_y@288.png b/tests/work/turbobadger/resources/default_skin/slider_bg_y@288.png new file mode 100644 index 000000000..7ab6f0862 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_y@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_bg_y@384.png b/tests/work/turbobadger/resources/default_skin/slider_bg_y@384.png new file mode 100644 index 000000000..30e3c65a3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_bg_y@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_handle.png b/tests/work/turbobadger/resources/default_skin/slider_handle.png new file mode 100644 index 000000000..be6aa5b65 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_handle.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_handle.psd b/tests/work/turbobadger/resources/default_skin/slider_handle.psd new file mode 100644 index 000000000..db0bcfdb8 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_handle.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_handle@192.png b/tests/work/turbobadger/resources/default_skin/slider_handle@192.png new file mode 100644 index 000000000..e23ba1ebf Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_handle@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_handle@288.png b/tests/work/turbobadger/resources/default_skin/slider_handle@288.png new file mode 100644 index 000000000..7ad3c97a3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_handle@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/slider_handle@384.png b/tests/work/turbobadger/resources/default_skin/slider_handle@384.png new file mode 100644 index 000000000..365a44dfa Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/slider_handle@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_bottom_active.png b/tests/work/turbobadger/resources/default_skin/tab_button_bottom_active.png new file mode 100644 index 000000000..27df061a4 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_bottom_active.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_bottom_inactive.png b/tests/work/turbobadger/resources/default_skin/tab_button_bottom_inactive.png new file mode 100644 index 000000000..32dd33fb1 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_bottom_inactive.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_left_active.png b/tests/work/turbobadger/resources/default_skin/tab_button_left_active.png new file mode 100644 index 000000000..45bc945aa Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_left_active.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_left_inactive.png b/tests/work/turbobadger/resources/default_skin/tab_button_left_inactive.png new file mode 100644 index 000000000..476acfa3a Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_left_inactive.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_right_active.png b/tests/work/turbobadger/resources/default_skin/tab_button_right_active.png new file mode 100644 index 000000000..f759ae530 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_right_active.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_right_inactive.png b/tests/work/turbobadger/resources/default_skin/tab_button_right_inactive.png new file mode 100644 index 000000000..59df9a951 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_right_inactive.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_top_active.png b/tests/work/turbobadger/resources/default_skin/tab_button_top_active.png new file mode 100644 index 000000000..ee14d6e6f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_top_active.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_button_top_inactive.png b/tests/work/turbobadger/resources/default_skin/tab_button_top_inactive.png new file mode 100644 index 000000000..4ead786e2 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_button_top_inactive.png differ diff --git a/tests/work/turbobadger/resources/default_skin/tab_section_work.psd b/tests/work/turbobadger/resources/default_skin/tab_section_work.psd new file mode 100644 index 000000000..1da781db6 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tab_section_work.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/tabbutton.psd b/tests/work/turbobadger/resources/default_skin/tabbutton.psd new file mode 100644 index 000000000..ff4b3f048 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tabbutton.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/tabbutton_left_right.psd b/tests/work/turbobadger/resources/default_skin/tabbutton_left_right.psd new file mode 100644 index 000000000..d6324ee3f Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/tabbutton_left_right.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/teststuff.psd b/tests/work/turbobadger/resources/default_skin/teststuff.psd new file mode 100644 index 000000000..f57925bae Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/teststuff.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/testtabbuttons.psd b/tests/work/turbobadger/resources/default_skin/testtabbuttons.psd new file mode 100644 index 000000000..2573d09af Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/testtabbuttons.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/toggle_section_icon.psd b/tests/work/turbobadger/resources/default_skin/toggle_section_icon.psd new file mode 100644 index 000000000..7cc80bd6d Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/toggle_section_icon.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/toggle_section_icon_down.png b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_down.png new file mode 100644 index 000000000..025141b76 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_down.png differ diff --git a/tests/work/turbobadger/resources/default_skin/toggle_section_icon_middle.png b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_middle.png new file mode 100644 index 000000000..87d6723de Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_middle.png differ diff --git a/tests/work/turbobadger/resources/default_skin/toggle_section_icon_up.png b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_up.png new file mode 100644 index 000000000..b2f681365 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/toggle_section_icon_up.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window.png b/tests/work/turbobadger/resources/default_skin/window.png new file mode 100644 index 000000000..e1090aebb Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window.psd b/tests/work/turbobadger/resources/default_skin/window.psd new file mode 100644 index 000000000..be310d746 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/window_active.png b/tests/work/turbobadger/resources/default_skin/window_active.png new file mode 100644 index 000000000..d1d3df09e Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_active.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close.png b/tests/work/turbobadger/resources/default_skin/window_close.png new file mode 100644 index 000000000..91ed790f4 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close.psd b/tests/work/turbobadger/resources/default_skin/window_close.psd new file mode 100644 index 000000000..bb85954f3 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close@192.png b/tests/work/turbobadger/resources/default_skin/window_close@192.png new file mode 100644 index 000000000..fdc8b18ef Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close@288.png b/tests/work/turbobadger/resources/default_skin/window_close@288.png new file mode 100644 index 000000000..47dcbfd96 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close@384.png b/tests/work/turbobadger/resources/default_skin/window_close@384.png new file mode 100644 index 000000000..d1d4f662b Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close_pressed.png b/tests/work/turbobadger/resources/default_skin/window_close_pressed.png new file mode 100644 index 000000000..1c7ab678c Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close_pressed.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close_pressed@192.png b/tests/work/turbobadger/resources/default_skin/window_close_pressed@192.png new file mode 100644 index 000000000..1171dc6fe Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close_pressed@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close_pressed@288.png b/tests/work/turbobadger/resources/default_skin/window_close_pressed@288.png new file mode 100644 index 000000000..9b2cde254 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close_pressed@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_close_pressed@384.png b/tests/work/turbobadger/resources/default_skin/window_close_pressed@384.png new file mode 100644 index 000000000..b9b29af0c Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_close_pressed@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover.psd b/tests/work/turbobadger/resources/default_skin/window_mover.psd new file mode 100644 index 000000000..9ae59c540 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover.psd differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile.png b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile.png new file mode 100644 index 000000000..ac469fefb Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@192.png b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@192.png new file mode 100644 index 000000000..6233950fb Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@192.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@288.png b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@288.png new file mode 100644 index 000000000..6233950fb Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@288.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@384.png b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@384.png new file mode 100644 index 000000000..0b121a658 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover_bg_tile@384.png differ diff --git a/tests/work/turbobadger/resources/default_skin/window_mover_overlay.png b/tests/work/turbobadger/resources/default_skin/window_mover_overlay.png new file mode 100644 index 000000000..748c63b39 Binary files /dev/null and b/tests/work/turbobadger/resources/default_skin/window_mover_overlay.png differ diff --git a/tests/work/turbobadger/resources/icon/icon.psd b/tests/work/turbobadger/resources/icon/icon.psd new file mode 100644 index 000000000..8e66fa811 Binary files /dev/null and b/tests/work/turbobadger/resources/icon/icon.psd differ diff --git a/tests/work/turbobadger/resources/icon/icon114.png b/tests/work/turbobadger/resources/icon/icon114.png new file mode 100644 index 000000000..838fdb3ed Binary files /dev/null and b/tests/work/turbobadger/resources/icon/icon114.png differ diff --git a/tests/work/turbobadger/resources/icon/icon128.png b/tests/work/turbobadger/resources/icon/icon128.png new file mode 100644 index 000000000..e6956b9b6 Binary files /dev/null and b/tests/work/turbobadger/resources/icon/icon128.png differ diff --git a/tests/work/turbobadger/resources/icon/icon48.png b/tests/work/turbobadger/resources/icon/icon48.png new file mode 100644 index 000000000..d30daa793 Binary files /dev/null and b/tests/work/turbobadger/resources/icon/icon48.png differ diff --git a/tests/work/turbobadger/resources/icon/icon_large.psd b/tests/work/turbobadger/resources/icon/icon_large.psd new file mode 100644 index 000000000..462f6f419 Binary files /dev/null and b/tests/work/turbobadger/resources/icon/icon_large.psd differ diff --git a/tests/work/turbobadger/resources/language/lng_en.tb.txt b/tests/work/turbobadger/resources/language/lng_en.tb.txt new file mode 100644 index 000000000..046301bfd --- /dev/null +++ b/tests/work/turbobadger/resources/language/lng_en.tb.txt @@ -0,0 +1,16 @@ +cut Cut +copy Copy +paste Paste +delete Delete +selectall Select all +undo Undo +redo Redo +TBMessageWindow.ok Ok +TBMessageWindow.cancel Cancel +TBMessageWindow.yes Yes +TBMessageWindow.no No +TBList.header Showing %d of %d +new New +save Save +close Close +search Search diff --git a/tests/work/turbobadger/resources/language/lng_sv.tb.txt b/tests/work/turbobadger/resources/language/lng_sv.tb.txt new file mode 100644 index 000000000..be22d2649 --- /dev/null +++ b/tests/work/turbobadger/resources/language/lng_sv.tb.txt @@ -0,0 +1,16 @@ +cut Klipp ut +copy Kopiera +paste Klistra in +delete Ta bort +selectall Markera all +undo Ångra +redo Gör om +TBMessageWindow.ok Ok +TBMessageWindow.cancel Avbryt +TBMessageWindow.yes Ja +TBMessageWindow.no Nej +TBList.header Visar %d av %d +new Ny +save Spara +close Stäng +search Sök diff --git a/tests/work/turbobadger/resources/metadata/tb_widgets_attr.tb.txt b/tests/work/turbobadger/resources/metadata/tb_widgets_attr.tb.txt new file mode 100644 index 000000000..40bf660da --- /dev/null +++ b/tests/work/turbobadger/resources/metadata/tb_widgets_attr.tb.txt @@ -0,0 +1,116 @@ +# +# List of supported resource attributes for all default widgets in Turbo Badger. +# All widgets of course support the attributes read by the classes they inherit (such as TBWidget). +# +# - 0 or 1 +# - number +# - number or string. Read into an TBID +# - numbers with optional unit (default is dp). F.ex 10mm +# - string +# - string or language string (f.ex "@search") +# - child widgets or attributes +# foo, bar - either foo or bar. +# foo | bar - flag combo of foo and bar. +# +# Note: As all node based resources, nodes/values may reference other node trees, +# use conditions and local & file includes. +# + +TBWidget + id + group-id + value + data + is-group-root + is-focusable + want-long-click + ignore-input + opacity (0-1) + text + connection + axis x, y + gravity left | top | right | bottom | all + visibility visible, invisible, gone + state disabled + skin + lp + width + height + min-width + min-height + max-width + max-height + pref-width + pref-height + font + name + size + rect + autofocus + +TBClickLabel +TBEditField + multiline + styling + readonly + wrap + adapt-to-content + virtual-width + placeholder + type text, search, password, email, phone, url, number + text-align left, center, right +TBTextField + text-align left, center, right +TBLayout + spacing + size preferred, available, gravity + position center, left, top, right, bottom, gravity + overflow clip, scroll + distribution preferred, available, gravity + distribution-position center, left, top, right, bottom +TBScrollContainer + adapt-content + adapt-to-content + scroll-mode xy, y, y-auto, auto, off +TBTabContainer + align left, top, right, bottom + tabs + + content + + root + +TBButton + squeezable + auto-repeat + toggle-mode +TBScrollBar +TBSlider + min + max +TBInlineSelect + min + max +TBSelectList + items + item + text + id +TBSelectDropdown + items + item + text + id +TBCheckBox +TBRadioButton +TBSkinImage +TBSeparator +TBProgressSpinner +TBContainer +TBSectionHeader +TBSection +TBToggleContainer + toggle enabled, opacity, expanded + invert +TBImageWidget + filename diff --git a/tests/work/turbobadger/resources/vera.ttf b/tests/work/turbobadger/resources/vera.ttf new file mode 100644 index 000000000..a99969e1b Binary files /dev/null and b/tests/work/turbobadger/resources/vera.ttf differ