@@ -172,4 +172,286 @@ struct PyYUPApplication : yup::YUPApplication
172172 }
173173};
174174
175+ // =================================================================================================
176+
177+ template <class Base = yup::MouseListener>
178+ struct PyMouseListener : Base
179+ {
180+ using Base::Base;
181+
182+ void mouseMove (const yup::MouseEvent& event) override
183+ {
184+ PYBIND11_OVERRIDE (void , Base, mouseMove, event);
185+ }
186+
187+ void mouseEnter (const yup::MouseEvent& event) override
188+ {
189+ {
190+ pybind11::gil_scoped_acquire gil;
191+
192+ if (pybind11::function override_ = pybind11::get_override (static_cast <Base*> (this ), " mouseEnter" ))
193+ {
194+ override_ (event);
195+ return ;
196+ }
197+ }
198+
199+ // if constexpr (! std::is_same_v<Base, yup::TooltipWindow>)
200+ // Base::mouseEnter (event);
201+ }
202+
203+ void mouseExit (const yup::MouseEvent& event) override
204+ {
205+ {
206+ pybind11::gil_scoped_acquire gil;
207+
208+ if (pybind11::function override_ = pybind11::get_override (static_cast <Base*> (this ), " mouseExit" ))
209+ {
210+ override_ (event);
211+ return ;
212+ }
213+ }
214+
215+ // if constexpr (! std::is_same_v<Base, yup::TooltipWindow>)
216+ // Base::mouseExit (event);
217+ }
218+
219+ void mouseDown (const yup::MouseEvent& event) override
220+ {
221+ {
222+ pybind11::gil_scoped_acquire gil;
223+
224+ if (pybind11::function override_ = pybind11::get_override (static_cast <Base*> (this ), " mouseDown" ))
225+ {
226+ override_ (event);
227+ return ;
228+ }
229+ }
230+
231+ // if constexpr (! std::is_same_v<Base, yup::TooltipWindow>)
232+ // Base::mouseDown (event);
233+ }
234+
235+ void mouseDrag (const yup::MouseEvent& event) override
236+ {
237+ PYBIND11_OVERRIDE (void , Base, mouseDrag, event);
238+ }
239+
240+ void mouseUp (const yup::MouseEvent& event) override
241+ {
242+ PYBIND11_OVERRIDE (void , Base, mouseUp, event);
243+ }
244+
245+ void mouseDoubleClick (const yup::MouseEvent& event) override
246+ {
247+ PYBIND11_OVERRIDE (void , Base, mouseDoubleClick, event);
248+ }
249+
250+ void mouseWheelMove (const yup::MouseEvent& event, const yup::MouseWheelData& wheel) override
251+ {
252+ {
253+ pybind11::gil_scoped_acquire gil;
254+
255+ if (pybind11::function override_ = pybind11::get_override (static_cast <Base*> (this ), " mouseWheelMove" ))
256+ {
257+ override_ (event, wheel);
258+ return ;
259+ }
260+ }
261+
262+ // if constexpr (! std::is_same_v<Base, yup::TooltipWindow>)
263+ // Base::mouseWheelMove (event, wheel);
264+ }
265+
266+ void mouseMagnify (const yup::MouseEvent& event, float scaleFactor) override
267+ {
268+ PYBIND11_OVERRIDE (void , Base, mouseMagnify, event, scaleFactor);
269+ }
270+ };
271+
272+ // =================================================================================================
273+
274+ template <class Base = yup::Component>
275+ struct PyComponent : PyMouseListener<Base>
276+ {
277+ using PyMouseListener<Base>::PyMouseListener;
278+
279+ void setName (const yup::String& newName) override
280+ {
281+ PYBIND11_OVERRIDE (void , Base, setName, newName);
282+ }
283+
284+ void setVisible (bool shouldBeVisible) override
285+ {
286+ PYBIND11_OVERRIDE (void , Base, setVisible, shouldBeVisible);
287+ }
288+
289+ void visibilityChanged () override
290+ {
291+ PYBIND11_OVERRIDE (void , Base, visibilityChanged);
292+ }
293+
294+ void userTriedToCloseWindow () override
295+ {
296+ PYBIND11_OVERRIDE (void , Base, userTriedToCloseWindow);
297+ }
298+
299+ void minimisationStateChanged (bool isNowMinimised) override
300+ {
301+ PYBIND11_OVERRIDE (void , Base, minimisationStateChanged, isNowMinimised);
302+ }
303+
304+ float getDesktopScaleFactor () const override
305+ {
306+ PYBIND11_OVERRIDE (float , Base, getDesktopScaleFactor);
307+ }
308+
309+ void parentHierarchyChanged () override
310+ {
311+ PYBIND11_OVERRIDE (void , Base, parentHierarchyChanged);
312+ }
313+
314+ void childrenChanged () override
315+ {
316+ PYBIND11_OVERRIDE (void , Base, childrenChanged);
317+ }
318+
319+ bool hitTest (int x, int y) override
320+ {
321+ PYBIND11_OVERRIDE (bool , Base, hitTest, x, y);
322+ }
323+
324+ void lookAndFeelChanged () override
325+ {
326+ PYBIND11_OVERRIDE (void , Base, lookAndFeelChanged);
327+ }
328+
329+ void enablementChanged () override
330+ {
331+ PYBIND11_OVERRIDE (void , Base, enablementChanged);
332+ }
333+
334+ void alphaChanged () override
335+ {
336+ PYBIND11_OVERRIDE (void , Base, alphaChanged);
337+ }
338+
339+ void paint (yup::Graphics& g) override
340+ {
341+ {
342+ pybind11::gil_scoped_acquire gil;
343+
344+ if (pybind11::function override_ = pybind11::get_override (static_cast <const Base*> (this ), " paint" ); override_)
345+ {
346+ override_ (std::addressof (g));
347+ return ;
348+ }
349+ }
350+
351+ // if constexpr (! std::is_same_v<Base, yup::TooltipWindow>)
352+ // Base::paint (g);
353+ }
354+
355+ void paintOverChildren (yup::Graphics& g) override
356+ {
357+ {
358+ pybind11::gil_scoped_acquire gil;
359+
360+ if (pybind11::function override_ = pybind11::get_override (static_cast <const Base*> (this ), " paintOverChildren" ); override_)
361+ {
362+ override_ (std::addressof (g));
363+ return ;
364+ }
365+ }
366+
367+ Base::paintOverChildren (g);
368+ }
369+
370+ bool keyPressed (const yup::KeyPress& key) override
371+ {
372+ PYBIND11_OVERRIDE (bool , Base, keyPressed, key);
373+ }
374+
375+ bool keyStateChanged (bool isDown) override
376+ {
377+ PYBIND11_OVERRIDE (bool , Base, keyStateChanged, isDown);
378+ }
379+
380+ // void modifierKeysChanged (const yup::ModifierKeys& modifiers) override
381+ // {
382+ // PYBIND11_OVERRIDE (void, Base, modifierKeysChanged, modifiers);
383+ // }
384+
385+ void focusGained () override
386+ {
387+ PYBIND11_OVERRIDE (void , Base, focusGained);
388+ }
389+
390+ void focusLost () override
391+ {
392+ PYBIND11_OVERRIDE (void , Base, focusLost);
393+ }
394+
395+ // void focusOfChildComponentChanged (yup::Component::FocusChangeType cause) override
396+ // {
397+ // PYBIND11_OVERRIDE (void, Base, focusOfChildComponentChanged, cause);
398+ // }
399+
400+ void resized () override
401+ {
402+ PYBIND11_OVERRIDE (void , Base, resized);
403+ }
404+
405+ void moved () override
406+ {
407+ PYBIND11_OVERRIDE (void , Base, moved);
408+ }
409+
410+ void childBoundsChanged (yup::Component* child) override
411+ {
412+ PYBIND11_OVERRIDE (void , Base, childBoundsChanged, child);
413+ }
414+
415+ void parentSizeChanged () override
416+ {
417+ PYBIND11_OVERRIDE (void , Base, parentSizeChanged);
418+ }
419+
420+ void broughtToFront () override
421+ {
422+ PYBIND11_OVERRIDE (void , Base, broughtToFront);
423+ }
424+
425+ void handleCommandMessage (int commandId) override
426+ {
427+ {
428+ pybind11::gil_scoped_acquire gil;
429+
430+ if (pybind11::function override_ = pybind11::get_override (static_cast <Base*> (this ), " handleCommandMessage" ); override_)
431+ {
432+ override_ (commandId);
433+ return ;
434+ }
435+ }
436+
437+ // if constexpr (! std::is_same_v<Base, yup::TextEditor>)
438+ // Base::handleCommandMessage (commandId);
439+ }
440+
441+ bool canModalEventBeSentToComponent (const yup::Component* targetComponent) override
442+ {
443+ PYBIND11_OVERRIDE (bool , Base, canModalEventBeSentToComponent, targetComponent);
444+ }
445+
446+ void inputAttemptWhenModal () override
447+ {
448+ PYBIND11_OVERRIDE (void , Base, inputAttemptWhenModal);
449+ }
450+
451+ void colourChanged () override
452+ {
453+ PYBIND11_OVERRIDE (void , Base, colourChanged);
454+ }
455+ };
456+
175457} // namespace yup::Bindings
0 commit comments