Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API change too: remove all DrawNode setLineWidth() stuff #2172

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 4 additions & 14 deletions core/2d/DrawNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static V2F_C4B_T2F* expandBufferAndGetPointer(axstd::pod_vector<V2F_C4B_T2F>& bu
return buffer.data() + oldSize;
}

DrawNode::DrawNode(float lineWidth) : _lineWidth(lineWidth), _defaultLineWidth(lineWidth)
DrawNode::DrawNode()
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;

Expand All @@ -105,9 +105,9 @@ DrawNode::~DrawNode()
freeShaderInternal(_customCommandLine);
}

DrawNode* DrawNode::create(float defaultLineWidth)
DrawNode* DrawNode::create()
{
DrawNode* ret = new DrawNode(defaultLineWidth);
DrawNode* ret = new DrawNode();
if (ret->init())
{
ret->autorelease();
Expand Down Expand Up @@ -790,8 +790,6 @@ void DrawNode::clear()
_triangles.clear();
_points.clear();
_lines.clear();

_lineWidth = _defaultLineWidth;
}

const BlendFunc& DrawNode::getBlendFunc() const
Expand All @@ -804,15 +802,7 @@ void DrawNode::setBlendFunc(const BlendFunc& blendFunc)
_blendFunc = blendFunc;
}

void DrawNode::setLineWidth(float lineWidth)
{
_defaultLineWidth = lineWidth;
}

float DrawNode::getLineWidth()
{
return _defaultLineWidth;
}

void DrawNode::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
{
Expand Down Expand Up @@ -1035,7 +1025,7 @@ void DrawNode::_drawPoly(const Vec2* verts,
{
if (thickness == 1.0f && !properties.drawOrder)
{
auto _vertices = _transform(verts, count);
auto _vertices = _transform(verts, count, closedPolygon);

unsigned int vertex_count = (closedPolygon) ? 2 * count : 2 * (count - 1);

Expand Down
28 changes: 3 additions & 25 deletions core/2d/DrawNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AX_DLL DrawNode : public Node
*
* @return Return an autorelease object.
*/
static DrawNode* create(float defaultLineWidth = DEFAULT_LINE_WIDTH);
static DrawNode* create(void);
// DrawNode();

/** Draw a point.
Expand Down Expand Up @@ -539,10 +539,6 @@ class AX_DLL DrawNode : public Node

virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;

void setLineWidth(float lineWidth);
// Get CocosStudio guide lines width.
float getLineWidth();

/**
* When isolated is set, the position of the node is no longer affected by parent nodes.
* Which means it will be drawn just like a root node.
Expand All @@ -551,7 +547,7 @@ class AX_DLL DrawNode : public Node

bool isIsolated() const { return _isolated; }

DrawNode(float lineWidth = DEFAULT_LINE_WIDTH);
DrawNode();
virtual ~DrawNode();
virtual bool init() override;

Expand Down Expand Up @@ -585,8 +581,6 @@ class AX_DLL DrawNode : public Node
axstd::pod_vector<V2F_C4B_T2F> _points;
axstd::pod_vector<V2F_C4B_T2F> _lines;

float _lineWidth = 1.0f;
float _defaultLineWidth = 1.0f;

private:
// Internal function _drawPoint
Expand Down Expand Up @@ -691,17 +685,14 @@ class AX_DLL DrawNode : public Node
class Properties
{
public:
float factor = 0.5f; /// set the lineWidth like Axmol 1.0
float factor = 0.5f; /// thickness factor

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

// Thickness stuff
float lineWidth;
float defaultLineWidth = 1.0f;

// Drawing flags
bool transform = false;
Expand Down Expand Up @@ -779,18 +770,6 @@ class AX_DLL DrawNode : public Node
*/
Vec2 getPosition() { return position; };

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

* @js NA
*/
void setLineWidth(float lw) { lineWidth = lw; };

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

* @js NA
*/
float getLineWidth() { return lineWidth; };

/** Set all default DrawNode properties.

* @js NA
Expand All @@ -801,7 +780,6 @@ class AX_DLL DrawNode : public Node
center = Vec2(0.0f, 0.0f);
rotation = 0.0f;
position = Vec2(0.0f, 0.0f);
lineWidth = 1.0f;
drawOrder = false;
};
} properties;
Expand Down
6 changes: 2 additions & 4 deletions core/2d/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,6 @@ void Label::updateContent()
{
// This is the logic for TTF fonts
const float charheight = (_textDesiredHeight / _numberOfLines);
_underlineNode->setLineWidth(charheight / 6);

// atlas font
for (int i = 0; i < _numberOfLines; ++i)
Expand All @@ -1731,23 +1730,22 @@ void Label::updateContent()
// Github issue #15214. Uses _displayedColor instead of _textColor for the underline.
// This is to have the same behavior of SystemFonts.
_underlineNode->drawLine(Vec2(_linesOffsetX[i], y), Vec2(_linesWidth[i] + _linesOffsetX[i], y),
Color4F(_displayedColor));
Color4F(_displayedColor), charheight / 6);
}
}
else if (_textSprite)
{
// ...and is the logic for System fonts
float y = 0;
const auto spriteSize = _textSprite->getContentSize();
_underlineNode->setLineWidth(spriteSize.height / 6);

if (_strikethroughEnabled)
// FIXME: system fonts don't report the height of the font correctly. only the size of the texture,
// which is POT
y += spriteSize.height / 2;
// FIXME: Might not work with different vertical alignments
_underlineNode->drawLine(Vec2(0.0f, y), Vec2(spriteSize.width, y),
Color4F(_textSprite->getDisplayedColor()));
Color4F(_textSprite->getDisplayedColor()), spriteSize.height / 6);
}
}

Expand Down
3 changes: 1 addition & 2 deletions extensions/fairygui/src/fairygui/GGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ void GGraph::updateShape()
{
if (_lineSize > 0)
{
_shape->setLineWidth(_lineSize);
_shape->drawCircle(Vec2(_size.width / 2, _size.height / 2), _size.width / 2, 0, 360, false, 1, _size.height / _size.width, _lineColor);
_shape->drawCircle(Vec2(_size.width / 2, _size.height / 2), _size.width / 2, 0, 360, false, 1, _size.height / _size.width, _lineColor, _lineSize);
}
_shape->drawSolidCircle(Vec2(_size.width / 2, _size.height / 2), _size.width / 2, 0, 360, 1, _size.height / _size.width, _fillColor);
break;
Expand Down
129 changes: 0 additions & 129 deletions extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53486,103 +53486,6 @@ int lua_ax_base_DrawNode_setBlendFunc(lua_State* tolua_S)

return 0;
}
int lua_ax_base_DrawNode_setLineWidth(lua_State* tolua_S)
{
int argc = 0;
ax::DrawNode* cobj = nullptr;
bool ok = true;

#if _AX_DEBUG >= 1
tolua_Error tolua_err;
#endif


#if _AX_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror;
#endif

cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0);

#if _AX_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_setLineWidth'", nullptr);
return 0;
}
#endif

argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
double arg0;

ok &= luaval_to_number(tolua_S, 2,&arg0, "ax.DrawNode:setLineWidth");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_setLineWidth'", nullptr);
return 0;
}
cobj->setLineWidth(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:setLineWidth",argc, 1);
return 0;

#if _AX_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_setLineWidth'.",&tolua_err);
#endif

return 0;
}
int lua_ax_base_DrawNode_getLineWidth(lua_State* tolua_S)
{
int argc = 0;
ax::DrawNode* cobj = nullptr;
bool ok = true;

#if _AX_DEBUG >= 1
tolua_Error tolua_err;
#endif


#if _AX_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror;
#endif

cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0);

#if _AX_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_getLineWidth'", nullptr);
return 0;
}
#endif

argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_getLineWidth'", nullptr);
return 0;
}
auto&& ret = cobj->getLineWidth();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:getLineWidth",argc, 0);
return 0;

#if _AX_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_getLineWidth'.",&tolua_err);
#endif

return 0;
}
int lua_ax_base_DrawNode_setIsolated(lua_State* tolua_S)
{
int argc = 0;
Expand Down Expand Up @@ -53706,19 +53609,6 @@ int lua_ax_base_DrawNode_create(lua_State* tolua_S)
object_to_luaval<ax::DrawNode>(tolua_S, "ax.DrawNode",(ax::DrawNode*)ret);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "ax.DrawNode:create");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_create'", nullptr);
return 0;
}
auto&& ret = ax::DrawNode::create(arg0);
object_to_luaval<ax::DrawNode>(tolua_S, "ax.DrawNode",(ax::DrawNode*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ax.DrawNode:create",argc, 0);
return 0;
#if _AX_DEBUG >= 1
Expand Down Expand Up @@ -53754,23 +53644,6 @@ int lua_ax_base_DrawNode_constructor(lua_State* tolua_S)
toluafix_pushusertype_object(tolua_S, ID, luaID, (void*)cobj,"ax.DrawNode");
return 1;
}
if (argc == 1)
{
double arg0;

ok &= luaval_to_number(tolua_S, 2,&arg0, "ax.DrawNode:DrawNode");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_constructor'", nullptr);
return 0;
}
cobj = new ax::DrawNode(arg0);
cobj->autorelease();
int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ;
toluafix_pushusertype_object(tolua_S, ID, luaID, (void*)cobj,"ax.DrawNode");
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:DrawNode",argc, 0);
return 0;

Expand Down Expand Up @@ -53813,8 +53686,6 @@ int lua_register_ax_base_DrawNode(lua_State* tolua_S)
tolua_function(tolua_S,"clear",lua_ax_base_DrawNode_clear);
tolua_function(tolua_S,"getBlendFunc",lua_ax_base_DrawNode_getBlendFunc);
tolua_function(tolua_S,"setBlendFunc",lua_ax_base_DrawNode_setBlendFunc);
tolua_function(tolua_S,"setLineWidth",lua_ax_base_DrawNode_setLineWidth);
tolua_function(tolua_S,"getLineWidth",lua_ax_base_DrawNode_getLineWidth);
tolua_function(tolua_S,"setIsolated",lua_ax_base_DrawNode_setIsolated);
tolua_function(tolua_S,"isIsolated",lua_ax_base_DrawNode_isIsolated);
tolua_function(tolua_S,"create", lua_ax_base_DrawNode_create);
Expand Down
Loading