Skip to content

Commit dd22eed

Browse files
committed
Reproduce Irrlicht visualization tweaks from main branch
1 parent 57e5110 commit dd22eed

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

src/gui/guihelper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ bool UI::IsRunning(double timestep) {
3131
// -----------------------------------------------------------------------------
3232

3333
GUI::GUI() {
34-
3534
#if defined(HYDROCHRONO_HAVE_VSG)
3635
pImpl = std::make_shared<hydroc::gui::GUIImplVSG>();
3736
#elif defined(HYDROCHRONO_HAVE_IRRLICHT)

src/gui/guihelperIRR.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class hydroc::gui::GUIImplIRR::MyActionReceiver : public irr::IEventReceiver {
2626
private:
2727
chrono::irrlicht::ChVisualSystemIrrlicht* vis;
2828
irr::gui::IGUIButton* pauseButton;
29-
irr::gui::IGUIStaticText* buttonText;
3029

3130
bool& pressed;
3231
};
@@ -40,8 +39,18 @@ void hydroc::gui::GUIImplIRR::MyActionReceiver::Init(chrono::irrlicht::ChVisualS
4039
vis = vsys;
4140

4241
// ..add a GUI button to control pause/play
43-
pauseButton = vis->GetGUIEnvironment()->addButton(rect<s32>(510, 20, 650, 35));
44-
buttonText = vis->GetGUIEnvironment()->addStaticText(L"Paused", rect<s32>(560, 20, 600, 35), false);
42+
pauseButton = vis->GetGUIEnvironment()->addButton(rect<s32>(500, 18, 700, 50));
43+
pauseButton->setIsPushButton(true);
44+
pauseButton->setScaleImage(true);
45+
// Increase text visibility by adjusting the skin font was done in Init; ensure border size is sane
46+
if (auto* skin = vis->GetGUIEnvironment()->getSkin()) {
47+
skin->setSize(irr::gui::EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X, 2);
48+
skin->setSize(irr::gui::EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y, 2);
49+
// Optional: increase button text distance to border for clarity
50+
skin->setSize(irr::gui::EGDS_TEXT_DISTANCE_X, 6);
51+
skin->setSize(irr::gui::EGDS_TEXT_DISTANCE_Y, 3);
52+
}
53+
pauseButton->setText(L"Paused");
4554
}
4655

4756
bool hydroc::gui::GUIImplIRR::MyActionReceiver::OnEvent(const irr::SEvent& event) {
@@ -51,9 +60,9 @@ bool hydroc::gui::GUIImplIRR::MyActionReceiver::OnEvent(const irr::SEvent& event
5160
case EGUI_EVENT_TYPE::EGET_BUTTON_CLICKED:
5261
pressed = !pressed;
5362
if (pressed) {
54-
buttonText->setText(L"Playing");
63+
pauseButton->setText(L"Playing");
5564
} else {
56-
buttonText->setText(L"Paused");
65+
pauseButton->setText(L"Paused");
5766
}
5867
return pressed;
5968
break;
@@ -115,11 +124,24 @@ void GUIImplIRR::Init(UI& ui, chrono::ChSystem* system, const char* title) {
115124
}
116125

117126
try {
118-
hydroc::debug::LogDebug("🔍 GUIImplIRR::Init - Setting up event receiver...");
127+
hydroc::debug::LogDebug("🔍 GUIImplIRR::Init - Setting up GUI skin and event receiver...");
128+
// Improve GUI readability: use built-in font for crisper text
129+
try {
130+
auto* env = pVis->GetGUIEnvironment();
131+
auto* skin = env ? env->getSkin() : nullptr;
132+
if (env && skin) {
133+
auto* builtin = env->getBuiltInFont();
134+
if (builtin) {
135+
skin->setFont(builtin);
136+
}
137+
}
138+
} catch (...) {
139+
// non-fatal if font override fails
140+
}
119141
InitReceiver(ui.simulationStarted);
120142
receiver->Init(pVis.get());
121143
pVis->AddUserEventReceiver(receiver.get());
122-
hydroc::debug::LogDebug("Event receiver set up successfully");
144+
hydroc::debug::LogDebug("GUI skin and event receiver set up successfully");
123145
} catch (const std::exception& e) {
124146
hydroc::cli::LogError(std::string("🔥 Exception during receiver setup: ") + e.what());
125147
// Don't re-throw here, receiver is optional

src/gui/guihelperVSG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MyComponentVSG : public chrono::vsg3d::ChGuiComponentVSG {
2626
ImGui::SetNextWindowSize(ImVec2(300, 0));
2727
ImGui::Begin("HydroChrono", NULL, window_flags);
2828

29-
if (ImGui::Button(pressed ? "Playing" : "Paused")) {
29+
if (ImGui::Button(pressed ? "Playing" : "Paused", ImVec2(200, 40))) {
3030
pressed = !pressed;
3131
}
3232

0 commit comments

Comments
 (0)