createWindow($title, 400, 350, $x, $y); // Create UI $container = new Container("flex flex-col p-6 gap-4 bg-$bgColor-100"); $titleLabel = new Label( text: $title, style: "text-2xl text-$bgColor-900" ); $processLabel = new Label( text: 'Process ID: ' . getmypid(), style: "text-sm text-$bgColor-700" ); $frameLabel = new Label( text: 'Frame: 0', style: "text-base text-$bgColor-600" ); $button = new Button( text: 'Click Me!', style: "bg-$bgColor-500 hover:bg-$bgColor-700 text-white p-4 rounded-lg" ); $clickCount = 0; $button->setOnClick(function() use (&$clickCount, $button, $title) { $clickCount++; $button->setText("Clicked $clickCount times"); echo "$title - Button clicked! Count: $clickCount\n"; }); $closeButton = new Button( text: 'Close Window', style: "bg-red-500 hover:bg-red-700 text-white p-3 rounded" ); $closeButton->setOnClick(function() use ($window) { echo "Close button clicked!\n"; $window->close(); }); $container->addComponent($titleLabel); $container->addComponent($processLabel); $container->addComponent($frameLabel); $container->addComponent($button); $container->addComponent($closeButton); $window->setRoot($container); echo "Process $id: Starting event loop\n"; // Run the window $frameCount = 0; while (!$window->shouldClose()) { $frameCount++; $frameLabel->setText("Frame: $frameCount"); $window->layout(); // Poll events rgfw_pollEvents(); $window->handleEvents(); // Update \PHPNative\Async\TaskManager::getInstance()->update(); $window->update(); // Render $window->render(); // ~60 FPS usleep(16666); } // Cleanup echo "Process $id: Window closed after $frameCount frames\n"; $window->cleanup(); }