Page MenuHome

CocoaProgressBar.patch

CocoaProgressBar.patch

Index: intern/ghost/GHOST_C-api.h
===================================================================
--- intern/ghost/GHOST_C-api.h (revision 29048)
+++ intern/ghost/GHOST_C-api.h (working copy)
@@ -264,7 +264,24 @@
extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
GHOST_EventConsumerHandle consumerhandle);
+/***************************************************************************************
+ ** Progress bar functionality
+ ***************************************************************************************/
+/**
+ * Sets the progress bar value displayed in the window/application icon
+ * @param windowhandle The handle to the window
+ * @param progress The progress % (0.0 to 1.0)
+ */
+extern GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress);
+
+/**
+ * Hides the progress bar in the icon
+ * @param windowhandle The handle to the window
+ */
+extern GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle);
+
+
/***************************************************************************************
** N-degree of freedom device management functionality
***************************************************************************************/
Index: intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- intern/ghost/intern/GHOST_WindowCocoa.mm (revision 29048)
+++ intern/ghost/intern/GHOST_WindowCocoa.mm (working copy)
@@ -1020,6 +1020,61 @@
return GHOST_kSuccess;
}
+#pragma mark Progress bar
+
+GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if ((progress >=0.0) && (progress <=1.0)) {
+ NSImage* dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128,128)];
+
+ [dockIcon lockFocus];
+ NSRect progressBox = {{4, 4}, {120, 16}};
+
+ [[NSImage imageNamed:@"NSApplicationIcon"] dissolveToPoint:NSZeroPoint fraction:1.0];
+
+ // Track & Outline
+ [[NSColor blackColor] setFill];
+ NSRectFill(progressBox);
+
+ [[NSColor whiteColor] set];
+ NSFrameRect(progressBox);
+
+ // Progress fill
+ progressBox = NSInsetRect(progressBox, 1, 1);
+ [[NSColor knobColor] setFill];
+ progressBox.size.width = progressBox.size.width * progress;
+ NSRectFill(progressBox);
+
+ [dockIcon unlockFocus];
+
+ [NSApp setApplicationIconImage:dockIcon];
+ [dockIcon release];
+ }
+
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_WindowCocoa::endProgressBar()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSImage* dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128,128)];
+ [dockIcon lockFocus];
+ [[NSImage imageNamed:@"NSApplicationIcon"] dissolveToPoint:NSZeroPoint fraction:1.0];
+ [dockIcon unlockFocus];
+ [NSApp setApplicationIconImage:dockIcon];
+ [dockIcon release];
+
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+
+
#pragma mark Cursor handling
void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor cursor) const
Index: intern/ghost/intern/GHOST_WindowCocoa.h
===================================================================
--- intern/ghost/intern/GHOST_WindowCocoa.h (revision 29048)
+++ intern/ghost/intern/GHOST_WindowCocoa.h (working copy)
@@ -226,6 +226,17 @@
GHOST_TabletData& GetCocoaTabletData()
{ return m_tablet; }
+
+ /**
+ * Sets the progress bar value displayed in the window/application icon
+ * @param progress The progress % (0.0 to 1.0)
+ */
+ virtual GHOST_TSuccess setProgressBar(float progress);
+
+ /**
+ * Hides the progress bar icon
+ */
+ virtual GHOST_TSuccess endProgressBar();
protected:
/**
* Tries to install a rendering context in this window.
@@ -291,14 +302,6 @@
NSCursor* m_customCursor;
GHOST_TabletData m_tablet;
-
- /**
- * The width/height of the size rectangle in the lower right corner of a
- * Mac/Carbon window. This is also the height of the gutter area.
- */
-#ifdef GHOST_DRAW_CARBON_GUTTER
- static const GHOST_TInt32 s_sizeRectSize;
-#endif // GHOST_DRAW_CARBON_GUTTER
};
#endif // _GHOST_WINDOW_COCOA_H_
Index: intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- intern/ghost/intern/GHOST_C-api.cpp (revision 29048)
+++ intern/ghost/intern/GHOST_C-api.cpp (working copy)
@@ -248,6 +248,21 @@
return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
}
+GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress)
+{
+ GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+ return window->setProgressBar(progress);
+}
+
+GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
+{
+ GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
+
+ return window->endProgressBar();
+}
+
+
int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle,
GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
Index: intern/ghost/intern/GHOST_Window.h
===================================================================
--- intern/ghost/intern/GHOST_Window.h (revision 29048)
+++ intern/ghost/intern/GHOST_Window.h (working copy)
@@ -192,6 +192,17 @@
virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect& bounds);
/**
+ * Sets the progress bar value displayed in the window/application icon
+ * @param progress The progress % (0.0 to 1.0)
+ */
+ virtual GHOST_TSuccess setProgressBar(float progress) {return GHOST_kFailure;};
+
+ /**
+ * Hides the progress bar in the icon
+ */
+ virtual GHOST_TSuccess endProgressBar() {return GHOST_kFailure;};
+
+ /**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
virtual void setAcceptDragOperation(bool canAccept);
Index: intern/ghost/GHOST_IWindow.h
===================================================================
--- intern/ghost/GHOST_IWindow.h (revision 29048)
+++ intern/ghost/GHOST_IWindow.h (working copy)
@@ -235,6 +235,21 @@
virtual const GHOST_TabletData* GetTabletData() = 0;
/***************************************************************************************
+ ** Progress bar functionality
+ ***************************************************************************************/
+
+ /**
+ * Sets the progress bar value displayed in the window/application icon
+ * @param progress The progress %
+ */
+ virtual GHOST_TSuccess setProgressBar(float progress) = 0;
+
+ /**
+ * Hides the progress bar in the icon
+ */
+ virtual GHOST_TSuccess endProgressBar() = 0;
+
+ /***************************************************************************************
** Cursor management functionality
***************************************************************************************/
Index: source/blender/editors/interface/interface_templates.c
===================================================================
--- source/blender/editors/interface/interface_templates.c (revision 29048)
+++ source/blender/editors/interface/interface_templates.c (working copy)
@@ -53,6 +53,8 @@
#include "UI_interface.h"
#include "interface_intern.h"
+#include "GHOST_C-api.h"
+
void ui_template_fix_linking()
{
}
@@ -2425,6 +2427,7 @@
uiBlock *block;
void *owner;
int handle_event;
+ static int ghostprogressbar = 0;
block= uiLayoutGetBlock(layout);
uiBlockSetCurLayout(block, layout);
@@ -2441,16 +2444,27 @@
if(WM_jobs_test(wm, owner)) {
uiLayout *abs;
+ float progress=0.0;
abs = uiLayoutAbsolute(layout, 0);
+ progress = WM_jobs_progress(wm, owner);
+ ghostprogressbar = 1;
uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE,
0, UI_UNIT_Y*0.1, UI_UNIT_X*0.8, UI_UNIT_Y*0.8, NULL, 0.0f, 0.0f, 0, 0, "Stop this job");
uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner),
- UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, "Progress");
+ UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, progress, 0, "Progress");
uiLayoutRow(layout, 0);
+ GHOST_SetProgressBar(wm->winactive->ghostwin, progress);
}
+ else {
+ if (ghostprogressbar) {
+ ghostprogressbar = 0;
+ GHOST_EndProgressBar(wm->winactive->ghostwin);
+ }
+ }
+
if(WM_jobs_test(wm, screen))
uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Capture", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast");
if(screen->animtimer)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f1/fe/9c64418c23573fdb13ee27a28a2a

Event Timeline