Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f5ca270
init
aismann Mar 2, 2026
d1a0ab8
Update DrawNode.cpp
aismann Mar 2, 2026
9f31fff
Update DrawNode.cpp
aismann Mar 2, 2026
cf33299
Reloaded all again
aismann Mar 2, 2026
7c58f49
Reloaded all again
aismann Mar 2, 2026
24ad5b8
Update DrawNode.cpp
aismann Mar 2, 2026
162d08d
Adapt Label.cpp underline/strikethrough
aismann Mar 2, 2026
14596b2
Update Label.cpp
aismann Mar 2, 2026
1c98dd8
clean code
aismann Mar 3, 2026
742df2e
Merge remote-tracking branch 'upstream/dev' into DrawNode_properties_…
aismann Mar 6, 2026
d9839ab
replaced Color::TRANSPARENT with Color(); removed pragma push_macro("…
aismann Mar 6, 2026
85b2438
Merge remote-tracking branch 'upstream/dev' into DrawNode_properties_…
aismann Mar 6, 2026
907c338
add missing properties.getScale(); repleaced ax::ui with ImGUI; remov…
aismann Mar 7, 2026
c9c9c5a
Merge branch 'dev' into DrawNode_properties_full_support_remove_clamps
aismann Mar 7, 2026
37a2c69
Add `const` to all properties getters.
aismann Mar 7, 2026
976f77b
Merge branch 'DrawNode_properties_full_support_remove_clamps' of http…
aismann Mar 7, 2026
9ae41b6
add const
aismann Mar 7, 2026
95e35df
Update controller.cpp
aismann Mar 7, 2026
72681b6
Update tests.h
aismann Mar 7, 2026
393abe0
Update DrawNodeTest.cpp
aismann Mar 7, 2026
ceaed66
Update DrawNodeTest.cpp
aismann Mar 7, 2026
a753a19
adapt path for "ImGui/ImGuiPresenter.h"
aismann Mar 7, 2026
b663c97
Merge remote-tracking branch 'upstream/dev' into DrawNode_properties_…
aismann Mar 8, 2026
f95cd86
#if AX_ENABLE_EXT_IMGUI
aismann Mar 8, 2026
2373c83
Committing clang-format changes
axmol-bot Mar 8, 2026
0eb2020
Merge branch 'dev' into DrawNode_properties_full_support_remove_clamps
halx99 Mar 8, 2026
07e6362
implement review comments
aismann Mar 8, 2026
bbb9107
add const and small codestyle
aismann Mar 9, 2026
b0d8ab4
Implement struct Properties
aismann Mar 11, 2026
ddeb3c0
Update DrawNode.h
aismann Mar 11, 2026
b3e89af
fix dll, add rotation (angle) on polygon test
aismann Mar 11, 2026
20ce35d
start redesign: flat Properties members
aismann Mar 11, 2026
655674b
replace properties with the flat version, adapt cpp tests ( _thicknes…
aismann Mar 11, 2026
c100a99
Adapt Label => underline/ strikethrough to _thicknessScale = 1.0f + …
aismann Mar 11, 2026
4616480
Improve LabelUnderlineStrikethroughMultiline all "text" is toggling now
aismann Mar 11, 2026
070e8f7
Apply suggestions from code review
halx99 Mar 11, 2026
e23fbce
fix review issues
halx99 Mar 11, 2026
3d98444
Improve code style and remove duplicate condition check
halx99 Mar 11, 2026
7870c8c
Committing clang-format changes
axmol-bot Mar 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
332 changes: 59 additions & 273 deletions axmol/2d/DrawNode.cpp

Large diffs are not rendered by default.

161 changes: 75 additions & 86 deletions axmol/2d/DrawNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ class AX_DLL DrawNode : public Node, public BlendProtocol
*/

void drawColoredTriangle(const Vec2* vertices3, const Color* color3);
void drawTriangle(const Vec2* vertices3, const Color& color);

void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color& color);
void drawTriangle(const Vec2* vertices3, const Color& color, float thickness = 1.0f);
void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color& color, float thickness = 1.0f);

void drawSolidTriangle(const Vec2* vertices3,
const Color& fillColor,
Expand Down Expand Up @@ -582,15 +582,9 @@ class AX_DLL DrawNode : public Node, public BlendProtocol
// Internal function _drawDot
void _drawDot(const Vec2& pos, float radius, const Color& color);

// Internal function _drawTriangle
// Internal function _drawColoredTriangle
// Note: modifies supplied vertex array
void _drawTriangle(Vec2* vertices3,
const Color& borderColor,
const Color& fillColor,
bool solid = true,
float thickness = 0.0f);

void _drawColoredTriangle(Vec2* vertices3, const Color* color3);
void _drawColoredTriangle(const Vec2* vertices3, const Color* color3);

// Internal function _drawAStar
void _drawAStar(const Vec2& center,
Expand Down Expand Up @@ -663,96 +657,91 @@ class AX_DLL DrawNode : public Node, public BlendProtocol
*/
tlx::pod_vector<Vec2> _transform(const Vec2* vertices, unsigned int& count, bool closedPolygon = false);

void applyTransform(const Vec2* from, Vec2* to, unsigned int count);

private:
AX_DISALLOW_COPY_AND_ASSIGN(DrawNode);
void applyLocalTransform(const Vec2* from, Vec2* to, unsigned int count) const;

/// Advanced settings
public:
class AX_DLL Properties
float getThicknessScale() const { return _thicknessScale; }
void setThicknessScale(float s)
{
public:
float factor; /// thickness scale factor

// transforming stuff
Vec2 scale;
Vec2 center;
float rotation;
Vec2 position;

// Drawing flags
bool transform = false;
bool drawOrder = false;

/** Set the DrawNode drawOrder
*
* @param drawOrder. true/false = On/Off
* Its for performance there
* false = cocos2dx behaviour => faster but works only on 1.0f thickness

*/
void setDrawOrder(bool dO) { drawOrder = dO; };

/** Get the DrawNode drawOrder
*
*/
bool getDrawOrder(void) { return drawOrder; };

/** Set the DrawNode transform
*
* @param transform. true/false = On/Off
*
*/
void setTransform(bool t) { transform = t; };

/** Get the DrawNode transform
*
*/
bool getTransform(void) { return transform; };

/** Set the DrawNode scale for each drawing primitive after this.

*/
void setScale(Vec2 s) { scale = s; };

/** Set the DrawNode rotation for each drawing primitive after this.
_thicknessScale = s;
_linesDirty = _trianglesDirty = true;
}

*/
void setRotation(float r) { rotation = r; };

/** Get the DrawNode rotation for each drawing primitive after this.

*/
float getRotation() { return rotation; };

/** Set the DrawNode center of rotation for each drawing primitive after this.
bool isLocalTransformEnabled() const { return _localTransformEnabled; }
void setLocalTransformEnabled(bool e)
{
_localTransformEnabled = e;
_linesDirty = _trianglesDirty = true;
}

*/
void setCenter(Vec2 c) { center = c; };
void setLocalScale(const Vec2& s)
{
_localScale = s;
_trianglesDirty = _linesDirty = true;
}
const Vec2& getLocalScale() const { return _localScale; }

/** Get the DrawNode center of rotation for each drawing primitive after this.
void setLocalPivot(const Vec2& c)
{
_localPivot = c;
_trianglesDirty = _linesDirty = true;
}
const Vec2& getLocalPivot() const { return _localPivot; }

*/
Vec2 getCenter() { return center; };
void setLocalRotation(float a)
{
_localRotation = a;
_localRotationRad = AX_DEGREES_TO_RADIANS(_localRotation);
_trianglesDirty = _linesDirty = true;
}
float getLocalRotation() const { return _localRotation; }

/** Set the DrawNode position for each drawing primitive after this.
void setLocalPosition(const Vec2& p)
{
_localPosition = p;
_trianglesDirty = _linesDirty = true;
}
const Vec2& getLocalPosition() const { return _localPosition; }

*/
void setPosition(Vec2 p) { position = p; };
void setPreserveDrawOrder(bool v)
{
_preserveDrawOrder = v;
_trianglesDirty = _linesDirty = true;
}
bool isPreserveDrawOrder() const { return _preserveDrawOrder; }

/** Get the DrawNode position for drawing primitive.
// convenience: reset to defaults
void resetAdvancedSettings()
{
_thicknessScale = 1.0f;
_localScale = Vec2(1.0f, 1.0f);
_localPivot = Vec2::ZERO;
_localRotation = 0.0f;
_localRotationRad = 0.0f;
_localPosition = Vec2::ZERO;
_preserveDrawOrder = false;
_localTransformEnabled = false;
_trianglesDirty = _linesDirty = _pointsDirty = true;
}

*/
Vec2 getPosition() { return position; };
protected:
// thickness scale (was factor)
float _thicknessScale{1.0f};

/** Set all default DrawNode properties.
// optional local transform applied to primitives when enabled
Vec2 _localScale{1.0f, 1.0f};
Vec2 _localPivot{0.0f, 0.0f};
float _localRotation{0.0f}; // local rotation in degrees
float _localRotationRad{0.0f}; // local rotation in radians (cached for efficiency)
Vec2 _localPosition{0.0f, 0.0f};

*/
void setDefaultValues();
float getFactor() { return factor; };
void setFactor(float fac) { factor = fac; };
// flags
bool _localTransformEnabled{false};
bool _preserveDrawOrder{false};

} properties;
private:
AX_DISALLOW_COPY_AND_ASSIGN(DrawNode);
};

/** @} */
Expand Down
6 changes: 2 additions & 4 deletions axmol/2d/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,8 +1523,7 @@ void Label::enableUnderline()
_lineDrawNode = DrawNode::create();
_lineDrawNode->setGlobalZOrder(getGlobalZOrder());
_lineDrawNode->setOpacity(_displayedColor.a);
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() *
2.0f); // 2.0f: Makes the line smaller
_lineDrawNode->setThicknessScale(_lineDrawNode->getThicknessScale() * 0.5f); // 0.5f: Makes the line smaller
addChild(_lineDrawNode, 100000);
}
}
Expand All @@ -1542,8 +1541,7 @@ void Label::enableStrikethrough()
_lineDrawNode = DrawNode::create();
_lineDrawNode->setGlobalZOrder(getGlobalZOrder());
_lineDrawNode->setOpacity(_displayedColor.a);
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() *
2.0f); // 2.0f: Makes the line smaller
_lineDrawNode->setThicknessScale(_lineDrawNode->getThicknessScale() * 0.5f); // 0.5f: Makes the line smaller
addChild(_lineDrawNode, 100000);
}
}
Expand Down
Loading
Loading