Browse Source

TabbedButtonBar fix. Small clean-ups.

tags/2021-05-28
jules 13 years ago
parent
commit
93a86b2600
3 changed files with 33 additions and 36 deletions
  1. +20
    -23
      modules/juce_core/native/juce_win32_Files.cpp
  2. +2
    -2
      modules/juce_events/messages/juce_MessageManager.h
  3. +11
    -11
      modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp

+ 20
- 23
modules/juce_core/native/juce_win32_Files.cpp View File

@@ -42,9 +42,13 @@ namespace WindowsFileHelpers
return (int64) ((reinterpret_cast<const ULARGE_INTEGER*> (ft)->QuadPart - literal64bit (116444736000000000)) / 10000); return (int64) ((reinterpret_cast<const ULARGE_INTEGER*> (ft)->QuadPart - literal64bit (116444736000000000)) / 10000);
} }
void timeToFileTime (const int64 time, FILETIME* const ft)
FILETIME* timeToFileTime (const int64 time, FILETIME* const ft) noexcept
{ {
if (time <= 0)
return nullptr;
reinterpret_cast<ULARGE_INTEGER*> (ft)->QuadPart = (ULONGLONG) (time * 10000 + literal64bit (116444736000000000)); reinterpret_cast<ULARGE_INTEGER*> (ft)->QuadPart = (ULONGLONG) (time * 10000 + literal64bit (116444736000000000));
return ft;
} }
String getDriveFromPath (String path) String getDriveFromPath (String path)
@@ -89,6 +93,14 @@ namespace WindowsFileHelpers
return File::nonexistent; return File::nonexistent;
} }
File getModuleFileName (HINSTANCE moduleHandle)
{
WCHAR dest [MAX_PATH + 256];
dest[0] = 0;
GetModuleFileName (moduleHandle, dest, (DWORD) numElementsInArray (dest));
return File (String (dest));
}
Result getResultForLastError() Result getResultForLastError()
{ {
TCHAR messageBuffer [256] = { 0 }; TCHAR messageBuffer [256] = { 0 };
@@ -367,8 +379,8 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int
if (GetFileAttributesEx (fullPath.toWideCharPointer(), GetFileExInfoStandard, &attributes)) if (GetFileAttributesEx (fullPath.toWideCharPointer(), GetFileExInfoStandard, &attributes))
{ {
modificationTime = fileTimeToTime (&attributes.ftLastWriteTime); modificationTime = fileTimeToTime (&attributes.ftLastWriteTime);
creationTime = fileTimeToTime (&attributes.ftCreationTime);
accessTime = fileTimeToTime (&attributes.ftLastAccessTime);
creationTime = fileTimeToTime (&attributes.ftCreationTime);
accessTime = fileTimeToTime (&attributes.ftLastAccessTime);
} }
else else
{ {
@@ -387,14 +399,11 @@ bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
{ {
FILETIME m, a, c; FILETIME m, a, c;
timeToFileTime (modificationTime, &m);
timeToFileTime (accessTime, &a);
timeToFileTime (creationTime, &c);
ok = SetFileTime (h, ok = SetFileTime (h,
creationTime > 0 ? &c : 0,
accessTime > 0 ? &a : 0,
modificationTime > 0 ? &m : 0) != 0;
timeToFileTime (creationTime, &c),
timeToFileTime (accessTime, &a),
timeToFileTime (modificationTime, &m)) != 0;
CloseHandle (h); CloseHandle (h);
} }
@@ -517,22 +526,10 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type)
case invokedExecutableFile: case invokedExecutableFile:
case currentExecutableFile: case currentExecutableFile:
case currentApplicationFile: case currentApplicationFile:
{
HINSTANCE moduleHandle = (HINSTANCE) Process::getCurrentModuleInstanceHandle();
WCHAR dest [MAX_PATH + 256];
dest[0] = 0;
GetModuleFileName (moduleHandle, dest, (DWORD) numElementsInArray (dest));
return File (String (dest));
}
return WindowsFileHelpers::getModuleFileName ((HINSTANCE) Process::getCurrentModuleInstanceHandle());
case hostApplicationPath: case hostApplicationPath:
{
WCHAR dest [MAX_PATH + 256];
dest[0] = 0;
GetModuleFileName (0, dest, (DWORD) numElementsInArray (dest));
return File (String (dest));
}
return WindowsFileHelpers::getModuleFileName (0);
default: default:
jassertfalse; // unknown type? jassertfalse; // unknown type?


+ 2
- 2
modules/juce_events/messages/juce_MessageManager.h View File

@@ -122,10 +122,10 @@ public:
*/ */
void setCurrentThreadAsMessageThread(); void setCurrentThreadAsMessageThread();
/** Returns the ID of the current message thread, as set by setCurrentMessageThread().
/** Returns the ID of the current message thread, as set by setCurrentThreadAsMessageThread().
(Best to ignore this method unless you really know what you're doing..) (Best to ignore this method unless you really know what you're doing..)
@see setCurrentMessageThread
@see setCurrentThreadAsMessageThread
*/ */
Thread::ThreadID getCurrentMessageThread() const noexcept { return messageThreadId; } Thread::ThreadID getCurrentMessageThread() const noexcept { return messageThreadId; }


+ 11
- 11
modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp View File

@@ -207,14 +207,16 @@ void TabbedButtonBar::addTab (const String& tabName,
if (! isPositiveAndBelow (insertIndex, tabs.size())) if (! isPositiveAndBelow (insertIndex, tabs.size()))
insertIndex = tabs.size(); insertIndex = tabs.size();
TabInfo* const currentTab = tabs [currentTabIndex];
TabInfo* newTab = new TabInfo(); TabInfo* newTab = new TabInfo();
newTab->name = tabName; newTab->name = tabName;
newTab->colour = tabBackgroundColour; newTab->colour = tabBackgroundColour;
newTab->component = createTabButton (tabName, insertIndex); newTab->component = createTabButton (tabName, insertIndex);
jassert (newTab->component != nullptr); jassert (newTab->component != nullptr);
tabs.insert (insertIndex, newTab); tabs.insert (insertIndex, newTab);
currentTabIndex = tabs.indexOf (currentTab);
addAndMakeVisible (newTab->component, insertIndex); addAndMakeVisible (newTab->component, insertIndex);
resized(); resized();
@@ -238,22 +240,20 @@ void TabbedButtonBar::setTabName (const int tabIndex, const String& newName)
void TabbedButtonBar::removeTab (const int tabIndex) void TabbedButtonBar::removeTab (const int tabIndex)
{ {
if (tabs [tabIndex] != nullptr)
{
const int oldTabIndex = currentTabIndex;
if (currentTabIndex == tabIndex)
currentTabIndex = -1;
if (tabIndex == currentTabIndex)
setCurrentTabIndex (-1);
tabs.remove (tabIndex);
resized();
setCurrentTabIndex (jlimit (0, jmax (0, tabs.size() - 1), oldTabIndex));
}
TabInfo* const currentTab = tabs [currentTabIndex];
tabs.remove (tabIndex);
currentTabIndex = tabs.indexOf (currentTab);
resized();
} }
void TabbedButtonBar::moveTab (const int currentIndex, const int newIndex) void TabbedButtonBar::moveTab (const int currentIndex, const int newIndex)
{ {
TabInfo* const currentTab = tabs [currentTabIndex];
tabs.move (currentIndex, newIndex); tabs.move (currentIndex, newIndex);
currentTabIndex = tabs.indexOf (currentTab);
resized(); resized();
} }


Loading…
Cancel
Save