Skip to content
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
8 changes: 8 additions & 0 deletions src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ class DevTools {
void drawAdvancedSettings();
void drawNodeAttributes(CCNode* node);
void drawAttributes();
void drawBasicAttributes(CCNode* node);
void drawColorAttributes(CCNode* node);
void drawLabelAttributes(CCNode* node);
void drawAxisGapAttribute(CCNode* node);
void drawTextureAttributes(CCNode* node);
void drawMenuItemAttributes(CCNode* node);
void drawLayoutOptionsAttributes(CCNode* node);
void drawLayoutAttributes(CCNode* node);
void drawPreview();
void drawNodePreview(CCNode* node);
void drawHighlight(CCNode* node, HighlightMode mode);
Expand Down
52 changes: 41 additions & 11 deletions src/pages/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ bool checkbox(const char* text, T* ptr, bool(T::* get)() const, R(T::* set)(bool
}

void DevTools::drawNodeAttributes(CCNode* node) {
drawBasicAttributes(node);
drawColorAttributes(node);
drawLabelAttributes(node);
drawAxisGapAttribute(node);

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();

drawTextureAttributes(node);
drawMenuItemAttributes(node);

drawLayoutOptionsAttributes(node);

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();

drawLayoutAttributes(node);
}

void DevTools::drawBasicAttributes(CCNode* node) {
if (ImGui::Button("Deselect")) {
return this->selectNode(nullptr);
}
Expand Down Expand Up @@ -138,7 +160,9 @@ void DevTools::drawNodeAttributes(CCNode* node) {
&CCNode::isIgnoreAnchorPointForPosition,
&CCNode::ignoreAnchorPointForPosition
);

}

void DevTools::drawColorAttributes(CCNode* node) {
if (auto rgbaNode = typeinfo_cast<CCRGBAProtocol*>(node)) {

if (auto gradient = typeinfo_cast<CCLayerGradient*>(node)) {
Expand Down Expand Up @@ -194,14 +218,18 @@ void DevTools::drawNodeAttributes(CCNode* node) {
ImGui::SameLine();
checkbox("Cascade Opacity", rgbaNode, &CCRGBAProtocol::isCascadeOpacityEnabled, &CCRGBAProtocol::setCascadeOpacityEnabled);
}
}

void DevTools::drawLabelAttributes(CCNode* node) {
if (auto labelNode = typeinfo_cast<CCLabelProtocol*>(node)) {
std::string str = labelNode->getString();
if (ImGui::InputText("Text", &str, 256)) {
labelNode->setString(str.c_str());
}
}

}

void DevTools::drawAxisGapAttribute(CCNode* node) {
if (auto gap = typeinfo_cast<AxisGap*>(node)){
float axisGap = gap->getGap();
if (ImGui::DragFloat("Axis Gap", &axisGap)) {
Expand All @@ -211,11 +239,9 @@ void DevTools::drawNodeAttributes(CCNode* node) {
}
}
}
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();

void DevTools::drawTextureAttributes(CCNode* node) {
if (auto textureProtocol = typeinfo_cast<CCTextureProtocol*>(node)) {
if (auto texture = textureProtocol->getTexture()) {
if (auto spriteNode = typeinfo_cast<CCSprite*>(node)) {
Expand Down Expand Up @@ -268,7 +294,9 @@ void DevTools::drawNodeAttributes(CCNode* node) {
ImGui::Separator();
ImGui::NewLine();
}

}

void DevTools::drawMenuItemAttributes(CCNode* node) {
if (auto menuItemNode = typeinfo_cast<CCMenuItem*>(node)) {
const auto selector = menuItemNode->m_pfnSelector;
if (!selector) {
Expand Down Expand Up @@ -311,7 +339,9 @@ void DevTools::drawNodeAttributes(CCNode* node) {
ImGui::Separator();
ImGui::NewLine();
}
}

void DevTools::drawLayoutOptionsAttributes(CCNode* node) {
if (auto rawOpts = node->getLayoutOptions()) {
ImGui::Text("Layout options: %s", typeid(*rawOpts).name());

Expand All @@ -323,6 +353,7 @@ void DevTools::drawNodeAttributes(CCNode* node) {
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_TRASH_2 " Remove Layout Options"))) {
node->setLayoutOptions(nullptr);
return;
}
if (auto opts = typeinfo_cast<SimpleAxisLayoutOptions*>(rawOpts)) {
bool updateLayout = false;
Expand Down Expand Up @@ -636,11 +667,9 @@ void DevTools::drawNodeAttributes(CCNode* node) {
node->setLayoutOptions(AnchorLayoutOptions::create());
}
}
}

ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();

void DevTools::drawLayoutAttributes(CCNode* node){
if (auto rawLayout = node->getLayout()) {
ImGui::Text("Layout: %s", typeid(*rawLayout).name());

Expand All @@ -650,6 +679,7 @@ void DevTools::drawNodeAttributes(CCNode* node) {
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_TRASH_2 " Remove Layout"))) {
node->setLayout(nullptr);
return;
}
ImGui::SameLine();
if (ImGui::Button(U8STR(FEATHER_PLUS " Add Test Child"))) {
Expand Down