Merge branch 'develop' into feature/sdl3

This commit is contained in:
Martín Lucas Golini
2026-05-02 14:45:56 -03:00
159 changed files with 15457 additions and 2257 deletions

View File

@@ -246,6 +246,8 @@ class EE_API FontTrueType : public Font {
mutable UnorderedMap<unsigned int, unsigned int> mClosestCharacterSize;
mutable UnorderedMap<Uint32, Uint32> mCodePointIndexCache;
mutable UnorderedMap<Uint32, std::tuple<Uint32, Uint32, bool>> mKeyCache;
mutable UnorderedMap<Uint64, Float> mKerningCache; // For codepoints (getKerning)
mutable UnorderedMap<Uint64, Float> mKerningGlyphCache; // For glyph indices
FontHinting mHinting{ FontHinting::Full };
FontAntialiasing mAntialiasing{ FontAntialiasing::Grayscale };
FontTrueType* mFontBold{ nullptr };

View File

@@ -2,7 +2,6 @@
#include <eepp/config.hpp>
#include <eepp/graphics/fontstyleconfig.hpp>
#include <vector>
namespace EE::Graphics {
@@ -11,12 +10,12 @@ enum class LineWrapMode { NoWrap, Letter, Word };
enum class LineWrapType { Viewport, LineBreakingColumn };
struct LineWrapInfo {
std::vector<Int64> wraps; // Each wrap character position (where the wrap must happen)
Float paddingStart{ 0 }; // Padding of the wrapped lines
SmallVector<Int64, 4> wraps; // Each wrap character position (where the wrap must happen)
Float paddingStart{ 0 }; // Padding of the wrapped lines
};
struct LineWrapInfoEx : public LineWrapInfo {
std::vector<Float> wrapsWidth; // Each wrap width
SmallVector<Float, 4> wrapsWidth; // Each wrap width
};
class EE_API LineWrap {

View File

@@ -3,6 +3,7 @@
#include <eepp/graphics/drawable.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/ui/csslayouttypes.hpp>
#include <memory>
#include <variant>
#include <vector>
@@ -33,6 +34,9 @@ class EE_API RichText : public Drawable {
*/
void addSpan( const String& text, const FontStyleConfig& style );
void addSpan( const String& text, const FontStyleConfig& style, const Rectf& margin,
const Rectf& padding );
/**
* @brief Adds a text span with individual style parameters.
* @param text The text content.
@@ -80,9 +84,17 @@ class EE_API RichText : public Drawable {
struct CustomBlock {
Sizef size;
bool isBlock{ false };
UI::CSSFloat floatType{ UI::CSSFloat::None };
UI::CSSClear clearType{ UI::CSSClear::None };
};
using Block = std::variant<std::shared_ptr<Text>, std::shared_ptr<Drawable>, CustomBlock>;
struct SpanBlock {
std::shared_ptr<Text> text;
Rectf margin;
Rectf padding;
};
using Block = std::variant<SpanBlock, std::shared_ptr<Drawable>, CustomBlock>;
/**
* @brief Adds a drawable (e.g., an image) into the text flow.
@@ -95,7 +107,9 @@ class EE_API RichText : public Drawable {
* @param size The physical dimensions of the spacer.
* @param isBlock Whether this spacer acts as a block-level element.
*/
void addCustomSize( const Sizef& size, bool isBlock = false );
void addCustomSize( const Sizef& size, bool isBlock = false,
UI::CSSFloat floatType = UI::CSSFloat::None,
UI::CSSClear clearType = UI::CSSClear::None );
/** @return The list of blocks. */
const std::vector<Block>& getBlocks() { return mBlocks; }

View File

@@ -258,7 +258,7 @@ class EE_API Text {
void setShadowColor( const Color& color );
/** @return Every cached text line width */
const std::vector<Float>& getLinesWidth();
const SmallVector<Float, 4>& getLinesWidth();
/** @return The last line width */
Float getLastLineWidth();
@@ -413,8 +413,8 @@ class EE_API Text {
TextDirection mDirection{ TextDirection::Unspecified };
Vector2f mInitialOffset{ 0.f, 0.f };
mutable std::vector<Int64> mVisualLines;
mutable std::vector<Float> mLinesWidth;
mutable SmallVector<Int64, 4> mVisualLines;
mutable SmallVector<Float, 4> mLinesWidth;
std::vector<VertexCoords> mVertices;
std::vector<Color> mColors;

View File

@@ -30,7 +30,7 @@ class EE_API TextLayout {
bool isRTL() const { return direction == TextDirection::RightToLeft; }
std::vector<Float> getLinesWidth() const;
SmallVector<Float, 4> getLinesWidth() const;
static Cache layout( const String& string, Font* font, const Uint32& fontSize,
const Uint32& style, const Uint32& tabWidth = 4,

View File

@@ -1,6 +1,7 @@
#ifndef EEPP_NETWORK_HPP
#define EEPP_NETWORK_HPP
#include <eepp/network/cookiemanager.hpp>
#include <eepp/network/ftp.hpp>
#include <eepp/network/http.hpp>
#include <eepp/network/ipaddress.hpp>

View File

@@ -0,0 +1,46 @@
#ifndef EE_NETWORK_COOKIEMANAGER_HPP
#define EE_NETWORK_COOKIEMANAGER_HPP
#include <eepp/config.hpp>
#include <eepp/network/http.hpp>
#include <map>
#include <string>
namespace EE { namespace Network {
class EE_API CookieManager {
public:
CookieManager();
/** Store Set-Cookie headers from an HTTP response for the given domain. */
void storeCookies( const std::string& domain, const Http::Response& response );
/** Store cookies from a raw Set-Cookie header string. */
void storeCookiesFromHeader( const std::string& domain, const std::string& setCookieHeader );
/** Build the Cookie header string for outgoing requests to the given domain. */
std::string getCookieHeader( const std::string& domain ) const;
/** Remove all stored cookies. */
void clear();
/** @return The number of cookie entries across all domains. */
size_t size() const;
/** @return true if no cookies are stored. */
bool empty() const;
/** @return true if the domain has cookies */
bool hasCookie( const std::string& domain ) const;
protected:
mutable Mutex mMutex;
UnorderedMap<std::string, std::map<std::string, std::string>> mCookies;
void parseSetCookie( const std::string& domain, const std::string& setCookieHeader );
};
}} // namespace EE::Network
#endif

View File

@@ -49,8 +49,9 @@ class EE_API Http : NonCopyable {
MultipleChoices = 300, ///< The requested page can be accessed from several locations
MovedPermanently = 301, ///< The requested page has permanently moved to a new location
MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
NotModified = 304, ///< For conditional requests, means the requested page hasn't
///< changed and doesn't need to be refreshed
SeeOther = 303, ///< The response can be found under a different URI using a GET method
NotModified = 304, ///< For conditional requests, means the requested page hasn't
///< changed and doesn't need to be refreshed
TemporaryRedirect = 307, ///< The requested page has temporarily moved to a new location
PermanentRedirect = 308, ///< The requested page has permanently moved to a new location
@@ -96,6 +97,8 @@ class EE_API Http : NonCopyable {
FieldTable getHeaders();
const FieldTable& getHeaders() const;
/** @brief Get the value of a field
** If the field @a field is not found in the response header,
** the empty string is returned. This function uses
@@ -180,7 +183,7 @@ class EE_API Http : NonCopyable {
///< target resource.
Patch, ///< The PATCH method is used to apply partial modifications to a resource.
Connect ///< The CONNECT method starts two-way communications with the requested
///< resource. It can be used to open a tunnel.
///< resource. It can be used to open a tunnel.
};
/** @brief Enumerate the available states for a request */
@@ -188,7 +191,8 @@ class EE_API Http : NonCopyable {
Connected, ///< Connected to server.
Sent, ///< Request sent to the server.
HeaderReceived, ///< Header received.
ContentReceived ///< Content received.
ContentReceived, ///< Content received.
Redirect, ///< A redirect has been handled
};
static std::string statusToString( Status status );
@@ -199,6 +203,9 @@ class EE_API Http : NonCopyable {
/** @return The method string from a method */
static std::string methodToString( const Method& method );
static Method getRedirectMethodFromStatus( Method requestMethod,
Response::Status responseStatus );
/** @brief Default constructor
** This constructor creates a GET request, with the root
** URI ("/") and an empty body.
@@ -675,25 +682,29 @@ class EE_API Http : NonCopyable {
const Request::ProgressCallback& progressCallback = Request::ProgressCallback(),
const Request::FieldTable& headers = Request::FieldTable(),
const std::string& body = "", const bool& validateCertificate = true,
const URI& proxy = URI() );
const URI& proxy = URI(), bool followRedirect = true );
/** Creates an async HTTP GET Request using the global HTTP Client Pool
** @return The unique async request id
*/
static Uint64 getAsync(
const Http::AsyncResponseCallback& cb, const URI& uri, const Time& timeout = Time::Zero,
const Request::ProgressCallback& progressCallback = Request::ProgressCallback(),
const Request::FieldTable& headers = Request::FieldTable(), const std::string& body = "",
const bool& validateCertificate = true, const URI& proxy = URI() );
static Uint64
getAsync( const Http::AsyncResponseCallback& cb, const URI& uri,
const Time& timeout = Time::Zero,
const Request::ProgressCallback& progressCallback = Request::ProgressCallback(),
const Request::FieldTable& headers = Request::FieldTable(),
const std::string& body = "", const bool& validateCertificate = true,
const URI& proxy = URI(), bool followRedirect = true );
/** Creates an async HTTP POST Request using the global HTTP Client Pool
** @return The unique async request id
*/
static Uint64 postAsync(
const Http::AsyncResponseCallback& cb, const URI& uri, const Time& timeout = Time::Zero,
const Request::ProgressCallback& progressCallback = Request::ProgressCallback(),
const Request::FieldTable& headers = Request::FieldTable(), const std::string& body = "",
const bool& validateCertificate = true, const URI& proxy = URI() );
static Uint64
postAsync( const Http::AsyncResponseCallback& cb, const URI& uri,
const Time& timeout = Time::Zero,
const Request::ProgressCallback& progressCallback = Request::ProgressCallback(),
const Request::FieldTable& headers = Request::FieldTable(),
const std::string& body = "", const bool& validateCertificate = true,
const URI& proxy = URI(), bool followRedirect = true );
/** It will try to get the proxy from the environment variables. */
static URI getEnvProxyURI();

View File

@@ -122,6 +122,10 @@ class EE_API Event {
OnFoldUnfoldRange,
OnResourceLoaded,
OnDiscard,
OnNavigationStarted,
OnNavigationCompleted,
OnNavigationError,
OnTitleChanged,
NoEvent = eeINDEX_NOT_FOUND
};

View File

@@ -79,7 +79,8 @@ enum NodeFlags {
NODE_FLAG_LOADING = ( 1 << 27 ),
NODE_FLAG_CLOSING_CHILDREN = ( 1 << 28 ),
NODE_FLAG_DISABLE_CLICK_FOCUS = ( 1 << 29 ),
NODE_FLAG_FREE_USE = ( 1 << 30 )
NODE_FLAG_TEXTNODE = ( 1 << 30 ),
NODE_FLAG_FREE_USE = ( 1 << 31 )
};
/**
@@ -209,6 +210,9 @@ class EE_API Node : public Transformable {
*/
virtual bool isType( const Uint32& type ) const;
/** @return True if this node is a UITextNode, false otherwise. */
bool isTextNode() const;
/**
* @brief Posts a message to this node and its ancestors.
*
@@ -1773,6 +1777,13 @@ class EE_API Node : public Transformable {
*/
bool isClosing() const;
/**
* @brief Checks if the node is marked for closure or any node in its parent tree.
*
* @return True if node is about to close
*/
bool inClosingTree() const;
/**
* @brief Checks if the node is in the process of closing children.
*

View File

@@ -1,11 +1,11 @@
#ifndef EE_SYSTEM_BASE64_HPP
#define EE_SYSTEM_BASE64_HPP
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <eepp/config.hpp>
#include <string>
#include <string_view>
namespace EE { namespace System {
@@ -13,25 +13,29 @@ class EE_API Base64 {
public:
/** Encode binary data into base64 digits with MIME style === pads
** @return The final length of the output */
static int encode( size_t in_len, const unsigned char* in, size_t out_len, char* out );
static size_t encode( size_t in_len, const unsigned char* in, size_t out_len, char* out );
/** Decode base64 digits with MIME style === pads into binary data
** @return The final length of the output */
static int decode( size_t in_len, const char* in, size_t out_len, unsigned char* out );
static size_t decode( size_t in_len, const char* in, size_t out_len, unsigned char* out );
/** Encodes a string into a base64 string
** @return True if encoding was successful */
static bool encode( const std::string& in, std::string& out );
static bool encode( std::string_view in, std::string& out );
/** Decodes a base64 string to a string
** @return True if encoding was successful */
static bool decode( const std::string& in, std::string& out );
static size_t decode( std::string_view in, std::string& out );
/** @return A safe encoding output length for an input of the length indicated */
static inline int encodeSafeOutLen( size_t in_len ) { return in_len / 3 * 4 + 4 + 1; }
static inline size_t encodeSafeOutLen( size_t in_len ) {
return ( ( in_len + 2 ) / 3 ) * 4 + 1;
}
/** @return A safe decoding output length for an input of the length indicated */
static inline int decodeSafeOutLen( size_t in_len ) { return in_len / 4 * 3 + 1; }
static inline size_t decodeSafeOutLen( size_t in_len ) {
return ( ( in_len + 3 ) / 4 ) * 3 + 1;
}
};
}} // namespace EE::System

View File

@@ -4,6 +4,7 @@
#include <eepp/ui/abstract/uiabstracttableview.hpp>
#include <eepp/ui/abstract/uiabstractview.hpp>
#include <eepp/ui/base.hpp>
#include <eepp/ui/blocklayouter.hpp>
#include <eepp/ui/border.hpp>
#include <eepp/ui/colorschemepreferences.hpp>
#include <eepp/ui/css/animationdefinition.hpp>
@@ -29,6 +30,7 @@
#include <eepp/ui/css/stylesheetvariable.hpp>
#include <eepp/ui/css/timingfunction.hpp>
#include <eepp/ui/css/transitiondefinition.hpp>
#include <eepp/ui/csslayouttypes.hpp>
#include <eepp/ui/doc/documentview.hpp>
#include <eepp/ui/doc/foldrangeservice.hpp>
#include <eepp/ui/doc/foldrangetype.hpp>
@@ -45,10 +47,8 @@
#include <eepp/ui/doc/textposition.hpp>
#include <eepp/ui/doc/textrange.hpp>
#include <eepp/ui/doc/textundostack.hpp>
#include <eepp/ui/htmlinput.hpp>
#include <eepp/ui/htmltextarea.hpp>
#include <eepp/ui/htmltextinput.hpp>
#include <eepp/ui/iconmanager.hpp>
#include <eepp/ui/inlinelayouter.hpp>
#include <eepp/ui/keyboardshortcut.hpp>
#include <eepp/ui/models/csspropertiesmodel.hpp>
#include <eepp/ui/models/filesystemmodel.hpp>
@@ -64,7 +64,9 @@
#include <eepp/ui/models/variant.hpp>
#include <eepp/ui/models/widgettreemodel.hpp>
#include <eepp/ui/mouseshortcut.hpp>
#include <eepp/ui/nonelayouter.hpp>
#include <eepp/ui/splitdirection.hpp>
#include <eepp/ui/tablelayouter.hpp>
#include <eepp/ui/tools/htmlformatter.hpp>
#include <eepp/ui/tools/textureatlaseditor.hpp>
#include <eepp/ui/tools/uiaudioplayer.hpp>
@@ -91,13 +93,22 @@
#include <eepp/ui/uifontstyleconfig.hpp>
#include <eepp/ui/uigridlayout.hpp>
#include <eepp/ui/uihelper.hpp>
#include <eepp/ui/uihtmlform.hpp>
#include <eepp/ui/uihtmlimage.hpp>
#include <eepp/ui/uihtmlinput.hpp>
#include <eepp/ui/uihtmllistitem.hpp>
#include <eepp/ui/uihtmltable.hpp>
#include <eepp/ui/uihtmltextarea.hpp>
#include <eepp/ui/uihtmltextinput.hpp>
#include <eepp/ui/uihtmlwidget.hpp>
#include <eepp/ui/uiicon.hpp>
#include <eepp/ui/uiicontheme.hpp>
#include <eepp/ui/uiiconthememanager.hpp>
#include <eepp/ui/uiimage.hpp>
#include <eepp/ui/uiitemcontainer.hpp>
#include <eepp/ui/uilayout.hpp>
#include <eepp/ui/uilayouter.hpp>
#include <eepp/ui/uilayoutermanager.hpp>
#include <eepp/ui/uilinearlayout.hpp>
#include <eepp/ui/uilistbox.hpp>
#include <eepp/ui/uilistboxitem.hpp>
@@ -129,6 +140,7 @@
#include <eepp/ui/uiscrollablewidget.hpp>
#include <eepp/ui/uiscrollbar.hpp>
#include <eepp/ui/uiscrollview.hpp>
#include <eepp/ui/uiwebview.hpp>
#include <eepp/ui/uiselectbutton.hpp>
#include <eepp/ui/uiskin.hpp>
#include <eepp/ui/uiskinstate.hpp>
@@ -140,6 +152,7 @@
#include <eepp/ui/uistackwidget.hpp>
#include <eepp/ui/uistate.hpp>
#include <eepp/ui/uistyle.hpp>
#include <eepp/ui/uisvg.hpp>
#include <eepp/ui/uitab.hpp>
#include <eepp/ui/uitablecell.hpp>
#include <eepp/ui/uitableheadercolumn.hpp>
@@ -148,6 +161,7 @@
#include <eepp/ui/uitabwidget.hpp>
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uitextinput.hpp>
#include <eepp/ui/uitextnode.hpp>
#include <eepp/ui/uitextspan.hpp>
#include <eepp/ui/uitextureregion.hpp>
#include <eepp/ui/uitextview.hpp>

View File

@@ -0,0 +1,28 @@
#ifndef EE_UI_BLOCKLAYOUTER_HPP
#define EE_UI_BLOCKLAYOUTER_HPP
#include <eepp/ui/uilayouter.hpp>
namespace EE::Graphics {
class RichText;
}
using namespace EE::Graphics;
namespace EE { namespace UI {
class EE_API BlockLayouter : public UILayouter {
public:
BlockLayouter( UIWidget* container ) : UILayouter( container ) {}
void updateLayout() override;
void computeIntrinsicWidths() override;
Float getMinIntrinsicWidth() override;
Float getMaxIntrinsicWidth() override;
protected:
void positionRichTextChildren( RichText* rt );
};
}} // namespace EE::UI
#endif

View File

@@ -230,15 +230,34 @@ enum class PropertyId : Uint32 {
DisplayOptions = String::hash( "display-options" ),
MenuWidthMode = String::hash( "menu-width-mode" ),
ExpandText = String::hash( "expand-text" ),
Colspan = String::hash( "colspan" ),
ColSpan = String::hash( "colspan" ),
TableLayout = String::hash( "table-layout" ),
Cellpadding = String::hash( "cellpadding" ),
Cellspacing = String::hash( "cellspacing" ),
CellPadding = String::hash( "cellpadding" ),
CellSpacing = String::hash( "cellspacing" ),
Size = String::hash( "size" ),
Type = String::hash( "type" ),
Rows = String::hash( "rows" ),
Cols = String::hash( "cols" ),
InputMode = String::hash( "input-mode" ),
Hidden = String::hash( "hidden" ),
Display = String::hash( "display" ),
Position = String::hash( "position" ),
Top = String::hash( "top" ),
Right = String::hash( "right" ),
Bottom = String::hash( "bottom" ),
Left = String::hash( "left" ),
ZIndex = String::hash( "z-index" ),
ListStyleType = String::hash( "list-style-type" ),
ListStylePosition = String::hash( "list-style-position" ),
ListStyleImage = String::hash( "list-style-image" ),
Float = String::hash( "float" ),
Clear = String::hash( "clear" ),
DataLanguage = String::hash( "data-language" ), // Minor hack
Action = String::hash( "action" ),
Method = String::hash( "method" ),
Enctype = String::hash( "enctype" ),
Overflow = String::hash( "overflow" ),
Target = String::hash( "target" ),
};
enum class PropertyType : Uint32 {

View File

@@ -24,7 +24,8 @@ enum class ShorthandId : Uint32 {
BorderWidth = String::hash( "border-width" ),
BorderRadius = String::hash( "border-radius" ),
MinSize = String::hash( "min-size" ),
MaxSize = String::hash( "max-size" )
MaxSize = String::hash( "max-size" ),
Font = String::hash( "font" )
};
typedef std::function<std::vector<StyleSheetProperty>( const ShorthandDefinition* shorthand,

View File

@@ -0,0 +1,82 @@
#ifndef EE_UI_CSSLAYOUTTYPES_HPP
#define EE_UI_CSSLAYOUTTYPES_HPP
#include <eepp/config.hpp>
#include <string>
namespace EE { namespace UI {
enum class CSSDisplay {
Inline,
Block,
InlineBlock,
ListItem,
Flex,
None,
Table,
TableRow,
TableCell,
TableHead,
TableBody,
TableFooter
};
struct EE_API CSSDisplayHelper {
static std::string toString( CSSDisplay display );
static CSSDisplay fromString( std::string_view val );
};
enum class CSSPosition { Static, Relative, Absolute, Fixed, Sticky };
struct EE_API CSSPositionHelper {
static std::string toString( CSSPosition position );
static CSSPosition fromString( std::string_view val );
};
enum class CSSListStyleType {
None,
Disc,
Circle,
Square,
Decimal,
LowerAlpha,
UpperAlpha,
LowerRoman,
UpperRoman
};
struct EE_API CSSListStyleTypeHelper {
static std::string toString( CSSListStyleType type );
static CSSListStyleType fromString( std::string_view val );
};
enum class CSSListStylePosition { Outside, Inside };
struct EE_API CSSListStylePositionHelper {
static std::string toString( CSSListStylePosition pos );
static CSSListStylePosition fromString( std::string_view val );
};
enum class CSSFloat { None, Left, Right };
struct EE_API CSSFloatHelper {
static std::string toString( CSSFloat val );
static CSSFloat fromString( std::string_view val );
};
enum class CSSClear { None, Left, Right, Both };
struct EE_API CSSClearHelper {
static std::string toString( CSSClear val );
static CSSClear fromString( std::string_view val );
};
}} // namespace EE::UI
#endif

View File

@@ -63,7 +63,7 @@ class EE_API DocumentView {
void updateCache( Int64 fromLine, Int64 toLine, Int64 numLines );
Config getConfig() const { return mConfig; }
const Config& getConfig() const { return mConfig; }
void setConfig( Config config );

View File

@@ -260,7 +260,9 @@ constexpr auto SyntaxStyleEmpty() {
*/
class EE_API SyntaxColorScheme {
public:
static SyntaxColorScheme getDefault();
static SyntaxColorScheme getDefaultDark();
static SyntaxColorScheme getDefaultLight();
static std::vector<SyntaxColorScheme> loadFromStream( IOStream& stream );

View File

@@ -658,7 +658,7 @@ class EE_API TextDocument {
TextPosition getMatchingBracket( TextPosition startPosition,
const String::StringBaseType& openBracket,
const String::StringBaseType& closeBracket, MatchDirection dir,
bool allowDepth = true );
bool allowDepth = true, Time timeout = Time::Zero );
TextRange getMatchingBracket( TextPosition startPosition, const String& openBracket,
const String& closeBracket, MatchDirection dir,

View File

@@ -0,0 +1,17 @@
#ifndef EE_UI_INLINELAYOUTER_HPP
#define EE_UI_INLINELAYOUTER_HPP
#include <eepp/ui/uilayouter.hpp>
namespace EE { namespace UI {
class EE_API InlineLayouter : public UILayouter {
public:
InlineLayouter( UIWidget* container ) : UILayouter( container ) {}
void updateLayout() override {}
void computeIntrinsicWidths() override {}
};
}} // namespace EE::UI
#endif

View File

@@ -0,0 +1,17 @@
#ifndef EE_UI_NONELAYOUTER_HPP
#define EE_UI_NONELAYOUTER_HPP
#include <eepp/ui/uilayouter.hpp>
namespace EE { namespace UI {
class EE_API NoneLayouter : public UILayouter {
public:
NoneLayouter( UIWidget* container ) : UILayouter( container ) {}
void updateLayout() override {}
void computeIntrinsicWidths() override {}
};
}} // namespace EE::UI
#endif

View File

@@ -0,0 +1,59 @@
#ifndef EE_UI_TABLELAYOUTER_HPP
#define EE_UI_TABLELAYOUTER_HPP
#include <eepp/core/small_vector.hpp>
#include <eepp/ui/uilayouter.hpp>
namespace EE { namespace UI {
class UIHTMLTableRow;
class UIHTMLTableCell;
class UIHTMLTableHead;
class UIHTMLTableBody;
class UIHTMLTableFooter;
enum class TableLayout { Auto, Fixed };
class EE_API TableLayouter : public UILayouter {
public:
TableLayouter( UIWidget* container ) : UILayouter( container ) {}
void updateLayout() override;
void computeIntrinsicWidths() override;
void setTableLayout( TableLayout layout );
TableLayout getTableLayout() const;
void setCellPadding( Float padding );
Float getCellPadding() const;
void setCellSpacing( Float spacing );
Float getCellSpacing() const;
Float getMinIntrinsicWidth() override;
Float getMaxIntrinsicWidth() override;
protected:
SmallVector<UIHTMLTableRow*> mRows;
SmallVector<Float> mColWidths;
SmallVector<UIHTMLTableCell*> mCells;
SmallVector<Uint32> mRowCellOffsets;
SmallVector<Float> mColMinWidths;
SmallVector<Float> mColMaxWidths;
SmallVector<Float> mColSpecifiedWidths;
TableLayout mTableLayout{ TableLayout::Auto };
UIHTMLTableHead* mHead{ nullptr };
UIHTMLTableBody* mBody{ nullptr };
UIHTMLTableFooter* mFooter{ nullptr };
Float mCellpadding{ 0 };
Float mCellspacing{ 0 };
};
}} // namespace EE::UI
#endif

View File

@@ -88,13 +88,13 @@ class EE_API UIBorderDrawable : public Drawable {
protected:
const UINode* mOwner;
VertexBuffer* mVertexBuffer;
Borders mBorders;
mutable Borders mBorders;
BorderStr mBorderStr;
BorderType mBorderType;
Sizef mSize;
bool mNeedsUpdate;
bool mColorNeedsUpdate;
bool mHasBorder;
mutable bool mHasBorder;
bool mSmooth{ false };
virtual void onAlphaChange();
@@ -105,7 +105,7 @@ class EE_API UIBorderDrawable : public Drawable {
void update();
void updateBorders();
void updateBorders() const;
};
}} // namespace EE::UI

View File

@@ -187,6 +187,10 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
static UICodeEditor* New();
static UICodeEditor* NewWithTag( const std::string& tag,
const bool& autoRegisterBaseCommands = true,
const bool& autoRegisterBaseKeybindings = true );
static UICodeEditor* NewOpt( const bool& autoRegisterBaseCommands,
const bool& autoRegisterBaseKeybindings );
@@ -844,6 +848,14 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
size_t getTotalVisibleLines() const;
bool usesDefaultStyle() const { return mUseDefaultStyle; }
void setUseDefaultStyle( bool use );
bool dynamicTheming() const { return mDynamicTheming; }
void setDynamicTheming( bool set );
protected:
struct LastXOffset {
TextPosition position{ 0, 0 };
@@ -893,6 +905,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
bool mTabStops{ false };
bool mKerningEnabled{ false };
bool mDisableScrollInvalidation{ false };
bool mDynamicTheming{ false };
DocumentView mDocView;
Clock mBlinkTimer;
Time mBlinkTime;
@@ -1219,6 +1232,10 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
virtual void onAutoSize();
virtual void onClassChange();
inline bool needsHorizontalLength() const;
void updateDynamicTheme();
};
}} // namespace EE::UI

View File

@@ -113,6 +113,7 @@ enum UINodeType {
UI_TYPE_TEXTSPAN,
UI_TYPE_RICHTEXT,
UI_TYPE_MARKDOWNVIEW,
UI_TYPE_HTML_WIDGET,
UI_TYPE_HTML_TABLE,
UI_TYPE_HTML_TABLE_HEAD,
UI_TYPE_HTML_TABLE_BODY,
@@ -127,6 +128,12 @@ enum UINodeType {
UI_TYPE_BR,
UI_TYPE_HTML_HTML,
UI_TYPE_HTML_BODY,
UI_TYPE_HTML_LIST_ITEM,
UI_TYPE_HTML_IMAGE,
UI_TYPE_HTML_FORM,
UI_TYPE_WEBVIEW,
UI_TYPE_SVG,
UI_TYPE_TEXTNODE,
UI_TYPE_MODULES = 10000,
UI_TYPE_TERMINAL = 10001,
UI_TYPE_USER = 200000,

View File

@@ -0,0 +1,56 @@
#ifndef EE_UI_UIHTMLFORM_HPP
#define EE_UI_UIHTMLFORM_HPP
#include <string>
#include <utility>
#include <vector>
#include <eepp/ui/uirichtext.hpp>
namespace EE { namespace UI {
class UISceneNode;
class EE_API UIHTMLForm : public UIRichText {
public:
static UIHTMLForm* New();
UIHTMLForm( const std::string& tag = "form" );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual bool applyProperty( const StyleSheetProperty& attribute );
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& propertyIndex = 0 ) const;
virtual std::vector<PropertyId> getPropertiesImplemented() const;
void submit();
const std::string& getAction() const { return mAction; }
void setAction( const std::string& action ) { mAction = action; }
const std::string& getMethod() const { return mMethod; }
void setMethod( const std::string& method ) { mMethod = method; }
const std::string& getEnctype() const { return mEnctype; }
void setEnctype( const std::string& enctype ) { mEnctype = enctype; }
protected:
std::string mAction;
std::string mMethod{ "GET" };
std::string mEnctype{ "application/x-www-form-urlencoded" };
virtual Uint32 onMessage( const NodeMessage* msg );
static void collectFormData( Node* node,
std::vector<std::pair<std::string, std::string>>& fields );
bool isSubmitTrigger( Node* sender ) const;
};
}} // namespace EE::UI
#endif

View File

@@ -0,0 +1,34 @@
#ifndef EE_UI_UIHTMLIMAGE_HPP
#define EE_UI_UIHTMLIMAGE_HPP
#include <eepp/ui/uiimage.hpp>
namespace EE { namespace UI {
class EE_API UIHTMLImage : public UIImage {
public:
static UIHTMLImage* New();
virtual ~UIHTMLImage();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual void loadFromXmlNode( const pugi::xml_node& node );
virtual void draw();
const std::string& getAlt() const;
UIHTMLImage* setAlt( const std::string& alt );
protected:
UIHTMLImage();
std::string mAlt;
};
}} // namespace EE::UI
#endif

View File

@@ -1,15 +1,15 @@
#ifndef EE_UI_HTMLINPUT_HPP
#define EE_UI_HTMLINPUT_HPP
#ifndef EE_UI_UIHTMLINPUT_HPP
#define EE_UI_UIHTMLINPUT_HPP
#include <eepp/ui/uiwidget.hpp>
namespace EE { namespace UI {
class EE_API HTMLInput : public UIWidget {
class EE_API UIHTMLInput : public UIWidget {
public:
static HTMLInput* New();
static UIHTMLInput* New();
HTMLInput();
UIHTMLInput();
virtual Uint32 getType() const;
@@ -32,10 +32,13 @@ class EE_API HTMLInput : public UIWidget {
UIWidget* getChildWidget() const;
String getFormValue() const;
protected:
std::string mInputType{ "text" };
UIWidget* mChildWidget{ nullptr };
std::map<PropertyId, StyleSheetProperty> mProperties;
String mValue;
void createChildWidget();

View File

@@ -0,0 +1,51 @@
#ifndef EE_UI_UIHTMLLISTITEM_HPP
#define EE_UI_UIHTMLLISTITEM_HPP
#include <eepp/graphics/text.hpp>
#include <eepp/ui/uirichtext.hpp>
#include <memory>
namespace EE { namespace UI {
class EE_API UIHTMLListItem : public UIRichText {
public:
static UIHTMLListItem* New();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual void draw();
virtual bool applyProperty( const StyleSheetProperty& attribute );
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& propertyIndex = 0 ) const;
virtual std::vector<PropertyId> getPropertiesImplemented() const;
CSSListStyleType getListStyleType() const { return mListStyleType; }
void setListStyleType( CSSListStyleType type );
CSSListStylePosition getListStylePosition() const { return mListStylePosition; }
void setListStylePosition( CSSListStylePosition pos );
protected:
UIHTMLListItem();
CSSListStyleType mListStyleType{ CSSListStyleType::None };
CSSListStylePosition mListStylePosition{ CSSListStylePosition::Outside };
std::unique_ptr<Graphics::Text> mListMarkerText;
int countPrecedingLiSiblings() const;
String::View getListMarkerString() const;
void invalidateList();
};
}} // namespace EE::UI
#endif

View File

@@ -2,64 +2,43 @@
#define EE_UI_UIHTMLTABLE_HPP
#include <eepp/core/small_vector.hpp>
#include <eepp/ui/uilayout.hpp>
#include <eepp/ui/uihtmlwidget.hpp>
#include <eepp/ui/uirichtext.hpp>
namespace EE { namespace UI {
class UIHTMLTableRow;
class UIHTMLTableCell;
class UIHTMLTableHead;
class UIHTMLTableBody;
class UIHTMLTableFooter;
enum class TableLayout { Auto, Fixed };
class EE_API UIHTMLTable : public UILayout {
class EE_API UIHTMLTable : public UIHTMLWidget {
public:
friend class TableLayouter;
static UIHTMLTable* New();
UIHTMLTable();
void setTableLayout( TableLayout layout );
TableLayout getTableLayout() const;
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual void updateLayout();
virtual Float getMinIntrinsicWidth() const;
virtual Float getMaxIntrinsicWidth() const;
virtual std::vector<PropertyId> getPropertiesImplemented() const;
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& state = 0 ) const;
virtual bool applyProperty( const StyleSheetProperty& attribute );
protected:
virtual Uint32 onMessage( const NodeMessage* Msg );
void computeIntrinsicWidths() const;
SmallVector<UIHTMLTableRow*> mRows;
SmallVector<Float> mColWidths;
SmallVector<UIHTMLTableCell*> mCells;
SmallVector<Uint32> mRowCellOffsets;
mutable SmallVector<Float> mColMinWidths;
mutable SmallVector<Float> mColMaxWidths;
mutable SmallVector<Float> mColSpecifiedWidths;
TableLayout mTableLayout{ TableLayout::Auto };
mutable UIHTMLTableHead* mHead{ nullptr };
mutable UIHTMLTableBody* mBody{ nullptr };
mutable UIHTMLTableFooter* mFooter{ nullptr };
Float mCellpadding{ 0 };
Float mCellspacing{ 0 };
};
class EE_API UIHTMLTableCell : public UIRichText {
public:
friend class UIHTMLTable;
friend class UIHTMLTable;
friend class TableLayouter;
static UIHTMLTableCell* New( const std::string& tag );
@@ -69,17 +48,22 @@ class EE_API UIHTMLTableCell : public UIRichText {
virtual bool isType( const Uint32& type ) const;
virtual std::vector<PropertyId> getPropertiesImplemented() const;
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& state = 0 ) const;
virtual bool applyProperty( const StyleSheetProperty& attribute );
Uint32 getColspan() const;
Uint32 getColSpan() const;
virtual void onSizeChange();
protected:
Uint32 mColspan{ 1 };
Uint32 mColSpan{ 1 };
};
class EE_API UIHTMLTableRow : public UIWidget {
class EE_API UIHTMLTableRow : public UIHTMLWidget {
public:
static UIHTMLTableRow* New();
@@ -90,7 +74,7 @@ class EE_API UIHTMLTableRow : public UIWidget {
virtual bool isType( const Uint32& type ) const;
};
class EE_API UIHTMLTableHead : public UIWidget {
class EE_API UIHTMLTableHead : public UIHTMLWidget {
public:
static UIHTMLTableHead* New();
@@ -101,7 +85,7 @@ class EE_API UIHTMLTableHead : public UIWidget {
virtual bool isType( const Uint32& type ) const;
};
class EE_API UIHTMLTableFooter : public UIWidget {
class EE_API UIHTMLTableFooter : public UIHTMLWidget {
public:
static UIHTMLTableFooter* New();
@@ -112,7 +96,7 @@ class EE_API UIHTMLTableFooter : public UIWidget {
virtual bool isType( const Uint32& type ) const;
};
class EE_API UIHTMLTableBody : public UIWidget {
class EE_API UIHTMLTableBody : public UIHTMLWidget {
public:
static UIHTMLTableBody* New();

View File

@@ -1,15 +1,15 @@
#ifndef EE_UI_HTMLTEXTAREA_HPP
#define EE_UI_HTMLTEXTAREA_HPP
#ifndef EE_UI_UIHTMLTEXTAREA_HPP
#define EE_UI_UIHTMLTEXTAREA_HPP
#include <eepp/ui/uitextedit.hpp>
namespace EE { namespace UI {
class EE_API HTMLTextArea : public UITextEdit {
class EE_API UIHTMLTextArea : public UITextEdit {
public:
static HTMLTextArea* New();
static UIHTMLTextArea* New();
HTMLTextArea();
UIHTMLTextArea();
virtual Uint32 getType() const;

View File

@@ -5,11 +5,11 @@
namespace EE { namespace UI {
class EE_API HTMLTextInput : public UITextInput {
class EE_API UIHTMLTextInput : public UITextInput {
public:
static HTMLTextInput* New();
static UIHTMLTextInput* New();
HTMLTextInput();
UIHTMLTextInput();
virtual Uint32 getType() const;
@@ -33,7 +33,7 @@ class EE_API HTMLTextInput : public UITextInput {
void setHtmlSize( Uint32 size );
protected:
HTMLTextInput( const std::string& tag );
UIHTMLTextInput( const std::string& tag );
Uint32 mHtmlSize{ 20 };
bool mPacking{ false };

View File

@@ -0,0 +1,91 @@
#ifndef EE_UI_UIHTMLWIDGET_HPP
#define EE_UI_UIHTMLWIDGET_HPP
#include <eepp/ui/csslayouttypes.hpp>
#include <eepp/ui/uilayout.hpp>
namespace EE { namespace Graphics {
class RichText;
}} // namespace EE::Graphics
namespace EE { namespace UI {
class UILayouter;
class EE_API UIHTMLWidget : public UILayout {
public:
static UIHTMLWidget* New();
UIHTMLWidget( const std::string& tag = "htmlwidget" );
virtual ~UIHTMLWidget();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
UILayouter* getLayouter();
virtual bool isPacking() const;
virtual void onDisplayChange();
CSSDisplay getDisplay() const { return mDisplay; }
void setDisplay( CSSDisplay display );
CSSPosition getCSSPosition() const { return mPosition; }
void setCSSPosition( CSSPosition position );
CSSFloat getCSSFloat() const { return mFloat; }
void setCSSFloat( CSSFloat cssFloat );
CSSClear getCSSClear() const { return mClear; }
void setCSSClear( CSSClear cssClear );
const Rectf& getOffsets() const { return mOffsets; }
void setOffsets( const Rectf& offsets );
int getZIndex() const { return mZIndex; }
void setZIndex( int zIndex );
virtual std::vector<PropertyId> getPropertiesImplemented() const;
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& state = 0 ) const;
virtual bool applyProperty( const StyleSheetProperty& attribute );
virtual void updateLayout();
UIWidget* getContainingBlock();
void positionOutOfFlowChildren();
virtual RichText* getRichTextPtr() { return nullptr; }
virtual bool isMergeable() const { return false; }
virtual String getFormValue() const { return String(); }
virtual void invalidateIntrinsicSize();
bool isOutOfFlow() const;
protected:
CSSDisplay mDisplay{ CSSDisplay::Block };
CSSPosition mPosition{ CSSPosition::Static };
CSSFloat mFloat{ CSSFloat::None };
CSSClear mClear{ CSSClear::None };
std::string mTopEq{ "auto" };
std::string mRightEq{ "auto" };
std::string mBottomEq{ "auto" };
std::string mLeftEq{ "auto" };
Rectf mOffsets{ 0, 0, 0, 0 };
int mZIndex{ 0 };
UILayouter* mLayouter{ nullptr };
UnorderedMap<std::string, StyleSheetProperty> mDataProperties;
};
}} // namespace EE::UI
#endif

View File

@@ -19,12 +19,17 @@ class EE_API UILayout : public UIWidget {
void setGravityOwner( bool gravityOwner );
bool isPacking() const { return mPacking; }
virtual bool isPacking() const { return mPacking; }
bool isLayoutDirty() const { return mDirtyLayout; }
void onAutoSizeChild( UIWidget* child );
void setLayoutDirty();
protected:
friend class UISceneNode;
friend class UILayouter;
UnorderedSet<UILayout*> mLayouts;
bool mDirtyLayout{ false };
@@ -49,11 +54,7 @@ class EE_API UILayout : public UIWidget {
virtual void updateLayoutWrappingContents();
void setLayoutDirty();
bool setMatchParentIfNeededVerticalGrowth();
void onAutoSizeChild( UIWidget* child );
};
}} // namespace EE::UI

View File

@@ -0,0 +1,37 @@
#ifndef EE_UI_UILAYOUTER_HPP
#define EE_UI_UILAYOUTER_HPP
#include <cstddef>
#include <eepp/config.hpp>
namespace EE { namespace UI {
class UIWidget;
class EE_API UILayouter {
public:
UILayouter( UIWidget* container ) : mContainer( container ) {}
virtual ~UILayouter() {}
virtual void updateLayout() = 0;
virtual void computeIntrinsicWidths() {}
virtual Float getMinIntrinsicWidth() { return 0; }
virtual Float getMaxIntrinsicWidth() { return 0; }
virtual void invalidateIntrinsicWidths() { mIntrinsicWidthsDirty = true; }
virtual bool isPacking() const { return mPacking; }
protected:
UIWidget* mContainer;
bool mPacking{ false };
size_t mResizedCount{ 0 };
bool mIntrinsicWidthsDirty{ true };
Float mMinIntrinsicWidth{ 0 };
Float mMaxIntrinsicWidth{ 0 };
void setMatchParentIfNeededVerticalGrowth();
};
}} // namespace EE::UI
#endif

View File

@@ -0,0 +1,19 @@
#ifndef EE_UI_UILAYOUTERMANAGER_HPP
#define EE_UI_UILAYOUTERMANAGER_HPP
#include <eepp/config.hpp>
#include <eepp/ui/csslayouttypes.hpp>
namespace EE { namespace UI {
class UILayouter;
class UIWidget;
class EE_API UILayouterManager {
public:
static UILayouter* create( CSSDisplay display, UIWidget* container );
};
}} // namespace EE::UI
#endif

View File

@@ -32,6 +32,9 @@ class UIWidget;
class EE_API UINode : public Node {
public:
friend class BlockLayouter;
friend class InlineLayouter;
friend class TableLayouter;
/**
* @brief Creates a new UINode instance.
*
@@ -1419,6 +1422,9 @@ class EE_API UINode : public Node {
*/
virtual bool isScrollable() const;
/** @brief Get a widget's computed absolute font size in pixels. */
Float getAbsoluteFontSize( const UIWidget* widget ) const;
protected:
Vector2f mDpPos;
Sizef mDpSize;
@@ -1859,8 +1865,6 @@ class EE_API UINode : public Node {
* @return The droppable hover color.
*/
Color getDroppableHoveringColor();
Float getAbsoluteFontSize( const UIWidget* widget ) const;
};
}} // namespace EE::UI

View File

@@ -89,6 +89,8 @@ class EE_API UIPushButton : public UIWidget {
UIPushButton* setExpandTextView( bool expand );
virtual void loadFromXmlNode( const pugi::xml_node& node );
protected:
UIImage* mIcon;
UITextView* mTextBox;

View File

@@ -2,12 +2,18 @@
#define EE_UI_UIRICHTEXT_HPP
#include <eepp/graphics/richtext.hpp>
#include <eepp/ui/uihtmlwidget.hpp>
#include <eepp/ui/uilayout.hpp>
namespace EE { namespace UI {
class EE_API UIRichText : public UILayout {
class EE_API UIRichText : public UIHTMLWidget {
public:
enum class IntrinsicMode { None, Min, Max };
static void rebuildRichText( UILayout* container, RichText& richText,
IntrinsicMode mode = IntrinsicMode::None );
static UIRichText* New();
static UIRichText* NewWithTag( const std::string& tag );
@@ -38,8 +44,6 @@ class EE_API UIRichText : public UILayout {
static UIRichText* NewPre() { return UIRichText::NewWithTag( "pre" ); };
static UIRichText* NewListItem() { return UIRichText::NewWithTag( "li" ); };
static UIRichText* NewBlockquote() { return UIRichText::NewWithTag( "blockquote" ); };
virtual Uint32 getType() const;
@@ -125,14 +129,13 @@ class EE_API UIRichText : public UILayout {
String getSelectionString() const;
virtual void updateLayout();
virtual RichText* getRichTextPtr() { return &mRichText; }
protected:
RichText mRichText;
Int64 mSelCurInit{ 0 };
Int64 mSelCurEnd{ 0 };
bool mSelecting{ false };
size_t mResizedCount{ 0 };
explicit UIRichText( const std::string& tag = "richtext" );
@@ -147,7 +150,6 @@ class EE_API UIRichText : public UILayout {
virtual void onChildCountChange( Node* child, const bool& removed );
virtual void onFontChanged();
virtual void onFontStyleChanged();
virtual void onAlphaChange();
virtual void onSelectionChange();
void selCurInit( const Int64& init );
@@ -155,9 +157,7 @@ class EE_API UIRichText : public UILayout {
Int64 selCurInit() const { return mSelCurInit; }
Int64 selCurEnd() const { return mSelCurEnd; }
enum class IntrinsicMode { None, Min, Max };
void rebuildRichText( RichText& richText, IntrinsicMode mode = IntrinsicMode::None );
void positionChildren();
void updateDefaultSpansStyle();
};
@@ -166,6 +166,7 @@ class EE_API UIHTMLHtml : public UIRichText {
static UIHTMLHtml* New( const std::string& tag );
virtual Uint32 getType() const override;
bool isType( const Uint32& type ) const override;
bool applyProperty( const StyleSheetProperty& attribute ) override;
protected:
UIHTMLHtml( const std::string& tag = "html" );
@@ -184,6 +185,18 @@ class EE_API UIHTMLBody : public UIRichText {
UIHTMLBody( const std::string& tag = "body" );
};
class EE_API UILineBreak : public UIRichText {
public:
static UILineBreak* New( const std::string& tag );
virtual Uint32 getType() const;
bool isType( const Uint32& type ) const;
protected:
UILineBreak( const std::string& tag = "br" );
};
}} // namespace EE::UI
#endif

View File

@@ -3,6 +3,7 @@
#include <eepp/network/uri.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/network/cookiemanager.hpp>
#include <eepp/system/threadpool.hpp>
#include <eepp/system/translator.hpp>
#include <eepp/ui/colorschemepreferences.hpp>
@@ -27,6 +28,13 @@ class UIWidget;
class UILayout;
class UIIcon;
struct NavigationRequest {
URI uri;
std::string method{ "GET" };
std::string body;
std::map<std::string, std::string> extraHeaders;
};
class EE_API UISceneNode : public SceneNode {
public:
/**
@@ -704,10 +712,14 @@ class EE_API UISceneNode : public SceneNode {
/** Handles opening an specific URI */
void openURL( URI uri );
/* Sets a callback to intercept the openURL calls, returns true if intercepted, false to leave
* the default openURL implementation handle it.
*/
void setURLInterceptorCb( std::function<bool( URI uri )> cb ) { mURLInterceptorCb = cb; };
/** Handles navigation (GET/POST) with request body and custom headers. */
void navigate( const NavigationRequest& request );
/** Sets a callback to intercept navigate() calls. Return true to handle the request,
* false to fall through to the URL interceptor and default handling. */
void setNavigationInterceptorCb( std::function<bool( const NavigationRequest& request )> cb ) {
mNavigationInterceptorCb = cb;
};
/**
* Solves a relative path with no scheme or authority into a complete URI.
@@ -718,6 +730,10 @@ class EE_API UISceneNode : public SceneNode {
/** @return The document referer */
URI getReferer() const { return mReferer; };
const Network::CookieManager& getCookieManager() const { return mCookieManager; }
Network::CookieManager& getCookieManager() { return mCookieManager; }
protected:
friend class EE::UI::UIWindow;
friend class EE::UI::UIWidget;
@@ -747,7 +763,8 @@ class EE_API UISceneNode : public SceneNode {
std::shared_ptr<ThreadPool> mThreadPool;
URI mURI;
URI mReferer;
std::function<bool( URI uri )> mURLInterceptorCb;
std::function<bool( const NavigationRequest& request )> mNavigationInterceptorCb;
Network::CookieManager mCookieManager;
/**
* @brief Protected constructor.

View File

@@ -74,6 +74,8 @@ class EE_API UIScrollView : public UITouchDraggableWidget {
Uint32 mParentSizeChangeCb{ 0 };
Uint32 mParentCloseCb{ 0 };
UIScrollView( const std::string& tag );
UIScrollView();
virtual Uint32 onMessage( const NodeMessage* Msg );

38
include/eepp/ui/uisvg.hpp Normal file
View File

@@ -0,0 +1,38 @@
#ifndef EE_UI_UISVG_HPP
#define EE_UI_UISVG_HPP
#include <eepp/ui/uiimage.hpp>
namespace EE { namespace UI {
class EE_API UISvg : public UIImage {
public:
static UISvg* New();
virtual ~UISvg();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual void loadFromXmlNode( const pugi::xml_node& node );
const std::string& getSvgXml() const;
protected:
UISvg();
void onSizeChange();
std::string mSvgXml;
Uint64 mTaskId{ 0 };
void loadSvgXml( const pugi::xml_node& node );
void scheduleRasterize();
void rasterizeSvg( const std::string& svgXml );
void clearThreadTag();
};
}} // namespace EE::UI
#endif

View File

@@ -10,6 +10,8 @@ class EE_API UITextEdit : public UICodeEditor {
public:
static UITextEdit* New();
static UITextEdit* NewWithTag( const std::string& tag );
virtual ~UITextEdit();
virtual Uint32 getType() const;
@@ -24,11 +26,11 @@ class EE_API UITextEdit : public UICodeEditor {
void setWordWrap( bool enabled );
protected:
UITextEdit();
virtual bool applyProperty( const StyleSheetProperty& attribute );
protected:
UITextEdit( const std::string& tag );
virtual void drawCursor( const Vector2f& startScroll, const Float& lineHeight,
const TextPosition& cursor );
};

View File

@@ -0,0 +1,35 @@
#ifndef EE_UI_UITEXTNODE_HPP
#define EE_UI_UITEXTNODE_HPP
#include <eepp/ui/uiwidget.hpp>
namespace EE { namespace UI {
class EE_API UITextNode : public UIWidget {
public:
static UITextNode* New();
UITextNode();
virtual ~UITextNode();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual void draw();
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
const Uint32& propertyIndex = 0 ) const;
const String& getText() const;
void setText( const String& text );
protected:
String mText;
};
}} // namespace EE::UI
#endif

View File

@@ -2,13 +2,14 @@
#define EE_UI_UITEXTSPAN_HPP
#include <eepp/ui/uifontstyleconfig.hpp>
#include <eepp/ui/uirichtext.hpp>
#include <eepp/ui/uiwidget.hpp>
namespace EE { namespace UI {
using SpanHitBoxes = SmallVector<Rectf, 4>;
class EE_API UITextSpan : public UIWidget {
class EE_API UITextSpan : public UIRichText {
public:
static UITextSpan* New();
@@ -32,12 +33,16 @@ class EE_API UITextSpan : public UIWidget {
static UITextSpan* NewCode() { return NewWithTag( "code" ); }
static UITextSpan* NewSmall() { return NewWithTag( "small" ); }
virtual ~UITextSpan();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
virtual bool isMergeable() const;
virtual void draw();
virtual bool applyProperty( const StyleSheetProperty& attribute );
@@ -51,7 +56,7 @@ class EE_API UITextSpan : public UIWidget {
UITextSpan* setText( const String& text );
const UIFontStyleConfig& getFontStyleConfig() const;
const FontStyleConfig& getFontStyleConfig() const;
virtual void loadFromXmlNode( const pugi::xml_node& node );
@@ -97,7 +102,7 @@ class EE_API UITextSpan : public UIWidget {
UITextSpan* setFontShadowOffset( const Vector2f& offset );
void setInheritedStyle( const UIFontStyleConfig& fontStyleConfig );
void setInheritedStyle( const FontStyleConfig& fontStyleConfig );
enum StyleState {
StyleStateNone = 0,
@@ -134,21 +139,18 @@ class EE_API UITextSpan : public UIWidget {
protected:
Uint32 mStyleState{ StyleStateNone };
String mText;
UIFontStyleConfig mFontStyleConfig;
SpanHitBoxes mHitBoxes;
explicit UITextSpan( const std::string& tag = "span" );
virtual void drawBorder();
virtual void onTextChanged();
virtual void onFontChanged();
virtual void onFontStyleChanged();
virtual void onAlphaChange();
virtual void onChildCountChange( Node* child, const bool& removed );
virtual Uint32 onMessage( const NodeMessage* Msg );
};
@@ -171,6 +173,7 @@ class EE_API UIAnchorSpan : public UITextSpan {
UIAnchorSpan( const std::string& tag = "a" );
std::string mHref;
std::string mTarget;
virtual Uint32 onKeyDown( const KeyEvent& event );

View File

@@ -0,0 +1,114 @@
#ifndef EE_UIWEBVIEW_HPP
#define EE_UIWEBVIEW_HPP
#include <eepp/network/http.hpp>
#include <eepp/network/uri.hpp>
#include <eepp/scene/event.hpp>
#include <eepp/system/time.hpp>
#include <eepp/ui/uiscrollview.hpp>
#include <functional>
#include <string>
#include <vector>
using namespace EE::Network;
namespace EE { namespace UI {
class UIHTMLHtml;
class UIHTMLBody;
class EE_API UIWebView : public UIScrollView {
public:
struct NavigationEvent : Scene::Event {
URI uri;
bool success{ false };
std::string error;
NavigationEvent( Node* node, const Uint32& eventType, const URI& ruri, bool succ = false,
std::string err = "" ) :
Scene::Event( node, eventType ),
uri( ruri ),
success( succ ),
error( std::move( err ) ) {}
};
static UIWebView* New();
virtual ~UIWebView();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;
void loadURI( URI uri );
void loadURI( URI uri, const std::string& method, const std::string& body,
const Http::Request::FieldTable& headers );
void goHistoryBack();
void goHistoryForward();
bool canGoBack() const;
bool canGoForward() const;
const std::vector<URI>& getHistory() const;
int getHistoryIndex() const;
const URI& getCurrentURI() const;
void reload();
UIWidget* getDocumentContainer() const;
void setStyleSheetDefaultMarker( Uint32 marker );
void setUserAgent( const std::string& userAgent );
const std::string& getUserAgent() const;
void setDefaultTimeout( const Time& timeout );
Uint32 onNavigationStarted( std::function<void( const URI& )> cb );
Uint32 onNavigationCompleted( std::function<void( const URI& )> cb );
Uint32 onNavigationError( std::function<void( const URI&, const std::string& )> cb );
Uint32 onTitleChanged( std::function<void( const std::string& )> cb );
protected:
UIWebView();
UIWidget* mDocContainer{ nullptr };
std::vector<URI> mHistory;
int mHistoryIndex{ -1 };
bool mIsLoading{ false };
std::string mUserAgent;
Time mDefaultTimeout{ Seconds( 30 ) };
Uint32 mStyleSheetDefaultMarker{ 0 };
void loadURI( URI uri, bool isHistoryNav );
void loadURI( URI uri, bool isHistoryNav, const std::string& method, const std::string& body,
const Http::Request::FieldTable& headers );
virtual void onSizeChange();
void loadDocumentData( URI url, std::string data );
void
loadDocumentAsync( const URI& url, const std::string& method = "GET",
const std::string& body = "",
const Http::Request::FieldTable& headers = Http::Request::FieldTable() );
void pushHistory( const URI& url );
void navigateToHistoryIndex( int index );
void updateHTMLMinHeight( UIHTMLHtml* html, UIHTMLBody* body );
void updateHTMLMinHeightForDocument();
};
}} // namespace EE::UI
#endif

View File

@@ -21,6 +21,13 @@ namespace EE { namespace UI {
class UITooltip;
class UIStyle;
struct MarginAuto {
static constexpr auto Left = ( 1 << 0 );
static constexpr auto Right = ( 1 << 1 );
static constexpr auto Top = ( 1 << 2 );
static constexpr auto Bottom = ( 1 << 3 );
};
/**
* @brief Base class for all UI widgets in the eepp framework.
*
@@ -531,7 +538,7 @@ class EE_API UIWidget : public UINode {
* Forces a recalculation of the intrinsic widths on the next call to
* getMinIntrinsicWidth() or getMaxIntrinsicWidth().
*/
void invalidateIntrinsicSize();
virtual void invalidateIntrinsicSize();
/**
* @brief Loads widget configuration from an XML node.
@@ -611,6 +618,15 @@ class EE_API UIWidget : public UINode {
*/
const Rectf& getPixelsPadding() const;
/**
* @brief Gets the content offset area (padding + border).
*
* Returns a Rectf containing padding + border for all 4 sides.
*
* @return The content offset as a Rectf.
*/
Rectf getPixelsContentOffset() const;
/**
* @brief Sets the padding for all sides.
*
@@ -784,6 +800,21 @@ class EE_API UIWidget : public UINode {
*/
std::vector<const char*> getStyleSheetPseudoClassesStrings() const;
/** @return True if the widget is not a text node. */
bool isWidgetElement() const;
/** @return The index of this element among its sibling elements. */
Uint32 getElementIndex() const;
/** @return The index of this element among its sibling elements of the same type. */
Uint32 getElementOfTypeIndex() const;
/** @return The number of child elements. */
Uint32 getChildElementCount() const;
/** @return The number of child elements of the specified type. */
Uint32 getChildElementOfTypeCount( const Uint32& type ) const;
/**
* @brief Resets all CSS classes and removes them.
*
@@ -1315,10 +1346,21 @@ class EE_API UIWidget : public UINode {
*/
virtual void onWidgetCreated();
/**@return The property `width` converted as length */
Float getPropertyWidth() const;
/**@return The property `height` converted as length */
Float getPropertyHeight() const;
/* @return The width of the widget when size policy is match_parent */
Float getMatchParentWidth() const;
/* @return The height of the widget when size policy is match_parent */
Float getMatchParentHeight() const;
/* @return The size of the widget when size policy is match_parent */
Sizef getSizeFromLayoutPolicy();
protected:
friend class UIManager;
friend class UISceneNode;
@@ -1350,11 +1392,6 @@ class EE_API UIWidget : public UINode {
mutable bool mIntrinsicWidthsDirty{ true };
Uint8 mMarginAuto{ 0 };
static constexpr Uint8 MarginAutoLeft = ( 1 << 0 );
static constexpr Uint8 MarginAutoRight = ( 1 << 1 );
static constexpr Uint8 MarginAutoTop = ( 1 << 2 );
static constexpr Uint8 MarginAutoBottom = ( 1 << 3 );
void calculateAutoMargin();
/**
@@ -1698,15 +1735,6 @@ class EE_API UIWidget : public UINode {
*/
void reloadFontFamily();
/* @return The width of the widget when size policy is match_parent */
Float getMatchParentWidth() const;
/* @return The height of the widget when size policy is match_parent */
Float getMatchParentHeight() const;
/* @return The size of the widget when size policy is match_parent */
Sizef getSizeFromLayoutPolicy();
UIWidget* setLayoutMarginAuto( Uint32 dir, bool isAuto );
};

View File

@@ -4,10 +4,10 @@
#include <eepp/config.hpp>
#include <string>
#define EEPP_MAJOR_VERSION 2
#define EEPP_MINOR_VERSION 9
#define EEPP_PATCH_LEVEL 2
#define EEPP_CODENAME "Sādhanā"
#define EEPP_MAJOR_VERSION 3
#define EEPP_MINOR_VERSION 0
#define EEPP_PATCH_LEVEL 0
#define EEPP_CODENAME "Khaya"
/** The compiled version of the library */
#define EEPP_VERSION( x ) \