• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kunitoki / popsicle / 8371986093

21 Mar 2024 08:38AM UTC coverage: 20.182% (+1.4%) from 18.801%
8371986093

Pull #24

github

kunitoki
More examples with wgpu
Pull Request #24: More tests coverage

324 of 487 new or added lines in 8 files covered. (66.53%)

45 existing lines in 5 files now uncovered.

23834 of 118095 relevant lines covered (20.18%)

3608.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.58
/modules/juce_python/bindings/ScriptJuceGuiBasicsBindings.h
1
/**
2
 * juce_python - Python bindings for the JUCE framework.
3
 *
4
 * This file is part of the popsicle project.
5
 *
6
 * Copyright (c) 2024 - kunitoki <kunitoki@gmail.com>
7
 *
8
 * popsicle is an open source library subject to commercial or open-source licensing.
9
 *
10
 * By using popsicle, you agree to the terms of the popsicle License Agreement, which can
11
 * be found at https://raw.githubusercontent.com/kunitoki/popsicle/master/LICENSE
12
 *
13
 * Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses).
14
 *
15
 * POPSICLE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED
16
 * OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED.
17
 */
18

19
#pragma once
20

21
#if !JUCE_MODULE_AVAILABLE_juce_gui_basics
22
 #error This binding file requires adding the juce_gui_basics module in the project
23
#else
24
 #include <juce_gui_basics/juce_gui_basics.h>
25
#endif
26

27
#define JUCE_PYTHON_INCLUDE_PYBIND11_FUNCTIONAL
28
#define JUCE_PYTHON_INCLUDE_PYBIND11_IOSTREAM
29
#define JUCE_PYTHON_INCLUDE_PYBIND11_OPERATORS
30
#include "../utilities/PyBind11Includes.h"
31

32
#include "ScriptJuceOptionsBindings.h"
33

34
#include <cstddef>
35
#include <exception>
36
#include <functional>
37
#include <memory>
38
#include <vector>
39
#include <utility>
40

41
namespace popsicle::Bindings {
42

43
// =================================================================================================
44

45
void registerJuceGuiBasicsBindings (pybind11::module_& m);
46

47
// =================================================================================================
48

49
struct PyJUCEApplication : juce::JUCEApplication
50
{
51
    const juce::String getApplicationName() override
×
52
    {
53
        PYBIND11_OVERRIDE_PURE (const juce::String, juce::JUCEApplication, getApplicationName);
×
54
    }
55

56
    const juce::String getApplicationVersion() override
×
57
    {
58
        PYBIND11_OVERRIDE_PURE (const juce::String, juce::JUCEApplication, getApplicationVersion);
×
59
    }
60

61
    bool moreThanOneInstanceAllowed() override
42✔
62
    {
63
        PYBIND11_OVERRIDE (bool, juce::JUCEApplication, moreThanOneInstanceAllowed);
84✔
64
    }
65

66
    void initialise (const juce::String& commandLineParameters) override
42✔
67
    {
68
        PYBIND11_OVERRIDE_PURE (void, juce::JUCEApplication, initialise, commandLineParameters);
42✔
69
    }
70

71
    void shutdown() override
×
72
    {
73
        PYBIND11_OVERRIDE_PURE (void, juce::JUCEApplication, shutdown);
×
74
    }
75

76
    void anotherInstanceStarted (const juce::String& commandLine) override
×
77
    {
78
        PYBIND11_OVERRIDE (void, juce::JUCEApplication, anotherInstanceStarted, commandLine);
×
79
    }
80

81
    void systemRequestedQuit() override
×
82
    {
83
        PYBIND11_OVERRIDE (void, juce::JUCEApplication, systemRequestedQuit);
×
84
    }
85

86
    void suspended() override
×
87
    {
88
        PYBIND11_OVERRIDE (void, juce::JUCEApplication, suspended);
×
89
    }
90

91
    void resumed() override
×
92
    {
93
        PYBIND11_OVERRIDE (void, juce::JUCEApplication, resumed);
×
94
    }
95

96
    void unhandledException (const std::exception* ex, const juce::String& sourceFilename, int lineNumber) override
×
97
    {
98
        pybind11::gil_scoped_acquire gil;
×
99

100
        const auto* pyEx = dynamic_cast<const pybind11::error_already_set*> (ex);
×
101
        auto traceback = pybind11::module_::import ("traceback");
×
102

103
        if (pybind11::function override_ = pybind11::get_override (static_cast<juce::JUCEApplication*> (this), "unhandledException"); override_)
×
104
        {
105
            if (pyEx != nullptr)
×
106
            {
107
                auto newPyEx = pyEx->type()(pyEx->value());
×
108
                PyException_SetTraceback (newPyEx.ptr(), pyEx->trace().ptr());
×
109

110
                override_ (newPyEx, sourceFilename, lineNumber);
×
111
            }
112
            else
113
            {
114
                auto runtimeError = pybind11::module_::import ("__builtins__").attr ("RuntimeError");
×
115
                auto newPyEx = runtimeError(ex != nullptr ? ex->what() : "unknown exception");
×
116
                PyException_SetTraceback (newPyEx.ptr(), traceback.attr ("extract_stack")().ptr());
×
117

118
                override_ (newPyEx, sourceFilename, lineNumber);
×
119
            }
120

121
            return;
×
122
        }
123

NEW
124
        if (pyEx != nullptr)
×
125
        {
NEW
126
            pybind11::print (ex->what());
×
NEW
127
            traceback.attr ("print_tb")(pyEx->trace());
×
128

NEW
129
            if (pyEx->matches (PyExc_KeyboardInterrupt) || PyErr_CheckSignals() != 0)
×
130
            {
NEW
131
                globalOptions().caughtKeyboardInterrupt = true;
×
NEW
132
                return;
×
133
            }
134
        }
135
        else
136
        {
NEW
137
            pybind11::print (ex->what());
×
NEW
138
            traceback.attr ("print_stack")();
×
139

NEW
140
            if (PyErr_CheckSignals() != 0)
×
141
            {
NEW
142
                globalOptions().caughtKeyboardInterrupt = true;
×
NEW
143
                return;
×
144
            }
145
        }
146

NEW
147
        if (! globalOptions().catchExceptionsAndContinue)
×
NEW
148
            std::terminate();
×
149
    }
150

151
    void memoryWarningReceived() override
×
152
    {
153
        PYBIND11_OVERRIDE (void, juce::JUCEApplication, memoryWarningReceived);
×
154
    }
155

156
    bool backButtonPressed() override
×
157
    {
158
        PYBIND11_OVERRIDE (bool, juce::JUCEApplication, backButtonPressed);
×
159
    }
160
};
161

162
// =================================================================================================
163

164
struct PyKeyListener : juce::KeyListener
165
{
166
    using juce::KeyListener::KeyListener;
167

168
    bool keyPressed (const juce::KeyPress& key, juce::Component* originatingComponent) override
×
169
    {
170
        PYBIND11_OVERRIDE_PURE (bool, juce::KeyListener, keyPressed, key, originatingComponent);
×
171
    }
172

173
    bool keyStateChanged (bool isKeyDown, juce::Component* originatingComponent) override
×
174
    {
175
        PYBIND11_OVERRIDE (bool, KeyListener, keyStateChanged, isKeyDown, originatingComponent);
×
176
    }
177
};
178

179
// =================================================================================================
180

181
template <class Base = juce::MouseListener>
182
struct PyMouseListener : Base
183
{
184
    using Base::Base;
185

186
    void mouseMove (const juce::MouseEvent& event) override
×
187
    {
188
        PYBIND11_OVERRIDE (void, Base, mouseMove, event);
×
189
    }
190

191
    void mouseEnter (const juce::MouseEvent& event) override
×
192
    {
193
        {
NEW
194
            pybind11::gil_scoped_acquire gil;
×
195

NEW
196
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "mouseEnter"))
×
197
            {
NEW
198
                override_ (event);
×
NEW
199
                return;
×
200
            }
201
        }
202

203
        if constexpr (! std::is_same_v<Base, juce::TooltipWindow>)
NEW
204
            Base::mouseEnter (event);
×
205
    }
206

207
    void mouseExit (const juce::MouseEvent& event) override
×
208
    {
209
        {
NEW
210
            pybind11::gil_scoped_acquire gil;
×
211

NEW
212
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "mouseExit"))
×
213
            {
NEW
214
                override_ (event);
×
NEW
215
                return;
×
216
            }
217
        }
218

219
        if constexpr (! std::is_same_v<Base, juce::TooltipWindow>)
NEW
220
            Base::mouseExit (event);
×
221
    }
222

223
    void mouseDown (const juce::MouseEvent& event) override
×
224
    {
225
        {
NEW
226
            pybind11::gil_scoped_acquire gil;
×
227

NEW
228
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "mouseDown"))
×
229
            {
NEW
230
                override_ (event);
×
NEW
231
                return;
×
232
            }
233
        }
234

235
        if constexpr (! std::is_same_v<Base, juce::TooltipWindow>)
NEW
236
            Base::mouseDown (event);
×
237
    }
238

239
    void mouseDrag (const juce::MouseEvent& event) override
×
240
    {
241
        PYBIND11_OVERRIDE (void, Base, mouseDrag, event);
×
242
    }
243

244
    void mouseUp (const juce::MouseEvent& event) override
×
245
    {
246
        PYBIND11_OVERRIDE (void, Base, mouseUp, event);
×
247
    }
248

249
    void mouseDoubleClick (const juce::MouseEvent& event) override
×
250
    {
251
        PYBIND11_OVERRIDE (void, Base, mouseDoubleClick, event);
×
252
    }
253

254
    void mouseWheelMove (const juce::MouseEvent& event, const juce::MouseWheelDetails& wheel) override
×
255
    {
256
        {
NEW
257
            pybind11::gil_scoped_acquire gil;
×
258

NEW
259
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "mouseWheelMove"))
×
260
            {
NEW
261
                override_ (event, wheel);
×
NEW
262
                return;
×
263
            }
264
        }
265

266
        if constexpr (! std::is_same_v<Base, juce::TooltipWindow>)
NEW
267
            Base::mouseWheelMove (event, wheel);
×
268
    }
269

270
    void mouseMagnify (const juce::MouseEvent& event, float scaleFactor) override
×
271
    {
272
        PYBIND11_OVERRIDE (void, Base, mouseMagnify, event, scaleFactor);
×
273
    }
274
};
275

276
// =================================================================================================
277

278
template <class Base = juce::TextInputTarget>
279
struct PyTextInputTarget : Base
280
{
281
    using Base::Base;
282

283
    bool isTextInputActive() const override
×
284
    {
285
        PYBIND11_OVERRIDE_PURE (bool, Base, isTextInputActive);
×
286
    }
287

288
    juce::Range<int> getHighlightedRegion() const override
×
289
    {
290
        PYBIND11_OVERRIDE_PURE (juce::Range<int>, Base, getHighlightedRegion);
×
291
    }
292

293
    void setHighlightedRegion (const juce::Range<int>& newRange) override
×
294
    {
295
        PYBIND11_OVERRIDE_PURE (void, Base, setHighlightedRegion, newRange);
×
296
    }
297

298
    void setTemporaryUnderlining (const juce::Array<juce::Range<int>>& underlinedRegions) override
×
299
    {
300
        PYBIND11_OVERRIDE_PURE (void, Base, setTemporaryUnderlining, underlinedRegions);
×
301
    }
302

303
    juce::String getTextInRange (const juce::Range<int>& range) const override
×
304
    {
305
        PYBIND11_OVERRIDE_PURE (juce::String, Base, getTextInRange, range);
×
306
    }
307

308
    void insertTextAtCaret (const juce::String& textToInsert) override
×
309
    {
310
        PYBIND11_OVERRIDE_PURE (void, Base, insertTextAtCaret, textToInsert);
×
311
    }
312

313
    int getCaretPosition() const override
×
314
    {
315
        PYBIND11_OVERRIDE_PURE (int, Base, getCaretPosition);
×
316
    }
317

318
    juce::Rectangle<int> getCaretRectangleForCharIndex (int characterIndex) const override
×
319
    {
320
        PYBIND11_OVERRIDE_PURE (juce::Rectangle<int>, Base, getCaretRectangleForCharIndex, characterIndex);
×
321
    }
322

323
    int getTotalNumChars() const override
×
324
    {
325
        PYBIND11_OVERRIDE_PURE (int, Base, getTotalNumChars);
×
326
    }
327

328
    int getCharIndexForPoint (juce::Point<int> point) const override
×
329
    {
330
        PYBIND11_OVERRIDE_PURE (int, Base, getCharIndexForPoint, point);
×
331
    }
332

333
    juce::RectangleList<int> getTextBounds (juce::Range<int> textRange) const override
×
334
    {
335
        PYBIND11_OVERRIDE_PURE (juce::Rectangle<int>, Base, getTextBounds, textRange);
×
336
    }
337

338
    juce::TextInputTarget::VirtualKeyboardType getKeyboardType() override
×
339
    {
340
        PYBIND11_OVERRIDE (juce::TextInputTarget::VirtualKeyboardType, Base, getKeyboardType);
×
341
    }
342
};
343

344
// =================================================================================================
345

346
template <class Base = juce::LookAndFeel>
347
struct PyLookAndFeel : Base
348
{
349
    using Base::Base;
350

351
    void drawSpinningWaitAnimation(juce::Graphics& g, const juce::Colour& colour, int x, int y, int w, int h) override
352
    {
353
        {
354
            pybind11::gil_scoped_acquire gil;
355

356
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawSpinningWaitAnimation"))
357
            {
358
                override_ (std::addressof (g), colour, x, y, w, h);
359
                return;
360
            }
361
        }
362

363
        pybind11::pybind11_fail ("Tried to call pure virtual function \"LookAndFeel::drawSpinningWaitAnimation\"");
364
    }
365

366
    juce::Path getTickShape (float height) override
367
    {
368
        PYBIND11_OVERRIDE_PURE (juce::Path, Base, getTickShape, height);
369
    }
370

371
    juce::Path getCrossShape (float height) override
372
    {
373
        PYBIND11_OVERRIDE_PURE (juce::Path, Base, getCrossShape, height);
374
    }
375

376
    std::unique_ptr<juce::DropShadower> createDropShadowerForComponent (juce::Component&) override
377
    {
378
        return {}; // TODO
379
    }
380

381
    std::unique_ptr<juce::FocusOutline> createFocusOutlineForComponent (juce::Component&) override
382
    {
383
        return {}; // TODO
384
    }
385

386
    juce::MouseCursor getMouseCursorFor (juce::Component& c) override
387
    {
388
        PYBIND11_OVERRIDE (juce::MouseCursor, Base, getMouseCursorFor, c);
389
    }
390

391
    void playAlertSound() override
392
    {
393
        PYBIND11_OVERRIDE (void, Base, playAlertSound);
394
    }
395
};
396

397
template <class Base = juce::LookAndFeel_V2>
398
struct PyLookAndFeel_V2 : PyLookAndFeel<Base>
399
{
400
    using PyLookAndFeel<Base>::PyLookAndFeel;
401

402
    void drawButtonBackground (juce::Graphics& g, juce::Button& b, const juce::Colour& backgroundColour,
403
                               bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
404
    {
405
        {
406
            pybind11::gil_scoped_acquire gil;
407

408
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawButtonBackground"))
409
            {
410
                override_ (std::addressof (g), std::addressof (b), backgroundColour, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
411
                return;
412
            }
413
        }
414

415
        Base::drawButtonBackground (g, b, backgroundColour, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
416
    }
417

418
    juce::Font getTextButtonFont (juce::TextButton& button, int buttonHeight) override
419
    {
420
        {
421
            pybind11::gil_scoped_acquire gil;
422

423
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "getTextButtonFont"))
424
            {
425
                return override_ (std::addressof (button), buttonHeight).cast<juce::Font>();
426
            }
427
        }
428

429
        return Base::getTextButtonFont (button, buttonHeight);
430
    }
431

432
    void drawButtonText (juce::Graphics& g, juce::TextButton& button,
433
                         bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
434
    {
435
        {
436
            pybind11::gil_scoped_acquire gil;
437

438
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawButtonText"))
439
            {
440
                override_ (std::addressof (g), std::addressof (button), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
441
                return;
442
            }
443
        }
444

445
        Base::drawButtonText (g, button, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
446
    }
447

448
    int getTextButtonWidthToFitText (juce::TextButton& button, int buttonHeight) override
449
    {
450
        {
451
            pybind11::gil_scoped_acquire gil;
452

453
            if (pybind11::function override_ = pybind11::get_override(static_cast<Base*>(this), "getTextButtonWidthToFitText"))
454
            {
455
                return override_ (std::addressof(button), buttonHeight).cast<int>();
456
            }
457
        }
458

459
        return Base::getTextButtonWidthToFitText(button, buttonHeight);
460
    }
461

462
    void drawToggleButton (juce::Graphics& g, juce::ToggleButton& button,
463
                           bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
464
    {
465
        {
466
            pybind11::gil_scoped_acquire gil;
467

468
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawToggleButton"))
469
            {
470
                override_ (std::addressof (g), std::addressof (button), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
471
                return;
472
            }
473
        }
474

475
        Base::drawToggleButton (g, button, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
476
    }
477

478
    void changeToggleButtonWidthToFitText (juce::ToggleButton& button) override
479
    {
480
        {
481
            pybind11::gil_scoped_acquire gil;
482

483
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "changeToggleButtonWidthToFitText"); override_)
484
            {
485
                override_ (std::addressof (button));
486
                return;
487
            }
488
        }
489

490
        Base::changeToggleButtonWidthToFitText (button);
491
    }
492

493
    void drawTickBox (juce::Graphics& g, juce::Component& component,
494
                      float x, float y, float w, float h,
495
                      bool ticked, bool isEnabled,
496
                      bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
497
    {
498
        {
499
            pybind11::gil_scoped_acquire gil;
500

501
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawTickBox"); override_)
502
            {
503
                override_ (std::addressof (g), std::addressof (component), x, y, w, h, ticked, isEnabled, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
504
                return;
505
            }
506
        }
507

508
        Base::drawTickBox (g, component, x, y, w, h, ticked, isEnabled, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
509
    }
510

511
    void drawDrawableButton (juce::Graphics& g, juce::DrawableButton& button,
512
                             bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
513
    {
514
        {
515
            pybind11::gil_scoped_acquire gil;
516

517
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawDrawableButton"); override_)
518
            {
519
                override_ (std::addressof (g), std::addressof (button), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
520
                return;
521
            }
522
        }
523

524
        Base::drawDrawableButton (g, button, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
525
    }
526

527
    juce::AlertWindow* createAlertWindow (const juce::String& title, const juce::String& message,
528
                                          const juce::String& button1, const juce::String& button2,
529
                                          const juce::String& button3, juce::MessageBoxIconType iconType,
530
                                          int numButtons, juce::Component* associatedComponent) override
531
    {
532
        PYBIND11_OVERRIDE (juce::AlertWindow*, Base, createAlertWindow, title, message, button1, button2, button3, iconType, numButtons, associatedComponent);
533
    }
534

535
    void drawAlertBox (juce::Graphics& g, juce::AlertWindow& alertWindow, const juce::Rectangle<int>& textArea, juce::TextLayout& textLayout) override
536
    {
537
        {
538
            pybind11::gil_scoped_acquire gil;
539

540
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawAlertBox"); override_)
541
            {
542
                override_ (std::addressof (g), std::addressof (alertWindow), textArea, std::addressof (textLayout));
543
                return;
544
            }
545
        }
546

547
        Base::drawAlertBox (g, alertWindow, textArea, textLayout);
548
    }
549

550
    int getAlertBoxWindowFlags() override
551
    {
552
        PYBIND11_OVERRIDE (int, Base, getAlertBoxWindowFlags);
553
    }
554

555
    juce::Array<int> getWidthsForTextButtons (juce::AlertWindow& alertWindow, const juce::Array<juce::TextButton*>& buttons) override
556
    {
557
        {
558
            pybind11::gil_scoped_acquire gil;
559

560
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "getWidthsForTextButtons"); override_)
561
            {
562
                pybind11::list list (buttons.size());
563
                for (int i = 0; i < buttons.size(); ++i)
564
                    list[static_cast<size_t> (i)] = buttons.getUnchecked (i);
565

566
                return override_ (std::addressof (alertWindow), list).cast<juce::Array<int>>();
567
            }
568
        }
569

570
        return Base::getWidthsForTextButtons (alertWindow, buttons);
571
    }
572

573
    int getAlertWindowButtonHeight() override
574
    {
575
        PYBIND11_OVERRIDE (int, Base, getAlertWindowButtonHeight);
576
    }
577

578
    juce::Font getAlertWindowTitleFont() override
579
    {
580
        PYBIND11_OVERRIDE (juce::Font, Base, getAlertWindowTitleFont);
581
    }
582

583
    juce::Font getAlertWindowMessageFont() override
584
    {
585
        PYBIND11_OVERRIDE (juce::Font, Base, getAlertWindowMessageFont);
586
    }
587

588
    juce::Font getAlertWindowFont() override
589
    {
590
        PYBIND11_OVERRIDE (juce::Font, Base, getAlertWindowFont);
591
    }
592
};
593

594
// =================================================================================================
595

596
template <class Base = juce::ComponentTraverser>
597
struct PyComponentTraverser : Base
598
{
599
    using Base::Base;
600

601
    juce::Component* getDefaultComponent (juce::Component* parentComponent) override
×
602
    {
603
        PYBIND11_OVERRIDE_PURE (juce::Component*, Base, getDefaultComponent, parentComponent);
×
604
    }
605

606
    juce::Component* getNextComponent (juce::Component* current) override
×
607
    {
608
        PYBIND11_OVERRIDE_PURE (juce::Component*, Base, getNextComponent, current);
×
609
    }
610

611
    juce::Component* getPreviousComponent (juce::Component* current) override
×
612
    {
613
        PYBIND11_OVERRIDE_PURE (juce::Component*, Base, getPreviousComponent, current);
×
614
    }
615

616
    std::vector<juce::Component*> getAllComponents (juce::Component* parentComponent) override
×
617
    {
618
        PYBIND11_OVERRIDE_PURE (std::vector<juce::Component*>, Base, getAllComponents, parentComponent);
×
619
    }
620
};
621

622
template <class Base = juce::FocusTraverser>
623
struct PyFocusTraverser : PyComponentTraverser<Base>
624
{
625
    using PyComponentTraverser<Base>::PyComponentTraverser;
626
};
627

628
// =================================================================================================
629

630
struct PyComponentListener : juce::ComponentListener
631
{
632
    using juce::ComponentListener::ComponentListener;
633

634
    void componentMovedOrResized (juce::Component& component, bool wasMoved, bool wasResized) override
×
635
    {
636
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentMovedOrResized, component, wasMoved, wasResized);
×
637
    }
638

639
    void componentBroughtToFront (juce::Component& component) override
×
640
    {
641
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentBroughtToFront, component);
×
642
    }
643

644
    void componentVisibilityChanged (juce::Component& component) override
×
645
    {
646
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentVisibilityChanged, component);
×
647
    }
648

649
    void componentChildrenChanged (juce::Component& component) override
×
650
    {
651
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentChildrenChanged, component);
×
652
    }
653

654
    void componentParentHierarchyChanged (juce::Component& component) override
×
655
    {
656
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentParentHierarchyChanged, component);
×
657
    }
658

659
    void componentNameChanged (juce::Component& component) override
×
660
    {
661
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentNameChanged, component);
×
662
    }
663

664
    void componentBeingDeleted (juce::Component& component) override
×
665
    {
666
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentBeingDeleted, component);
×
667
    }
668

669
    void componentEnablementChanged (juce::Component& component) override
×
670
    {
671
        PYBIND11_OVERRIDE (void, juce::ComponentListener, componentEnablementChanged, component);
×
672
    }
673
};
674

675
// =================================================================================================
676

677
struct PyModalComponentManagerCallback : juce::ModalComponentManager::Callback
678
{
679
    using juce::ModalComponentManager::Callback::Callback;
680

681
    void modalStateFinished (int returnValue) override
×
682
    {
683
        PYBIND11_OVERRIDE_PURE (void, juce::ModalComponentManager::Callback, modalStateFinished, returnValue);
×
684
    }
685
};
686

687
struct PyModalComponentManagerCallbackCallable : juce::ModalComponentManager::Callback
688
{
689
    explicit PyModalComponentManagerCallbackCallable (pybind11::function f)
×
690
        : fn (std::move (f))
×
691
    {
692
    }
×
693

694
    void modalStateFinished (int result) override
×
695
    {
696
        if (fn)
×
697
            fn (result);
×
698
    }
×
699

700
private:
701
    pybind11::function fn;
702
};
703

704
// =================================================================================================
705

706
template <class Base = juce::Component>
707
struct PyComponent : PyMouseListener<Base>
708
{
709
    using PyMouseListener<Base>::PyMouseListener;
710

711
    void setName (const juce::String& newName) override
×
712
    {
713
        PYBIND11_OVERRIDE (void, Base, setName, newName);
×
714
    }
715

716
    void setVisible (bool shouldBeVisible) override
3✔
717
    {
718
        PYBIND11_OVERRIDE (void, Base, setVisible, shouldBeVisible);
6✔
719
    }
720

721
    void visibilityChanged() override
3✔
722
    {
723
        PYBIND11_OVERRIDE (void, Base, visibilityChanged);
6✔
724
    }
725

726
    void userTriedToCloseWindow() override
×
727
    {
728
        PYBIND11_OVERRIDE (void, Base, userTriedToCloseWindow);
×
729
    }
730

731
    void minimisationStateChanged(bool isNowMinimised) override
×
732
    {
733
        PYBIND11_OVERRIDE (void, Base, minimisationStateChanged, isNowMinimised);
×
734
    }
735

736
    float getDesktopScaleFactor() const override
6✔
737
    {
738
        PYBIND11_OVERRIDE (float, Base, getDesktopScaleFactor);
12✔
739
    }
740

741
    void parentHierarchyChanged() override
7✔
742
    {
743
        PYBIND11_OVERRIDE (void, Base, parentHierarchyChanged);
14✔
744
    }
745

746
    void childrenChanged() override
18✔
747
    {
748
        PYBIND11_OVERRIDE (void, Base, childrenChanged);
36✔
749
    }
750

751
    bool hitTest (int x, int y) override
×
752
    {
753
        PYBIND11_OVERRIDE (bool, Base, hitTest, x, y);
×
754
    }
755

756
    void lookAndFeelChanged() override
4✔
757
    {
758
        PYBIND11_OVERRIDE (void, Base, lookAndFeelChanged);
8✔
759
    }
760

761
    void enablementChanged() override
×
762
    {
763
        PYBIND11_OVERRIDE (void, Base, enablementChanged);
×
764
    }
765

766
    void alphaChanged() override
×
767
    {
768
        PYBIND11_OVERRIDE (void, Base, alphaChanged);
×
769
    }
770

771
    void paint (juce::Graphics& g) override
2✔
772
    {
773
        {
774
            pybind11::gil_scoped_acquire gil;
2✔
775

776
            if (pybind11::function override_ = pybind11::get_override (static_cast<const Base*> (this), "paint"); override_)
2✔
777
            {
778
                override_ (std::addressof (g));
×
779
                return;
×
780
            }
781
        }
782

783
        if constexpr (! std::is_same_v<Base, juce::TooltipWindow>)
784
            Base::paint (g);
2✔
785
    }
786

787
    void paintOverChildren (juce::Graphics& g) override
2✔
788
    {
789
        {
790
            pybind11::gil_scoped_acquire gil;
2✔
791

792
            if (pybind11::function override_ = pybind11::get_override (static_cast<const Base*> (this), "paintOverChildren"); override_)
2✔
793
            {
794
                override_ (std::addressof (g));
×
795
                return;
×
796
            }
797
        }
798

799
        Base::paintOverChildren (g);
2✔
800
    }
801

802
    bool keyPressed (const juce::KeyPress& key) override
×
803
    {
804
        PYBIND11_OVERRIDE (bool, Base, keyPressed, key);
×
805
    }
806

807
    bool keyStateChanged (bool isDown) override
×
808
    {
809
        PYBIND11_OVERRIDE (bool, Base, keyStateChanged, isDown);
×
810
    }
811

812
    void modifierKeysChanged (const juce::ModifierKeys& modifiers) override
×
813
    {
814
        PYBIND11_OVERRIDE (void, Base, modifierKeysChanged, modifiers);
×
815
    }
816

817
    void focusGained (juce::Component::FocusChangeType cause) override
2✔
818
    {
819
        PYBIND11_OVERRIDE (void, Base, focusGained, cause);
4✔
820
    }
821

822
    void focusGainedWithDirection (juce::Component::FocusChangeType cause, juce::Component::FocusChangeDirection direction) override
2✔
823
    {
824
        PYBIND11_OVERRIDE (void, Base, focusGainedWithDirection, cause, direction);
4✔
825
    }
826

827
    void focusLost (juce::Component::FocusChangeType cause) override
1✔
828
    {
829
        PYBIND11_OVERRIDE (void, Base, focusLost, cause);
2✔
830
    }
831

832
    void focusOfChildComponentChanged (juce::Component::FocusChangeType cause) override
3✔
833
    {
834
        PYBIND11_OVERRIDE (void, Base, focusOfChildComponentChanged, cause);
6✔
835
    }
836

837
    void resized () override
8✔
838
    {
839
        PYBIND11_OVERRIDE (void, Base, resized);
16✔
840
    }
841

842
    void moved () override
1✔
843
    {
844
        PYBIND11_OVERRIDE (void, Base, moved);
2✔
845
    }
846

847
    void childBoundsChanged (juce::Component* child) override
15✔
848
    {
849
        PYBIND11_OVERRIDE (void, Base, childBoundsChanged, child);
30✔
850
    }
851

852
    void parentSizeChanged () override
×
853
    {
854
        PYBIND11_OVERRIDE (void, Base, parentSizeChanged);
×
855
    }
856

857
    void broughtToFront () override
2✔
858
    {
859
        PYBIND11_OVERRIDE (void, Base, broughtToFront);
4✔
860
    }
861

862
    void handleCommandMessage (int commandId) override
5✔
863
    {
864
        {
865
            pybind11::gil_scoped_acquire gil;
5✔
866

867
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "handleCommandMessage"); override_)
5✔
868
            {
869
                override_ (commandId);
×
870
                return;
×
871
            }
872
        }
873

874
        if constexpr (! std::is_same_v<Base, juce::TextEditor>)
875
            Base::handleCommandMessage (commandId);
5✔
876
    }
877

878
    bool canModalEventBeSentToComponent (const juce::Component* targetComponent) override
×
879
    {
880
        PYBIND11_OVERRIDE (bool, Base, canModalEventBeSentToComponent, targetComponent);
×
881
    }
882

883
    void inputAttemptWhenModal () override
×
884
    {
885
        PYBIND11_OVERRIDE (void, Base, inputAttemptWhenModal);
×
886
    }
887

888
    void colourChanged () override
×
889
    {
890
        PYBIND11_OVERRIDE (void, Base, colourChanged);
×
891
    }
892
};
893

894
// =================================================================================================
895

896
template <class Base = juce::Drawable>
897
struct PyDrawable : PyComponent<Base>
898
{
899
    using PyComponent<Base>::PyComponent;
900

901
    std::unique_ptr<juce::Drawable> createCopy() const override
×
902
    {
903
        /*
904
        {
905
            pybind11::gil_scoped_acquire gil;
906

907
            if (pybind11::function override_ = pybind11::get_override (static_cast<const Base*> (this), "createCopy"); override_)
908
            {
909
                pybind11::object result = override_();
910

911
                return std::unique_ptr<Drawable> (result.release().cast<Base*>());
912
            }
913
        }
914

915
        pybind11::pybind11_fail("Tried to call pure virtual function \"Drawable::createCopy\"");
916
        */
917

918
        return nullptr;
×
919
    }
920

921
    juce::Path getOutlineAsPath() const override
×
922
    {
923
        PYBIND11_OVERRIDE_PURE (juce::Path, Base, getOutlineAsPath);
×
924
    }
925

926
    juce::Rectangle<float> getDrawableBounds() const override
×
927
    {
928
        PYBIND11_OVERRIDE_PURE (juce::Rectangle<float>, Base, getDrawableBounds);
×
929
    }
930

931
    bool replaceColour (juce::Colour originalColour, juce::Colour replacementColour) override
×
932
    {
933
        PYBIND11_OVERRIDE (bool, Base, replaceColour, originalColour, replacementColour);
×
934
    }
935
};
936

937
template <class Base = juce::DrawableComposite>
938
struct PyDrawableComposite : PyDrawable<Base>
939
{
940
    using PyDrawable<Base>::PyDrawable;
941

942
    std::unique_ptr<juce::Drawable> createCopy() const override { return nullptr; }
×
943

944
    juce::Path getOutlineAsPath() const override
×
945
    {
946
        PYBIND11_OVERRIDE (juce::Path, Base, getOutlineAsPath);
×
947
    }
948

949
    juce::Rectangle<float> getDrawableBounds() const override
×
950
    {
951
        PYBIND11_OVERRIDE (juce::Rectangle<float>, Base, getDrawableBounds);
×
952
    }
953
};
954

955
template <class Base = juce::DrawableImage>
956
struct PyDrawableImage : PyDrawable<Base>
957
{
958
    using PyDrawable<Base>::PyDrawable;
959

960
    std::unique_ptr<juce::Drawable> createCopy() const override { return nullptr; }
961

962
    juce::Path getOutlineAsPath() const override
963
    {
964
        PYBIND11_OVERRIDE (juce::Path, Base, getOutlineAsPath);
965
    }
966

967
    juce::Rectangle<float> getDrawableBounds() const override
968
    {
969
        PYBIND11_OVERRIDE (juce::Rectangle<float>, Base, getDrawableBounds);
970
    }
971
};
972

973
template <class Base = juce::DrawablePath>
974
struct PyDrawablePath : PyDrawable<Base>
975
{
976
    using PyDrawable<Base>::PyDrawable;
977

978
    std::unique_ptr<juce::Drawable> createCopy() const override { return nullptr; }
×
979
};
980

981
template <class Base = juce::DrawableShape>
982
struct PyDrawableShape : PyDrawable<Base>
983
{
984
    using PyDrawable<Base>::PyDrawable;
985

986
    std::unique_ptr<juce::Drawable> createCopy() const override { return nullptr; }
×
987

988
    juce::Path getOutlineAsPath() const override
×
989
    {
990
        PYBIND11_OVERRIDE (juce::Path, Base, getOutlineAsPath);
×
991
    }
992

993
    juce::Rectangle<float> getDrawableBounds() const override
×
994
    {
995
        PYBIND11_OVERRIDE (juce::Rectangle<float>, Base, getDrawableBounds);
×
996
    }
997

998
    bool replaceColour (juce::Colour originalColour, juce::Colour replacementColour) override
×
999
    {
1000
        PYBIND11_OVERRIDE (bool, Base, replaceColour, originalColour, replacementColour);
×
1001
    }
1002
};
1003

1004
template <class Base = juce::DrawableText>
1005
struct PyDrawableText : PyDrawable<Base>
1006
{
1007
    using PyDrawable<Base>::PyDrawable;
1008

1009
    std::unique_ptr<juce::Drawable> createCopy() const override { return nullptr; }
×
1010

1011
    juce::Path getOutlineAsPath() const override
×
1012
    {
1013
        PYBIND11_OVERRIDE (juce::Path, Base, getOutlineAsPath);
×
1014
    }
1015

1016
    juce::Rectangle<float> getDrawableBounds() const override
×
1017
    {
1018
        PYBIND11_OVERRIDE (juce::Rectangle<float>, Base, getDrawableBounds);
×
1019
    }
1020

1021
    bool replaceColour (juce::Colour originalColour, juce::Colour replacementColour) override
×
1022
    {
1023
        PYBIND11_OVERRIDE (bool, Base, replaceColour, originalColour, replacementColour);
×
1024
    }
1025
};
1026

1027
// =================================================================================================
1028

1029
template <class Base = juce::Button>
1030
struct PyButton : PyComponent<Base>
1031
{
1032
    using PyComponent<Base>::PyComponent;
1033

1034
    explicit PyButton (const juce::String& name)
10✔
1035
        : PyComponent<Base> (name)
10✔
1036
    {
1037
    }
10✔
1038

1039
    void triggerClick() override
5✔
1040
    {
1041
        PYBIND11_OVERRIDE (void, Base, triggerClick);
10✔
1042
    }
1043

1044
    void clicked() override
7✔
1045
    {
1046
        PYBIND11_OVERRIDE (void, Base, clicked);
7✔
1047
    }
1048

1049
    void clicked (const juce::ModifierKeys& modifiers) override
7✔
1050
    {
1051
        {
1052
            pybind11::gil_scoped_acquire gil;
7✔
1053

1054
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "clickedWithModifiers"); override_)
7✔
1055
            {
1056
                override_ (modifiers);
×
1057
                return;
×
1058
            }
1059
        }
1060

1061
        if constexpr (! std::is_same_v<Base, juce::HyperlinkButton>)
1062
            Base::clicked (modifiers);
7✔
1063
    }
1064

1065
    void paintButton (juce::Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
2✔
1066
    {
1067
        {
1068
            pybind11::gil_scoped_acquire gil;
2✔
1069

1070
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "paintButton"); override_)
2✔
1071
            {
1072
                override_ (std::addressof (g), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
2✔
1073
                return;
4✔
1074
            }
1075
        }
1076

1077
        pybind11::pybind11_fail ("Tried to call pure virtual function \"Button::paintButton\"");
×
1078
    }
1079

1080
    void buttonStateChanged() override
11✔
1081
    {
1082
        PYBIND11_OVERRIDE (void, Base, buttonStateChanged);
11✔
1083
    }
1084
};
1085

1086
struct PyButtonListener : juce::Button::Listener
1087
{
1088
    using juce::Button::Listener::Listener;
1089

1090
    void buttonClicked (juce::Button* button) override
3✔
1091
    {
1092
        PYBIND11_OVERRIDE_PURE (void, juce::Button::Listener, buttonClicked, button);
3✔
1093
    }
1094

1095
    void buttonStateChanged (juce::Button* button) override
3✔
1096
    {
1097
        PYBIND11_OVERRIDE (void, juce::Button::Listener, buttonStateChanged, button);
3✔
1098
    }
1099
};
1100

1101
template <class Base = juce::DrawableButton>
1102
struct PyDrawableButton : PyButton<Base>
1103
{
1104
    using PyButton<Base>::PyButton;
1105

1106
    juce::Rectangle<float> getImageBounds() const override
×
1107
    {
1108
        PYBIND11_OVERRIDE (juce::Rectangle<float>, Base, getImageBounds);
×
1109
    }
1110
};
1111

1112
// =================================================================================================
1113

1114
template <class Base = juce::Label>
1115
struct PyLabel : PyComponent<Base>
1116
{
1117
    using PyComponent<Base>::PyComponent;
1118

1119
    juce::TextEditor* createEditorComponent() override
×
1120
    {
1121
        PYBIND11_OVERRIDE (juce::TextEditor*, Base, createEditorComponent);
×
1122
    }
1123

1124
    void textWasEdited() override
×
1125
    {
1126
        PYBIND11_OVERRIDE (void, Base, textWasEdited);
×
1127
    }
1128

1129
    void textWasChanged() override
×
1130
    {
1131
        PYBIND11_OVERRIDE (void, Base, textWasChanged);
×
1132
    }
1133

1134
    void editorShown (juce::TextEditor* e) override
×
1135
    {
1136
        PYBIND11_OVERRIDE (void, Base, editorShown, e);
×
1137
    }
1138

1139
    void editorAboutToBeHidden (juce::TextEditor* e) override
×
1140
    {
1141
        PYBIND11_OVERRIDE (void, Base, editorAboutToBeHidden, e);
×
1142
    }
1143
};
1144

1145
struct PyLabelListener : juce::Label::Listener
1146
{
1147
    using juce::Label::Listener::Listener;
1148

1149
    void labelTextChanged (juce::Label* labelThatHasChanged) override
×
1150
    {
1151
        PYBIND11_OVERRIDE_PURE (void, juce::Label::Listener, labelTextChanged, labelThatHasChanged);
×
1152
    }
1153

1154
    void editorShown (juce::Label* label, juce::TextEditor& e) override
×
1155
    {
1156
        PYBIND11_OVERRIDE (void, juce::Label::Listener, editorShown, label, e);
×
1157
    }
1158

1159
    void editorHidden (juce::Label* label, juce::TextEditor& e) override
×
1160
    {
1161
        PYBIND11_OVERRIDE (void, juce::Label::Listener, editorHidden, label, e);
×
1162
    }
1163
};
1164

1165
// =================================================================================================
1166

1167
template <class Base = juce::TextEditor>
1168
struct PyTextEditor : /*PyTextInputTarget<Base>,*/ PyComponent<Base>
1169
{
1170
    using PyComponent<Base>::PyComponent;
1171
    //using PyTextInputTarget<Base>::PyTextInputTarget;
1172

1173
    void addPopupMenuItems (juce::PopupMenu& menuToAddTo, const juce::MouseEvent* mouseClickEvent) override
×
1174
    {
1175
        PYBIND11_OVERRIDE (void, Base, addPopupMenuItems, menuToAddTo, mouseClickEvent);
×
1176
    }
1177

1178
    void performPopupMenuAction (int menuItemID) override
×
1179
    {
1180
        PYBIND11_OVERRIDE (void, Base, performPopupMenuAction, menuItemID);
×
1181
    }
1182
};
1183

1184
struct PyTextEditorListener : juce::TextEditor::Listener
1185
{
1186
    using juce::TextEditor::Listener::Listener;
1187

1188
    void textEditorTextChanged (juce::TextEditor& e) override
×
1189
    {
1190
        PYBIND11_OVERRIDE_PURE (void, juce::TextEditor::Listener, textEditorTextChanged, e);
×
1191
    }
1192

1193
    void textEditorReturnKeyPressed (juce::TextEditor& e) override
×
1194
    {
1195
        PYBIND11_OVERRIDE_PURE (void, juce::TextEditor::Listener, textEditorReturnKeyPressed, e);
×
1196
    }
1197

1198
    void textEditorEscapeKeyPressed (juce::TextEditor& e) override
×
1199
    {
1200
        PYBIND11_OVERRIDE_PURE (void, juce::TextEditor::Listener, textEditorEscapeKeyPressed, e);
×
1201
    }
1202

1203
    void textEditorFocusLost (juce::TextEditor& e) override
×
1204
    {
1205
        PYBIND11_OVERRIDE_PURE (void, juce::TextEditor::Listener, textEditorFocusLost, e);
×
1206
    }
1207
};
1208

1209
template <class Base = juce::TextEditor::InputFilter>
1210
struct PyTextEditorInputFilter : Base
1211
{
1212
    using Base::Base;
1213

1214
    juce::String filterNewText (juce::TextEditor& e, const juce::String& newInput) override
×
1215
    {
1216
        PYBIND11_OVERRIDE_PURE (juce::String, Base, filterNewText, e, newInput);
×
1217
    }
1218
};
1219

1220
// =================================================================================================
1221

1222
struct PyListBoxModel : juce::ListBoxModel
1223
{
1224
    using juce::ListBoxModel::ListBoxModel;
1225

1226
    int getNumRows() override
×
1227
    {
1228
        PYBIND11_OVERRIDE_PURE (int, juce::ListBoxModel, getNumRows);
×
1229
    }
1230

1231
    void paintListBoxItem (int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) override
×
1232
    {
1233
        {
1234
            pybind11::gil_scoped_acquire gil;
×
1235

1236
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::ListBoxModel*> (this), "paintListBoxItem"); override_)
×
1237
            {
1238
                override_ (rowNumber, std::addressof (g), width, height, rowIsSelected);
×
1239
                return;
×
1240
            }
1241
        }
1242

1243
        pybind11::pybind11_fail ("Tried to call pure virtual function \"ListBoxModel::paintListBoxItem\"");
×
1244
    }
1245

1246
    juce::Component* refreshComponentForRow (int rowNumber, bool isRowSelected, juce::Component* existingComponentToUpdate) override
×
1247
    {
1248
        {
1249
            pybind11::gil_scoped_acquire gil;
×
1250

1251
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::ListBoxModel*> (this), "refreshComponentForRow"); override_)
×
1252
            {
1253
                auto result = override_ (rowNumber, isRowSelected, existingComponentToUpdate);
×
1254
                if (result.is_none())
×
1255
                    return nullptr;
×
1256

1257
                if (! pybind11::isinstance<juce::Component> (result))
×
1258
                    pybind11::pybind11_fail ("Method \"ListBoxModel::refreshComponentForRow\" returned something else than a \"Component\"");
×
1259

1260
                return result.release().cast<juce::Component*>();
×
1261
            }
1262
        }
1263

1264
        return juce::ListBoxModel::refreshComponentForRow (rowNumber, isRowSelected, existingComponentToUpdate);
×
1265
    }
1266

1267
    juce::String getNameForRow (int rowNumber) override
×
1268
    {
1269
        PYBIND11_OVERRIDE (juce::String, juce::ListBoxModel, getNameForRow, rowNumber);
×
1270
    }
1271

1272
    void listBoxItemClicked (int row, const juce::MouseEvent& event) override
×
1273
    {
1274
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, listBoxItemClicked, row, event);
×
1275
    }
1276

1277
    void listBoxItemDoubleClicked (int row, const juce::MouseEvent& event) override
×
1278
    {
1279
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, listBoxItemDoubleClicked, row, event);
×
1280
    }
1281

1282
    void backgroundClicked (const juce::MouseEvent& event) override
×
1283
    {
1284
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, backgroundClicked, event);
×
1285
    }
1286

1287
    void selectedRowsChanged (int lastRowSelected) override
×
1288
    {
1289
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, selectedRowsChanged, lastRowSelected);
×
1290
    }
1291

1292
    void deleteKeyPressed (int lastRowSelected) override
×
1293
    {
1294
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, deleteKeyPressed, lastRowSelected);
×
1295
    }
1296

1297
    void returnKeyPressed (int lastRowSelected) override
×
1298
    {
1299
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, returnKeyPressed, lastRowSelected);
×
1300
    }
1301

1302
    void listWasScrolled() override
×
1303
    {
1304
        PYBIND11_OVERRIDE (void, juce::ListBoxModel, listWasScrolled);
×
1305
    }
1306

1307
    juce::var getDragSourceDescription (const juce::SparseSet<int>& rowsToDescribe) override
×
1308
    {
1309
        PYBIND11_OVERRIDE (juce::var, juce::ListBoxModel, getDragSourceDescription, rowsToDescribe);
×
1310
    }
1311

1312
    bool mayDragToExternalWindows() const override
×
1313
    {
1314
        PYBIND11_OVERRIDE (bool, juce::ListBoxModel, mayDragToExternalWindows);
×
1315
    }
1316

1317
    juce::String getTooltipForRow (int row) override
×
1318
    {
1319
        PYBIND11_OVERRIDE (juce::String, juce::ListBoxModel, getTooltipForRow, row);
×
1320
    }
1321

1322
    juce::MouseCursor getMouseCursorForRow (int row) override
×
1323
    {
1324
        PYBIND11_OVERRIDE (juce::MouseCursor, juce::ListBoxModel, getMouseCursorForRow, row);
×
1325
    }
1326
};
1327

1328
template <class Base = juce::ListBox>
1329
struct PyListBox : PyComponent<Base>
1330
{
1331
    using PyComponent<Base>::PyComponent;
1332

1333
    juce::ScaledImage createSnapshotOfRows (const juce::SparseSet<int>& rows, int& x, int& y) override
×
1334
    {
1335
        juce::ignoreUnused (rows, x, y);
×
1336

1337
        return {}; // TODO
×
1338
    }
1339
};
1340

1341
// =================================================================================================
1342

1343
template <class Base = juce::TableHeaderComponent>
1344
struct PyTableHeaderComponent : PyComponent<Base>
1345
{
1346
    using PyComponent<Base>::PyComponent;
1347

1348
    void columnClicked (int columnId, const juce::ModifierKeys& mods) override
×
1349
    {
1350
        PYBIND11_OVERRIDE (void, juce::TableHeaderComponent, columnClicked, columnId, mods);
×
1351
    }
1352

1353
    void addMenuItems (juce::PopupMenu& menu, int columnIdClicked) override
×
1354
    {
1355
        PYBIND11_OVERRIDE (void, juce::TableHeaderComponent, addMenuItems, menu, columnIdClicked);
×
1356
    }
1357

1358
    void reactToMenuItem (int menuReturnId, int columnIdClicked) override
×
1359
    {
1360
        PYBIND11_OVERRIDE (void, juce::TableHeaderComponent, reactToMenuItem, menuReturnId, columnIdClicked);
×
1361
    }
1362

1363
    void showColumnChooserMenu (int columnIdClicked) override
×
1364
    {
1365
        PYBIND11_OVERRIDE (void, juce::TableHeaderComponent, showColumnChooserMenu, columnIdClicked);
×
1366
    }
1367
};
1368

1369
struct PyTableHeaderComponentListener : juce::TableHeaderComponent::Listener
1370
{
1371
    using juce::TableHeaderComponent::Listener::Listener;
1372

1373
    void tableColumnsChanged (juce::TableHeaderComponent* tableHeader) override
×
1374
    {
1375
        PYBIND11_OVERRIDE_PURE (void, juce::TableHeaderComponent::Listener, tableColumnsChanged, tableHeader);
×
1376
    }
1377

1378
    void tableColumnsResized (juce::TableHeaderComponent* tableHeader) override
×
1379
    {
1380
        PYBIND11_OVERRIDE_PURE (void, juce::TableHeaderComponent::Listener, tableColumnsResized, tableHeader);
×
1381
    }
1382

1383
    void tableSortOrderChanged (juce::TableHeaderComponent* tableHeader) override
×
1384
    {
1385
        PYBIND11_OVERRIDE_PURE (void, juce::TableHeaderComponent::Listener, tableSortOrderChanged, tableHeader);
×
1386
    }
1387

1388
    void tableColumnDraggingChanged (juce::TableHeaderComponent* tableHeader, int columnIdNowBeingDragged) override
×
1389
    {
1390
        PYBIND11_OVERRIDE (void, juce::TableHeaderComponent::Listener, tableColumnDraggingChanged, tableHeader, columnIdNowBeingDragged);
×
1391
    }
1392
};
1393

1394
// =================================================================================================
1395

1396
struct PyTableListBoxModel : juce::TableListBoxModel
1397
{
1398
    using juce::TableListBoxModel::TableListBoxModel;
1399

1400
    int getNumRows() override
×
1401
    {
1402
        PYBIND11_OVERRIDE_PURE (int, juce::TableListBoxModel, getNumRows);
×
1403
    }
1404

1405
    void paintRowBackground (juce::Graphics& g, int rowNumber, int width, int height, bool rowIsSelected) override
×
1406
    {
1407
        {
1408
            pybind11::gil_scoped_acquire gil;
×
1409

1410
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::TableListBoxModel*> (this), "paintRowBackground"); override_)
×
1411
            {
1412
                override_ (std::addressof (g), rowNumber, width, height, rowIsSelected);
×
1413
                return;
×
1414
            }
1415
        }
1416

1417
        pybind11::pybind11_fail ("Tried to call pure virtual function \"TableListBoxModel::paintListBoxItem\"");
×
1418
    }
1419

1420
    void paintCell (juce::Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override
×
1421
    {
1422
        {
1423
            pybind11::gil_scoped_acquire gil;
×
1424

1425
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::TableListBoxModel*> (this), "paintCell"); override_)
×
1426
            {
1427
                override_ (std::addressof (g), rowNumber, columnId, width, height, rowIsSelected);
×
1428
                return;
×
1429
            }
1430
        }
1431

1432
        pybind11::pybind11_fail ("Tried to call pure virtual function \"TableListBoxModel::paintCell\"");
×
1433
    }
1434

1435
    juce::Component* refreshComponentForCell (int rowNumber, int columnId, bool isRowSelected, juce::Component* existingComponentToUpdate) override
×
1436
    {
1437
        {
1438
            pybind11::gil_scoped_acquire gil;
×
1439

1440
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::TableListBoxModel*> (this), "refreshComponentForCell"); override_)
×
1441
            {
1442
                auto result = override_ (rowNumber, columnId, isRowSelected, existingComponentToUpdate);
×
1443
                if (result.is_none())
×
1444
                    return nullptr;
×
1445

1446
                if (! pybind11::isinstance<juce::Component> (result))
×
1447
                    pybind11::pybind11_fail ("Method \"TableListBoxModel::refreshComponentForRow\" returned something else than a \"Component\"");
×
1448

1449
                return result.release().cast<juce::Component*>();
×
1450
            }
1451
        }
1452

1453
        return juce::TableListBoxModel::refreshComponentForCell (rowNumber, columnId, isRowSelected, existingComponentToUpdate);
×
1454
    }
1455

1456
    void cellClicked (int rowNumber, int columnId, const juce::MouseEvent& event) override
×
1457
    {
1458
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, cellClicked, rowNumber, columnId, event);
×
1459
    }
1460

1461
    void cellDoubleClicked (int rowNumber, int columnId, const juce::MouseEvent& event) override
×
1462
    {
1463
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, cellDoubleClicked, rowNumber, columnId, event);
×
1464
    }
1465

1466
    void backgroundClicked (const juce::MouseEvent& event) override
×
1467
    {
1468
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, backgroundClicked, event);
×
1469
    }
1470

1471
    void sortOrderChanged (int newSortColumnId, bool isForwards) override
×
1472
    {
1473
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, sortOrderChanged, newSortColumnId, isForwards);
×
1474
    }
1475

1476
    int getColumnAutoSizeWidth (int columnId) override
×
1477
    {
1478
        PYBIND11_OVERRIDE (int, juce::TableListBoxModel, getColumnAutoSizeWidth, columnId);
×
1479
    }
1480

1481
    juce::String getCellTooltip (int rowNumber, int columnId) override
×
1482
    {
1483
        PYBIND11_OVERRIDE ( juce::String, juce::TableListBoxModel, getCellTooltip, rowNumber, columnId);
×
1484
    }
1485

1486
    void selectedRowsChanged (int lastRowSelected) override
×
1487
    {
1488
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, selectedRowsChanged, lastRowSelected);
×
1489
    }
1490

1491
    void deleteKeyPressed (int lastRowSelected) override
×
1492
    {
1493
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, deleteKeyPressed, lastRowSelected);
×
1494
    }
1495

1496
    void returnKeyPressed (int lastRowSelected) override
×
1497
    {
1498
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, returnKeyPressed, lastRowSelected);
×
1499
    }
1500

1501
    void listWasScrolled() override
×
1502
    {
1503
        PYBIND11_OVERRIDE (void, juce::TableListBoxModel, listWasScrolled);
×
1504
    }
1505

1506
    juce::var getDragSourceDescription (const juce::SparseSet<int>& currentlySelectedRows) override
×
1507
    {
1508
        PYBIND11_OVERRIDE (juce::var, juce::TableListBoxModel, getDragSourceDescription, currentlySelectedRows);
×
1509
    }
1510

1511
    bool mayDragToExternalWindows() const override
×
1512
    {
1513
        PYBIND11_OVERRIDE (bool, juce::TableListBoxModel, mayDragToExternalWindows);
×
1514
    }
1515
};
1516

1517
// =================================================================================================
1518

1519
struct PyToolbarItemFactory : juce::ToolbarItemFactory
1520
{
1521
    using juce::ToolbarItemFactory::ToolbarItemFactory;
1522

1523
    void getAllToolbarItemIds (juce::Array<int>& ids) override
×
1524
    {
1525
        {
1526
            pybind11::gil_scoped_acquire gil;
×
1527

1528
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::ToolbarItemFactory*> (this), "getAllToolbarItemIds"); override_)
×
1529
            {
1530
                auto result = override_ ();
×
1531

1532
                ids.addArray (result.cast<juce::Array<int>>());
×
1533
            }
1534
        }
1535

1536
        pybind11::pybind11_fail ("Tried to call pure virtual function \"ToolbarItemFactory::getAllToolbarItemIds\"");
×
1537
    }
1538

1539
    void getDefaultItemSet (juce::Array<int>& ids) override
×
1540
    {
1541
        {
1542
            pybind11::gil_scoped_acquire gil;
×
1543

1544
            if (pybind11::function override_ = pybind11::get_override (static_cast<juce::ToolbarItemFactory*> (this), "getDefaultItemSet"); override_)
×
1545
            {
1546
                auto result = override_ ();
×
1547

1548
                ids.addArray (result.cast<juce::Array<int>>());
×
1549
            }
1550
        }
1551

1552
        pybind11::pybind11_fail ("Tried to call pure virtual function \"ToolbarItemFactory::getDefaultItemSet\"");
×
1553
    }
1554

1555
    juce::ToolbarItemComponent* createItem (int itemId) override
×
1556
    {
1557
        PYBIND11_OVERRIDE_PURE (juce::ToolbarItemComponent*, juce::ToolbarItemFactory, createItem, itemId);
×
1558
    }
1559
};
1560

1561
template <class Base = juce::ToolbarItemComponent>
1562
struct PyToolbarItemComponent : PyButton<Base>
1563
{
1564
    using PyButton<Base>::PyButton;
1565

1566
    void setStyle (const juce::Toolbar::ToolbarItemStyle& newStyle) override
×
1567
    {
1568
        PYBIND11_OVERRIDE (void, Base, setStyle, newStyle);
×
1569
    }
1570

1571
    bool getToolbarItemSizes (int toolbarThickness, bool isToolbarVertical, int& preferredSize, int& minSize, int& maxSize) override
×
1572
    {
1573
        {
1574
            pybind11::gil_scoped_acquire gil;
×
1575

1576
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "getToolbarItemSizes"); override_)
×
1577
            {
1578
                auto result = override_ (toolbarThickness, isToolbarVertical, std::ref (preferredSize), std::ref (minSize), std::ref (maxSize));
×
1579

1580
                return pybind11::detail::cast_safe<bool> (std::move (result));
×
1581
            }
1582
        }
1583

1584
        pybind11::pybind11_fail ("Tried to call pure virtual function \"ToolbarItemComponent::getToolbarItemSizes\"");
×
1585
    }
1586

1587
    void paintButtonArea (juce::Graphics& g, int width, int height, bool isMouseOver, bool isMouseDown) override
×
1588
    {
1589
        {
1590
            pybind11::gil_scoped_acquire gil;
×
1591

1592
            if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "paintButtonArea"); override_)
×
1593
            {
1594
                override_ (std::addressof (g), width, height, isMouseOver, isMouseDown);
×
1595

1596
                return;
×
1597
            }
1598
        }
1599

1600
        pybind11::pybind11_fail ("Tried to call pure virtual function \"ToolbarItemComponent::paintButtonArea\"");
×
1601
    }
1602

1603
    void contentAreaChanged (const juce::Rectangle<int>& newBounds) override
×
1604
    {
1605
        PYBIND11_OVERRIDE_PURE (void, Base, contentAreaChanged, newBounds);
×
1606
    }
1607
};
1608

1609
// ============================================================================================
1610

1611
struct PyMenuBarModel : juce::MenuBarModel
1612
{
1613
    juce::StringArray getMenuBarNames() override
×
1614
    {
1615
        PYBIND11_OVERRIDE_PURE (juce::StringArray, juce::MenuBarModel, getMenuBarNames);
×
1616
    }
1617

1618
    juce::PopupMenu getMenuForIndex (int topLevelMenuIndex, const juce::String& menuName) override
×
1619
    {
1620
        PYBIND11_OVERRIDE_PURE (juce::PopupMenu, juce::MenuBarModel, getMenuForIndex, topLevelMenuIndex, menuName);
×
1621
    }
1622

1623
    void menuItemSelected (int menuItemID, int topLevelMenuIndex) override
×
1624
    {
1625
        PYBIND11_OVERRIDE_PURE (void, juce::MenuBarModel, menuItemSelected, menuItemID, topLevelMenuIndex);
×
1626
    }
1627

1628
    void menuBarActivated (bool isActive) override
×
1629
    {
1630
        PYBIND11_OVERRIDE (void, juce::MenuBarModel, menuBarActivated, isActive);
×
1631
    }
1632
};
1633

1634
struct PyMenuBarModelListener : juce::MenuBarModel::Listener
1635
{
1636
    void menuBarItemsChanged (juce::MenuBarModel* menuBarModel) override
×
1637
    {
1638
        PYBIND11_OVERRIDE_PURE (void, juce::MenuBarModel::Listener, menuBarItemsChanged, menuBarModel);
×
1639
    }
1640

1641
    void menuCommandInvoked (juce::MenuBarModel* menuBarModel, const juce::ApplicationCommandTarget::InvocationInfo& info) override
×
1642
    {
1643
        PYBIND11_OVERRIDE_PURE (void, juce::MenuBarModel::Listener, menuCommandInvoked, menuBarModel, info);
×
1644
    }
1645

1646
    void menuBarActivated (juce::MenuBarModel* menuBarModel, bool isActive) override
×
1647
    {
1648
        PYBIND11_OVERRIDE_PURE (void, juce::MenuBarModel::Listener, menuBarActivated, menuBarModel, isActive);
×
1649
    }
1650
};
1651

1652
// =================================================================================================
1653

1654
template <class Base = juce::Slider>
1655
struct PySlider : PyComponent<Base>
1656
{
1657
    using PyComponent<Base>::PyComponent;
1658

1659
    void startedDragging() override
×
1660
    {
1661
        PYBIND11_OVERRIDE (void, Base, startedDragging);
×
1662
    }
1663

1664
    void stoppedDragging() override
×
1665
    {
1666
        PYBIND11_OVERRIDE (void, Base, stoppedDragging);
×
1667
    }
1668

1669
    void valueChanged() override
×
1670
    {
1671
        PYBIND11_OVERRIDE (void, Base, valueChanged);
×
1672
    }
1673

1674
    double getValueFromText (const juce::String& text) override
×
1675
    {
1676
        PYBIND11_OVERRIDE (double, Base, getValueFromText, text);
×
1677
    }
1678

1679
    juce::String getTextFromValue (double value) override
×
1680
    {
1681
        PYBIND11_OVERRIDE (juce::String, Base, getTextFromValue, value);
×
1682
    }
1683

1684
    double proportionOfLengthToValue (double proportion) override
×
1685
    {
1686
        PYBIND11_OVERRIDE (double, Base, proportionOfLengthToValue, proportion);
×
1687
    }
1688

1689
    double valueToProportionOfLength (double value) override
×
1690
    {
1691
        PYBIND11_OVERRIDE (double, Base, valueToProportionOfLength, value);
×
1692
    }
1693

1694
    double snapValue (double attemptedValue, juce::Slider::DragMode dragMode) override
×
1695
    {
1696
        PYBIND11_OVERRIDE (double, Base, snapValue, attemptedValue, dragMode);
×
1697
    }
1698
};
1699

1700
struct PySliderListener : juce::Slider::Listener
1701
{
1702
    using juce::Slider::Listener::Listener;
1703

1704
    void sliderValueChanged (juce::Slider* slider) override
×
1705
    {
1706
        PYBIND11_OVERRIDE_PURE (void, juce::Slider::Listener, sliderValueChanged, slider);
×
1707
    }
1708

1709
    void sliderDragStarted (juce::Slider* slider) override
×
1710
    {
1711
        PYBIND11_OVERRIDE (void, juce::Slider::Listener, sliderDragStarted, slider);
×
1712
    }
1713

1714
    void sliderDragEnded (juce::Slider* slider) override
×
1715
    {
1716
        PYBIND11_OVERRIDE (void, juce::Slider::Listener, sliderDragEnded, slider);
×
1717
    }
1718
};
1719

1720
// ============================================================================================
1721

1722
template <class Base = juce::DocumentWindow>
1723
struct PyDocumentWindow : PyComponent<Base>
1724
{
1725
    using PyComponent<Base>::PyComponent;
1726

1727
    void closeButtonPressed() override
×
1728
    {
1729
        PYBIND11_OVERRIDE (void, Base, closeButtonPressed);
×
1730
    }
1731

1732
    void minimiseButtonPressed() override
×
1733
    {
1734
        PYBIND11_OVERRIDE (void, Base, minimiseButtonPressed);
×
1735
    }
1736

1737
    void maximiseButtonPressed() override
×
1738
    {
1739
        PYBIND11_OVERRIDE (void, Base, maximiseButtonPressed);
×
1740
    }
1741
};
1742

1743
// ============================================================================================
1744

1745
template <class Base = juce::TooltipWindow>
1746
struct PyTooltipWindow : PyComponent<Base>
1747
{
1748
    using PyComponent<Base>::PyComponent;
1749

NEW
1750
    juce::String getTipFor (juce::Component& c) override
×
1751
    {
NEW
1752
        PYBIND11_OVERRIDE (juce::String, Base, getTipFor, c);
×
1753
    }
1754
};
1755

1756
// ============================================================================================
1757

1758
template <class Base = juce::ThreadWithProgressWindow>
1759
struct PyThreadWithProgressWindow : PyThread<Base>
1760
{
1761
    using PyThread<Base>::PyThread;
1762

NEW
1763
    void threadComplete (bool userPressedCancel) override
×
1764
    {
NEW
1765
        PYBIND11_OVERRIDE (void, Base, threadComplete, userPressedCancel);
×
1766
    }
1767
};
1768

1769
} // namespace popsicle::Bindings
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc