diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp index 347f9bc661..50aa63df6d 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp @@ -298,7 +298,7 @@ const char* brushed_aluminium_png = (const char*) temp_9aa09877; static const unsigned char temp_b8a2e640[] = "\r\n" "\r\n" -"\r\n" +"; 13.0 Regular\">\r\n" " \r\n" " \r\n" " \r\n" @@ -899,7 +899,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0x950fd7dd: case 0xa6cfe0e2: numBytes = 14724; return brushed_aluminium_png; case 0x42b71ae6: - case 0xfbf631c1: numBytes = 1045; return dark_scheme_xml; + case 0xfbf631c1: numBytes = 1052; return dark_scheme_xml; case 0x27c5a93a: case 0xb6575890: numBytes = 1008; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.h b/extras/Introjucer/JuceLibraryCode/BinaryData.h index 70e8dbea55..61b40c86eb 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.h +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.h @@ -14,7 +14,7 @@ namespace BinaryData const int brushed_aluminium_pngSize = 14724; extern const char* dark_scheme_xml; - const int dark_scheme_xmlSize = 1045; + const int dark_scheme_xmlSize = 1052; extern const char* jucer_AudioPluginEditorTemplate_cpp; const int jucer_AudioPluginEditorTemplate_cppSize = 1008; diff --git a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp index 6ab35f91e8..d1a3ce0ae5 100644 --- a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp +++ b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp @@ -289,50 +289,6 @@ Colour AppearanceSettings::getScrollbarColourForBackground (const Colour& backgr //============================================================================== struct AppearanceEditor { - class Window : public DialogWindow - { - public: - Window() : DialogWindow ("Appearance Settings", Colours::darkgrey, true, true) - { - setUsingNativeTitleBar (true); - - if (getAppSettings().monospacedFontNames.size() == 0) - setContentOwned (new FontScanPanel(), false); - else - setContentOwned (new EditorPanel(), false); - - setResizable (true, true); - - const int width = 350; - setResizeLimits (width, 200, width, 1000); - - String windowState (getAppProperties().getValue (getWindowPosName())); - - if (windowState.isNotEmpty()) - restoreWindowStateFromString (windowState); - else - centreAroundComponent (Component::getCurrentlyFocusedComponent(), width, 500); - - setVisible (true); - } - - ~Window() - { - getAppProperties().setValue (getWindowPosName(), getWindowStateAsString()); - } - - void closeButtonPressed() - { - JucerApplication::getApp().appearanceEditorWindow = nullptr; - } - - private: - static const char* getWindowPosName() { return "colourSchemeEditorPos"; } - - JUCE_DECLARE_NON_COPYABLE (Window); - }; - - //============================================================================== class FontScanPanel : public Component, private Timer { @@ -362,7 +318,7 @@ struct AppearanceEditor if (fontsToScan.size() == 0) { getAppSettings().monospacedFontNames = fontsFound; - Window* w = findParentComponentOfClass(); + DialogWindow* w = findParentComponentOfClass(); if (w != nullptr) w->setContentOwned (new EditorPanel(), false); @@ -552,9 +508,27 @@ struct AppearanceEditor }; }; -Component* AppearanceSettings::createEditorWindow() +void AppearanceSettings::showEditorWindow (ScopedPointer& ownerPointer) { - return new AppearanceEditor::Window(); + if (ownerPointer != nullptr) + { + ownerPointer->toFront (true); + } + else + { + Component* content; + if (getAppSettings().monospacedFontNames.size() == 0) + content = new AppearanceEditor::FontScanPanel(); + else + content = new AppearanceEditor::EditorPanel(); + + const int width = 350; + new FloatingToolWindow ("Appearance Settings", + "colourSchemeEditorPos", + content, ownerPointer, + width, 500, + width, 200, width, 1000); + } } //============================================================================== diff --git a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h index ad0d7cc7ed..d9d5e2417a 100644 --- a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h +++ b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h @@ -56,7 +56,7 @@ public: static Font getDefaultCodeFont(); static Colour getScrollbarColourForBackground (const Colour& background); - static Component* createEditorWindow(); + static void showEditorWindow (ScopedPointer& ownerPointer); static const char* getSchemeFileSuffix() { return ".scheme"; } static const char* getSchemeFileWildCard() { return "*.scheme"; } diff --git a/extras/Introjucer/Source/Application/jucer_Application.h b/extras/Introjucer/Source/Application/jucer_Application.h index f9328a3dd8..126dd53fc4 100644 --- a/extras/Introjucer/Source/Application/jucer_Application.h +++ b/extras/Introjucer/Source/Application/jucer_Application.h @@ -97,6 +97,7 @@ public: void shutdown() { appearanceEditorWindow = nullptr; + utf8Window = nullptr; #if JUCE_MAC MenuBarModel::setMacMainMenu (nullptr); @@ -390,8 +391,8 @@ public: case CommandIDs::showPrefs: showPrefsPanel(); break; case CommandIDs::saveAll: openDocumentManager.saveAll(); break; case CommandIDs::closeAllDocuments: closeAllDocuments (true); break; - case CommandIDs::showUTF8Tool: showUTF8ToolWindow(); break; - case CommandIDs::showAppearanceSettings: showAppearanceEditorWindow(); break; + case CommandIDs::showUTF8Tool: showUTF8ToolWindow (utf8Window); break; + case CommandIDs::showAppearanceSettings: AppearanceSettings::showEditorWindow (appearanceEditorWindow); break; case CommandIDs::updateModules: runModuleUpdate (String::empty); break; default: return JUCEApplication::perform (info); } @@ -462,14 +463,6 @@ public: return ModuleList::isJuceOrModulesFolder (list.getModulesFolder()); } - void showAppearanceEditorWindow() - { - if (appearanceEditorWindow == nullptr) - appearanceEditorWindow = AppearanceSettings::createEditorWindow(); - - appearanceEditorWindow->toFront (true); - } - //============================================================================== virtual void doExtraInitialisation() {} virtual void addExtraConfigItems (Project&, TreeViewItem&) {} @@ -490,7 +483,7 @@ public: MainWindowList mainWindowList; OpenDocumentManager openDocumentManager; - ScopedPointer appearanceEditorWindow; + ScopedPointer appearanceEditorWindow, utf8Window; private: class AsyncQuitRetrier : private Timer diff --git a/extras/Introjucer/Source/BinaryData/dark_scheme.xml b/extras/Introjucer/Source/BinaryData/dark_scheme.xml index 9db2982280..f858ef7f15 100644 --- a/extras/Introjucer/Source/BinaryData/dark_scheme.xml +++ b/extras/Introjucer/Source/BinaryData/dark_scheme.xml @@ -1,6 +1,6 @@ - + diff --git a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp index 63838d2ae1..cf6d5ff088 100644 --- a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp +++ b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp @@ -373,20 +373,22 @@ public: : desc (String::empty, "Type any string into the box, and it'll be shown below as a portable UTF-8 literal, ready to cut-and-paste into your source-code...") { - setSize (400, 300); - - desc.setBounds ("8, 8, parent.width - 8, 55"); desc.setJustificationType (Justification::centred); + desc.setColour (Label::textColourId, Colours::white); addAndMakeVisible (&desc); + const Colour bkgd (Colours::white.withAlpha (0.6f)); + userText.setMultiLine (true, true); - userText.setBounds ("8, 60, parent.width - 8, parent.height / 2 - 4"); + userText.setReturnKeyStartsNewLine (true); + userText.setColour (TextEditor::backgroundColourId, bkgd); addAndMakeVisible (&userText); userText.addListener (this); resultText.setMultiLine (true, true); + resultText.setColour (TextEditor::backgroundColourId, bkgd); resultText.setReadOnly (true); - resultText.setBounds ("8, parent.height / 2 + 4, parent.width - 8, parent.height - 8"); + resultText.setSelectAllWhenFocused (true); addAndMakeVisible (&resultText); userText.setText (getLastText()); @@ -407,6 +409,13 @@ public: getLastText() = userText.getText(); resultText.setText (CodeHelpers::stringLiteral (getLastText()), false); } + + void resized() + { + desc.setBounds (8, 8, getWidth() - 16, 44); + userText.setBounds (desc.getX(), desc.getBottom() + 8, getWidth() - 16, getHeight() / 2 - desc.getBottom() - 8); + resultText.setBounds (desc.getX(), userText.getBottom() + 4, getWidth() - 16, getHeight() - userText.getBottom() - 12); + } private: Label desc; @@ -419,11 +428,20 @@ private: } }; -void showUTF8ToolWindow() +void showUTF8ToolWindow (ScopedPointer& ownerPointer) { - UTF8Component comp; - DialogWindow::showModalDialog ("UTF-8 String Literal Converter", &comp, - nullptr, Colours::white, true, true); + if (ownerPointer != nullptr) + { + ownerPointer->toFront (true); + } + else + { + new FloatingToolWindow ("UTF-8 String Literal Converter", + "utf8WindowPos", + new UTF8Component(), ownerPointer, + 400, 300, + 300, 300, 1000, 1000); + } } bool cancelAnyModalComponents() diff --git a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h index 7656c914bf..98877522e5 100644 --- a/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h +++ b/extras/Introjucer/Source/Utility/jucer_MiscUtilities.h @@ -49,7 +49,7 @@ void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scr void drawComponentPlaceholder (Graphics& g, int w, int h, const String& text); void drawTexturedBackground (Graphics& g); -void showUTF8ToolWindow(); +void showUTF8ToolWindow (ScopedPointer& ownerPointer); bool cancelAnyModalComponents(); bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&); @@ -172,6 +172,54 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSourceFilter); }; +//============================================================================== +class FloatingToolWindow : public DialogWindow +{ +public: + FloatingToolWindow (const String& title, + const String& windowPosPropertyName, + Component* content, + ScopedPointer& ownerPointer, + int defaultW, int defaultH, + int minW, int minH, + int maxW, int maxH) + : DialogWindow (title, Colours::darkgrey, true, true), + windowPosProperty (windowPosPropertyName), + owner (ownerPointer) + { + setUsingNativeTitleBar (true); + setResizable (true, true); + setResizeLimits (minW, minH, maxW, maxH); + setContentOwned (content, false); + + const String windowState (getAppProperties().getValue (windowPosProperty)); + + if (windowState.isNotEmpty()) + restoreWindowStateFromString (windowState); + else + centreAroundComponent (Component::getCurrentlyFocusedComponent(), defaultW, defaultH); + + setVisible (true); + owner = this; + } + + ~FloatingToolWindow() + { + getAppProperties().setValue (windowPosProperty, getWindowStateAsString()); + } + + void closeButtonPressed() + { + owner = nullptr; + } + +private: + String windowPosProperty; + ScopedPointer& owner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FloatingToolWindow); +}; + //============================================================================== class PopupColourSelector : public Component, public ChangeListener, diff --git a/modules/juce_graphics/native/juce_linux_Fonts.cpp b/modules/juce_graphics/native/juce_linux_Fonts.cpp index 7fc2dc9ecb..5a7ceda903 100644 --- a/modules/juce_graphics/native/juce_linux_Fonts.cpp +++ b/modules/juce_graphics/native/juce_linux_Fonts.cpp @@ -533,8 +533,8 @@ private: StringArray allFonts; FTTypefaceList::getInstance()->getMonospacedNames (allFonts); - const char* targets[] = { "Bitstream Vera Sans Mono", "Courier", "Sans Mono", - "Liberation Mono", "DejaVu Mono", "Mono", 0 }; + const char* targets[] = { "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Sans Mono", + "Liberation Mono", "Courier", "DejaVu Mono", "Mono", 0 }; return pickBestFont (allFonts, targets); } diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 3a95b2795b..47ce92e896 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1109,11 +1109,6 @@ void TextEditor::setSelectAllWhenFocused (const bool b) } //============================================================================== -const Font& TextEditor::getFont() const -{ - return currentFont; -} - void TextEditor::setFont (const Font& newFont) { currentFont = newFont; diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 429431a1c5..0603a04b93 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -35,7 +35,7 @@ //============================================================================== /** - A component containing text that can be edited. + An editable text box. A TextEditor can either be in single- or multi-line mode, and supports mixed fonts and colours. @@ -62,8 +62,7 @@ public: juce_wchar passwordCharacter = 0); /** Destructor. */ - virtual ~TextEditor(); - + ~TextEditor(); //============================================================================== /** Puts the editor into either multi- or single-line mode. @@ -79,8 +78,7 @@ public: void setMultiLine (bool shouldBeMultiLine, bool shouldWordWrap = true); - /** Returns true if the editor is in multi-line mode. - */ + /** Returns true if the editor is in multi-line mode. */ bool isMultiLine() const; //============================================================================== @@ -94,7 +92,6 @@ public: void setReturnKeyStartsNewLine (bool shouldStartNewLine); /** Returns the value set by setReturnKeyStartsNewLine(). - See setReturnKeyStartsNewLine() for more info. */ bool getReturnKeyStartsNewLine() const { return returnKeyStartsNewLine; } @@ -124,8 +121,7 @@ public: */ void setReadOnly (bool shouldBeReadOnly); - /** Returns true if the editor is in read-only mode. - */ + /** Returns true if the editor is in read-only mode. */ bool isReadOnly() const; //============================================================================== @@ -138,7 +134,7 @@ public: /** Returns true if the caret is enabled. @see setCaretVisible */ - bool isCaretVisible() const { return caret != nullptr; } + bool isCaretVisible() const noexcept { return caret != nullptr; } //============================================================================== /** Enables/disables a vertical scrollbar. @@ -154,7 +150,7 @@ public: /** Returns true if scrollbars are enabled. @see setScrollbarsShown */ - bool areScrollbarsShown() const { return scrollbarVisible; } + bool areScrollbarsShown() const noexcept { return scrollbarVisible; } /** Changes the password character used to disguise the text. @@ -171,7 +167,7 @@ public: /** Returns the current password character. @see setPasswordCharacter */ - juce_wchar getPasswordCharacter() const { return passwordCharacter; } + juce_wchar getPasswordCharacter() const noexcept { return passwordCharacter; } //============================================================================== @@ -187,11 +183,10 @@ public: /** Returns true if the right-click menu is enabled. @see setPopupMenuEnabled */ - bool isPopupMenuEnabled() const { return popupMenuEnabled; } + bool isPopupMenuEnabled() const noexcept { return popupMenuEnabled; } - /** Returns true if a popup-menu is currently being displayed. - */ - bool isPopupMenuCurrentlyActive() const { return menuActive; } + /** Returns true if a popup-menu is currently being displayed. */ + bool isPopupMenuCurrentlyActive() const noexcept { return menuActive; } //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the editor. @@ -239,18 +234,15 @@ public: void setFont (const Font& newFont); /** Applies a font to all the text in the editor. - This will also set the current font to use for any new text that's added. - @see setFont */ void applyFontToAllText (const Font& newFont); /** Returns the font that's currently being used for new text. - @see setFont */ - const Font& getFont() const; + const Font& getFont() const noexcept { return currentFont; } //============================================================================== /** If set to true, focusing on the editor will highlight all its text. @@ -260,7 +252,7 @@ public: This is useful for boxes where you expect the user to re-enter all the text when they focus on the component, rather than editing what's already there. */ - void setSelectAllWhenFocused (bool b); + void setSelectAllWhenFocused (bool shouldSelectAll); /** Sets limits on the characters that can be entered. @@ -282,7 +274,6 @@ public: //============================================================================== /** Changes the size of the scrollbars that are used. - Handy if you need smaller scrollbars for a small text box. */ void setScrollBarThickness (int newThicknessPixels); @@ -313,13 +304,11 @@ public: }; /** Registers a listener to be told when things happen to the text. - @see removeListener */ void addListener (Listener* newListener); /** Deregisters a listener. - @see addListener */ void removeListener (Listener* listenerToRemove); @@ -332,8 +321,7 @@ public: String getTextInRange (const Range& textRange) const; /** Returns true if there are no characters in the editor. - - This is more efficient than calling getText().isEmpty(). + This is far more efficient than calling getText().isEmpty(). */ bool isEmpty() const; @@ -355,8 +343,8 @@ public: /** Returns a Value object that can be used to get or set the text. Bear in mind that this operate quite slowly if your text box contains large - amounts of text, as it needs to dynamically build the string that's involved. It's - best used for small text boxes. + amounts of text, as it needs to dynamically build the string that's involved. + It's best used for small text boxes. */ Value& getTextValue(); @@ -440,7 +428,6 @@ public: String getHighlightedText() const; /** Finds the index of the character at a given position. - The co-ordinates are relative to the component's top-left. */ int getTextIndexAt (int x, int y); @@ -467,19 +454,16 @@ public: int getTextHeight() const; /** Changes the size of the gap at the top and left-edge of the editor. - By default there's a gap of 4 pixels. */ void setIndents (int newLeftIndent, int newTopIndent); /** Changes the size of border left around the edge of the component. - @see getBorder */ void setBorder (const BorderSize& border); /** Returns the size of border around the edge of the component. - @see setBorder */ BorderSize getBorder() const; @@ -492,41 +476,6 @@ public: void setScrollToShowCursor (bool shouldScrollToShowCaret); //============================================================================== - /** @internal */ - void paint (Graphics& g); - /** @internal */ - void paintOverChildren (Graphics& g); - /** @internal */ - void mouseDown (const MouseEvent& e); - /** @internal */ - void mouseUp (const MouseEvent& e); - /** @internal */ - void mouseDrag (const MouseEvent& e); - /** @internal */ - void mouseDoubleClick (const MouseEvent& e); - /** @internal */ - void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); - /** @internal */ - bool keyPressed (const KeyPress& key); - /** @internal */ - bool keyStateChanged (bool isKeyDown); - /** @internal */ - void focusGained (FocusChangeType cause); - /** @internal */ - void focusLost (FocusChangeType cause); - /** @internal */ - void resized(); - /** @internal */ - void enablementChanged(); - /** @internal */ - void colourChanged(); - /** @internal */ - void lookAndFeelChanged(); - /** @internal */ - bool isTextInputActive() const; - /** @internal */ - void setTemporaryUnderlining (const Array >&); - bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting); bool moveCaretRight (bool moveInWholeWordSteps, bool selecting); bool moveCaretUp (bool selecting); @@ -594,6 +543,41 @@ public: void refreshFromValueTree (const ValueTree&, ComponentBuilder&); + //============================================================================== + /** @internal */ + void paint (Graphics& g); + /** @internal */ + void paintOverChildren (Graphics& g); + /** @internal */ + void mouseDown (const MouseEvent& e); + /** @internal */ + void mouseUp (const MouseEvent& e); + /** @internal */ + void mouseDrag (const MouseEvent& e); + /** @internal */ + void mouseDoubleClick (const MouseEvent& e); + /** @internal */ + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); + /** @internal */ + bool keyPressed (const KeyPress& key); + /** @internal */ + bool keyStateChanged (bool isKeyDown); + /** @internal */ + void focusGained (FocusChangeType); + /** @internal */ + void focusLost (FocusChangeType); + /** @internal */ + void resized(); + /** @internal */ + void enablementChanged(); + /** @internal */ + void colourChanged(); + /** @internal */ + void lookAndFeelChanged(); + /** @internal */ + bool isTextInputActive() const; + /** @internal */ + void setTemporaryUnderlining (const Array >&); protected: //==============================================================================