Browse Source

Update juce again

tags/1.9.7
falkTX 9 years ago
parent
commit
f76a715f4b
5 changed files with 66 additions and 51 deletions
  1. +5
    -8
      source/modules/juce_core/native/juce_mac_Files.mm
  2. +11
    -0
      source/modules/juce_graphics/native/juce_mac_Fonts.mm
  3. +10
    -5
      source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp
  4. +21
    -20
      source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp
  5. +19
    -18
      source/modules/juce_gui_basics/widgets/juce_TextEditor.h

+ 5
- 8
source/modules/juce_core/native/juce_mac_Files.mm View File

@@ -308,14 +308,11 @@ bool File::moveToTrash() const
#else #else
JUCE_AUTORELEASEPOOL JUCE_AUTORELEASEPOOL
{ {
NSString* p = juceStringToNS (getFullPathName());
return [[NSWorkspace sharedWorkspace]
performFileOperation: NSWorkspaceRecycleOperation
source: [p stringByDeletingLastPathComponent]
destination: nsEmptyString()
files: [NSArray arrayWithObject: [p lastPathComponent]]
tag: nil ];
NSURL* url = [NSURL fileURLWithPath: juceStringToNS (getFullPathName())];
[[NSWorkspace sharedWorkspace] recycleURLs: [NSArray arrayWithObject: url]
completionHandler: nil];
return true;
} }
#endif #endif
} }


+ 11
- 0
source/modules/juce_graphics/native/juce_mac_Fonts.mm View File

@@ -272,16 +272,27 @@ namespace CoreTextTypeLayout
} }
// Paragraph Attributes // Paragraph Attributes
#if defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
CTTextAlignment ctTextAlignment = kCTTextAlignmentLeft;
#else
CTTextAlignment ctTextAlignment = kCTLeftTextAlignment; CTTextAlignment ctTextAlignment = kCTLeftTextAlignment;
#endif
CTLineBreakMode ctLineBreakMode = kCTLineBreakByWordWrapping; CTLineBreakMode ctLineBreakMode = kCTLineBreakByWordWrapping;
const CGFloat ctLineSpacing = text.getLineSpacing(); const CGFloat ctLineSpacing = text.getLineSpacing();
switch (text.getJustification().getOnlyHorizontalFlags()) switch (text.getJustification().getOnlyHorizontalFlags())
{ {
case Justification::left: break; case Justification::left: break;
#if defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
case Justification::right: ctTextAlignment = kCTTextAlignmentRight; break;
case Justification::horizontallyCentred: ctTextAlignment = kCTTextAlignmentCenter; break;
case Justification::horizontallyJustified: ctTextAlignment = kCTTextAlignmentJustified; break;
#else
case Justification::right: ctTextAlignment = kCTRightTextAlignment; break; case Justification::right: ctTextAlignment = kCTRightTextAlignment; break;
case Justification::horizontallyCentred: ctTextAlignment = kCTCenterTextAlignment; break; case Justification::horizontallyCentred: ctTextAlignment = kCTCenterTextAlignment; break;
case Justification::horizontallyJustified: ctTextAlignment = kCTJustifiedTextAlignment; break; case Justification::horizontallyJustified: ctTextAlignment = kCTJustifiedTextAlignment; break;
#endif
default: jassertfalse; break; // Illegal justification flags default: jassertfalse; break; // Illegal justification flags
} }


+ 10
- 5
source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp View File

@@ -2965,9 +2965,13 @@ private:
CWBorderPixel | CWColormap | CWBackPixmap | CWEventMask | CWOverrideRedirect, CWBorderPixel | CWColormap | CWBackPixmap | CWEventMask | CWOverrideRedirect,
&swa); &swa);
unsigned int buttonMask = EnterWindowMask | LeaveWindowMask | PointerMotionMask;
if ((styleFlags & windowIgnoresMouseClicks) == 0)
buttonMask |= ButtonPressMask | ButtonReleaseMask;
XGrabButton (display, AnyButton, AnyModifier, windowH, False, XGrabButton (display, AnyButton, AnyModifier, windowH, False,
ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, None, None);
buttonMask, GrabModeAsync, GrabModeAsync, None, None);
// Set the window context to identify the window handle object // Set the window context to identify the window handle object
if (XSaveContext (display, (XID) windowH, windowHandleXContext, (XPointer) this)) if (XSaveContext (display, (XID) windowH, windowHandleXContext, (XPointer) this))
@@ -3037,11 +3041,12 @@ private:
{} {}
} }
static int getAllEventsMask() noexcept
int getAllEventsMask() const noexcept
{ {
return NoEventMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask
return NoEventMask | KeyPressMask | KeyReleaseMask
| EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask
| ExposureMask | StructureNotifyMask | FocusChangeMask;
| ExposureMask | StructureNotifyMask | FocusChangeMask
| ((styleFlags & windowIgnoresMouseClicks) != 0 ? (ButtonPressMask | ButtonReleaseMask) : 0);
} }
template <typename EventType> template <typename EventType>


+ 21
- 20
source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp View File

@@ -49,7 +49,7 @@ struct TextAtom
return atomText.substring (0, numChars); return atomText.substring (0, numChars);
if (isNewLine()) if (isNewLine())
return String::empty;
return String();
return String::repeatedString (String::charToString (passwordCharacter), numChars); return String::repeatedString (String::charToString (passwordCharacter), numChars);
} }
@@ -111,7 +111,7 @@ public:
UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar)
{ {
UniformTextSection* const section2 = new UniformTextSection (String::empty, font, colour, passwordChar);
UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar);
int index = 0; int index = 0;
for (int i = 0; i < atoms.size(); ++i) for (int i = 0; i < atoms.size(); ++i)
@@ -902,6 +902,7 @@ TextEditor::TextEditor (const String& name,
: Component (name), : Component (name),
borderSize (1, 1, 1, 3), borderSize (1, 1, 1, 3),
readOnly (false), readOnly (false),
caretVisible (true),
multiline (false), multiline (false),
wordWrap (false), wordWrap (false),
returnKeyStartsNewLine (false), returnKeyStartsNewLine (false),
@@ -933,7 +934,7 @@ TextEditor::TextEditor (const String& name,
viewport->setScrollBarsShown (false, false); viewport->setScrollBarsShown (false, false);
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
setCaretVisible (true);
recreateCaret();
} }
TextEditor::~TextEditor() TextEditor::~TextEditor()
@@ -1020,7 +1021,7 @@ void TextEditor::setReadOnly (const bool shouldBeReadOnly)
} }
} }
bool TextEditor::isReadOnly() const
bool TextEditor::isReadOnly() const noexcept
{ {
return readOnly || ! isEnabled(); return readOnly || ! isEnabled();
} }
@@ -1084,20 +1085,27 @@ void TextEditor::colourChanged()
void TextEditor::lookAndFeelChanged() void TextEditor::lookAndFeelChanged()
{ {
recreateCaret(); recreateCaret();
repaint();
} }
void TextEditor::recreateCaret()
void TextEditor::enablementChanged()
{ {
if (isCaretVisible())
recreateCaret();
repaint();
}
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible)
{
if (caretVisible != shouldCaretBeVisible)
{ {
setCaretVisible (false);
setCaretVisible (true);
caretVisible = shouldCaretBeVisible;
recreateCaret();
} }
} }
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible)
void TextEditor::recreateCaret()
{ {
if (shouldCaretBeVisible && ! isReadOnly())
if (isCaretVisible())
{ {
if (caret == nullptr) if (caret == nullptr)
{ {
@@ -1139,8 +1147,7 @@ void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership)
inputFilter.set (newFilter, takeOwnership); inputFilter.set (newFilter, takeOwnership);
} }
void TextEditor::setInputRestrictions (const int maxLen,
const String& chars)
void TextEditor::setInputRestrictions (const int maxLen, const String& chars)
{ {
setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true);
} }
@@ -1570,7 +1577,7 @@ void TextEditor::cut()
if (! isReadOnly()) if (! isReadOnly())
{ {
moveCaret (selection.getEnd()); moveCaret (selection.getEnd());
insertTextAtCaret (String::empty);
insertTextAtCaret (String());
} }
} }
@@ -2131,12 +2138,6 @@ void TextEditor::handleCommandMessage (const int commandId)
} }
} }
void TextEditor::enablementChanged()
{
recreateCaret();
repaint();
}
void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections) void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections)
{ {
underlinedSections = newUnderlinedSections; underlinedSections = newUnderlinedSections;
@@ -2361,7 +2362,7 @@ String TextEditor::getText() const
String TextEditor::getTextInRange (const Range<int>& range) const String TextEditor::getTextInRange (const Range<int>& range) const
{ {
if (range.isEmpty()) if (range.isEmpty())
return String::empty;
return String();
MemoryOutputStream mo; MemoryOutputStream mo;
mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength()));


+ 19
- 18
source/modules/juce_gui_basics/widgets/juce_TextEditor.h View File

@@ -51,7 +51,7 @@ public:
for a black splodge (not all fonts include this, though), or 0x2022, for a black splodge (not all fonts include this, though), or 0x2022,
which is a bullet (probably the best choice for linux). which is a bullet (probably the best choice for linux).
*/ */
explicit TextEditor (const String& componentName = String::empty,
explicit TextEditor (const String& componentName = String(),
juce_wchar passwordCharacter = 0); juce_wchar passwordCharacter = 0);
/** Destructor. */ /** Destructor. */
@@ -123,7 +123,7 @@ public:
void setReadOnly (bool shouldBeReadOnly); 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;
bool isReadOnly() const noexcept;
//============================================================================== //==============================================================================
/** Makes the caret visible or invisible. /** Makes the caret visible or invisible.
@@ -135,7 +135,7 @@ public:
/** Returns true if the caret is enabled. /** Returns true if the caret is enabled.
@see setCaretVisible @see setCaretVisible
*/ */
bool isCaretVisible() const noexcept { return caret != nullptr; }
bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); }
//============================================================================== //==============================================================================
/** Enables/disables a vertical scrollbar. /** Enables/disables a vertical scrollbar.
@@ -347,7 +347,7 @@ public:
this string, otherwise it will be inserted. this string, otherwise it will be inserted.
To delete a section of text, you can use setHighlightedRegion() to To delete a section of text, you can use setHighlightedRegion() to
highlight it, and call insertTextAtCursor (String::empty).
highlight it, and call insertTextAtCaret (String()).
@see setCaretPosition, getCaretPosition, setHighlightedRegion @see setCaretPosition, getCaretPosition, setHighlightedRegion
*/ */
@@ -583,7 +583,7 @@ public:
this string are allowed to be entered into the editor. this string are allowed to be entered into the editor.
*/ */
void setInputRestrictions (int maxTextLength, void setInputRestrictions (int maxTextLength,
const String& allowedCharacters = String::empty);
const String& allowedCharacters = String());
void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; }
@@ -670,19 +670,20 @@ private:
TextHolderComponent* textHolder; TextHolderComponent* textHolder;
BorderSize<int> borderSize; BorderSize<int> borderSize;
bool readOnly : 1;
bool multiline : 1;
bool wordWrap : 1;
bool returnKeyStartsNewLine : 1;
bool popupMenuEnabled : 1;
bool selectAllTextWhenFocused : 1;
bool scrollbarVisible : 1;
bool wasFocused : 1;
bool keepCaretOnScreen : 1;
bool tabKeyUsed : 1;
bool menuActive : 1;
bool valueTextNeedsUpdating : 1;
bool consumeEscAndReturnKeys : 1;
bool readOnly;
bool caretVisible;
bool multiline;
bool wordWrap;
bool returnKeyStartsNewLine;
bool popupMenuEnabled;
bool selectAllTextWhenFocused;
bool scrollbarVisible;
bool wasFocused;
bool keepCaretOnScreen;
bool tabKeyUsed;
bool menuActive;
bool valueTextNeedsUpdating;
bool consumeEscAndReturnKeys;
UndoManager undoManager; UndoManager undoManager;
ScopedPointer<CaretComponent> caret; ScopedPointer<CaretComponent> caret;


Loading…
Cancel
Save