@@ -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
4756bool 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
0 commit comments