@@ -77,7 +77,6 @@ class hydroc::gui::GUIImpl::MyActionReceiver : public irr::IEventReceiver {
7777 private:
7878 chrono::irrlicht::ChVisualSystemIrrlicht* vis;
7979 irr::gui::IGUIButton* pauseButton;
80- irr::gui::IGUIStaticText* buttonText;
8180
8281 bool & pressed;
8382};
@@ -131,11 +130,24 @@ void GUIImpl::Init(UI& ui, chrono::ChSystem* system, const char* title) {
131130 }
132131
133132 try {
134- hydroc::debug::LogDebug (" 🔍 GUIImpl::Init - Setting up event receiver..." );
133+ hydroc::debug::LogDebug (" 🔍 GUIImpl::Init - Setting up GUI skin and event receiver..." );
134+ // Improve GUI readability: use built-in font for crisper text
135+ try {
136+ auto * env = pVis->GetGUIEnvironment ();
137+ auto * skin = env ? env->getSkin () : nullptr ;
138+ if (env && skin) {
139+ auto * builtin = env->getBuiltInFont ();
140+ if (builtin) {
141+ skin->setFont (builtin);
142+ }
143+ }
144+ } catch (...) {
145+ // non-fatal if font override fails
146+ }
135147 InitReceiver (ui.simulationStarted );
136148 receiver->Init (pVis.get ());
137149 pVis->AddUserEventReceiver (receiver.get ());
138- hydroc::debug::LogDebug (" ✅ Event receiver set up successfully" );
150+ hydroc::debug::LogDebug (" ✅ GUI skin and event receiver set up successfully" );
139151 } catch (const std::exception& e) {
140152 hydroc::cli::LogError (std::string (" 🔥 Exception during receiver setup: " ) + e.what ());
141153 // Don't re-throw here, receiver is optional
@@ -288,8 +300,18 @@ void hydroc::gui::GUIImpl::MyActionReceiver::Init(chrono::irrlicht::ChVisualSyst
288300 vis = vsys;
289301
290302 // ..add a GUI button to control pause/play
291- pauseButton = vis->GetGUIEnvironment ()->addButton (rect<s32>(510 , 20 , 650 , 35 ));
292- buttonText = vis->GetGUIEnvironment ()->addStaticText (L" Paused" , rect<s32>(560 , 20 , 600 , 35 ), false );
303+ pauseButton = vis->GetGUIEnvironment ()->addButton (rect<s32>(500 , 18 , 700 , 50 ));
304+ pauseButton->setIsPushButton (true );
305+ pauseButton->setScaleImage (true );
306+ // Increase text visibility by adjusting the skin font was done in Init; ensure border size is sane
307+ if (auto * skin = vis->GetGUIEnvironment ()->getSkin ()) {
308+ skin->setSize (irr::gui::EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X, 2 );
309+ skin->setSize (irr::gui::EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y, 2 );
310+ // Optional: increase button text distance to border for clarity
311+ skin->setSize (irr::gui::EGDS_TEXT_DISTANCE_X, 6 );
312+ skin->setSize (irr::gui::EGDS_TEXT_DISTANCE_Y, 3 );
313+ }
314+ pauseButton->setText (L" Paused" );
293315}
294316
295317bool hydroc::gui::GUIImpl::MyActionReceiver::OnEvent (const irr::SEvent& event) {
@@ -299,9 +321,9 @@ bool hydroc::gui::GUIImpl::MyActionReceiver::OnEvent(const irr::SEvent& event) {
299321 case EGUI_EVENT_TYPE::EGET_BUTTON_CLICKED:
300322 pressed = !pressed;
301323 if (pressed) {
302- buttonText ->setText (L" Playing" );
324+ pauseButton ->setText (L" Playing" );
303325 } else {
304- buttonText ->setText (L" Paused" );
326+ pauseButton ->setText (L" Paused" );
305327 }
306328 return pressed;
307329 break ;
0 commit comments