TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
Utilities

Base types, results, hashing, JSON and number parsing. More...

Namespaces

namespace  tachyon::Hash

Classes

struct  tachyon::int2
 Integer 2D vector. More...
struct  tachyon::int3
struct  tachyon::int4
struct  tachyon::uint2
struct  tachyon::uint3
struct  tachyon::uint4
struct  tachyon::float2
struct  tachyon::float3
struct  tachyon::float4
struct  tachyon::float2x2
struct  tachyon::float3x2
 2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1.x*x + r1.y*y + r1.z More...
struct  tachyon::float4x4
struct  tachyon::byte2
struct  tachyon::byte3
struct  tachyon::byte4
struct  tachyon::short2
struct  tachyon::short3
struct  tachyon::short4
struct  tachyon::ushort2
struct  tachyon::ushort3
struct  tachyon::ushort4
struct  tachyon::color4b
struct  tachyon::color4f
struct  tachyon::IntRect
union  tachyon::IntRect::[union].__unnamed0__
struct  tachyon::IntRect::[struct].__unnamed0__.__unnamed0__
struct  tachyon::IntRect::[struct].__unnamed0__.__unnamed1__
struct  tachyon::Error
 A failure: its category and a human-readable message. More...
class  tachyon::Result< void >
 Success, or the Error saying why not. More...
class  tachyon::JsonValue
 A JSON value (RFC 8259): null, bool, number, string, array or object. More...
class  tachyon::Result< T >
 A value, or the Error saying why there is none. More...

Typedefs

using tachyon::OnGuiFunc = std::function<void()>
using tachyon::byte = unsigned char
using tachyon::ushort = unsigned short
using tachyon::SteadyClockSource = int64_t (*)()
 Where SteadyClockNowNanos reads the time; must never go backwards.

Enumerations

enum class  tachyon::PathCaseCheck : uint8_t { tachyon::PathCaseCheck::Off , tachyon::PathCaseCheck::Warn , tachyon::PathCaseCheck::Fail }
 What the library does when a resource file it opens is named in a case other than the one it has on disk. More...
enum class  tachyon::ErrorCode : uint8_t {
  tachyon::ErrorCode::Failed , tachyon::ErrorCode::InvalidArgument , tachyon::ErrorCode::NotFound , tachyon::ErrorCode::ParseFailed ,
  tachyon::ErrorCode::Unsupported , tachyon::ErrorCode::OutOfMemory , tachyon::ErrorCode::DeviceLost
}
 Why a call failed. More...

Functions

uint16_t tachyon::FloatToHalf (float value)
float tachyon::HalfToFloat (uint16_t value)
int64_t tachyon::SteadyClockNowNanos ()
 Monotonic steady_clock time in nanoseconds; a plain int64_t keeps <chrono> out of widely-included headers.
void tachyon::SetSteadyClockSource (SteadyClockSource source)
 Makes SteadyClockNowNanos read source, e.g.
template<typename T>
std::from_chars_result tachyon::FromCharsStream (const char *first, const char *last, T &value)
 std::from_chars for a decimal number, through a classic-locale stream.
template<typename T>
std::from_chars_result tachyon::FromChars (const char *first, const char *last, T &value)
 std::from_chars, falling back to FromCharsStream on standard libraries without the floating-point overloads (libc++ before LLVM 20, Apple's included).
 tachyon::JsonValue::JsonValue ()=default
 Default is null.
 tachyon::JsonValue::JsonValue (std::nullptr_t)
 tachyon::JsonValue::JsonValue (bool value)
 tachyon::JsonValue::JsonValue (int value)
 tachyon::JsonValue::JsonValue (double value)
 tachyon::JsonValue::JsonValue (std::string value)
 tachyon::JsonValue::JsonValue (std::string_view value)
 tachyon::JsonValue::JsonValue (const char *value)
 tachyon::JsonValue::JsonValue (Array value)
 tachyon::JsonValue::JsonValue (Object value)
void tachyon::SetPathCaseCheck (PathCaseCheck mode)
 Sets how resource paths are checked; see PathCaseCheck. Thread safe.
PathCaseCheck tachyon::GetPathCaseCheck ()
std::string tachyon::FindPathCaseMismatch (std::string_view path)
 The spelling on disk of the file or folder at path when it exists under a name that differs from path in case only: "Images/logo" gives "images/logo" on a file system that ignores case.
bool tachyon::CheckPathCase (std::string_view path)
 Applies the PathCaseCheck mode to a resource file about to be opened: false only in Fail mode when path is in the wrong case.
std::span< const std::byte > tachyon::FindBuiltInResource (std::string_view path)
 The copy of a resource compiled into the library: the default themes (dark.css, light.css, styles.css) and fonts (Inter, JetBrains Mono), unless the library was built with TACHYON_EMBED_RESOURCES off.
Result< std::string > tachyon::ReadResource (std::string_view path)
 A resource's contents: the file at path when it exists, else its built-in copy (which is logged, so a theme file that went missing shows up).
 tachyon::Result< T >::Result (T value)
 Implicit from a value or an Error, so functions can return either.
 tachyon::Result< T >::Result (Error error)

Detailed Description

Base types, results, hashing, JSON and number parsing.

Typedef Documentation

◆ OnGuiFunc

using tachyon::OnGuiFunc = std::function<void()>

◆ byte

using tachyon::byte = unsigned char

◆ ushort

using tachyon::ushort = unsigned short

◆ SteadyClockSource

using tachyon::SteadyClockSource = int64_t (*)()

#include <gui_core/gui_base_types.h>

Where SteadyClockNowNanos reads the time; must never go backwards.

Enumeration Type Documentation

◆ PathCaseCheck

enum class tachyon::PathCaseCheck : uint8_t
strong

#include <gui_core/gui_resources.h>

What the library does when a resource file it opens is named in a case other than the one it has on disk.

Windows and macOS open a file whatever the case of its name; Linux doesn't, so the check finds the mistake on the platform that would hide it.

Enumerator
Off 

Don't compare; opening a file costs nothing extra. The default in release builds.

Warn 

Log an error naming both spellings, and open the file. The default in debug builds.

Fail 

Log the error and refuse the file, as Linux would. The test suites use this.

◆ ErrorCode

enum class tachyon::ErrorCode : uint8_t
strong

#include <gui_core/gui_result.h>

Why a call failed.

Enumerator
Failed 

anything else; see the message

InvalidArgument 
NotFound 

a file, a device, an element

ParseFailed 

a theme, a layout

Unsupported 

the device or backend lacks a feature

OutOfMemory 
DeviceLost 

the GPU device was lost (the library recreates it)

Function Documentation

◆ FloatToHalf()

uint16_t tachyon::FloatToHalf ( float value)

◆ HalfToFloat()

float tachyon::HalfToFloat ( uint16_t value)

◆ SteadyClockNowNanos()

int64_t tachyon::SteadyClockNowNanos ( )

#include <gui_core/gui_base_types.h>

Monotonic steady_clock time in nanoseconds; a plain int64_t keeps <chrono> out of widely-included headers.

Redraw timers, the frame clock, tooltips, double-clicks and thumbnails read it, so moving it moves them all.

◆ SetSteadyClockSource()

void tachyon::SetSteadyClockSource ( SteadyClockSource source)

#include <gui_core/gui_base_types.h>

Makes SteadyClockNowNanos read source, e.g.

a test's clock that it moves on instead of sleeping; null for the steady clock again.

◆ FromCharsStream()

template<typename T>
std::from_chars_result tachyon::FromCharsStream ( const char * first,
const char * last,
T & value )

#include <gui_core/gui_from_chars.h>

std::from_chars for a decimal number, through a classic-locale stream.

For standard libraries without floating-point from_chars. The number is scanned first, as from_chars does ([-]digits[.digits][e[+-]digits], no '+' or whitespace before it): libc++'s stream would also take the letters of a hex float, so "0.25px" fails there.

◆ FromChars()

template<typename T>
std::from_chars_result tachyon::FromChars ( const char * first,
const char * last,
T & value )

#include <gui_core/gui_from_chars.h>

std::from_chars, falling back to FromCharsStream on standard libraries without the floating-point overloads (libc++ before LLVM 20, Apple's included).

◆ JsonValue() [1/10]

tachyon::JsonValue::JsonValue ( )
default

#include <gui_core/gui_json.h>

Default is null.

Converts from the matching C++ types; all numbers are stored as double.

◆ JsonValue() [2/10]

tachyon::JsonValue::JsonValue ( std::nullptr_t )
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [3/10]

tachyon::JsonValue::JsonValue ( bool value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [4/10]

tachyon::JsonValue::JsonValue ( int value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [5/10]

tachyon::JsonValue::JsonValue ( double value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [6/10]

tachyon::JsonValue::JsonValue ( std::string value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [7/10]

tachyon::JsonValue::JsonValue ( std::string_view value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [8/10]

tachyon::JsonValue::JsonValue ( const char * value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [9/10]

tachyon::JsonValue::JsonValue ( Array value)
inline

#include <gui_core/gui_json.h>

◆ JsonValue() [10/10]

tachyon::JsonValue::JsonValue ( Object value)
inline

#include <gui_core/gui_json.h>

◆ SetPathCaseCheck()

void tachyon::SetPathCaseCheck ( PathCaseCheck mode)

#include <gui_core/gui_resources.h>

Sets how resource paths are checked; see PathCaseCheck. Thread safe.

◆ GetPathCaseCheck()

PathCaseCheck tachyon::GetPathCaseCheck ( )

◆ FindPathCaseMismatch()

std::string tachyon::FindPathCaseMismatch ( std::string_view path)

#include <gui_core/gui_resources.h>

The spelling on disk of the file or folder at path when it exists under a name that differs from path in case only: "Images/logo" gives "images/logo" on a file system that ignores case.

Empty when every part matches exactly, or when nothing is there (as on Linux). A name no folder lists, such as an 8.3 short name ("RUNNER~1"), is taken as it is, and the parts after it are still compared. A relative path is compared below the working directory; an absolute one from its root. Lists one folder per part, so it costs a directory read per part.

◆ CheckPathCase()

bool tachyon::CheckPathCase ( std::string_view path)

#include <gui_core/gui_resources.h>

Applies the PathCaseCheck mode to a resource file about to be opened: false only in Fail mode when path is in the wrong case.

The library checks every theme, font, icon and shader file it opens this way; an app can check its own files the same way.

◆ FindBuiltInResource()

std::span< const std::byte > tachyon::FindBuiltInResource ( std::string_view path)

#include <gui_core/gui_resources.h>

The copy of a resource compiled into the library: the default themes (dark.css, light.css, styles.css) and fonts (Inter, JetBrains Mono), unless the library was built with TACHYON_EMBED_RESOURCES off.

Found by the end of the path, so "themes/styles.css" and "C:/app/resources/themes/styles.css" both find it, in the exact case of the file it was made from on every platform. Empty when there is none.

◆ ReadResource()

Result< std::string > tachyon::ReadResource ( std::string_view path)

#include <gui_core/gui_resources.h>

A resource's contents: the file at path when it exists, else its built-in copy (which is logged, so a theme file that went missing shows up).

The library reads its themes this way, so an app needs no resource files, and a file of the same name under the resource root replaces the built-in one. A file the PathCaseCheck refuses is an error.

◆ Result() [1/2]

template<class T>
tachyon::Result< T >::Result ( T value)
inline

#include <gui_core/gui_result.h>

Implicit from a value or an Error, so functions can return either.

◆ Result() [2/2]

template<class T>
tachyon::Result< T >::Result ( Error error)
inline