Skip to content

Commit

Permalink
Merge tokens inc/decr with caption edition for places
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Dec 17, 2023
1 parent 0d27b56 commit 056c105
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/Editor/PetriEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,30 +672,41 @@ void Editor::inspector()
// Place captions and tokens
{
ImGui::Begin("Places");

// Options
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::Checkbox(m_states.show_place_captions ?
"Show place identifiers" : "Show place captions",
&m_states.show_place_captions);
ImGui::PopStyleVar();

ImGui::Separator();

// TODO pour event graph: afficher ImGui::InputText("T1 P0 T2", &p.places);
ImGui::Text("%s", "Captions:");
for (auto& place: m_net.places())
{
ImGui::PushID(place.key.c_str());
ImGui::AlignTextToFramePadding();
ImGui::InputText(place.key.c_str(), &place.caption, readonly);
}

ImGui::Separator();
ImGui::Text("%s", "Tokens:");
for (auto& place: m_net.places())
{
inputInteger(m_states.show_place_captions ?
place.caption.c_str() : place.key.c_str(),
Net::Settings::maxTokens, place.tokens);
}
// Increment/decrement tokens
ImGui::SameLine();
ImGui::PushButtonRepeat(true);
if (ImGui::ArrowButton("##left", ImGuiDir_Left))
{
place.decrement();
}
ImGui::SameLine();
if (ImGui::ArrowButton("##right", ImGuiDir_Right))
{
place.increment();
}
ImGui::PopButtonRepeat();

// Caption edition
ImGui::SameLine();
ImGui::Text("%zu", place.tokens);

ImGui::PopID();
}
ImGui::End();
}

Expand Down

0 comments on commit 056c105

Please sign in to comment.