diff --git a/include/gui/gCircuit.h b/include/gui/gCircuit.h index 5fc84a8..d09b5d4 100644 --- a/include/gui/gCircuit.h +++ b/include/gui/gCircuit.h @@ -35,11 +35,12 @@ namespace Logicon { const int POSTPONED_CLEAR = 1 << 1; const int POSTPONED_CONNECT = 1 << 2; const int POSTPONED_DISCONNECT = 1 << 3; - ID postponedRemoveId; /// ID of gate to be removed, -1 if no postponed removal - Connection postponedConnectFrom; /// Connection info for postponed connect operation... - Connection postponedConnectTo; /// ... - Connection postponedDisconnectFrom; /// Connection info for postponed disconnect operation... - Connection postponedDisconnectTo; /// ... + std::list postponedRemoveList; /// ID of gate to be removed, -1 if no postponed removal + std::list> postponedConnectList; /// Connection info for postponed connect operation + std::list> postponedDisconnectList; /// Connection info for postponed disconnect operation + + UI::Vec2 hovered_grid_cell; + // @formatter:on GCircuit(std::shared_ptr circuit); @@ -56,6 +57,9 @@ namespace Logicon { */ bool close(); + const UI::Vec2 &getHovered_grid_cell() const; + + /** * @brief Returns this circuit * @@ -72,7 +76,7 @@ namespace Logicon { /** * @breif Returns pointer to GBlock at given position * - * @param pos position to check for + * @param pos position to check for in grid coordinates * @return pointer to GBlock or nullptr if block at given pos doesn't exist */ std::shared_ptr getGBlockAt(UI::Vec2 &pos); @@ -176,16 +180,16 @@ namespace Logicon { void executePostponed(); /// @brief apllies modification during executePostponed() - void postponedRemove(ID id); + void postponedRemove(); /// @brief apllies modification during executePostponed() void postponedClear(); /// @brief apllies modification during executePostponed() - void postponedConnect(ID idFrom, Port output, ID idTo, Port input); + void postponedConnect(); /// @brief apllies modification during executePostponed() - void postponedDisconnect(ID idFrom, Port output, ID idTo, Port input); + void postponedDisconnect(); }; } // namespace Logicon diff --git a/include/gui/gUtils.h b/include/gui/gUtils.h index e4e91ef..ef80209 100644 --- a/include/gui/gUtils.h +++ b/include/gui/gUtils.h @@ -23,37 +23,39 @@ namespace Logicon { // TODO: make all extern and init in App.init() // @formatter:off - const float MARGIN = 16.0; /// Margin between elements - const float MENU_WIDGET_HEIGHT = 64.0; - const float MENU_WIDGET_BUTTON_SIZE = 48.0; - const ImColor MENU_WIDGET_BUTTON_FG_COLOR = ImColor(229, 229, 229); /// Foreground color for buttons - const float BLOCKS_WIDGET_WIDTH = 300.0; - const float FOOTER_WIDGET_HEIGHT = 32.0; - - const float CANVAS_GRID_SIZE = 32.0; /// Basic square size on canvas - - const int CANVAS_CHANNEL_COUNT = 6; /// Like z-index, that many layers to draw - const int DEFAULT_GBLOCK_CHANNEL = 0; - const int DEFAULT_CONNECTION_CHANNEL = 1; - const int DEFAULT_GPORT_CHANNEL = 2; - const int ACTIVE_GBLOCK_CHANNEL = 3; - const int ACTIVE_GPORT_CHANNEL = 4; - const int ACTIVE_CONNECTION_CHANNEL = 5; - - const float GPORT_PADDING = CANVAS_GRID_SIZE / 8.0; - const float GPORT_SIZE = CANVAS_GRID_SIZE - 2*GPORT_PADDING; /// Dimensions for GPort button - const float BEZIER_CONTROL_DISTANCE = UI::CANVAS_GRID_SIZE * 2.0; /// How far in canvas coordinates is control point away from gPort - const float BEZIER_THICKNESS = 4.0; /// Thickness of bezier lines - const int BEZIER_SEGMENTS = 20; /// Higher = smoother bezier - - const ImColor ON_STATE_COLOR = ImColor(255, 195, 17); - const ImColor OFF_STATE_COLOR = ImColor(68, 74, 119); - const ImColor DEFAULT_GBLOCK_COLOR = ImColor(255, 255, 255, 200); /// Default - const ImColor DIMMED_GBLOCK_COLOR = ImColor(100, 100, 100, 200); - const ImColor DEFAULT_GPORT_COLOR = ImColor(68, 75, 119); - const ImColor DIMMED_GPORT_COLOR = ImColor(34, 40, 61, 200); - - const std::string GPORT_NONE_HOVERED = "-"; /// value for GPORT_CURRENTLY_HOVERED flag while non is hovered + const float MARGIN = 16.0; /// Margin between elements + const float MENU_WIDGET_HEIGHT = 64.0; + const float MENU_WIDGET_BUTTON_SIZE = 48.0; + const ImColor MENU_WIDGET_BUTTON_NORMAL_COLOR = ImColor(229, 229, 229); /// Foreground color for normal buttons + const ImColor MENU_WIDGET_BUTTON_PLAY_PUSHED_COLOR = ImColor(0, 145, 0); /// Foreground color for pushed in play button + const ImColor MENU_WIDGET_BUTTON_PAUSE_PUSHED_COLOR = ImColor(125, 0, 0); /// Foreground color for pushed in pause button + const float BLOCKS_WIDGET_WIDTH = 300.0; + const float FOOTER_WIDGET_HEIGHT = 32.0; + + const float CANVAS_GRID_SIZE = 32.0; /// Basic square size on canvas + + const int CANVAS_CHANNEL_COUNT = 6; /// Like z-index, that many layers to draw + const int DEFAULT_GBLOCK_CHANNEL = 0; + const int DEFAULT_CONNECTION_CHANNEL = 1; + const int DEFAULT_GPORT_CHANNEL = 2; + const int ACTIVE_GBLOCK_CHANNEL = 3; + const int ACTIVE_GPORT_CHANNEL = 4; + const int ACTIVE_CONNECTION_CHANNEL = 5; + + const float GPORT_PADDING = CANVAS_GRID_SIZE / 8.0; + const float GPORT_SIZE = CANVAS_GRID_SIZE - 2*GPORT_PADDING; /// Dimensions for GPort button + const float BEZIER_CONTROL_DISTANCE = UI::CANVAS_GRID_SIZE * 2.0; /// How far in canvas coordinates is control point away from gPort + const float BEZIER_THICKNESS = 4.0; /// Thickness of bezier lines + const int BEZIER_SEGMENTS = 20; /// Higher = smoother bezier + + const ImColor ON_STATE_COLOR = ImColor(255, 195, 17); + const ImColor OFF_STATE_COLOR = ImColor(68, 74, 119); + const ImColor DEFAULT_GBLOCK_COLOR = ImColor(255, 255, 255, 200); /// Default + const ImColor DIMMED_GBLOCK_COLOR = ImColor(100, 100, 100, 200); + const ImColor DEFAULT_GPORT_COLOR = ImColor(68, 75, 119); + const ImColor DIMMED_GPORT_COLOR = ImColor(34, 40, 61, 200); + + const std::string GPORT_NONE_HOVERED = "-"; /// value for GPORT_CURRENTLY_HOVERED flag while non is hovered const int KEY_DELETE = 261; // @formatter:on diff --git a/src/gui/gBlock.cpp b/src/gui/gBlock.cpp index 378d47c..2764fb9 100644 --- a/src/gui/gBlock.cpp +++ b/src/gui/gBlock.cpp @@ -90,10 +90,30 @@ namespace Logicon { ImGui::SetItemAllowOverlap(); /// FLAGS SETUP + + printf("CUR_HOV: %d CUR_DRAG: %d BEG: %d\n", GBLOCK_CURRENTLY_HOVERED, GBLOCK_CURRENTLY_DRAGGED, + GBLOCK_CLICK_BEGIN_ON_GBLOCK); + + // Set HOVERED flag + if (GBLOCK_DRAGGED_FLAG // if the block is dragged or + || (ImGui::IsItemHovered() // is hovered... + && GBLOCK_CURRENTLY_DRAGGED == -1 // and none other is dragged... + && GPort::getHovered() == UI::GPORT_NONE_HOVERED)) { // and no port is hovered... + GBLOCK_HOVERED_FLAG = true; + GBLOCK_CURRENTLY_HOVERED = gate->id; + } + // set GBLOCK_CLICK_BEGIN_ON_GBLOCK if (ImGui::IsMouseDown(0)) { - if (GBLOCK_CLICK_BEGIN_ON_GBLOCK == -1) - GBLOCK_CLICK_BEGIN_ON_GBLOCK = GBLOCK_CURRENTLY_HOVERED != -1 ? 1 : 0; + if(GBLOCK_CLICK_BEGIN_ON_GBLOCK == -1) { + auto hoveredGridCell = parentGCircuit.lock()->getHovered_grid_cell(); + if(hoveredGridCell != UI::Vec2(-1,-1)) { + if(parentGCircuit.lock()->getGBlockAt(hoveredGridCell) != nullptr) + GBLOCK_CLICK_BEGIN_ON_GBLOCK = GBLOCK_CURRENTLY_HOVERED; + else + GBLOCK_CLICK_BEGIN_ON_GBLOCK = -2; + } + } } // unset GBLOCK_CLICK_BEGIN_ON_GBLOCK @@ -102,25 +122,15 @@ namespace Logicon { } // Set DRAGGED flag - if (ImGui::IsItemHovered() // if item is hovered... - && GBLOCK_CURRENTLY_DRAGGED == -1 // and if currently dragged is nothing... + if (GBLOCK_CURRENTLY_DRAGGED == -1 // and if currently dragged is nothing... && GPort::getHovered() == UI::GPORT_NONE_HOVERED // and no port is hovered... && GPort::getDragged() == UI::GPORT_NONE_HOVERED // and no port is dragged... && ImGui::IsMouseDragging(0, 4.0) // and is dragging with minimal threshold of 4 pixels - && GBLOCK_CLICK_BEGIN_ON_GBLOCK) { + && GBLOCK_CLICK_BEGIN_ON_GBLOCK == gate->getId()) { GBLOCK_DRAGGED_FLAG = true; GBLOCK_CURRENTLY_DRAGGED = gate->id; } - // Set HOVERED flag - if (GBLOCK_DRAGGED_FLAG // if the block is dragged or - || (ImGui::IsItemHovered() // is hovered... - && GBLOCK_CURRENTLY_DRAGGED == -1 // and none other is dragged... - && GPort::getHovered() == UI::GPORT_NONE_HOVERED)) { // and no port is hovered... - GBLOCK_HOVERED_FLAG = true; - GBLOCK_CURRENTLY_HOVERED = gate->id; - } - // unset HOVERED flag if (!ImGui::IsItemHovered() // if no longer hovered or || GPort::getHovered() != UI::GPORT_NONE_HOVERED) { // if any GPort hovered @@ -136,23 +146,23 @@ namespace Logicon { GATE_TYPE gt = gate->getGateType(); if (gt == Logicon::DELAY) { auto gDelay = std::static_pointer_cast(gate); - if(ImGui::Button("options")) + if (ImGui::Button("options")) ImGui::OpenPopup("delay_opt"); - if(ImGui::BeginPopup("delay_opt")) { + if (ImGui::BeginPopup("delay_opt")) { int delay_opt = gDelay->getDelay(); ImGui::PushItemWidth(100.0); ImGui::InputInt("delay", &delay_opt); ImGui::PopItemWidth(); - if(delay_opt < 0) delay_opt = 0; + if (delay_opt < 0) delay_opt = 0; gDelay->setDelay(delay_opt); ImGui::EndPopup(); } } if (gt == Logicon::CLOCK) { auto gClock = std::static_pointer_cast(gate); - if(ImGui::Button("options")) + if (ImGui::Button("options")) ImGui::OpenPopup("clock_opt"); - if(ImGui::BeginPopup("clock_opt")) { + if (ImGui::BeginPopup("clock_opt")) { int onPeriod_opt = gClock->getOnPeriod(); int offPeriod_opt = gClock->getOffPeriod(); int phase_opt = gClock->getPhase(); @@ -161,9 +171,9 @@ namespace Logicon { ImGui::InputInt("OFF period", &offPeriod_opt); ImGui::InputInt("phase", &phase_opt); ImGui::PopItemWidth(); - if(onPeriod_opt < 0) onPeriod_opt = 0; - if(offPeriod_opt < 0) offPeriod_opt = 0; - if(phase_opt < 0) phase_opt = 0; + if (onPeriod_opt < 0) onPeriod_opt = 0; + if (offPeriod_opt < 0) offPeriod_opt = 0; + if (phase_opt < 0) phase_opt = 0; gClock->changeSettings(onPeriod_opt, offPeriod_opt, phase_opt); ImGui::EndPopup(); } diff --git a/src/gui/gCircuit.cpp b/src/gui/gCircuit.cpp index 8d702af..b077566 100644 --- a/src/gui/gCircuit.cpp +++ b/src/gui/gCircuit.cpp @@ -22,12 +22,7 @@ namespace Logicon { GCircuit::GCircuit(std::shared_ptr circuit) : circuit(circuit), - POSTPONED_OPERATIONS(0), - postponedRemoveId(0), - postponedConnectFrom(0, 0), - postponedConnectTo(0, 0), - postponedDisconnectFrom(0, 0), - postponedDisconnectTo(0, 0) {} + POSTPONED_OPERATIONS(0) {} bool GCircuit::init() { assert(circuit != nullptr); @@ -50,10 +45,9 @@ namespace Logicon { }; std::shared_ptr GCircuit::getGBlockAt(UI::Vec2 &pos) { - UI::Vec2 gridPos = UI::toGridCoordinates(pos); auto found = std::find_if( gBlocks.begin(), gBlocks.end(), - [gridPos](const std::shared_ptr &gBlock) { return gBlock->getRect().contains(gridPos); } + [pos](const std::shared_ptr &gBlock) { return gBlock->getRect().contains(pos); } ); if (found == gBlocks.end()) @@ -78,7 +72,7 @@ namespace Logicon { void GCircuit::remove(ID id) { POSTPONED_OPERATIONS |= POSTPONED_REMOVE; - postponedRemoveId = id; + postponedRemoveList.push_back(id); } void GCircuit::clear() { @@ -87,14 +81,12 @@ namespace Logicon { void GCircuit::connect(ID idFrom, Port output, ID idTo, Port input) { POSTPONED_OPERATIONS |= POSTPONED_CONNECT; - postponedConnectFrom = {idFrom, output}; - postponedConnectTo = {idTo, input}; + postponedConnectList.push_back(std::make_pair(Connection(idFrom, output), Connection(idTo, input))); } void GCircuit::disconnect(ID idFrom, Port output, ID idTo, Port input) { POSTPONED_OPERATIONS |= POSTPONED_DISCONNECT; - postponedDisconnectFrom = {idFrom, output}; - postponedDisconnectTo = {idTo, input}; + postponedDisconnectList.push_back(std::make_pair(Connection(idFrom, output), Connection(idTo, input))); } bool GCircuit::isOccupied(ID id, UI::Rect rect) { @@ -136,8 +128,8 @@ namespace Logicon { const UI::Vec2 dl_origin = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin(); { - UI::Vec2 hovered_grid_cell = - UI::toGridCoordinates(ImGui::GetMousePos() - dl_origin); + hovered_grid_cell = ImGui::IsWindowHovered() ? UI::toGridCoordinates(ImGui::GetMousePos() - dl_origin) + : UI::Vec2(-1, -1); std::string status_x = ImGui::IsWindowHovered() ? std::to_string((int) hovered_grid_cell.x) : "-"; std::string status_y = ImGui::IsWindowHovered() ? std::to_string((int) hovered_grid_cell.y) : "-"; @@ -329,11 +321,11 @@ namespace Logicon { void GCircuit::executePostponed() { // @formatter:off if (POSTPONED_OPERATIONS & POSTPONED_CONNECT) - postponedConnect(postponedConnectFrom.id, postponedConnectFrom.port, postponedConnectTo.id, postponedConnectTo.port); + postponedConnect(); if (POSTPONED_OPERATIONS & POSTPONED_DISCONNECT) - postponedDisconnect(postponedConnectFrom.id, postponedConnectFrom.port, postponedConnectTo.id, postponedConnectTo.port); + postponedDisconnect(); if (POSTPONED_OPERATIONS & POSTPONED_REMOVE) - postponedRemove(postponedRemoveId); + postponedRemove(); if (POSTPONED_OPERATIONS & POSTPONED_CLEAR) postponedClear(); @@ -341,14 +333,17 @@ namespace Logicon { // @formatter:on } - void GCircuit::postponedRemove(ID id) { - // remove from graphical model - auto found = std::find_if(gBlocks.begin(), gBlocks.end(), - [id](const std::shared_ptr &gBlock) { return gBlock->getId() == id; }); - if (found != gBlocks.end()) - gBlocks.erase(found); - // remove from model - circuit->remove(id); + void GCircuit::postponedRemove() { + for (auto id : postponedRemoveList) { + // remove from graphical model + auto found = std::find_if(gBlocks.begin(), gBlocks.end(), + [id](const std::shared_ptr &gBlock) { return gBlock->getId() == id; }); + if (found != gBlocks.end()) + gBlocks.erase(found); + // remove from model + circuit->remove(id); + } + postponedRemoveList.clear(); } void GCircuit::postponedClear() { @@ -356,12 +351,22 @@ namespace Logicon { circuit->clear(); } - void GCircuit::postponedConnect(ID idFrom, Port output, ID idTo, Port input) { - circuit->connect(idFrom, output, idTo, input); + void GCircuit::postponedConnect() { + for (auto connectionPair : postponedConnectList) + circuit->connect(connectionPair.first.id, connectionPair.first.port, + connectionPair.second.id, connectionPair.second.port); + postponedConnectList.clear(); + } + + void GCircuit::postponedDisconnect() { + for (auto connectionPair : postponedDisconnectList) + circuit->disconnect(connectionPair.first.id, connectionPair.first.port, + connectionPair.second.id, connectionPair.second.port); + postponedDisconnectList.clear(); } - void GCircuit::postponedDisconnect(ID idFrom, Port output, ID idTo, Port input) { - circuit->disconnect(idFrom, output, idTo, input); + const UI::Vec2 &GCircuit::getHovered_grid_cell() const { + return hovered_grid_cell; } diff --git a/src/gui/gPort.cpp b/src/gui/gPort.cpp index ec7132a..84785b5 100644 --- a/src/gui/gPort.cpp +++ b/src/gui/gPort.cpp @@ -53,6 +53,11 @@ namespace Logicon { GPORT_CURRENTLY_HOVERED = UI::GPORT_NONE_HOVERED; } + if (ImGui::IsMouseReleased(0)) { + GPORT_DRAGGED_FLAG = false; + GPORT_CURRENTLY_DRAGGED = UI::GPORT_NONE_HOVERED; + } + /// DISPLAY TOOLTIP if (GPORT_HOVERED_FLAG) { auto connections = isInput ? @@ -79,6 +84,7 @@ namespace Logicon { parentGBlock.lock()->getId(), port) : parentGBlock.lock()->getParentGCircuit().lock()->disconnect(parentGBlock.lock()->getId(), port, connection.id, connection.port); + GPORT_CURRENTLY_DRAGGED = uniqeElemId; } /// Send drag'n'drop payload @@ -111,8 +117,6 @@ namespace Logicon { delete (data); } ImGui::EndDragDropTarget(); - GPORT_DRAGGED_FLAG = false; - GPORT_CURRENTLY_DRAGGED = UI::GPORT_NONE_HOVERED; } ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin(); diff --git a/src/gui/menu_widget.cpp b/src/gui/menu_widget.cpp index 4fce069..c66b091 100644 --- a/src/gui/menu_widget.cpp +++ b/src/gui/menu_widget.cpp @@ -30,7 +30,8 @@ namespace Logicon { return true; } - void MenuWidget::render(const UI::Vec2 &window_pos, const UI::Vec2 &window_size, const UI::Vec2 &dialog_pos, const UI::Vec2 &dialog_size) { + void MenuWidget::render(const UI::Vec2 &window_pos, const UI::Vec2 &window_size, const UI::Vec2 &dialog_pos, + const UI::Vec2 &dialog_size) { ImGuiWindowFlags window_flags = 0 | ImGuiWindowFlags_NoTitleBar @@ -43,31 +44,31 @@ namespace Logicon { ImGui::SetWindowSize(window_size, ImGuiCond_Always); /// NEW - if(ImGui::ImageButton( + if (ImGui::ImageButton( reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::NEW).textureId), {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR - )){ + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR + )) { CanvasWidget::getInstance().getGCircuit()->clear(); } ImGui::SameLine(); /// OPEN static ImGuiFs::Dialog open_dlg; const bool open_clicked = ImGui::ImageButton( - reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::OPEN).textureId), - {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, - UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::OPEN).textureId), + {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, + UI::Vec2(0, 0), UI::Vec2(1, 1), 0, + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR ); const char *open_path = open_dlg.chooseFileDialog( - open_clicked, - nullptr, - Data::LOGICON_FILE_EXTENSION.c_str(), - nullptr, - dialog_size, - dialog_pos + open_clicked, + nullptr, + Data::LOGICON_FILE_EXTENSION.c_str(), + nullptr, + dialog_size, + dialog_pos ); if (strlen(open_path) > 0) { auto gc = Data::read(open_path); @@ -78,20 +79,20 @@ namespace Logicon { /// SAVE static ImGuiFs::Dialog save_dlg; const bool save_clicked = ImGui::ImageButton( - reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::SAVE).textureId), - {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, - UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::SAVE).textureId), + {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, + UI::Vec2(0, 0), UI::Vec2(1, 1), 0, + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR ); const char *save_path = save_dlg.saveFileDialog( - save_clicked, - nullptr, - ("circuit"+Data::LOGICON_FILE_EXTENSION).c_str(), - Data::LOGICON_FILE_EXTENSION.c_str(), - nullptr, - dialog_size, - dialog_pos + save_clicked, + nullptr, + ("circuit" + Data::LOGICON_FILE_EXTENSION).c_str(), + Data::LOGICON_FILE_EXTENSION.c_str(), + nullptr, + dialog_size, + dialog_pos ); if (strlen(save_path) > 0) { Data::save(save_path, CanvasWidget::getInstance().getGCircuit()); @@ -106,7 +107,8 @@ namespace Logicon { reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::PLAY).textureId), {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + ImVec4(0, 0, 0, 0), App::getInstance().state == App::STATE::RUNNING ? + UI::MENU_WIDGET_BUTTON_PLAY_PUSHED_COLOR : UI::MENU_WIDGET_BUTTON_NORMAL_COLOR )) { App::getInstance().state = App::STATE::RUNNING; } @@ -116,7 +118,8 @@ namespace Logicon { reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::PAUSE).textureId), {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + ImVec4(0, 0, 0, 0), App::getInstance().state == App::STATE::PAUSED ? + UI::MENU_WIDGET_BUTTON_PAUSE_PUSHED_COLOR : UI::MENU_WIDGET_BUTTON_NORMAL_COLOR )) { App::getInstance().state = App::STATE::PAUSED; } @@ -126,7 +129,7 @@ namespace Logicon { reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::RESTART).textureId), {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR )) { App::getInstance().state = App::STATE::RESTART; } @@ -148,10 +151,10 @@ namespace Logicon { /// STEP if (ImGui::ImageButton( reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::STEP).textureId), - {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, - UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), - UI::MENU_WIDGET_BUTTON_FG_COLOR + {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, + UI::Vec2(0, 0), UI::Vec2(1, 1), 0, + ImVec4(0, 0, 0, 0), + UI::MENU_WIDGET_BUTTON_NORMAL_COLOR )) { App::getInstance().state = App::PAUSED; App::getInstance().STEP_NEXT_STEP = true; @@ -163,19 +166,20 @@ namespace Logicon { ImGui::SameLine(); static ImGuiFs::Dialog load_free_inputs_dlg; const bool load_free_inputs_clicked = ImGui::ImageButton( - reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::LOAD_INPUTS).textureId), - {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, - UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + reinterpret_cast(Logicon::AssetLoader::getIconTexture( + AssetLoader::LOAD_INPUTS).textureId), + {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, + UI::Vec2(0, 0), UI::Vec2(1, 1), 0, + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR ); const char *load_free_inputs_path = load_free_inputs_dlg.chooseFileDialog( - load_free_inputs_clicked, - nullptr, - Data::FREE_IO_FILE_EXTENSION.c_str(), - nullptr, - dialog_size, - dialog_pos + load_free_inputs_clicked, + nullptr, + Data::FREE_IO_FILE_EXTENSION.c_str(), + nullptr, + dialog_size, + dialog_pos ); if (strlen(load_free_inputs_path) > 0) { Data::loadFreeInputs(load_free_inputs_path, CanvasWidget::getInstance().getGCircuit()); @@ -185,20 +189,21 @@ namespace Logicon { ImGui::SameLine(); static ImGuiFs::Dialog save_free_outputs_dlg; const bool save_free_outputs_clicked = ImGui::ImageButton( - reinterpret_cast(Logicon::AssetLoader::getIconTexture(AssetLoader::SAVE_OUTPUTS).textureId), - {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, - UI::Vec2(0, 0), UI::Vec2(1, 1), 0, - ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_FG_COLOR + reinterpret_cast(Logicon::AssetLoader::getIconTexture( + AssetLoader::SAVE_OUTPUTS).textureId), + {Logicon::UI::MENU_WIDGET_BUTTON_SIZE, Logicon::UI::MENU_WIDGET_BUTTON_SIZE}, + UI::Vec2(0, 0), UI::Vec2(1, 1), 0, + ImVec4(0, 0, 0, 0), UI::MENU_WIDGET_BUTTON_NORMAL_COLOR ); const char *save_free_outputs_path = save_free_outputs_dlg.saveFileDialog( - save_free_outputs_clicked, - nullptr, - ("outputs"+Data::FREE_IO_FILE_EXTENSION).c_str(), - Data::FREE_IO_FILE_EXTENSION.c_str(), - nullptr, - dialog_size, - dialog_pos + save_free_outputs_clicked, + nullptr, + ("outputs" + Data::FREE_IO_FILE_EXTENSION).c_str(), + Data::FREE_IO_FILE_EXTENSION.c_str(), + nullptr, + dialog_size, + dialog_pos ); if (strlen(save_free_outputs_path) > 0) { Data::saveFreeOutputs(save_free_outputs_path, CanvasWidget::getInstance().getGCircuit());