|
|
|
@@ -40,15 +40,23 @@ struct Spinner : public Component, private Timer |
|
|
|
|
|
|
|
struct OnlineUnlockForm::OverlayComp : public Component,
|
|
|
|
private Thread,
|
|
|
|
private Timer
|
|
|
|
private Timer,
|
|
|
|
private Button::Listener
|
|
|
|
{
|
|
|
|
OverlayComp (OnlineUnlockForm& f) : Thread (String()), form (f)
|
|
|
|
OverlayComp (OnlineUnlockForm& f, bool hasCancelButton = false)
|
|
|
|
: Thread (String()), form (f)
|
|
|
|
{
|
|
|
|
result.succeeded = false;
|
|
|
|
email = form.emailBox.getText();
|
|
|
|
password = form.passwordBox.getText();
|
|
|
|
addAndMakeVisible (spinner);
|
|
|
|
|
|
|
|
if (hasCancelButton)
|
|
|
|
{
|
|
|
|
addAndMakeVisible (cancelButton = new TextButton (TRANS ("Cancel")));
|
|
|
|
cancelButton->addListener (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
startThread (4);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -73,6 +81,9 @@ struct OnlineUnlockForm::OverlayComp : public Component, |
|
|
|
{
|
|
|
|
const int spinnerSize = 40;
|
|
|
|
spinner.setBounds ((getWidth() - spinnerSize) / 2, proportionOfHeight (0.6f), spinnerSize, spinnerSize);
|
|
|
|
|
|
|
|
if (cancelButton != nullptr)
|
|
|
|
cancelButton->setBounds (getLocalBounds().removeFromBottom (50).reduced (getWidth() / 4, 5));
|
|
|
|
}
|
|
|
|
|
|
|
|
void run() override
|
|
|
|
@@ -114,11 +125,24 @@ struct OnlineUnlockForm::OverlayComp : public Component, |
|
|
|
f.dismiss();
|
|
|
|
}
|
|
|
|
|
|
|
|
void buttonClicked (Button* button) override
|
|
|
|
{
|
|
|
|
if (button == cancelButton)
|
|
|
|
{
|
|
|
|
spinner.setVisible (false);
|
|
|
|
stopTimer();
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OnlineUnlockForm& form;
|
|
|
|
Spinner spinner;
|
|
|
|
OnlineUnlockStatus::UnlockResult result;
|
|
|
|
String email, password;
|
|
|
|
|
|
|
|
ScopedPointer<TextButton> cancelButton;
|
|
|
|
|
|
|
|
JUCE_LEAK_DETECTOR (OnlineUnlockForm::OverlayComp)
|
|
|
|
};
|
|
|
|
|
|
|
|
@@ -133,12 +157,14 @@ static juce_wchar getDefaultPasswordChar() noexcept |
|
|
|
|
|
|
|
OnlineUnlockForm::OnlineUnlockForm (OnlineUnlockStatus& s,
|
|
|
|
const String& userInstructions,
|
|
|
|
bool hasCancelButton)
|
|
|
|
bool hasCancelButton,
|
|
|
|
bool overlayHasCancelButton)
|
|
|
|
: message (String(), userInstructions),
|
|
|
|
passwordBox (String(), getDefaultPasswordChar()),
|
|
|
|
registerButton (TRANS("Register")),
|
|
|
|
cancelButton (TRANS ("Cancel")),
|
|
|
|
status (s)
|
|
|
|
status (s),
|
|
|
|
showOverlayCancelButton (overlayHasCancelButton)
|
|
|
|
{
|
|
|
|
// Please supply a message to tell your users what to do!
|
|
|
|
jassert (userInstructions.isNotEmpty());
|
|
|
|
@@ -276,7 +302,7 @@ void OnlineUnlockForm::attemptRegistration() |
|
|
|
|
|
|
|
status.setUserEmail (emailBox.getText());
|
|
|
|
|
|
|
|
addAndMakeVisible (unlockingOverlay = new OverlayComp (*this));
|
|
|
|
addAndMakeVisible (unlockingOverlay = new OverlayComp (*this, showOverlayCancelButton));
|
|
|
|
resized();
|
|
|
|
unlockingOverlay->enterModalState();
|
|
|
|
}
|
|
|
|
|