Browse Source

Misc minor tidying up.

tags/2021-05-28
jules 13 years ago
parent
commit
9fde239d9c
13 changed files with 172 additions and 219 deletions
  1. +1
    -2
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h
  2. +6
    -6
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h
  3. +1
    -2
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h
  4. +5
    -5
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h
  5. +8
    -8
      extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h
  6. +4
    -4
      extras/Introjucer/Source/Project/jucer_GroupInformationComponent.h
  7. +15
    -15
      extras/Introjucer/Source/Project/jucer_ModulesPanel.h
  8. +1
    -1
      extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h
  9. +8
    -8
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  10. +4
    -4
      extras/Introjucer/Source/Utility/jucer_RelativePath.h
  11. +32
    -66
      modules/juce_core/time/juce_RelativeTime.cpp
  12. +46
    -47
      modules/juce_graphics/native/juce_RenderingHelpers.h
  13. +41
    -51
      modules/juce_gui_basics/widgets/juce_TextEditor.cpp

+ 1
- 2
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h View File

@@ -46,8 +46,7 @@ public:
} }
//============================================================================== //==============================================================================
AndroidProjectExporter (Project& project_, const ValueTree& settings_)
: ProjectExporter (project_, settings_)
AndroidProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
{ {
name = getNameAndroid(); name = getNameAndroid();


+ 6
- 6
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h View File

@@ -33,8 +33,8 @@
class MSVCProjectExporterBase : public ProjectExporter class MSVCProjectExporterBase : public ProjectExporter
{ {
public: public:
MSVCProjectExporterBase (Project& project_, const ValueTree& settings_, const char* const folderName)
: ProjectExporter (project_, settings_)
MSVCProjectExporterBase (Project& p, const ValueTree& t, const char* const folderName)
: ProjectExporter (p, t)
{ {
if (getTargetLocationString().isEmpty()) if (getTargetLocationString().isEmpty())
getTargetLocationValue() = getDefaultBuildsRootFolder() + folderName; getTargetLocationValue() = getDefaultBuildsRootFolder() + folderName;
@@ -863,8 +863,8 @@ protected:
class MSVCProjectExporterVC2005 : public MSVCProjectExporterVC2008 class MSVCProjectExporterVC2005 : public MSVCProjectExporterVC2008
{ {
public: public:
MSVCProjectExporterVC2005 (Project& project_, const ValueTree& settings_)
: MSVCProjectExporterVC2008 (project_, settings_, "VisualStudio2005")
MSVCProjectExporterVC2005 (Project& p, const ValueTree& t)
: MSVCProjectExporterVC2008 (p, t, "VisualStudio2005")
{ {
name = getName(); name = getName();
} }
@@ -892,8 +892,8 @@ protected:
class MSVCProjectExporterVC2010 : public MSVCProjectExporterBase class MSVCProjectExporterVC2010 : public MSVCProjectExporterBase
{ {
public: public:
MSVCProjectExporterVC2010 (Project& project_, const ValueTree& settings_)
: MSVCProjectExporterBase (project_, settings_, "VisualStudio2010")
MSVCProjectExporterVC2010 (Project& p, const ValueTree& t)
: MSVCProjectExporterBase (p, t, "VisualStudio2010")
{ {
name = getName(); name = getName();
} }


+ 1
- 2
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h View File

@@ -47,8 +47,7 @@ public:
//============================================================================== //==============================================================================
MakefileProjectExporter (Project& project_, const ValueTree& settings_)
: ProjectExporter (project_, settings_)
MakefileProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
{ {
name = getNameLinux(); name = getNameLinux();


+ 5
- 5
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h View File

@@ -53,9 +53,9 @@ public:
static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; } static const char* getValueTreeTypeName (bool iOS) { return iOS ? "XCODE_IPHONE" : "XCODE_MAC"; }
//============================================================================== //==============================================================================
XCodeProjectExporter (Project& project_, const ValueTree& settings_, const bool iOS_)
: ProjectExporter (project_, settings_),
iOS (iOS_)
XCodeProjectExporter (Project& p, const ValueTree& t, const bool isIOS)
: ProjectExporter (p, t),
iOS (isIOS)
{ {
name = iOS ? getNameiOS() : getNameMac(); name = iOS ? getNameiOS() : getNameMac();
@@ -176,8 +176,8 @@ protected:
class XcodeBuildConfiguration : public BuildConfiguration class XcodeBuildConfiguration : public BuildConfiguration
{ {
public: public:
XcodeBuildConfiguration (Project& project, const ValueTree& settings, const bool iOS_)
: BuildConfiguration (project, settings), iOS (iOS_)
XcodeBuildConfiguration (Project& p, const ValueTree& t, const bool isIOS)
: BuildConfiguration (p, t), iOS (isIOS)
{ {
if (iOS) if (iOS)
{ {


+ 8
- 8
extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h View File

@@ -35,9 +35,9 @@
class ProjectSaver class ProjectSaver
{ {
public: public:
ProjectSaver (Project& project_, const File& projectFile_)
: project (project_),
projectFile (projectFile_),
ProjectSaver (Project& p, const File& file)
: project (p),
projectFile (file),
generatedCodeFolder (project.getGeneratedCodeFolder()), generatedCodeFolder (project.getGeneratedCodeFolder()),
generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__")) generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__"))
{ {
@@ -49,9 +49,9 @@ public:
struct SaveThread : public ThreadWithProgressWindow struct SaveThread : public ThreadWithProgressWindow
{ {
public: public:
SaveThread (ProjectSaver& saver_)
SaveThread (ProjectSaver& ps)
: ThreadWithProgressWindow ("Saving...", true, false), : ThreadWithProgressWindow ("Saving...", true, false),
saver (saver_), result (Result::ok())
saver (ps), result (Result::ok())
{} {}
void run() void run()
@@ -567,10 +567,10 @@ private:
class ExporterJob : public ThreadPoolJob class ExporterJob : public ThreadPoolJob
{ {
public: public:
ExporterJob (ProjectSaver& owner_, ProjectExporter* exporter_,
const OwnedArray<LibraryModule>& modules_)
ExporterJob (ProjectSaver& ps, ProjectExporter* pe,
const OwnedArray<LibraryModule>& moduleList)
: ThreadPoolJob ("export"), : ThreadPoolJob ("export"),
owner (owner_), exporter (exporter_), modules (modules_)
owner (ps), exporter (pe), modules (moduleList)
{ {
} }


+ 4
- 4
extras/Introjucer/Source/Project/jucer_GroupInformationComponent.h View File

@@ -37,8 +37,8 @@ class GroupInformationComponent : public Component,
{ {
public: public:
//============================================================================== //==============================================================================
GroupInformationComponent (const Project::Item& item_)
: item (item_)
GroupInformationComponent (const Project::Item& group)
: item (group)
{ {
list.setModel (this); list.setModel (this);
list.setColour (ListBox::backgroundColourId, Colours::transparentBlack); list.setColour (ListBox::backgroundColourId, Colours::transparentBlack);
@@ -113,8 +113,8 @@ private:
class FileOptionComponent : public Component class FileOptionComponent : public Component
{ {
public: public:
FileOptionComponent (const Project::Item& item_)
: item (item_),
FileOptionComponent (const Project::Item& fileItem)
: item (fileItem),
compileButton ("Compile"), compileButton ("Compile"),
resourceButton ("Add to Binary Resources") resourceButton ("Add to Binary Resources")
{ {


+ 15
- 15
extras/Introjucer/Source/Project/jucer_ModulesPanel.h View File

@@ -32,16 +32,16 @@ class ModulesPanel : public PropertyComponent,
public ButtonListener public ButtonListener
{ {
public: public:
ModulesPanel (Project& project_)
ModulesPanel (Project& p)
: PropertyComponent ("Modules", 500), : PropertyComponent ("Modules", 500),
project (project_),
project (p),
modulesLocation ("modules", ModuleList::getLocalModulesFolder (&project), modulesLocation ("modules", ModuleList::getLocalModulesFolder (&project),
true, true, false, "*", String::empty, true, true, false, "*", String::empty,
"Select a folder containing your JUCE modules..."), "Select a folder containing your JUCE modules..."),
modulesLabel (String::empty, "Module source folder:"), modulesLabel (String::empty, "Module source folder:"),
updateModulesButton ("Check for module updates..."), updateModulesButton ("Check for module updates..."),
moduleListBox (moduleList), moduleListBox (moduleList),
copyingMessage (project_, moduleList)
copyingMessage (p, moduleList)
{ {
moduleList.rescan (ModuleList::getLocalModulesFolder (&project)); moduleList.rescan (ModuleList::getLocalModulesFolder (&project));
@@ -138,17 +138,17 @@ public:
public ListBoxModel public ListBoxModel
{ {
public: public:
ModuleSelectionListBox (ModuleList& list_)
: list (list_), owner (nullptr)
ModuleSelectionListBox (ModuleList& ml)
: list (ml), owner (nullptr)
{ {
setColour (ListBox::backgroundColourId, Colours::white.withAlpha (0.4f)); setColour (ListBox::backgroundColourId, Colours::white.withAlpha (0.4f));
setTooltip ("Use this list to select which modules should be included in your app.\n" setTooltip ("Use this list to select which modules should be included in your app.\n"
"Any modules which have missing dependencies will be shown in red."); "Any modules which have missing dependencies will be shown in red.");
} }
void setOwner (ModulesPanel* owner_)
void setOwner (ModulesPanel* newOwner)
{ {
owner = owner_;
owner = newOwner;
setModel (this); setModel (this);
} }
@@ -225,8 +225,8 @@ public:
class ModuleSettingsPanel : public PropertyPanel class ModuleSettingsPanel : public PropertyPanel
{ {
public: public:
ModuleSettingsPanel (Project& project_, ModuleList& moduleList_, const String& moduleID_)
: project (project_), moduleList (moduleList_), moduleID (moduleID_)
ModuleSettingsPanel (Project& p, ModuleList& list, const String& modID)
: project (p), moduleList (list), moduleID (modID)
{ {
refreshAll(); refreshAll();
} }
@@ -296,8 +296,8 @@ public:
class ModuleInfoComponent : public PropertyComponent class ModuleInfoComponent : public PropertyComponent
{ {
public: public:
ModuleInfoComponent (Project& project_, ModuleList& moduleList_, const String& moduleID_)
: PropertyComponent ("Module", 100), project (project_), moduleList (moduleList_), moduleID (moduleID_)
ModuleInfoComponent (Project& p, ModuleList& list, const String& modID)
: PropertyComponent ("Module", 100), project (p), moduleList (list), moduleID (modID)
{ {
} }
@@ -336,9 +336,9 @@ public:
public ButtonListener public ButtonListener
{ {
public: public:
MissingDependenciesComponent (Project& project_, ModuleList& moduleList_, const String& moduleID_)
MissingDependenciesComponent (Project& p, ModuleList& list, const String& modID)
: PropertyComponent ("Dependencies", 100), : PropertyComponent ("Dependencies", 100),
project (project_), moduleList (moduleList_), moduleID (moduleID_),
project (p), moduleList (list), moduleID (modID),
fixButton ("Enable Required Modules") fixButton ("Enable Required Modules")
{ {
const ModuleList::Module* module = moduleList.findModuleInfo (moduleID); const ModuleList::Module* module = moduleList.findModuleInfo (moduleID);
@@ -402,8 +402,8 @@ public:
public Timer public Timer
{ {
public: public:
ModuleCopyingInfo (Project& project_, ModuleList& list_)
: project (project_), list (list_),
ModuleCopyingInfo (Project& p, ModuleList& modules)
: project (p), list (modules),
copyModeButton ("Set Copying Mode...") copyModeButton ("Set Copying Mode...")
{ {
addAndMakeVisible (&copyModeButton); addAndMakeVisible (&copyModeButton);


+ 1
- 1
extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h View File

@@ -184,7 +184,7 @@ private:
class TreeItemComponent : public Component class TreeItemComponent : public Component
{ {
public: public:
TreeItemComponent (JucerTreeViewBase& item_) : item (item_)
TreeItemComponent (JucerTreeViewBase& i) : item (i)
{ {
setInterceptsMouseClicks (false, true); setInterceptsMouseClicks (false, true);
} }


+ 8
- 8
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -224,12 +224,12 @@ class PopupColourSelector : public Component,
public ButtonListener public ButtonListener
{ {
public: public:
PopupColourSelector (const Value& colourValue_,
const Colour& defaultColour_,
PopupColourSelector (const Value& colour,
const Colour& defaultCol,
const bool canResetToDefault) const bool canResetToDefault)
: defaultButton ("Reset to Default"), : defaultButton ("Reset to Default"),
colourValue (colourValue_),
defaultColour (defaultColour_)
colourValue (colour),
defaultColour (defaultCol)
{ {
addAndMakeVisible (&selector); addAndMakeVisible (&selector);
selector.setName ("Colour"); selector.setName ("Colour");
@@ -312,10 +312,10 @@ class ColourEditorComponent : public Component,
public Value::Listener public Value::Listener
{ {
public: public:
ColourEditorComponent (UndoManager* undoManager_, const Value& colourValue_,
const Colour& defaultColour_, const bool canResetToDefault_)
: undoManager (undoManager_), colourValue (colourValue_), defaultColour (defaultColour_),
canResetToDefault (canResetToDefault_)
ColourEditorComponent (UndoManager* um, const Value& colour,
const Colour& defaultCol, const bool canReset)
: undoManager (um), colourValue (colour), defaultColour (defaultCol),
canResetToDefault (canReset)
{ {
colourValue.addListener (this); colourValue.addListener (this);
} }


+ 4
- 4
extras/Introjucer/Source/Utility/jucer_RelativePath.h View File

@@ -47,13 +47,13 @@ public:
: root (unknown) : root (unknown)
{} {}
RelativePath (const String& path_, const RootFolder root_)
: path (FileHelpers::unixStylePath (path_)), root (root_)
RelativePath (const String& relPath, const RootFolder rootType)
: path (FileHelpers::unixStylePath (relPath)), root (rootType)
{ {
} }
RelativePath (const File& file, const File& rootFolder, const RootFolder root_)
: path (FileHelpers::unixStylePath (FileHelpers::getRelativePathFrom (file, rootFolder))), root (root_)
RelativePath (const File& file, const File& rootFolder, const RootFolder rootType)
: path (FileHelpers::unixStylePath (FileHelpers::getRelativePathFrom (file, rootFolder))), root (rootType)
{ {
} }


+ 32
- 66
modules/juce_core/time/juce_RelativeTime.cpp View File

@@ -23,19 +23,9 @@
============================================================================== ==============================================================================
*/ */
RelativeTime::RelativeTime (const double seconds_) noexcept
: seconds (seconds_)
{
}
RelativeTime::RelativeTime (const RelativeTime& other) noexcept
: seconds (other.seconds)
{
}
RelativeTime::~RelativeTime() noexcept
{
}
RelativeTime::RelativeTime (const double secs) noexcept : seconds (secs) {}
RelativeTime::RelativeTime (const RelativeTime& other) noexcept : seconds (other.seconds) {}
RelativeTime::~RelativeTime() noexcept {}
//============================================================================== //==============================================================================
const RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); } const RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); }
@@ -52,6 +42,24 @@ double RelativeTime::inHours() const noexcept { return seconds / (60.0 * 6
double RelativeTime::inDays() const noexcept { return seconds / (60.0 * 60.0 * 24.0); } double RelativeTime::inDays() const noexcept { return seconds / (60.0 * 60.0 * 24.0); }
double RelativeTime::inWeeks() const noexcept { return seconds / (60.0 * 60.0 * 24.0 * 7.0); } double RelativeTime::inWeeks() const noexcept { return seconds / (60.0 * 60.0 * 24.0 * 7.0); }
//==============================================================================
RelativeTime& RelativeTime::operator= (const RelativeTime& other) noexcept { seconds = other.seconds; return *this; }
const RelativeTime& RelativeTime::operator+= (const RelativeTime& t) noexcept { seconds += t.seconds; return *this; }
const RelativeTime& RelativeTime::operator-= (const RelativeTime& t) noexcept { seconds -= t.seconds; return *this; }
const RelativeTime& RelativeTime::operator+= (const double secs) noexcept { seconds += secs; return *this; }
const RelativeTime& RelativeTime::operator-= (const double secs) noexcept { seconds -= secs; return *this; }
RelativeTime operator+ (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t += t2; }
RelativeTime operator- (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t -= t2; }
bool operator== (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() == t2.inSeconds(); }
bool operator!= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() != t2.inSeconds(); }
bool operator> (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() > t2.inSeconds(); }
bool operator< (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() < t2.inSeconds(); }
bool operator>= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() >= t2.inSeconds(); }
bool operator<= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() <= t2.inSeconds(); }
//============================================================================== //==============================================================================
String RelativeTime::getDescription (const String& returnValueForZeroTime) const String RelativeTime::getDescription (const String& returnValueForZeroTime) const
{ {
@@ -68,16 +76,16 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
int n = std::abs ((int) inWeeks()); int n = std::abs ((int) inWeeks());
if (n > 0) if (n > 0)
{ {
result << n << (n == 1 ? TRANS(" week ")
: TRANS(" weeks "));
result << n << TRANS (n == 1 ? " week "
: " weeks ");
++fieldsShown; ++fieldsShown;
} }
n = std::abs ((int) inDays()) % 7; n = std::abs ((int) inDays()) % 7;
if (n > 0) if (n > 0)
{ {
result << n << (n == 1 ? TRANS(" day ")
: TRANS(" days "));
result << n << TRANS (n == 1 ? " day "
: " days ");
++fieldsShown; ++fieldsShown;
} }
@@ -86,8 +94,8 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
n = std::abs ((int) inHours()) % 24; n = std::abs ((int) inHours()) % 24;
if (n > 0) if (n > 0)
{ {
result << n << (n == 1 ? TRANS(" hr ")
: TRANS(" hrs "));
result << n << TRANS (n == 1 ? " hr "
: " hrs ");
++fieldsShown; ++fieldsShown;
} }
@@ -96,8 +104,8 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
n = std::abs ((int) inMinutes()) % 60; n = std::abs ((int) inMinutes()) % 60;
if (n > 0) if (n > 0)
{ {
result << n << (n == 1 ? TRANS(" min ")
: TRANS(" mins "));
result << n << TRANS (n == 1 ? " min "
: " mins ");
++fieldsShown; ++fieldsShown;
} }
@@ -106,8 +114,8 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
n = std::abs ((int) inSeconds()) % 60; n = std::abs ((int) inSeconds()) % 60;
if (n > 0) if (n > 0)
{ {
result << n << (n == 1 ? TRANS(" sec ")
: TRANS(" secs "));
result << n << TRANS (n == 1 ? " sec "
: " secs ");
++fieldsShown; ++fieldsShown;
} }
@@ -115,7 +123,7 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
{ {
n = std::abs ((int) inMilliseconds()) % 1000; n = std::abs ((int) inMilliseconds()) % 1000;
if (n > 0) if (n > 0)
result << n << TRANS(" ms");
result << n << TRANS (" ms");
} }
} }
} }
@@ -123,45 +131,3 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const
return result.trimEnd(); return result.trimEnd();
} }
//==============================================================================
RelativeTime& RelativeTime::operator= (const RelativeTime& other) noexcept
{
seconds = other.seconds;
return *this;
}
//==============================================================================
const RelativeTime& RelativeTime::operator+= (const RelativeTime& timeToAdd) noexcept
{
seconds += timeToAdd.seconds;
return *this;
}
const RelativeTime& RelativeTime::operator-= (const RelativeTime& timeToSubtract) noexcept
{
seconds -= timeToSubtract.seconds;
return *this;
}
const RelativeTime& RelativeTime::operator+= (const double secondsToAdd) noexcept
{
seconds += secondsToAdd;
return *this;
}
const RelativeTime& RelativeTime::operator-= (const double secondsToSubtract) noexcept
{
seconds -= secondsToSubtract;
return *this;
}
bool operator== (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() == t2.inSeconds(); }
bool operator!= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() != t2.inSeconds(); }
bool operator> (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() > t2.inSeconds(); }
bool operator< (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() < t2.inSeconds(); }
bool operator>= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() >= t2.inSeconds(); }
bool operator<= (const RelativeTime& t1, const RelativeTime& t2) noexcept { return t1.inSeconds() <= t2.inSeconds(); }
RelativeTime operator+ (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t += t2; }
RelativeTime operator- (const RelativeTime& t1, const RelativeTime& t2) noexcept { RelativeTime t (t1); return t -= t2; }

+ 46
- 47
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -40,8 +40,8 @@ namespace RenderingHelpers
class TranslationOrTransform class TranslationOrTransform
{ {
public: public:
TranslationOrTransform (int xOffset_, int yOffset_) noexcept
: xOffset (xOffset_), yOffset (yOffset_), isOnlyTranslated (true)
TranslationOrTransform (int x, int y) noexcept
: xOffset (x), yOffset (y), isOnlyTranslated (true)
{ {
} }
@@ -393,11 +393,11 @@ namespace GradientPixelIterators
{ {
public: public:
Linear (const ColourGradient& gradient, const AffineTransform& transform, Linear (const ColourGradient& gradient, const AffineTransform& transform,
const PixelARGB* const lookupTable_, const int numEntries_)
: lookupTable (lookupTable_),
numEntries (numEntries_)
const PixelARGB* const colours, const int numColours)
: lookupTable (colours),
numEntries (numColours)
{ {
jassert (numEntries_ >= 0);
jassert (numColours >= 0);
Point<float> p1 (gradient.point1); Point<float> p1 (gradient.point1);
Point<float> p2 (gradient.point2); Point<float> p2 (gradient.point2);
@@ -467,13 +467,13 @@ namespace GradientPixelIterators
{ {
public: public:
Radial (const ColourGradient& gradient, const AffineTransform&, Radial (const ColourGradient& gradient, const AffineTransform&,
const PixelARGB* const lookupTable_, const int numEntries_)
: lookupTable (lookupTable_),
numEntries (numEntries_),
const PixelARGB* const colours, const int numColours)
: lookupTable (colours),
numEntries (numColours),
gx1 (gradient.point1.x), gx1 (gradient.point1.x),
gy1 (gradient.point1.y) gy1 (gradient.point1.y)
{ {
jassert (numEntries_ >= 0);
jassert (numColours >= 0);
const Point<float> diff (gradient.point1 - gradient.point2); const Point<float> diff (gradient.point1 - gradient.point2);
maxDist = diff.x * diff.x + diff.y * diff.y; maxDist = diff.x * diff.x + diff.y * diff.y;
invScale = numEntries / std::sqrt (maxDist); invScale = numEntries / std::sqrt (maxDist);
@@ -510,8 +510,8 @@ namespace GradientPixelIterators
{ {
public: public:
TransformedRadial (const ColourGradient& gradient, const AffineTransform& transform, TransformedRadial (const ColourGradient& gradient, const AffineTransform& transform,
const PixelARGB* const lookupTable_, const int numEntries_)
: Radial (gradient, transform, lookupTable_, numEntries_),
const PixelARGB* const colours, const int numColours)
: Radial (gradient, transform, colours, numColours),
inverseTransform (transform.inverted()) inverseTransform (transform.inverted())
{ {
tM10 = inverseTransform.mat10; tM10 = inverseTransform.mat10;
@@ -555,9 +555,8 @@ namespace EdgeTableFillers
class SolidColour class SolidColour
{ {
public: public:
SolidColour (const Image::BitmapData& data_, const PixelARGB& colour)
: data (data_),
sourceColour (colour)
SolidColour (const Image::BitmapData& image, const PixelARGB& colour)
: data (image), sourceColour (colour)
{ {
if (sizeof (PixelType) == 3 && data.pixelStride == sizeof (PixelType)) if (sizeof (PixelType) == 3 && data.pixelStride == sizeof (PixelType))
{ {
@@ -727,10 +726,10 @@ namespace EdgeTableFillers
class Gradient : public GradientType class Gradient : public GradientType
{ {
public: public:
Gradient (const Image::BitmapData& destData_, const ColourGradient& gradient, const AffineTransform& transform,
const PixelARGB* const lookupTable_, const int numEntries_)
: GradientType (gradient, transform, lookupTable_, numEntries_ - 1),
destData (destData_)
Gradient (const Image::BitmapData& dest, const ColourGradient& gradient, const AffineTransform& transform,
const PixelARGB* const colours, const int numColours)
: GradientType (gradient, transform, colours, numColours - 1),
destData (dest)
{ {
} }
@@ -808,13 +807,13 @@ namespace EdgeTableFillers
class ImageFill class ImageFill
{ {
public: public:
ImageFill (const Image::BitmapData& destData_, const Image::BitmapData& srcData_,
const int extraAlpha_, const int x, const int y)
: destData (destData_),
srcData (srcData_),
extraAlpha (extraAlpha_ + 1),
xOffset (repeatPattern ? negativeAwareModulo (x, srcData_.width) - srcData_.width : x),
yOffset (repeatPattern ? negativeAwareModulo (y, srcData_.height) - srcData_.height : y)
ImageFill (const Image::BitmapData& dest, const Image::BitmapData& src,
const int alpha, const int x, const int y)
: destData (dest),
srcData (src),
extraAlpha (alpha + 1),
xOffset (repeatPattern ? negativeAwareModulo (x, src.width) - src.width : x),
yOffset (repeatPattern ? negativeAwareModulo (y, src.height) - src.height : y)
{ {
} }
@@ -969,17 +968,17 @@ namespace EdgeTableFillers
class TransformedImageFill class TransformedImageFill
{ {
public: public:
TransformedImageFill (const Image::BitmapData& destData_, const Image::BitmapData& srcData_,
const AffineTransform& transform, const int extraAlpha_, const bool betterQuality_)
TransformedImageFill (const Image::BitmapData& dest, const Image::BitmapData& src,
const AffineTransform& transform, const int alpha, const bool higherQuality)
: interpolator (transform, : interpolator (transform,
betterQuality_ ? 0.5f : 0.0f,
betterQuality_ ? -128 : 0),
destData (destData_),
srcData (srcData_),
extraAlpha (extraAlpha_ + 1),
betterQuality (betterQuality_),
maxX (srcData_.width - 1),
maxY (srcData_.height - 1),
higherQuality ? 0.5f : 0.0f,
higherQuality ? -128 : 0),
destData (dest),
srcData (src),
extraAlpha (alpha + 1),
betterQuality (higherQuality),
maxX (src.width - 1),
maxY (src.height - 1),
scratchSize (2048) scratchSize (2048)
{ {
scratchBuffer.malloc (scratchSize); scratchBuffer.malloc (scratchSize);
@@ -1353,9 +1352,9 @@ namespace EdgeTableFillers
{ {
public: public:
TransformedImageSpanInterpolator (const AffineTransform& transform, TransformedImageSpanInterpolator (const AffineTransform& transform,
const float pixelOffset_, const int pixelOffsetInt_) noexcept
const float offsetFloat, const int offsetInt) noexcept
: inverseTransform (transform.inverted()), : inverseTransform (transform.inverted()),
pixelOffset (pixelOffset_), pixelOffsetInt (pixelOffsetInt_)
pixelOffset (offsetFloat), pixelOffsetInt (offsetInt)
{} {}
void setStartOfLine (float x, float y, const int numPixels) noexcept void setStartOfLine (float x, float y, const int numPixels) noexcept
@@ -1971,8 +1970,8 @@ namespace ClipRegions
class SubRectangleIterator class SubRectangleIterator
{ {
public: public:
SubRectangleIterator (const RectangleList& clip_, const Rectangle<int>& area_)
: clip (clip_), area (area_)
SubRectangleIterator (const RectangleList& clipList, const Rectangle<int>& clipBounds)
: clip (clipList), area (clipBounds)
{} {}
template <class Renderer> template <class Renderer>
@@ -2010,8 +2009,8 @@ namespace ClipRegions
class SubRectangleIteratorFloat class SubRectangleIteratorFloat
{ {
public: public:
SubRectangleIteratorFloat (const RectangleList& clip_, const Rectangle<float>& area_) noexcept
: clip (clip_), area (area_)
SubRectangleIteratorFloat (const RectangleList& clipList, const Rectangle<float>& clipBounds) noexcept
: clip (clipList), area (clipBounds)
{ {
} }
@@ -2107,17 +2106,17 @@ namespace ClipRegions
class SoftwareRendererSavedState class SoftwareRendererSavedState
{ {
public: public:
SoftwareRendererSavedState (const Image& image_, const Rectangle<int>& clip_)
: image (image_), clip (new ClipRegions::RectangleListRegion (clip_)),
SoftwareRendererSavedState (const Image& im, const Rectangle<int>& clipBounds)
: image (im), clip (new ClipRegions::RectangleListRegion (clipBounds)),
transform (0, 0), transform (0, 0),
interpolationQuality (Graphics::mediumResamplingQuality), interpolationQuality (Graphics::mediumResamplingQuality),
transparencyLayerAlpha (1.0f) transparencyLayerAlpha (1.0f)
{ {
} }
SoftwareRendererSavedState (const Image& image_, const RectangleList& clip_, const int xOffset_, const int yOffset_)
: image (image_), clip (new ClipRegions::RectangleListRegion (clip_)),
transform (xOffset_, yOffset_),
SoftwareRendererSavedState (const Image& im, const RectangleList& clipList, const int x, const int y)
: image (im), clip (new ClipRegions::RectangleListRegion (clipList)),
transform (x, y),
interpolationQuality (Graphics::mediumResamplingQuality), interpolationQuality (Graphics::mediumResamplingQuality),
transparencyLayerAlpha (1.0f) transparencyLayerAlpha (1.0f)
{ {


+ 41
- 51
modules/juce_gui_basics/widgets/juce_TextEditor.cpp View File

@@ -60,19 +60,14 @@ struct TextAtom
class TextEditor::UniformTextSection class TextEditor::UniformTextSection
{ {
public: public:
UniformTextSection (const String& text,
const Font& font_,
const Colour& colour_,
const juce_wchar passwordCharacter)
: font (font_),
colour (colour_)
UniformTextSection (const String& text, const Font& f, const Colour& col, const juce_wchar passwordChar)
: font (f), colour (col)
{ {
initialiseAtoms (text, passwordCharacter);
initialiseAtoms (text, passwordChar);
} }
UniformTextSection (const UniformTextSection& other) UniformTextSection (const UniformTextSection& other)
: font (other.font),
colour (other.colour)
: font (other.font), colour (other.colour)
{ {
atoms.ensureStorageAllocated (other.atoms.size()); atoms.ensureStorageAllocated (other.atoms.size());
@@ -80,10 +75,7 @@ public:
atoms.add (new TextAtom (*other.atoms.getUnchecked(i))); atoms.add (new TextAtom (*other.atoms.getUnchecked(i)));
} }
~UniformTextSection()
{
// (no need to delete the atoms, as they're explicitly deleted by the caller)
}
~UniformTextSection() {} // (no need to delete the atoms, as they're explicitly deleted by the caller)
void clear() void clear()
{ {
@@ -320,9 +312,9 @@ private:
class TextEditor::Iterator class TextEditor::Iterator
{ {
public: public:
Iterator (const Array <UniformTextSection*>& sections_,
const float wordWrapWidth_,
const juce_wchar passwordCharacter_)
Iterator (const Array <UniformTextSection*>& sectionList,
const float wrapWidth,
const juce_wchar passwordChar)
: indexInText (0), : indexInText (0),
lineY (0), lineY (0),
lineHeight (0), lineHeight (0),
@@ -331,13 +323,13 @@ public:
atomRight (0), atomRight (0),
atom (0), atom (0),
currentSection (nullptr), currentSection (nullptr),
sections (sections_),
sections (sectionList),
sectionIndex (0), sectionIndex (0),
atomIndex (0), atomIndex (0),
wordWrapWidth (wordWrapWidth_),
passwordCharacter (passwordCharacter_)
wordWrapWidth (wrapWidth),
passwordCharacter (passwordChar)
{ {
jassert (wordWrapWidth_ > 0);
jassert (wordWrapWidth > 0);
if (sections.size() > 0) if (sections.size() > 0)
{ {
@@ -687,7 +679,7 @@ public:
} }
//============================================================================== //==============================================================================
bool getCharPosition (const int index, float& cx, float& cy, float& lineHeight_)
bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound)
{ {
while (next()) while (next())
{ {
@@ -695,14 +687,14 @@ public:
{ {
cx = indexToX (index); cx = indexToX (index);
cy = lineY; cy = lineY;
lineHeight_ = lineHeight;
lineHeightFound = lineHeight;
return true; return true;
} }
} }
cx = atomX; cx = atomX;
cy = lineY; cy = lineY;
lineHeight_ = lineHeight;
lineHeightFound = lineHeight;
return false; return false;
} }
@@ -750,19 +742,19 @@ class TextEditor::InsertAction : public UndoableAction
{ {
public: public:
InsertAction (TextEditor& ed, InsertAction (TextEditor& ed,
const String& text_,
const int insertIndex_,
const Font& font_,
const Colour& colour_,
const int oldCaretPos_,
const int newCaretPos_)
const String& newText,
const int insertPos,
const Font& newFont,
const Colour& newColour,
const int oldCaret,
const int newCaret)
: owner (ed), : owner (ed),
text (text_),
insertIndex (insertIndex_),
oldCaretPos (oldCaretPos_),
newCaretPos (newCaretPos_),
font (font_),
colour (colour_)
text (newText),
insertIndex (insertPos),
oldCaretPos (oldCaret),
newCaretPos (newCaret),
font (newFont),
colour (newColour)
{ {
} }
@@ -798,15 +790,15 @@ class TextEditor::RemoveAction : public UndoableAction
{ {
public: public:
RemoveAction (TextEditor& ed, RemoveAction (TextEditor& ed,
const Range<int> range_,
const int oldCaretPos_,
const int newCaretPos_,
const Array <UniformTextSection*>& removedSections_)
const Range<int> rangeToRemove,
const int oldCaret,
const int newCaret,
const Array <UniformTextSection*>& oldSections)
: owner (ed), : owner (ed),
range (range_),
oldCaretPos (oldCaretPos_),
newCaretPos (newCaretPos_),
removedSections (removedSections_)
range (rangeToRemove),
oldCaretPos (oldCaret),
newCaretPos (newCaret),
removedSections (oldSections)
{ {
} }
@@ -814,9 +806,8 @@ public:
{ {
for (int i = removedSections.size(); --i >= 0;) for (int i = removedSections.size(); --i >= 0;)
{ {
UniformTextSection* const section = removedSections.getUnchecked (i);
ScopedPointer<UniformTextSection> section (removedSections.getUnchecked (i));
section->clear(); section->clear();
delete section;
} }
} }
@@ -952,7 +943,7 @@ namespace TextEditorDefs
//============================================================================== //==============================================================================
TextEditor::TextEditor (const String& name, TextEditor::TextEditor (const String& name,
const juce_wchar passwordCharacter_)
const juce_wchar passwordChar)
: Component (name), : Component (name),
borderSize (1, 1, 1, 3), borderSize (1, 1, 1, 3),
readOnly (false), readOnly (false),
@@ -975,7 +966,7 @@ TextEditor::TextEditor (const String& name,
currentFont (14.0f), currentFont (14.0f),
totalNumChars (0), totalNumChars (0),
caretPosition (0), caretPosition (0),
passwordCharacter (passwordCharacter_),
passwordCharacter (passwordChar),
dragType (notDragging) dragType (notDragging)
{ {
setOpaque (true); setOpaque (true);
@@ -1564,16 +1555,15 @@ void TextEditor::moveCaretTo (const int newPosition,
} }
} }
int TextEditor::getTextIndexAt (const int x,
const int y)
int TextEditor::getTextIndexAt (const int x, const int y)
{ {
return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent), return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent),
(float) (y + viewport->getViewPositionY() - topIndent)); (float) (y + viewport->getViewPositionY() - topIndent));
} }
void TextEditor::insertTextAtCaret (const String& newText_)
void TextEditor::insertTextAtCaret (const String& t)
{ {
String newText (newText_);
String newText (t);
if (allowedCharacters.isNotEmpty()) if (allowedCharacters.isNotEmpty())
newText = newText.retainCharacters (allowedCharacters); newText = newText.retainCharacters (allowedCharacters);


Loading…
Cancel
Save