Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include "../JuceLibraryCode/JuceHeader.h"
  2. #include "InputForm.h"
  3.  
  4. InputForm::InputForm()
  5. {
  6. addAndMakeVisible(m_usernameLabel);
  7. m_usernameLabel.setText("Username:", dontSendNotification);
  8. m_usernameLabel.attachToComponent(&m_usernameInput, true);
  9. m_usernameLabel.setColour(Label::textColourId, Colours::orange);
  10. m_usernameLabel.setJustificationType(Justification::right);
  11.  
  12. addAndMakeVisible(m_passwordLabel);
  13. m_passwordLabel.setText("Password:", dontSendNotification);
  14. m_passwordLabel.attachToComponent(&m_passwordInput, true);
  15. m_passwordLabel.setColour(Label::textColourId, Colours::orange);
  16. m_passwordLabel.setJustificationType(Justification::right);
  17.  
  18. addAndMakeVisible(m_usernameInput);
  19. m_usernameInput.setEditable(true);
  20. m_usernameInput.setColour(Label::backgroundColourId, Colours::darkblue);
  21. m_usernameInput.setJustificationType(Justification::left);
  22.  
  23. addAndMakeVisible(m_passwordInput);
  24. m_passwordInput.setEditable(true);
  25. m_passwordInput.setColour(Label::backgroundColourId, Colours::darkblue);
  26. m_passwordInput.setJustificationType(Justification::left);
  27. }
  28.  
  29. InputForm::~InputForm()
  30. {
  31. }
  32.  
  33. void InputForm::paint (Graphics& g)
  34. {
  35.  
  36. g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); // clear the background
  37.  
  38. g.setColour (Colours::grey);
  39. g.drawRect (getLocalBounds(), 1);
  40.  
  41. }
  42.  
  43. void InputForm::resized()
  44. {
  45. auto marginX = 10;
  46. auto marginY = 10;
  47. auto localBounds = getLocalBounds();
  48.  
  49. auto usernameRect = localBounds.removeFromTop(50);
  50. m_usernameLabel.setBounds(usernameRect.removeFromLeft(usernameRect.getWidth() / 5).reduced(marginX, marginY));
  51. m_usernameInput.setBounds(usernameRect.reduced(marginX, marginY));
  52.  
  53. auto passwordRect = localBounds.removeFromTop(50);
  54. m_passwordLabel.setBounds(passwordRect.removeFromLeft(passwordRect.getWidth() / 5).reduced(marginX));
  55. m_passwordInput.setBounds(passwordRect.reduced(marginX, marginY));
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement