Skip to content

Commit

Permalink
fix(NodeView): colors for branches and scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
berdal84 committed Feb 22, 2023
1 parent c59a034 commit ea62a96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
1 change: 1 addition & 0 deletions projects/nodable/gui/include/ndbl/gui/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace ndbl {
ImVec4 ui_node_invokableColor;
ImVec4 ui_node_instructionColor;
ImVec4 ui_node_literalColor;
ImVec4 ui_node_condStructColor;
ImVec4 ui_node_shadowColor;
ImVec4 ui_node_borderHighlightedColor;
ImVec4 ui_node_borderColor;
Expand Down
7 changes: 4 additions & 3 deletions projects/nodable/gui/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ ndbl::Config::Config()
// nodes
ui_node_padding = 6.0f;
ui_node_propertyConnectorRadius = 5.0f;
ui_node_invokableColor = ImColor(255, 199, 115); // light orange
ui_node_variableColor = ImColor( 171, 190, 255); // blue
ui_node_invokableColor = ImColor(255, 199, 115); // light orange
ui_node_variableColor = ImColor( 171, 190, 255); // blue
ui_node_instructionColor = ImVec4(0.7f, 0.9f, 0.7f, 1.0f); // green
ui_node_literalColor = ImVec4(0.75f, 0.75f, 0.75f, 1.0f); // light grey
ui_node_fillColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
ui_node_condStructColor = ImVec4(1.f, 1.f, 1.f, 1.0f); // white
ui_node_fillColor = ImVec4(0.7f, 0.9f, 0.7f, 1.0f); // green
ui_node_highlightedColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
ui_node_borderColor = ImVec4(0.2f, 0.2f, 0.2f, 1.0f);
ui_node_borderHighlightedColor = ImVec4(1.0f, 1.0f, 1.0f, 0.8f);
Expand Down
24 changes: 14 additions & 10 deletions projects/nodable/gui/src/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,36 @@ File::File(std::string _name)
// Code executed after node instantiation

// add a view
auto view = _node->add_component<NodeView>();
auto node_view = _node->add_component<NodeView>();

// Set common colors
const Config& config = Nodable::get_instance().config;
view->set_color(fw::View::ColorType_Highlighted , &config.ui_node_highlightedColor);
view->set_color(fw::View::ColorType_Border , &config.ui_node_borderColor);
view->set_color(fw::View::ColorType_BorderHighlights , &config.ui_node_borderHighlightedColor);
view->set_color(fw::View::ColorType_Shadow , &config.ui_node_shadowColor);
view->set_color(fw::View::ColorType_Fill , &config.ui_node_fillColor);
node_view->set_color(fw::View::ColorType_Highlighted , &config.ui_node_highlightedColor);
node_view->set_color(fw::View::ColorType_Border , &config.ui_node_borderColor);
node_view->set_color(fw::View::ColorType_BorderHighlights , &config.ui_node_borderHighlightedColor);
node_view->set_color(fw::View::ColorType_Shadow , &config.ui_node_shadowColor);
node_view->set_color(fw::View::ColorType_Fill , &config.ui_node_fillColor);

// Set specific colors
if(_node->is<VariableNode>())
{
view->set_color(fw::View::ColorType_Fill, &config.ui_node_variableColor);
node_view->set_color(fw::View::ColorType_Fill, &config.ui_node_variableColor);
}
else if (_node->has<InvokableComponent>())
{
view->set_color(fw::View::ColorType_Fill, &config.ui_node_invokableColor);
node_view->set_color(fw::View::ColorType_Fill, &config.ui_node_invokableColor);
}
else if (_node->is<InstructionNode>())
{
view->set_color(fw::View::ColorType_Fill, &config.ui_node_instructionColor);
node_view->set_color(fw::View::ColorType_Fill, &config.ui_node_instructionColor);
}
else if (_node->is<LiteralNode>())
{
view->set_color(fw::View::ColorType_Fill, &config.ui_node_literalColor);
node_view->set_color(fw::View::ColorType_Fill, &config.ui_node_literalColor);
}
else if (_node->is<ConditionalStructNode>() || _node->is<ForLoopNode>())
{
node_view->set_color(fw::View::ColorType_Fill, &config.ui_node_condStructColor);
}
})
, m_history(&Nodable::get_instance().config.experimental_hybrid_history)
Expand Down
24 changes: 1 addition & 23 deletions projects/nodable/gui/src/NodeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,7 @@ void NodeView::set_owner(Node *_node)
expose(this_property);
}

// 2. Determine a color depending on node type
//---------------------------------------------

fw::type clss = _node->get_type();

if (_node->has<InvokableComponent>())
{
set_color(ColorType_Fill, &config.ui_node_invokableColor);
}
else if (clss.is_child_of<VariableNode>())
{
set_color(ColorType_Fill, &config.ui_node_variableColor);
}
else if (clss.is_child_of<LiteralNode>())
{
set_color(ColorType_Fill, &config.ui_node_literalColor);
}
else
{
set_color(ColorType_Fill, &config.ui_node_instructionColor);
}

// 3. NodeConnectors
// 2. NodeConnectors
//------------------

// add a successor connector per successor slot
Expand Down

0 comments on commit ea62a96

Please sign in to comment.