Holiday coding log :)
authorTon Roosendaal <ton@blender.org>
Wed, 12 Dec 2012 18:58:11 +0000 (18:58 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 12 Dec 2012 18:58:11 +0000 (18:58 +0000)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability

Short list of main changes:

- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)

91 files changed:
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_System.cpp
intern/ghost/intern/GHOST_System.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_WindowCocoa.mm
intern/ghost/intern/GHOST_WindowX11.cpp
release/scripts/startup/bl_ui/space_userpref.py
source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf.c
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/scene.c
source/blender/blenlib/BLI_path_util.h
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/include/BIF_gl.h
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_screen.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_view2d.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/interface/view2d.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_console/console_draw.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_info/info_draw.c
source/blender/editors/space_info/textview.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_add.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_templates.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_text/text_intern.h
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_text/text_python.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_screen_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_event_system.h
source/blender/windowmanager/wm_event_types.h
source/blender/windowmanager/wm_files.h
source/blender/windowmanager/wm_window.h
source/creator/creator.c

index f886dfd9d7d632d57dfb08f37a26b1c910e20984..ab5feb287d833a702ebd7d157111db53b8227ba8 100644 (file)
@@ -852,6 +852,16 @@ extern int GHOST_toggleConsole(int action);
  */
 extern int GHOST_confirmQuit(GHOST_WindowHandle windowhandle);
 
  */
 extern int GHOST_confirmQuit(GHOST_WindowHandle windowhandle);
 
+/**
+ * Use native pixel size (MacBook pro 'retina'), if supported.
+ */
+extern int GHOST_UseNativePixels(void);
+
+/**
+ * If window was opened using native pixel size, it returns scaling factor.
+ */
+extern float GHOST_GetNativePixelSize(void);
+
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index ad5d2379787afcbb2ad936a1f8720c7914aac886..dfe01521a2972b57843f777bb6cd390564b2ceda 100644 (file)
@@ -294,6 +294,13 @@ public:
         * \return The current status.
         */
        virtual bool getFullScreen(void) = 0;
         * \return The current status.
         */
        virtual bool getFullScreen(void) = 0;
+       
+       /**
+        * Native pixel size support (MacBook 'retina').
+        * \return The pixel size in float.
+        */
+       virtual bool useNativePixel(void) = 0;
+       virtual float getNativePixelSize(void) = 0;
 
        /***************************************************************************************
         * Event management functionality
 
        /***************************************************************************************
         * Event management functionality
index 88d02c46f61fc5d1d81df6eabb3ac6c369c27ccc..ba0a6eba36f92afc8bbe6b67228eec8575560d3f 100644 (file)
@@ -878,3 +878,16 @@ int GHOST_confirmQuit(GHOST_WindowHandle windowhandle)
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
        return system->confirmQuit((GHOST_IWindow *) windowhandle);
 }
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
        return system->confirmQuit((GHOST_IWindow *) windowhandle);
 }
+
+int GHOST_UseNativePixels(void)
+{
+       GHOST_ISystem *system = GHOST_ISystem::getSystem();
+       return system->useNativePixel();
+}
+
+float GHOST_GetNativePixelSize(void)
+{
+       GHOST_ISystem *system = GHOST_ISystem::getSystem();
+       return system->getNativePixelSize();
+}
+
index 8c6491bcbfd95d971e028dfea459e03dba069b09..a008d224a200003f50755199aba5ab467918d16e 100644 (file)
@@ -373,3 +373,16 @@ int GHOST_System::confirmQuit(GHOST_IWindow *window) const
 {
        return 1;
 }
 {
        return 1;
 }
+
+bool GHOST_System::useNativePixel(void)
+{
+       m_nativePixel = 1;
+       return 1;
+}
+
+float GHOST_System::getNativePixelSize(void)
+{
+       if (m_nativePixel)
+               return m_nativePixelSize;
+       return 1.0f;
+}
index d2e3377f6ce39c49ddc448cb689d748c84f4015f..5060f22c5097f03f6dde2f5bf3f9490e5fc506f4 100644 (file)
@@ -167,6 +167,16 @@ public:
         */
        virtual bool getFullScreen(void);
 
         */
        virtual bool getFullScreen(void);
 
+       
+       /**
+        * Native pixel size support (MacBook 'retina').
+        * \return The pixel size in float.
+        */
+       virtual bool useNativePixel(void);
+       bool m_nativePixel;
+
+       virtual float getNativePixelSize(void);
+       float m_nativePixelSize;
 
        /***************************************************************************************
         * Event management functionality
 
        /***************************************************************************************
         * Event management functionality
@@ -350,6 +360,7 @@ protected:
 
        /** Settings of the display before the display went fullscreen. */
        GHOST_DisplaySetting m_preFullScreenSetting;
 
        /** Settings of the display before the display went fullscreen. */
        GHOST_DisplaySetting m_preFullScreenSetting;
+       
 };
 
 inline GHOST_TimerManager *GHOST_System::getTimerManager() const
 };
 
 inline GHOST_TimerManager *GHOST_System::getTimerManager() const
index 16edb4af575a385a24ae39b3c8f7d080b3939c22..7f6b69d9d504a3091d091314f71c7fa050eb6844 100644 (file)
@@ -1058,7 +1058,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
                                        pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
                                        //Mouse up event is trapped by the resizing event loop, so send it anyway to the window manager
                                        pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonUp, window, convertButton(0)));
                                        pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
                                        //Mouse up event is trapped by the resizing event loop, so send it anyway to the window manager
                                        pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonUp, window, convertButton(0)));
-                                       m_ignoreWindowSizedMessages = true;
+                                       //m_ignoreWindowSizedMessages = true;
                                }
                                break;
                        default:
                                }
                                break;
                        default:
@@ -1450,13 +1450,22 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 {
        NSEvent *event = (NSEvent *)eventPtr;
        GHOST_WindowCocoa* window;
 {
        NSEvent *event = (NSEvent *)eventPtr;
        GHOST_WindowCocoa* window;
+       CocoaWindow *cocoawindow;
        
        
+       /* [event window] returns other windows if mouse-over, that's OSX input standard
+          however, if mouse exits window(s), the windows become inactive, until you click.
+          We then fall back to the active window from ghost */
        window = (GHOST_WindowCocoa*)m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
        if (!window) {
        window = (GHOST_WindowCocoa*)m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
        if (!window) {
-               //printf("\nW failure for event 0x%x",[event type]);
-               return GHOST_kFailure;
+               window = (GHOST_WindowCocoa*)m_windowManager->getActiveWindow();
+               if (!window) {
+                       //printf("\nW failure for event 0x%x",[event type]);
+                       return GHOST_kFailure;
+               }
        }
 
        }
 
+       cocoawindow = (CocoaWindow *)window->getOSWindow();
+       
        switch ([event type]) {
                case NSLeftMouseDown:
                case NSRightMouseDown:
        switch ([event type]) {
                case NSLeftMouseDown:
                case NSRightMouseDown:
@@ -1509,7 +1518,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                                break;
                                        case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries
                                        {
                                                break;
                                        case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries
                                        {
-                                               NSPoint mousePos = [event locationInWindow];
+                                               NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                                GHOST_TInt32 x_mouse= mousePos.x;
                                                GHOST_TInt32 y_mouse= mousePos.y;
                                                GHOST_TInt32 x_accum, y_accum, x_cur, y_cur, x, y;
                                                GHOST_TInt32 x_mouse= mousePos.x;
                                                GHOST_TInt32 y_mouse= mousePos.y;
                                                GHOST_TInt32 x_accum, y_accum, x_cur, y_cur, x, y;
@@ -1555,9 +1564,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                        default:
                                        {
                                                //Normal cursor operation: send mouse position in window
                                        default:
                                        {
                                                //Normal cursor operation: send mouse position in window
-                                               NSPoint mousePos = [event locationInWindow];
+                                               NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                                GHOST_TInt32 x, y;
                                                GHOST_TInt32 x, y;
-
+                                               
                                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                                pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
 
                                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                                pushEvent(new GHOST_EventCursor([event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
 
@@ -1584,7 +1593,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                        pushEvent(new GHOST_EventWheel([event timestamp] * 1000, window, delta));
                                }
                                else {
                                        pushEvent(new GHOST_EventWheel([event timestamp] * 1000, window, delta));
                                }
                                else {
-                                       NSPoint mousePos = [event locationInWindow];
+                                       NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                        GHOST_TInt32 x, y;
                                        double dx = [event deltaX];
                                        double dy = -[event deltaY];
                                        GHOST_TInt32 x, y;
                                        double dx = [event deltaX];
                                        double dy = -[event deltaY];
@@ -1616,7 +1625,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                        
                case NSEventTypeMagnify:
                        {
                        
                case NSEventTypeMagnify:
                        {
-                               NSPoint mousePos = [event locationInWindow];
+                               NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                GHOST_TInt32 x, y;
                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventMagnify, x, y,
                                GHOST_TInt32 x, y;
                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventMagnify, x, y,
@@ -1626,7 +1635,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 
                case NSEventTypeRotate:
                        {
 
                case NSEventTypeRotate:
                        {
-                               NSPoint mousePos = [event locationInWindow];
+                               NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                GHOST_TInt32 x, y;
                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventRotate, x, y,
                                GHOST_TInt32 x, y;
                                window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
                                pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000, window, GHOST_kTrackpadEventRotate, x, y,
index 46c71f57c6fe322da1a177e5d46159c795ed120a..9f62ed767352f12b86319afdaf9d190071a334c3 100644 (file)
@@ -782,8 +782,8 @@ GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
 
 void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax)
 {
 
 void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax)
 {
-       minmax->ptMinTrackSize.x = 320;
-       minmax->ptMinTrackSize.y = 240;
+       minmax->ptMinTrackSize.x = 640;
+       minmax->ptMinTrackSize.y = 480;
 }
 
 #ifdef WITH_INPUT_NDOF
 }
 
 #ifdef WITH_INPUT_NDOF
index a483c030b31aad1703a82f6dda03798f767473f5..2c833fcaf9d50363146f4955ace11e032dcd19c6 100644 (file)
@@ -470,8 +470,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
        [m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
        
        //Forbid to resize the window below the blender defined minimum one
        [m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
        
        //Forbid to resize the window below the blender defined minimum one
-       minSize.width = 320;
-       minSize.height = 240;
+       minSize.width = 640;
+       minSize.height = 480;
        [m_window setContentMinSize:minSize];
        
        setTitle(title);
        [m_window setContentMinSize:minSize];
        
        setTitle(title);
@@ -579,6 +579,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
        updateDrawingContext();
        activateDrawingContext();
        
        updateDrawingContext();
        activateDrawingContext();
        
+       if (m_systemCocoa->m_nativePixel) {
+               [m_openGLView setWantsBestResolutionOpenGLSurface:YES];
+               NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
+               m_systemCocoa->m_nativePixelSize = (float)backingBounds.size.width / (float)rect.size.width;
+       }
+       
+       
        m_tablet.Active = GHOST_kTabletModeNone;
        
        CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
        m_tablet.Active = GHOST_kTabletModeNone;
        
        CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
@@ -1008,7 +1015,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
                                [tmpWindow registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
                                                                                                   NSStringPboardType, NSTIFFPboardType, nil]];
                                //Forbid to resize the window below the blender defined minimum one
                                [tmpWindow registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
                                                                                                   NSStringPboardType, NSTIFFPboardType, nil]];
                                //Forbid to resize the window below the blender defined minimum one
-                               [tmpWindow setContentMinSize:NSMakeSize(320, 240)];
+                               [tmpWindow setContentMinSize:NSMakeSize(640, 480)];
                                
                                //Assign the openGL view to the new window
                                [tmpWindow setContentView:m_openGLView];
                                
                                //Assign the openGL view to the new window
                                [tmpWindow setContentView:m_openGLView];
index 156bc86869a5a83dfcaa02a5e333750f8c28f400..3440e3ce15aea52e1d62b921946fdecff07882ea 100644 (file)
@@ -363,8 +363,8 @@ GHOST_WindowX11(
        xsizehints->y = top;
        xsizehints->width = width;
        xsizehints->height = height;
        xsizehints->y = top;
        xsizehints->width = width;
        xsizehints->height = height;
-       xsizehints->min_width = 320;     /* size hints, could be made apart of the ghost api */
-       xsizehints->min_height = 240;    /* limits are also arbitrary, but should not allow 1x1 window */
+       xsizehints->min_width = 640;     /* size hints, could be made apart of the ghost api */
+       xsizehints->min_height = 480;    /* limits are also arbitrary, but should not allow 1x1 window */
        xsizehints->max_width = 65535;
        xsizehints->max_height = 65535;
        XSetWMNormalHints(m_display, m_window, xsizehints);
        xsizehints->max_width = 65535;
        xsizehints->max_height = 65535;
        XSetWMNormalHints(m_display, m_window, xsizehints);
index 0bb25e984564378aeb15990d0f44b36a9c858ff3..42d64078acb9109edaa948c5056072678e3731ca 100644 (file)
@@ -84,7 +84,7 @@ class USERPREF_HT_header(Header):
         userpref = context.user_preferences
 
         layout.operator_context = 'EXEC_AREA'
         userpref = context.user_preferences
 
         layout.operator_context = 'EXEC_AREA'
-        layout.operator("wm.save_homefile", text="Save As Default")
+        layout.operator("wm.save_userpref")
 
         layout.operator_context = 'INVOKE_DEFAULT'
 
 
         layout.operator_context = 'INVOKE_DEFAULT'
 
@@ -445,6 +445,7 @@ class USERPREF_PT_system(Panel):
         col.label(text="Window Draw Method:")
         col.prop(system, "window_draw_method", text="")
         col.prop(system, "multi_sample", text="")
         col.label(text="Window Draw Method:")
         col.prop(system, "window_draw_method", text="")
         col.prop(system, "multi_sample", text="")
+        col.prop(system, "use_region_overlap")
         col.label(text="Text Draw Options:")
         col.prop(system, "use_text_antialiasing")
         col.label(text="Textures:")
         col.label(text="Text Draw Options:")
         col.prop(system, "use_text_antialiasing")
         col.label(text="Textures:")
@@ -855,6 +856,7 @@ class USERPREF_PT_file(Panel):
         col.prop(paths, "recent_files")
         col.prop(paths, "use_save_preview_images")
         col.label(text="Auto Save:")
         col.prop(paths, "recent_files")
         col.prop(paths, "use_save_preview_images")
         col.label(text="Auto Save:")
+        col.prop(paths, "use_keep_session")
         col.prop(paths, "use_auto_save_temporary_files")
         sub = col.column()
         sub.active = paths.use_auto_save_temporary_files
         col.prop(paths, "use_auto_save_temporary_files")
         sub = col.column()
         sub.active = paths.use_auto_save_temporary_files
index 6f348ccc26748e41c9cd14fa45073dc46a9df160..25b55eacd77990d56dbd2b22dac925892eb1f49b 100644 (file)
@@ -37,6 +37,7 @@ struct ColorManagedDisplay;
 
 int BLF_init(int points, int dpi);
 void BLF_exit(void);
 
 int BLF_init(int points, int dpi);
 void BLF_exit(void);
+void BLF_default_dpi(int dpi);
 
 void BLF_cache_clear(void);
 
 
 void BLF_cache_clear(void);
 
index 778b6c11e5af8f87b10820980c4c61866345c14e..16756769675c2bac215b785fb395e370c29f0fcd 100644 (file)
@@ -87,6 +87,11 @@ int BLF_init(int points, int dpi)
        return blf_font_init();
 }
 
        return blf_font_init();
 }
 
+void BLF_default_dpi(int dpi)
+{
+       global_font_dpi = dpi;
+}
+
 void BLF_exit(void)
 {
        FontBLF *font;
 void BLF_exit(void)
 {
        FontBLF *font;
index cd75749fa3cd881be271dfcb827f626932a93b14..ffdbc9cb9d835b51c6c9c645ff7e8680f3b78be0 100644 (file)
@@ -62,6 +62,7 @@ struct bContext;
 struct ReportList;
 struct Scene;
 struct Main;
 struct ReportList;
 struct Scene;
 struct Main;
+struct ID;
 
 int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *reports);
 
 
 int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *reports);
 
@@ -72,12 +73,17 @@ int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *r
 int BKE_read_file_from_memory(struct bContext *C, char *filebuf, int filelength, struct ReportList *reports);
 int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile, struct ReportList *reports);
 
 int BKE_read_file_from_memory(struct bContext *C, char *filebuf, int filelength, struct ReportList *reports);
 int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile, struct ReportList *reports);
 
+int BKE_read_file_userdef(const char *filepath, struct ReportList *reports);
+int BKE_write_file_userdef(const char *filepath, struct ReportList *reports);
+
 void free_blender(void);
 void initglobals(void);
 
 /* load new userdef from file, exit blender */
 void BKE_userdef_free(void);
 void free_blender(void);
 void initglobals(void);
 
 /* load new userdef from file, exit blender */
 void BKE_userdef_free(void);
-
+/* handle changes in userdef */
+void BKE_userdef_state(void);
+       
 /* set this callback when a UI is running */
 void set_blender_test_break_cb(void (*func)(void) );
 int blender_test_break(void);
 /* set this callback when a UI is running */
 void set_blender_test_break_cb(void (*func)(void) );
 int blender_test_break(void);
@@ -93,9 +99,15 @@ extern void BKE_reset_undo(void);
 extern char *BKE_undo_menu_string(void);
 extern void BKE_undo_number(struct bContext *C, int nr);
 extern const char *BKE_undo_get_name(int nr, int *active);
 extern char *BKE_undo_menu_string(void);
 extern void BKE_undo_number(struct bContext *C, int nr);
 extern const char *BKE_undo_get_name(int nr, int *active);
-extern void BKE_undo_save_quit(void);
+extern int BKE_undo_save_file(const struct bContext *C, char *filename);
 extern struct Main *BKE_undo_get_main(struct Scene **scene);
 
 extern struct Main *BKE_undo_get_main(struct Scene **scene);
 
+       /* copybuffer */
+void BKE_copybuffer_begin(void);
+void BKE_copybuffer_tag_ID(struct ID *id);
+int BKE_copybuffer_save(char *filename, struct ReportList *reports);
+       int BKE_copybuffer_paste(struct bContext *C, char *libname, struct ReportList *reports);
+
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index f6276a69d57742c792ae51e9e1568d0dcd4ea22c..38a88607119c3f6ef249aa84fe7ed7869217160d 100644 (file)
@@ -149,7 +149,7 @@ enum {
 /* #define G_FILE_SHOW_PROFILE   (1 << 6) */            /* deprecated */
 #define G_FILE_LOCK              (1 << 7)
 #define G_FILE_SIGN              (1 << 8)
 /* #define G_FILE_SHOW_PROFILE   (1 << 6) */            /* deprecated */
 #define G_FILE_LOCK              (1 << 7)
 #define G_FILE_SIGN              (1 << 8)
-/* #define G_FILE_PUBLISH        (1 << 9) */            /* deprecated */
+#define G_FILE_USERPREFS         (1 << 9)
 #define G_FILE_NO_UI             (1 << 10)
 /* #define G_FILE_GAME_TO_IPO    (1 << 11) */           /* deprecated */
 #define G_FILE_GAME_MAT          (1 << 12)              /* deprecated */
 #define G_FILE_NO_UI             (1 << 10)
 /* #define G_FILE_GAME_TO_IPO    (1 << 11) */           /* deprecated */
 #define G_FILE_GAME_MAT          (1 << 12)              /* deprecated */
index cfdcf1436bf0c519204b314e06a290ee79afc82f..b49c5fda475358d2be5420df5bc9b8ecf4cf9e98 100644 (file)
@@ -53,7 +53,8 @@ typedef struct Main {
        char name[1024]; /* 1024 = FILE_MAX */
        short versionfile, subversionfile;
        short minversionfile, minsubversionfile;
        char name[1024]; /* 1024 = FILE_MAX */
        short versionfile, subversionfile;
        short minversionfile, minsubversionfile;
-       int revision;   /* svn revision of binary that saved file */
+       int revision;           /* svn revision of binary that saved file */
+       short recovered;        /* indicate the main->name (file) is the recovered one */
        
        struct Library *curlib;
        ListBase scene;
        
        struct Library *curlib;
        ListBase scene;
index 9927c7a42ed6b87af041e416ded3539e26e898b1..3be07e72fc2f481ea6d0f112890fb0ce24f22593 100644 (file)
@@ -47,7 +47,7 @@ struct RenderData;
 struct SceneRenderLayer;
 struct Scene;
 struct Text;
 struct SceneRenderLayer;
 struct Scene;
 struct Text;
-struct Text;
+struct Main;
 
 #define SCE_COPY_NEW        0
 #define SCE_COPY_EMPTY      1
 
 #define SCE_COPY_NEW        0
 #define SCE_COPY_EMPTY      1
@@ -68,6 +68,7 @@ void free_qtcodecdata(struct QuicktimeCodecData *acd);
 
 void BKE_scene_free(struct Scene *sce);
 struct Scene *BKE_scene_add(const char *name);
 
 void BKE_scene_free(struct Scene *sce);
 struct Scene *BKE_scene_add(const char *name);
+struct Scene *BKE_main_scene_add(struct Main *bmain, const char *name);
 
 /* base functions */
 struct Base *BKE_scene_base_find(struct Scene *scene, struct Object *ob);
 
 /* base functions */
 struct Base *BKE_scene_base_find(struct Scene *scene, struct Object *ob);
index f0d201ea3f7a737813249ed635620c2e4467d22d..3aa425bdbb915f5d1cc458ad7edbaaa9327dbe13 100644 (file)
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
 #include "BKE_sound.h"
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
 #include "BKE_sound.h"
+
 #include "RE_pipeline.h"
 
 #include "RE_pipeline.h"
 
+#include "BLF_api.h"
+
 #include "BLO_undofile.h"
 #include "BLO_readfile.h" 
 #include "BLO_writefile.h" 
 #include "BLO_undofile.h"
 #include "BLO_readfile.h" 
 #include "BLO_writefile.h" 
@@ -230,6 +233,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
                /* but use new Scene pointer */
                curscene = bfd->curscene;
                if (curscene == NULL) curscene = bfd->main->scene.first;
                /* but use new Scene pointer */
                curscene = bfd->curscene;
                if (curscene == NULL) curscene = bfd->main->scene.first;
+               /* empty file, we add a scene to make Blender work */
+               if (curscene == NULL) curscene = BKE_main_scene_add(bfd->main, "Empty");
+               
                /* and we enforce curscene to be in current screen */
                if (curscreen) curscreen->scene = curscene;  /* can run in bgmode */
 
                /* and we enforce curscene to be in current screen */
                if (curscreen) curscreen->scene = curscene;  /* can run in bgmode */
 
@@ -270,7 +276,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
                G.fileflags = bfd->fileflags;
                CTX_wm_manager_set(C, G.main->wm.first);
                CTX_wm_screen_set(C, bfd->curscreen);
                G.fileflags = bfd->fileflags;
                CTX_wm_manager_set(C, G.main->wm.first);
                CTX_wm_screen_set(C, bfd->curscreen);
-               CTX_data_scene_set(C, bfd->curscreen->scene);
+               CTX_data_scene_set(C, bfd->curscene);
                CTX_wm_area_set(C, NULL);
                CTX_wm_region_set(C, NULL);
                CTX_wm_menu_set(C, NULL);
                CTX_wm_area_set(C, NULL);
                CTX_wm_region_set(C, NULL);
                CTX_wm_menu_set(C, NULL);
@@ -310,22 +316,23 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        if (G.main->versionfile < 250)
                do_versions_ipos_to_animato(G.main);
        
        if (G.main->versionfile < 250)
                do_versions_ipos_to_animato(G.main);
        
-       if (recover && bfd->filename[0] && G.relbase_valid) {
+       G.main->recovered = 0;
+       
+       /* startup.blend or recovered startup */
+       if (bfd->filename[0] == 0) {
+               G.main->name[0] = 0;
+       }
+       else if (recover && G.relbase_valid) {
                /* in case of autosave or quit.blend, use original filename instead
                 * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
                filepath = bfd->filename;
                /* in case of autosave or quit.blend, use original filename instead
                 * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
                filepath = bfd->filename;
+               G.main->recovered = 1;
+       
+               /* these are the same at times, should never copy to the same location */
+               if (G.main->name != filepath)
+                       BLI_strncpy(G.main->name, filepath, FILE_MAX);
        }
        }
-#if 0
-       else if (!G.relbase_valid) {
-               /* otherwise, use an empty string as filename, rather than <memory2> */
-               filepath = "";
-       }
-#endif
        
        
-       /* these are the same at times, should never copy to the same location */
-       if (G.main->name != filepath)
-               BLI_strncpy(G.main->name, filepath, FILE_MAX);
-
        /* baseflags, groups, make depsgraph, etc */
        BKE_scene_set_background(G.main, CTX_data_scene(C));
 
        /* baseflags, groups, make depsgraph, etc */
        BKE_scene_set_background(G.main, CTX_data_scene(C));
 
@@ -334,7 +341,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        }
 
        MEM_freeN(bfd);
        }
 
        MEM_freeN(bfd);
-
+       
        (void)curscene; /* quiet warning */
 }
 
        (void)curscene; /* quiet warning */
 }
 
@@ -393,6 +400,14 @@ void BKE_userdef_free(void)
        BLI_freelistN(&U.addons);
 }
 
        BLI_freelistN(&U.addons);
 }
 
+/* handle changes in settings that need recalc */
+void BKE_userdef_state(void)
+{
+       BLF_default_dpi(U.pixelsize * U.dpi);
+       U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
+
+}
+
 int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
 {
        BlendFileData *bfd;
 int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
 {
        BlendFileData *bfd;
@@ -439,14 +454,57 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report
        BlendFileData *bfd;
 
        bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
        BlendFileData *bfd;
 
        bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
-       if (bfd)
+       if (bfd) {
+               /* remove the unused screens and wm */
+               while (bfd->main->wm.first)
+                       BKE_libblock_free(&bfd->main->wm, bfd->main->wm.first);
+               while (bfd->main->screen.first)
+                       BKE_libblock_free(&bfd->main->screen, bfd->main->screen.first);
+               
                setup_app_data(C, bfd, "<memory1>");
                setup_app_data(C, bfd, "<memory1>");
+       }
        else
                BKE_reports_prepend(reports, "Loading failed: ");
 
        return (bfd ? 1 : 0);
 }
 
        else
                BKE_reports_prepend(reports, "Loading failed: ");
 
        return (bfd ? 1 : 0);
 }
 
+/* only read the userdef from a .blend */
+int BKE_read_file_userdef(const char *filepath, ReportList *reports)
+{
+       BlendFileData *bfd;
+       int retval = 0;
+       
+       bfd = BLO_read_from_file(filepath, reports);
+       if (bfd->user) {
+               retval = BKE_READ_FILE_OK_USERPREFS;
+               
+               /* only here free userdef themes... */
+               BKE_userdef_free();
+               
+               U = *bfd->user;
+               MEM_freeN(bfd->user);
+       }
+       free_main(bfd->main);
+       MEM_freeN(bfd);
+       
+       return retval;
+}
+
+/* only write the userdef in a .blend */
+int BKE_write_file_userdef(const char *filepath, ReportList *reports)
+{
+       Main *mainb = MEM_callocN(sizeof(Main), "empty main");
+       int retval = 0;
+       
+       if (BLO_write_file(mainb, filepath, G_FILE_USERPREFS, reports, NULL)) {
+               retval = 1;
+       }
+       
+       MEM_freeN(mainb);
+       
+       return retval;
+}
 
 /* *****************  testing for break ************* */
 
 
 /* *****************  testing for break ************* */
 
@@ -728,48 +786,39 @@ char *BKE_undo_menu_string(void)
        return menu;
 }
 
        return menu;
 }
 
-/* saves quit.blend */
-void BKE_undo_save_quit(void)
+/* saves .blend using undo buffer, returns 1 == success */
+int BKE_undo_save_file(const bContext *C, char *filename)
 {
        UndoElem *uel;
        MemFileChunk *chunk;
 {
        UndoElem *uel;
        MemFileChunk *chunk;
-       char str[FILE_MAX];
        const int flag = O_BINARY + O_WRONLY + O_CREAT + O_TRUNC + O_EXCL;
        int file;
 
        if ((U.uiflag & USER_GLOBALUNDO) == 0) {
        const int flag = O_BINARY + O_WRONLY + O_CREAT + O_TRUNC + O_EXCL;
        int file;
 
        if ((U.uiflag & USER_GLOBALUNDO) == 0) {
-               return;
+               return 0;
        }
 
        uel = curundo;
        if (uel == NULL) {
                fprintf(stderr, "No undo buffer to save recovery file\n");
        }
 
        uel = curundo;
        if (uel == NULL) {
                fprintf(stderr, "No undo buffer to save recovery file\n");
-               return;
+               return 0;
        }
 
        }
 
-       /* no undo state to save */
-       if (undobase.first == undobase.last) {
-               return;
-       }
-
-       /* save the undo state as quit.blend */
-       BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
-
        /* first try create the file, if it exists call without 'O_CREAT',
         * to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
        errno = 0;
        /* first try create the file, if it exists call without 'O_CREAT',
         * to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
        errno = 0;
-       file = BLI_open(str, flag, 0666);
+       file = BLI_open(filename, flag, 0666);
        if (file == -1) {
                if (errno == EEXIST) {
                        errno = 0;
        if (file == -1) {
                if (errno == EEXIST) {
                        errno = 0;
-                       file = BLI_open(str, flag & ~O_CREAT, 0666);
+                       file = BLI_open(filename, flag & ~O_CREAT, 0666);
                }
        }
 
        if (file == -1) {
                fprintf(stderr, "Unable to save '%s': %s\n",
                }
        }
 
        if (file == -1) {
                fprintf(stderr, "Unable to save '%s': %s\n",
-                       str, errno ? strerror(errno) : "Unknown error opening file");
-               return;
+                       filename, errno ? strerror(errno) : "Unknown error opening file");
+               return 0;
        }
 
        for (chunk = uel->memfile.chunks.first; chunk; chunk = chunk->next) {
        }
 
        for (chunk = uel->memfile.chunks.first; chunk; chunk = chunk->next) {
@@ -777,16 +826,15 @@ void BKE_undo_save_quit(void)
                        break;
                }
        }
                        break;
                }
        }
-
+       
        close(file);
        
        if (chunk) {
                fprintf(stderr, "Unable to save '%s': %s\n",
        close(file);
        
        if (chunk) {
                fprintf(stderr, "Unable to save '%s': %s\n",
-                       str, errno ? strerror(errno) : "Unknown error writing file");
-       }
-       else {
-               printf("Saved session recovery to '%s'\n", str);
+                       filename, errno ? strerror(errno) : "Unknown error writing file");
+               return 0;
        }
        }
+       return 1;
 }
 
 /* sets curscene */
 }
 
 /* sets curscene */
@@ -806,3 +854,131 @@ Main *BKE_undo_get_main(Scene **scene)
        return mainp;
 }
 
        return mainp;
 }
 
+/* ************** copy paste .blend, partial saves ********** */
+
+/* assumes data is in G.main */
+
+void BKE_copybuffer_begin(void)
+{
+       /* set all id flags to zero; */
+       flag_all_listbases_ids(LIB_NEED_EXPAND | LIB_DOIT, 0);
+}
+
+void BKE_copybuffer_tag_ID(ID *id)
+{
+       id->flag |= LIB_NEED_EXPAND | LIB_DOIT;
+}
+
+static void copybuffer_doit(void *UNUSED(handle), Main *UNUSED(bmain), void *vid)
+{
+       if (vid) {
+               ID *id = vid;
+               id->flag |= LIB_NEED_EXPAND | LIB_DOIT;
+       }
+}
+
+/* frees main in end */
+int BKE_copybuffer_save(char *filename, ReportList *reports)
+{
+       Main *mainb = MEM_callocN(sizeof(Main), "copybuffer");
+       ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
+       int a, retval;
+       
+       BLO_main_expander(copybuffer_doit);
+       BLO_expand_main(NULL, G.main);
+       
+       /* move over all tagged blocks */
+       set_listbasepointers(G.main, fromarray);
+       a = set_listbasepointers(mainb, lbarray);
+       while (a--) {
+               ID *id, *nextid;
+               ListBase *lb1 = lbarray[a], *lb2 = fromarray[a];
+               
+               for (id = lb2->first; id; id= nextid) {
+                       nextid = id->next;
+                       if (id->flag & LIB_DOIT) {
+                               BLI_remlink(lb2, id);
+                               BLI_addtail(lb1, id);
+                       }
+               }
+       }
+       
+       
+       /* save the buffer */
+       retval = BLO_write_file(mainb, filename, 0, reports, NULL);
+       
+       /* move back the main, now sorted again */
+       set_listbasepointers(G.main, lbarray);
+       a = set_listbasepointers(mainb, fromarray);
+       while (a--) {
+               ID *id;
+               ListBase *lb1 = lbarray[a], *lb2 = fromarray[a];
+               
+               while (lb2->first) {
+                       id = lb2->first;
+                       BLI_remlink(lb2, id);
+                       BLI_addtail(lb1, id);
+                       id_sort_by_name(lb1, id);
+               }
+       }
+       
+       MEM_freeN(mainb);
+       
+       /* set id flag to zero; */
+       flag_all_listbases_ids(LIB_NEED_EXPAND | LIB_DOIT, 0);
+       
+       return retval;
+}
+
+/* return success (1) */
+int BKE_copybuffer_paste(bContext *C, char *libname, ReportList *reports)
+{
+       Main *bmain = CTX_data_main(C);
+       Scene *scene = CTX_data_scene(C);
+       Main *mainl = NULL;
+       Library *lib;
+       BlendHandle *bh;
+               
+       bh = BLO_blendhandle_from_file(libname, reports);
+       
+       if (bh == NULL) {
+               /* error reports will have been made by BLO_blendhandle_from_file() */
+               return 0;
+       }
+
+       BKE_scene_base_deselect_all(scene);
+       
+       /* tag everything, all untagged data can be made local
+        * its also generally useful to know what is new
+        *
+        * take extra care flag_all_listbases_ids(LIB_LINK_TAG, 0) is called after! */
+       flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
+       
+       /* here appending/linking starts */
+       mainl = BLO_library_append_begin(bmain, &bh, libname);
+       
+       BLO_library_append_all(mainl, bh);
+
+       BLO_library_append_end(C, mainl, &bh, 0, 0);
+       
+       /* mark all library linked objects to be updated */
+       recalc_all_library_objects(bmain);
+       IMB_colormanagement_check_file_config(bmain);
+       
+       /* append, rather than linking */
+       lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
+       BKE_library_make_local(bmain, lib, 1);
+       
+       /* important we unset, otherwise these object wont
+        * link into other scenes from this blend file */
+       flag_all_listbases_ids(LIB_PRE_EXISTING, 0);
+       
+       /* recreate dependency graph to include new objects */
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
+       
+       BLO_blendhandle_close(bh);
+       /* remove library... */
+       
+       return 1;
+}
index 9bb2fb2de5234970d06821fb731101da7d60d14d..47f0da1816330e46e5297310b102590e45180082 100644 (file)
@@ -372,9 +372,8 @@ void BKE_scene_free(Scene *sce)
        BKE_color_managed_view_settings_free(&sce->view_settings);
 }
 
        BKE_color_managed_view_settings_free(&sce->view_settings);
 }
 
-Scene *BKE_scene_add(const char *name)
+static Scene *scene_add(Main *bmain, const char *name)
 {
 {
-       Main *bmain = G.main;
        Scene *sce;
        ParticleEditSettings *pset;
        int a;
        Scene *sce;
        ParticleEditSettings *pset;
        int a;
@@ -605,6 +604,16 @@ Scene *BKE_scene_add(const char *name)
        return sce;
 }
 
        return sce;
 }
 
+Scene *BKE_scene_add(const char *name)
+{
+       return scene_add(G.main, name);
+}
+
+Scene *BKE_main_scene_add(Main *bmain, const char *name)
+{
+       return scene_add(bmain, name);
+}
+
 Base *BKE_scene_base_find(Scene *scene, Object *ob)
 {
        return BLI_findptr(&scene->base, ob, offsetof(Base, object));
 Base *BKE_scene_base_find(Scene *scene, Object *ob)
 {
        return BLI_findptr(&scene->base, ob, offsetof(Base, object));
index 5e47adf25ef37541b76aac0754f28e580a516d7b..43724d8dd443f3a3754bea8f5e83d8361e63460a 100644 (file)
@@ -67,6 +67,7 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
 #define BLENDER_RESOURCE_PATH_SYSTEM    2
 
 #define BLENDER_STARTUP_FILE    "startup.blend"
 #define BLENDER_RESOURCE_PATH_SYSTEM    2
 
 #define BLENDER_STARTUP_FILE    "startup.blend"
+#define BLENDER_USERPREF_FILE   "userpref.blend"
 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
 #define BLENDER_HISTORY_FILE    "recent-files.txt"
 
 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
 #define BLENDER_HISTORY_FILE    "recent-files.txt"
 
index 16a4d8d46ec8e9d5fd57fe28622c219c343b41bc..2ee5decdfac0eda98c1a8fedd3d60b228fcfe249 100644 (file)
@@ -240,13 +240,32 @@ struct ID *BLO_library_append_named_part_ex(const struct bContext *C, struct Mai
 
 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag);
 
 
 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag);
 
+void BLO_library_append_all(struct Main *mainl, BlendHandle *bh);
+
 void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
 
 BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports);
 void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
 
 BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports);
-
+       
 /* internal function but we need to expose it */
 void blo_lib_link_screen_restore(struct Main *newmain, struct bScreen *curscreen, struct Scene *curscene);
 
 /* internal function but we need to expose it */
 void blo_lib_link_screen_restore(struct Main *newmain, struct bScreen *curscreen, struct Scene *curscene);
 
+/**
+ * BLO_expand_main() loops over all ID data in Main to mark relations.
+ * Set (id->flag & LIB_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.
+ *
+ * \param expand_doit_func() gets called for each ID block it finds
+ */
+void BLO_main_expander(void (*expand_doit_func)(void *, struct Main *, void *));
+
+/**
+ * BLO_expand_main() loops over all ID data in Main to mark relations.
+ * Set (id->flag & LIB_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.
+ *
+ * \param fdhandle usually filedata, or own handle
+ * \param mainvar the Main database to expand
+ */
+void BLO_expand_main(void *fdhandle, struct Main *mainvar);
+       
 #ifdef __cplusplus
 } 
 #endif
 #ifdef __cplusplus
 } 
 #endif
index 203af1d83160a46a36690ddacefcf85d24ffa7a1..cf4deb7213df5f9e04809a53d8fbaa557a4e0e63 100644 (file)
@@ -2981,7 +2981,7 @@ static void direct_link_text(FileData *fd, Text *text)
        if (text->flags & TXT_ISEXT) {
                BKE_text_reload(text);
                }
        if (text->flags & TXT_ISEXT) {
                BKE_text_reload(text);
                }
-               else {
+               /* else { */
 #endif
        
        link_list(fd, &text->lines);
 #endif
        
        link_list(fd, &text->lines);
@@ -5160,6 +5160,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
                win->drawdata = NULL;
                win->drawmethod = -1;
                win->drawfail = 0;
                win->drawdata = NULL;
                win->drawmethod = -1;
                win->drawfail = 0;
+               win->active = 0;
        }
        
        wm->timers.first = wm->timers.last = NULL;
        }
        
        wm->timers.first = wm->timers.last = NULL;
@@ -5231,27 +5232,6 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 
 /* ****************** READ SCREEN ***************** */
 
 
 /* ****************** READ SCREEN ***************** */
 
-static void butspace_version_132(SpaceButs *buts)
-{
-       buts->v2d.tot.xmin = 0.0f;
-       buts->v2d.tot.ymin = 0.0f;
-       buts->v2d.tot.xmax = 1279.0f;
-       buts->v2d.tot.ymax = 228.0f;
-       
-       buts->v2d.min[0] = 256.0f;
-       buts->v2d.min[1] = 42.0f;
-       
-       buts->v2d.max[0] = 2048.0f;
-       buts->v2d.max[1] = 450.0f;
-       
-       buts->v2d.minzoom = 0.5f;
-       buts->v2d.maxzoom = 1.21f;
-       
-       buts->v2d.scroll = 0;
-       buts->v2d.keepzoom = 1;
-       buts->v2d.keeptot = 1;
-}
-
 /* note: file read without screens option G_FILE_NO_UI; 
  * check lib pointers in call below */
 static void lib_link_screen(FileData *fd, Main *main)
 /* note: file read without screens option G_FILE_NO_UI; 
  * check lib pointers in call below */
 static void lib_link_screen(FileData *fd, Main *main)
@@ -5305,18 +5285,9 @@ static void lib_link_screen(FileData *fd, Main *main)
                                        else if (sl->spacetype == SPACE_BUTS) {
                                                SpaceButs *sbuts = (SpaceButs *)sl;
                                                sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid);
                                        else if (sl->spacetype == SPACE_BUTS) {
                                                SpaceButs *sbuts = (SpaceButs *)sl;
                                                sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid);
-                                               sbuts->mainbo = sbuts->mainb;
-                                               sbuts->mainbuser = sbuts->mainb;
-                                               if (main->versionfile < 132)
-                                                       butspace_version_132(sbuts);
                                        }
                                        else if (sl->spacetype == SPACE_FILE) {
                                        }
                                        else if (sl->spacetype == SPACE_FILE) {
-                                               SpaceFile *sfile = (SpaceFile *)sl;
-                                               sfile->files = NULL;
-                                               sfile->op = NULL;
-                                               sfile->layout = NULL;
-                                               sfile->folders_prev = NULL;
-                                               sfile->folders_next = NULL;
+                                               ;
                                        }
                                        else if (sl->spacetype == SPACE_ACTION) {
                                                SpaceAction *saction = (SpaceAction *)sl;
                                        }
                                        else if (sl->spacetype == SPACE_ACTION) {
                                                SpaceAction *saction = (SpaceAction *)sl;
@@ -5348,12 +5319,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                 */
                                                sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
 
                                                 */
                                                sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
 
-                                               sseq->scopes.reference_ibuf = NULL;
-                                               sseq->scopes.zebra_ibuf = NULL;
-                                               sseq->scopes.waveform_ibuf = NULL;
-                                               sseq->scopes.sep_waveform_ibuf = NULL;
-                                               sseq->scopes.vector_ibuf = NULL;
-                                               sseq->scopes.histogram_ibuf = NULL;
                                        }
                                        else if (sl->spacetype == SPACE_NLA) {
                                                SpaceNla *snla= (SpaceNla *)sl;
                                        }
                                        else if (sl->spacetype == SPACE_NLA) {
                                                SpaceNla *snla= (SpaceNla *)sl;
@@ -5368,7 +5333,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceText *st= (SpaceText *)sl;
                                                
                                                st->text= newlibadr(fd, sc->id.lib, st->text);
                                                SpaceText *st= (SpaceText *)sl;
                                                
                                                st->text= newlibadr(fd, sc->id.lib, st->text);
-                                               st->drawcache= NULL;
                                        }
                                        else if (sl->spacetype == SPACE_SCRIPT) {
                                                SpaceScript *scpt = (SpaceScript *)sl;
                                        }
                                        else if (sl->spacetype == SPACE_SCRIPT) {
                                                SpaceScript *scpt = (SpaceScript *)sl;
@@ -5385,7 +5349,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                TreeStoreElem *tselem;
                                                int a;
                                                
                                                TreeStoreElem *tselem;
                                                int a;
                                                
-                                               so->tree.first = so->tree.last= NULL;
                                                so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
                                                
                                                if (so->treestore) {
                                                so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
                                                
                                                if (so->treestore) {
@@ -5399,7 +5362,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceNode *snode = (SpaceNode *)sl;
                                                
                                                snode->id = newlibadr(fd, sc->id.lib, snode->id);
                                                SpaceNode *snode = (SpaceNode *)sl;
                                                
                                                snode->id = newlibadr(fd, sc->id.lib, snode->id);
-                                               snode->edittree = NULL;
                                                
                                                if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
                                                        /* internal data, a bit patchy */
                                                
                                                if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
                                                        /* internal data, a bit patchy */
@@ -5420,19 +5382,12 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                else {
                                                        snode->nodetree = newlibadr_us(fd, sc->id.lib, snode->nodetree);
                                                }
                                                else {
                                                        snode->nodetree = newlibadr_us(fd, sc->id.lib, snode->nodetree);
                                                }
-                                               
-                                               snode->linkdrag.first = snode->linkdrag.last = NULL;
                                        }
                                        else if (sl->spacetype == SPACE_CLIP) {
                                                SpaceClip *sclip = (SpaceClip *)sl;
                                                
                                                sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
                                                sclip->mask_info.mask = newlibadr_us(fd, sc->id.lib, sclip->mask_info.mask);
                                        }
                                        else if (sl->spacetype == SPACE_CLIP) {
                                                SpaceClip *sclip = (SpaceClip *)sl;
                                                
                                                sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
                                                sclip->mask_info.mask = newlibadr_us(fd, sc->id.lib, sclip->mask_info.mask);
-                                               
-                                               sclip->scopes.track_search = NULL;
-                                               sclip->scopes.track_preview = NULL;
-                                               sclip->draw_context = NULL;
-                                               sclip->scopes.ok = 0;
                                        }
                                        else if (sl->spacetype == SPACE_LOGIC) {
                                                SpaceLogic *slogic = (SpaceLogic *)sl;
                                        }
                                        else if (sl->spacetype == SPACE_LOGIC) {
                                                SpaceLogic *slogic = (SpaceLogic *)sl;
@@ -5774,6 +5729,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
        ar->type = NULL;
        ar->swap = 0;
        ar->do_draw = FALSE;
        ar->type = NULL;
        ar->swap = 0;
        ar->do_draw = FALSE;
+       ar->regiontimer = NULL;
        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
 }
 
        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
 }
 
@@ -5918,6 +5874,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        soops->treestore->totelem = soops->treestore->usedelem;
                                        soops->storeflag |= SO_TREESTORE_CLEANUP;       // at first draw
                                }
                                        soops->treestore->totelem = soops->treestore->usedelem;
                                        soops->storeflag |= SO_TREESTORE_CLEANUP;       // at first draw
                                }
+                                soops->tree.first = soops->tree.last= NULL;
                        }
                        else if (sl->spacetype == SPACE_IMAGE) {
                                SpaceImage *sima = (SpaceImage *)sl;
                        }
                        else if (sl->spacetype == SPACE_IMAGE) {
                                SpaceImage *sima = (SpaceImage *)sl;
@@ -5950,6 +5907,13 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        snode->gpd = newdataadr(fd, snode->gpd);
                                        direct_link_gpencil(fd, snode->gpd);
                                }
                                        snode->gpd = newdataadr(fd, snode->gpd);
                                        direct_link_gpencil(fd, snode->gpd);
                                }
+                               snode->edittree = NULL;
+                               snode->linkdrag.first = snode->linkdrag.last = NULL;
+                       }
+                       else if (sl->spacetype == SPACE_TEXT) {
+                               SpaceText *st= (SpaceText *)sl;
+                               
+                               st->drawcache= NULL;
                        }
                        else if (sl->spacetype == SPACE_TIME) {
                                SpaceTime *stime = (SpaceTime *)sl;
                        }
                        else if (sl->spacetype == SPACE_TIME) {
                                SpaceTime *stime = (SpaceTime *)sl;
@@ -5965,6 +5929,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                }
                        }
                        else if (sl->spacetype == SPACE_SEQ) {
                                }
                        }
                        else if (sl->spacetype == SPACE_SEQ) {
+                               SpaceSeq *sseq = (SpaceSeq *)sl;
+                               
                                /* grease pencil data is not a direct data and can't be linked from direct_link*
                                 * functions, it should be linked from lib_link* functions instead
                                 *
                                /* grease pencil data is not a direct data and can't be linked from direct_link*
                                 * functions, it should be linked from lib_link* functions instead
                                 *
@@ -5973,17 +5939,26 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                 * simple return NULL here (sergey)
                                 */
 #if 0
                                 * simple return NULL here (sergey)
                                 */
 #if 0
-                               SpaceSeq *sseq = (SpaceSeq *)sl;
                                if (sseq->gpd) {
                                        sseq->gpd = newdataadr(fd, sseq->gpd);
                                        direct_link_gpencil(fd, sseq->gpd);
                                }
 #endif
                                if (sseq->gpd) {
                                        sseq->gpd = newdataadr(fd, sseq->gpd);
                                        direct_link_gpencil(fd, sseq->gpd);
                                }
 #endif
+                               sseq->scopes.reference_ibuf = NULL;
+                               sseq->scopes.zebra_ibuf = NULL;
+                               sseq->scopes.waveform_ibuf = NULL;
+                               sseq->scopes.sep_waveform_ibuf = NULL;
+                               sseq->scopes.vector_ibuf = NULL;
+                               sseq->scopes.histogram_ibuf = NULL;
+
                        }
                        else if (sl->spacetype == SPACE_BUTS) {
                                SpaceButs *sbuts = (SpaceButs *)sl;
                        }
                        else if (sl->spacetype == SPACE_BUTS) {
                                SpaceButs *sbuts = (SpaceButs *)sl;
+                               
                                sbuts->path= NULL;
                                sbuts->texuser= NULL;
                                sbuts->path= NULL;
                                sbuts->texuser= NULL;
+                               sbuts->mainbo = sbuts->mainb;
+                               sbuts->mainbuser = sbuts->mainb;
                        }
                        else if (sl->spacetype == SPACE_CONSOLE) {
                                SpaceConsole *sconsole = (SpaceConsole *)sl;
                        }
                        else if (sl->spacetype == SPACE_CONSOLE) {
                                SpaceConsole *sconsole = (SpaceConsole *)sl;
@@ -6023,6 +5998,14 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                sfile->op = NULL;
                                sfile->params = newdataadr(fd, sfile->params);
                        }
                                sfile->op = NULL;
                                sfile->params = newdataadr(fd, sfile->params);
                        }
+                       else if (sl->spacetype == SPACE_CLIP) {
+                               SpaceClip *sclip = (SpaceClip *)sl;
+                               
+                               sclip->scopes.track_search = NULL;
+                               sclip->scopes.track_preview = NULL;
+                               sclip->draw_context = NULL;
+                               sclip->scopes.ok = 0;
+                       }
                }
                
                sa->actionzones.first = sa->actionzones.last = NULL;
                }
                
                sa->actionzones.first = sa->actionzones.last = NULL;
@@ -8401,8 +8384,11 @@ static void lib_link_all(FileData *fd, Main *main)
 {
        oldnewmap_sort(fd);
        
 {
        oldnewmap_sort(fd);
        
-       lib_link_windowmanager(fd, main);
-       lib_link_screen(fd, main);
+       /* No load UI for undo memfiles */
+       if (fd->memfile == NULL) {
+               lib_link_windowmanager(fd, main);
+               lib_link_screen(fd, main);
+       }
        lib_link_scene(fd, main);
        lib_link_object(fd, main);
        lib_link_curve(fd, main);
        lib_link_scene(fd, main);
        lib_link_object(fd, main);
        lib_link_curve(fd, main);
@@ -8675,9 +8661,10 @@ static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
        return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
 }
 
        return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
 }
 
-static void expand_doit(FileData *fd, Main *mainvar, void *old)
+static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
 {
        BHead *bhead;
 {
        BHead *bhead;
+       FileData *fd = fdhandle;
        ID *id;
        
        bhead = find_bhead(fd, old);
        ID *id;
        
        bhead = find_bhead(fd, old);
@@ -8744,7 +8731,7 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
        }
 }
 
        }
 }
 
-
+static void (*expand_doit)(void *, Main *, void *);
 
 // XXX deprecated - old animation system
 static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
 
 // XXX deprecated - old animation system
 static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
@@ -9455,14 +9442,18 @@ static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
        }
 }
 
        }
 }
 
-static void expand_main(FileData *fd, Main *mainvar)
+void BLO_main_expander(void (*expand_doit_func)(void *, Main *, void *))
+{
+       expand_doit = expand_doit_func;
+}
+
+void BLO_expand_main(void *fdhandle, Main *mainvar)
 {
        ListBase *lbarray[MAX_LIBARRAY];
 {
        ListBase *lbarray[MAX_LIBARRAY];
+       FileData *fd = fdhandle;
        ID *id;
        int a, do_it = TRUE;
        
        ID *id;
        int a, do_it = TRUE;
        
-       if (fd == NULL) return;
-       
        while (do_it) {
                do_it = FALSE;
                
        while (do_it) {
                do_it = FALSE;
                
@@ -9553,6 +9544,9 @@ static void expand_main(FileData *fd, Main *mainvar)
        }
 }
 
        }
 }
 
+
+/* ***************************** */
+       
 static int object_in_any_scene(Main *mainvar, Object *ob)
 {
        Scene *sce;
 static int object_in_any_scene(Main *mainvar, Object *ob)
 {
        Scene *sce;
@@ -9701,6 +9695,28 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons
        return (found) ? id : NULL;
 }
 
        return (found) ? id : NULL;
 }
 
+/* simple reader for copy/paste buffers */
+void BLO_library_append_all(Main *mainl, BlendHandle *bh)
+{
+       FileData *fd = (FileData *)(bh);
+       BHead *bhead;
+       ID *id = NULL;
+       
+       for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
+               if (bhead->code == ENDB)
+                       break;
+               if (bhead->code == ID_OB)
+                       read_libblock(fd, mainl, bhead, LIB_TESTIND, &id);
+                       
+               if (id) {
+                       /* sort by name in list */
+                       ListBase *lb = which_libbase(mainl, GS(id->name));
+                       id_sort_by_name(lb, id);
+               }
+       }
+}
+
+
 static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag)
 {
        ID *id= append_named_part(mainl, fd, idname, idcode);
 static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag)
 {
        ID *id= append_named_part(mainl, fd, idname, idcode);
@@ -9805,8 +9821,11 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
        Main *mainvar;
        Library *curlib;
        
        Main *mainvar;
        Library *curlib;
        
+       /* expander now is callback function */
+       BLO_main_expander(expand_doit_library);
+       
        /* make main consistent */
        /* make main consistent */
-       expand_main(*fd, mainl);
+       BLO_expand_main(*fd, mainl);
        
        /* do this when expand found other libs */
        read_libraries(*fd, (*fd)->mainlist);
        
        /* do this when expand found other libs */
        read_libraries(*fd, (*fd)->mainlist);
@@ -9901,6 +9920,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
        ListBase *lbarray[MAX_LIBARRAY];
        int a, do_it = TRUE;
        
        ListBase *lbarray[MAX_LIBARRAY];
        int a, do_it = TRUE;
        
+       /* expander now is callback function */
+       BLO_main_expander(expand_doit_library);
+       
        while (do_it) {
                do_it = FALSE;
                
        while (do_it) {
                do_it = FALSE;
                
@@ -10000,7 +10022,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                                }
                                        }
                                        
                                                }
                                        }
                                        
-                                       expand_main(fd, mainptr);
+                                       BLO_expand_main(fd, mainptr);
                                }
                        }
                        
                                }
                        }
                        
index b010cae68933884358548e810cc8bc3d3d94e108..cee61858467064b1ff089f7f419accbc79777c1d 100644 (file)
@@ -2515,6 +2515,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
 
                sc= sc->id.next;
        }
 
                sc= sc->id.next;
        }
+       
+       /* flush helps the compression for undo-save */
+       mywrite(wd, MYWRITE_FLUSH, 0);
 }
 
 static void write_libraries(WriteData *wd, Main *main)
 }
 
 static void write_libraries(WriteData *wd, Main *main)
@@ -2877,7 +2880,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
 
        /* XXX still remap G */
        fg.curscreen= screen;
 
        /* XXX still remap G */
        fg.curscreen= screen;
-       fg.curscene= screen->scene;
+       fg.curscene= screen? screen->scene : NULL;
        fg.displaymode= G.displaymode;
        fg.winpos= G.winpos;
 
        fg.displaymode= G.displaymode;
        fg.winpos= G.winpos;
 
@@ -2886,7 +2889,6 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
 
        fg.globalf= G.f;
        BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
 
        fg.globalf= G.f;
        BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
-
        sprintf(subvstr, "%4d", BLENDER_SUBVERSION);
        memcpy(fg.subvstr, subvstr, 4);
        
        sprintf(subvstr, "%4d", BLENDER_SUBVERSION);
        memcpy(fg.subvstr, subvstr, 4);
        
@@ -2938,11 +2940,8 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
        write_thumb(wd, thumb);
        write_global(wd, write_flags, mainvar);
 
        write_thumb(wd, thumb);
        write_global(wd, write_flags, mainvar);
 
-       /* no UI save in undo */
-       if (current==NULL) {
-               write_windowmanagers(wd, &mainvar->wm);
-               write_screens  (wd, &mainvar->screen);
-       }
+       write_windowmanagers(wd, &mainvar->wm);
+       write_screens  (wd, &mainvar->screen);
        write_movieclips (wd, &mainvar->movieclip);
        write_masks    (wd, &mainvar->mask);
        write_scenes   (wd, &mainvar->scene);
        write_movieclips (wd, &mainvar->movieclip);
        write_masks    (wd, &mainvar->mask);
        write_scenes   (wd, &mainvar->scene);
@@ -3027,7 +3026,6 @@ static int do_history(const char *name, ReportList *reports)
 /* return: success (1) */
 int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, const int *thumb)
 {
 /* return: success (1) */
 int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, const int *thumb)
 {
-       char userfilename[FILE_MAX];
        char tempname[FILE_MAX+1];
        int file, err, write_user_block;
 
        char tempname[FILE_MAX+1];
        int file, err, write_user_block;
 
@@ -3074,8 +3072,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
                }
        }
 
                }
        }
 
-       BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
-       write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
+       write_user_block= write_flags & G_FILE_USERPREFS;
 
        if (write_flags & G_FILE_RELATIVE_REMAP)
                BLI_bpath_relative_convert(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */
 
        if (write_flags & G_FILE_RELATIVE_REMAP)
                BLI_bpath_relative_convert(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */
@@ -3151,3 +3148,4 @@ int BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int wr
        if (err==0) return 1;
        return 0;
 }
        if (err==0) return 1;
        return 0;
 }
+
index 9ceecd60bef85dc528f8840e0641eb49083645f4..f5c9bfb4cf5d2fa97f908fc006dadc877effbde0 100644 (file)
@@ -82,7 +82,7 @@
 #define EXTRA_SCROLL_PAD    100.0f
 
 /* size of indent steps */
 #define EXTRA_SCROLL_PAD    100.0f
 
 /* size of indent steps */
-#define INDENT_STEP_SIZE    7
+#define INDENT_STEP_SIZE    (0.35f * U.widget_unit)
 
 /* size of string buffers used for animation channel displayed names */
 #define ANIM_CHAN_NAME_SIZE 256
 
 /* size of string buffers used for animation channel displayed names */
 #define ANIM_CHAN_NAME_SIZE 256
@@ -305,15 +305,15 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
        if (ale->id) {
                /* texture animdata */
                if (GS(ale->id->name) == ID_TE) {
        if (ale->id) {
                /* texture animdata */
                if (GS(ale->id->name) == ID_TE) {
-                       offset += 21;
+                       offset += U.widget_unit;
                }
                /* materials and particles animdata */
                else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
                }
                /* materials and particles animdata */
                else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
-                       offset += 14;
+                       offset += (short)(0.7f * U.widget_unit);
                        
                /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */
                else if (ac->datatype != ANIMCONT_ACTION)
                        
                /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */
                else if (ac->datatype != ANIMCONT_ACTION)
-                       offset += 14;
+                       offset += (short)(0.7f * U.widget_unit);
                        
                /* nodetree animdata */
                if (GS(ale->id->name) == ID_NT) {
                        
                /* nodetree animdata */
                if (GS(ale->id->name) == ID_NT) {
@@ -2911,12 +2911,12 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting,
 
 /* --------------------------- */
 
 
 /* --------------------------- */
 
-// XXX hardcoded size of icons
-#define ICON_WIDTH      17
-// XXX hardcoded width of sliders
-#define SLIDER_WIDTH    80
-// XXX hardcoded width of rename textboxes
-#define RENAME_TEXT_WIDTH 100
+// size of icons
+#define ICON_WIDTH      (0.85f * U.widget_unit)
+// width of sliders
+#define SLIDER_WIDTH    (4 * U.widget_unit)
+// width of rename textboxes
+#define RENAME_TEXT_WIDTH (5 * U.widget_unit)
 
 /* Draw the given channel */
 void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
 
 /* Draw the given channel */
 void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
@@ -2937,12 +2937,11 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
-        *      7 is hardcoded factor for half-height of icons
         */
        y = (ymaxc - yminc) / 2 + yminc;
         */
        y = (ymaxc - yminc) / 2 + yminc;
-       ymid = y - 7;
+       ymid = y - 0.5f * ICON_WIDTH;
        /* y-coordinates for text is only 4 down from middle */
        /* y-coordinates for text is only 4 down from middle */
-       ytext = y - 4;
+       ytext = y - 0.2f * U.widget_unit;
        
        /* check if channel is selected */
        if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
        
        /* check if channel is selected */
        if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
@@ -2989,10 +2988,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                                glColor3fv(fcu->color);
                                
                                /* just a solid color rect
                                glColor3fv(fcu->color);
                                
                                /* just a solid color rect
-                                *  hardcoded 17 pixels width is slightly wider than icon width, so that
-                                *      there's a slight border around it 
                                 */
                                 */
-                               glRectf(offset, yminc, offset + 17, ymaxc);
+                               glRectf(offset, yminc, offset + ICON_WIDTH, ymaxc);
                        }
                        
                        /* icon is drawn as widget now... */
                        }
                        
                        /* icon is drawn as widget now... */
@@ -3086,7 +3083,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                }
                
                
                }
                
                
-               /* finally draw a backdrop rect behind these 
+               /* finally draw a backdrop rect behind these
                 *      - starts from the point where the first toggle/slider starts, 
                 *      - ends past the space that might be reserved for a scroller
                 */
                 *      - starts from the point where the first toggle/slider starts, 
                 *      - ends past the space that might be reserved for a scroller
                 */
@@ -3365,12 +3362,9 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
-        *      7 is hardcoded factor for half-height of icons
         */
        y = (ymaxc - yminc) / 2 + yminc;
         */
        y = (ymaxc - yminc) / 2 + yminc;
-       ymid = y - 7;
-       /* y-coordinates for text is only 4 down from middle */
-       /* ytext = y - 4; */
+       ymid = y - 0.5f * ICON_WIDTH;
        
        /* no button backdrop behind icons */
        uiBlockSetEmboss(block, UI_EMBOSSN);
        
        /* no button backdrop behind icons */
        uiBlockSetEmboss(block, UI_EMBOSSN);
index 0f0584ad8fef594033470033d5d7e981df5153fe..d83d1805f0eaa436c3d647e3646b0a4baeb009f3 100644 (file)
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+
 #include "BLI_math.h"
 
 #include "BKE_context.h"
 #include "BLI_math.h"
 
 #include "BKE_context.h"
+#include "BKE_blender.h"
 #include "BKE_global.h"
 #include "BKE_nla.h"
 #include "BKE_object.h"
 #include "BKE_global.h"
 #include "BKE_nla.h"
 #include "BKE_object.h"
@@ -197,15 +200,15 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, float cfra, short time)
        
        /* get starting coordinates for drawing */
        x = cfra * xscale;
        
        /* get starting coordinates for drawing */
        x = cfra * xscale;
-       y = 18;
+       y = 0.9f * U.widget_unit;
        
        /* draw green box around/behind text */
        UI_ThemeColorShade(TH_CFRAME, 0);
        
        /* draw green box around/behind text */
        UI_ThemeColorShade(TH_CFRAME, 0);
-       glRectf(x, y,  x + slen,  y + 15);
+       glRectf(x, y,  x + slen,  y + 0.75f * U.widget_unit);
        
        /* draw current frame number - black text */
        UI_ThemeColor(TH_TEXT);
        
        /* draw current frame number - black text */
        UI_ThemeColor(TH_TEXT);
-       UI_DrawString(x - 5, y + 3, numstr);
+       UI_DrawString(x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr);
        
        /* restore view transform */
        glScalef(xscale, 1.0, 1.0);
        
        /* restore view transform */
        glScalef(xscale, 1.0, 1.0);
index 1b980790fdcff337bbc054e6cb0290f060173aee..f684e57c2bca63acfbac5c65397923a5b2d9c080 100644 (file)
@@ -395,7 +395,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
                          ICON_MARKER;
        }
        
                          ICON_MARKER;
        }
        
-       UI_icon_draw(xpos * xscale - 5.0f, 16.0f, icon_id);
+       UI_icon_draw(xpos * xscale - 0.3f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id);
        
        glDisable(GL_BLEND);
        
        
        glDisable(GL_BLEND);
        
@@ -405,18 +405,18 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
                
                if (marker->flag & SELECT) {
                        UI_ThemeColor(TH_TEXT_HI);
                
                if (marker->flag & SELECT) {
                        UI_ThemeColor(TH_TEXT_HI);
-                       x = xpos * xscale + 4.0f;
-                       y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f;
+                       x = xpos * xscale + 4.0f * UI_DPI_FAC;
+                       y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
                }
                else {
                        UI_ThemeColor(TH_TEXT);
                        if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
                }
                else {
                        UI_ThemeColor(TH_TEXT);
                        if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
-                               x = xpos * xscale + 4.0f;
-                               y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f;
+                               x = xpos * xscale + 8.0f * UI_DPI_FAC;
+                               y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
                        }
                        else {
                        }
                        else {
-                               x = xpos * xscale + 4.0f;
-                               y = 17.0f;
+                               x = xpos * xscale + 8.0f * UI_DPI_FAC;
+                               y = 17.0f * UI_DPI_FAC;
                        }
                }
 
                        }
                }
 
index e520a95aa95b4ea8634826ba2bf70d9d62d4d215..d9d2180e184e558c5f78ece6b88388d1cc3fa1c0 100644 (file)
@@ -649,7 +649,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
        ActKeyColumn *ak;
        ActKeyBlock *ab;
        float xscale;
        ActKeyColumn *ak;
        ActKeyBlock *ab;
        float xscale;
-       
+       float iconsize = U.widget_unit / 4.0f;
        glEnable(GL_BLEND);
        
        /* get View2D scaling factor */
        glEnable(GL_BLEND);
        
        /* get View2D scaling factor */
@@ -665,7 +665,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
                                else
                                        UI_ThemeColor4(TH_STRIP);
                                
                                else
                                        UI_ThemeColor4(TH_STRIP);
                                
-                               glRectf(ab->start, ypos - 5, ab->end, ypos + 5);
+                               glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize);
                        }
                }
        }
                        }
                }
        }
@@ -686,7 +686,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
                        /* draw using OpenGL - uglier but faster */
                        /* NOTE1: a previous version of this didn't work nice for some intel cards
                         * NOTE2: if we wanted to go back to icons, these are  icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */
                        /* draw using OpenGL - uglier but faster */
                        /* NOTE1: a previous version of this didn't work nice for some intel cards
                         * NOTE2: if we wanted to go back to icons, these are  icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */
-                       draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, kalpha);
+                       draw_keyframe_shape(ak->cfra, ypos, xscale, iconsize, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, kalpha);
                }
        }
 
                }
        }
 
index 11e07584405f8aba750847effc3c563b14c3d67f..3e092ed8c5b51ae4f36984596743db896d7e5409 100644 (file)
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_view3d_types.h"
 
 #include "DNA_view3d_types.h"
 
+#include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
index 479e0b65177a5a00857d8ac198798638d8e4ae53..cdf9b71972d52960593aa671fa030e3237f9c8cb 100644 (file)
 
 #include "GL/glew.h"
 
 
 #include "GL/glew.h"
 
+#ifdef __APPLE__
+
+/* hacking pointsize and linewidth */
+#define glPointSize(f) glPointSize(U.pixelsize*(f))
+#define glLineWidth(f) glLineWidth(U.pixelsize*(f))
+
+#endif
+
 /*
  * these should be phased out. cpack should be replaced in
  * code with calls to glColor3ub. - zr
 /*
  * these should be phased out. cpack should be replaced in
  * code with calls to glColor3ub. - zr
index 8d7ae3aad6a8de7a25ae70f400f0b26c6ce7e717..551d3041398525f1cfbf4a85e570fcf8179e1761 100644 (file)
@@ -300,34 +300,34 @@ typedef enum eAnimFilter_Flags {
 /* -------------- Channel Defines -------------- */
 
 /* channel heights */
 /* -------------- Channel Defines -------------- */
 
 /* channel heights */
-#define ACHANNEL_FIRST          -16
-#define ACHANNEL_HEIGHT         16
-#define ACHANNEL_HEIGHT_HALF    8
-#define ACHANNEL_SKIP           2
+#define ACHANNEL_FIRST          (-0.8f * U.widget_unit)
+#define ACHANNEL_HEIGHT         (0.8f * U.widget_unit)
+#define ACHANNEL_HEIGHT_HALF    (0.4f * U.widget_unit)
+#define ACHANNEL_SKIP           (0.1f * U.widget_unit)
 #define ACHANNEL_STEP           (ACHANNEL_HEIGHT + ACHANNEL_SKIP)
 
 /* channel widths */
 #define ACHANNEL_STEP           (ACHANNEL_HEIGHT + ACHANNEL_SKIP)
 
 /* channel widths */
-#define ACHANNEL_NAMEWIDTH      200
+#define ACHANNEL_NAMEWIDTH      (10 * U.widget_unit)
 
 /* channel toggle-buttons */
 
 /* channel toggle-buttons */
-#define ACHANNEL_BUTTON_WIDTH   16
+#define ACHANNEL_BUTTON_WIDTH   (0.8f * U.widget_unit)
 
 
 /* -------------- NLA Channel Defines -------------- */
 
 /* NLA channel heights */
 // XXX: NLACHANNEL_FIRST isn't used?
 
 
 /* -------------- NLA Channel Defines -------------- */
 
 /* NLA channel heights */
 // XXX: NLACHANNEL_FIRST isn't used?
-#define NLACHANNEL_FIRST                -16
-#define NLACHANNEL_HEIGHT(snla)         ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? 16 : 24)
-#define NLACHANNEL_HEIGHT_HALF(snla)    ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ?  8 : 12)
-#define NLACHANNEL_SKIP                 2
+#define NLACHANNEL_FIRST                (-0.8f * U.widget_unit)
+#define NLACHANNEL_HEIGHT(snla)         ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit))
+#define NLACHANNEL_HEIGHT_HALF(snla)    ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.4f * U.widget_unit) : (0.6f * U.widget_unit))
+#define NLACHANNEL_SKIP                 (0.1f * U.widget_unit)
 #define NLACHANNEL_STEP(snla)           (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP)
 
 /* channel widths */
 #define NLACHANNEL_STEP(snla)           (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP)
 
 /* channel widths */
-#define NLACHANNEL_NAMEWIDTH        200
+#define NLACHANNEL_NAMEWIDTH                   (10 * U.widget_unit)
 
 /* channel toggle-buttons */
 
 /* channel toggle-buttons */
-#define NLACHANNEL_BUTTON_WIDTH 16
+#define NLACHANNEL_BUTTON_WIDTH                        (0.8f * U.widget_unit)
 
 /* ---------------- API  -------------------- */
 
 
 /* ---------------- API  -------------------- */
 
index 860d176ffb38e69b1043b5fc9de5d0ce82b70885..f7a42d5b1ac4ccb5196b8f1ad39a7bce386b8f97 100644 (file)
@@ -64,9 +64,9 @@ void    ED_region_panels(const struct bContext *C, struct ARegion *ar, int verti
 void    ED_region_header_init(struct ARegion *ar);
 void    ED_region_header(const struct bContext *C, struct ARegion *ar);
 void    ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
 void    ED_region_header_init(struct ARegion *ar);
 void    ED_region_header(const struct bContext *C, struct ARegion *ar);
 void    ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
-void    region_scissor_winrct(struct ARegion *ar, struct rcti *winrct);
 void    ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha);
 void    ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
 void    ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha);
 void    ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
+float  ED_region_blend_factor(struct ARegion *ar);
 
 /* spaces */
 void    ED_spacetypes_init(void);
 
 /* spaces */
 void    ED_spacetypes_init(void);
index 2dc552d0fcedbe20bccb724b7d7bd6e32b4db008..abd1782d0f2d3d522b201aedb36cd48589feaa65 100644 (file)
@@ -175,10 +175,10 @@ typedef struct uiLayout uiLayout;
 /* uiBut->drawflag */
 #define UI_BUT_DRAW_ENUM_ARROWS    (1 << 0) /* draw enum-like up/down arrows for button */
 
 /* uiBut->drawflag */
 #define UI_BUT_DRAW_ENUM_ARROWS    (1 << 0) /* draw enum-like up/down arrows for button */
 
-/* scale fixed button widths by this to account for DPI
- * 8.4852 == sqrtf(72.0f)) */
-#define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f)
-#define UI_DPI_ICON_FAC (((float)U.dpi) / 72.0f)
+/* scale fixed button widths by this to account for DPI (no difference for buttons or icons anymore */
+
+#define UI_DPI_FAC ((U.pixelsize * (float)U.dpi) / 72.0f)
+#define UI_DPI_ICON_FAC ((U.pixelsize * (float)U.dpi) / 72.0f)
 /* 16 to copy ICON_DEFAULT_HEIGHT */
 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC)
 
 /* 16 to copy ICON_DEFAULT_HEIGHT */
 #define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC)
 
@@ -893,7 +893,10 @@ void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, const cha
 int UI_GetStringWidth(const char *str); // XXX temp
 void UI_DrawString(float x, float y, const char *str); // XXX temp
 void UI_DrawTriIcon(float x, float y, char dir);
 int UI_GetStringWidth(const char *str); // XXX temp
 void UI_DrawString(float x, float y, const char *str); // XXX temp
 void UI_DrawTriIcon(float x, float y, char dir);
-uiStyle *UI_GetStyle(void);
+
+uiStyle *UI_GetStyle(void);            /* use for fonts etc */
+uiStyle *UI_GetStyleDraw(void);        /* DPI scaled settings for drawing */
+
 /* linker workaround ack! */
 void UI_template_fix_linking(void);
 
 /* linker workaround ack! */
 void UI_template_fix_linking(void);
 
index 24759fa778a7f8457a9a37303998ada48eb9bfcd..3b94291b43a51bddb65a931c712d7a92459ab42c 100644 (file)
@@ -102,11 +102,11 @@ enum {
 /* ------ Defines for Scrollers ----- */
 
 /* scroller area */
 /* ------ Defines for Scrollers ----- */
 
 /* scroller area */
-#define V2D_SCROLL_HEIGHT   17
-#define V2D_SCROLL_WIDTH    17
+#define V2D_SCROLL_HEIGHT   (0.85f * U.widget_unit)
+#define V2D_SCROLL_WIDTH    (0.85f * U.widget_unit)
 
 /* scroller 'handles' hotspot radius for mouse */
 
 /* scroller 'handles' hotspot radius for mouse */
-#define V2D_SCROLLER_HANDLE_SIZE    12
+#define V2D_SCROLLER_HANDLE_SIZE    (0.6f * U.widget_unit)
 
 /* ------ Define for UI_view2d_sync ----- */
 
 
 /* ------ Define for UI_view2d_sync ----- */
 
index ce82e0645314a95849e69e20f95eb4b31febe5ad..3a377ade44c1419dbf17b9dd588249a485e21f20 100644 (file)
@@ -69,7 +69,6 @@
 #include "WM_api.h"
 #include "WM_types.h"
 #include "wm_subwindow.h"
 #include "WM_api.h"
 #include "WM_types.h"
 #include "wm_subwindow.h"
-#include "wm_window.h"
 
 #include "RNA_access.h"
 
 
 #include "RNA_access.h"
 
@@ -298,9 +297,9 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
        /* note: this is used for the splash where window bounds event has not been
         * updated by ghost, get the window bounds from ghost directly */
 
        /* note: this is used for the splash where window bounds event has not been
         * updated by ghost, get the window bounds from ghost directly */
 
-       // wm_window_get_size(window, &xmax, &ymax);
-       wm_window_get_size_ghost(window, &xmax, &ymax);
-       
+       xmax = WM_window_pixels_x(window);
+       ymax = WM_window_pixels_y(window);
+
        ui_bounds_block(block);
        
        width  = BLI_rctf_size_x(&block->rect);
        ui_bounds_block(block);
        
        width  = BLI_rctf_size_x(&block->rect);
@@ -326,7 +325,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
        /* compute mouse position with user defined offset */
        ui_bounds_block(block);
        
        /* compute mouse position with user defined offset */
        ui_bounds_block(block);
        
-       wm_window_get_size(window, &xmax, &ymax);
+       xmax = WM_window_pixels_x(window);
+       ymax = WM_window_pixels_y(window);
 
        oldwidth  = BLI_rctf_size_x(&block->rect);
        oldheight = BLI_rctf_size_y(&block->rect);
 
        oldwidth  = BLI_rctf_size_x(&block->rect);
        oldheight = BLI_rctf_size_y(&block->rect);
@@ -334,7 +334,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
        /* first we ensure wide enough text bounds */
        if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
                if (block->flag & UI_BLOCK_LOOP) {
        /* first we ensure wide enough text bounds */
        if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
                if (block->flag & UI_BLOCK_LOOP) {
-                       block->bounds = 50;
+                       block->bounds = 2.5f * UI_UNIT_X;
                        ui_text_bounds_block(block, block->rect.xmin);
                }
        }
                        ui_text_bounds_block(block, block->rect.xmin);
                }
        }
@@ -983,7 +983,8 @@ void ui_fontscale(short *points, float aspect)
                float pointsf = *points;
                
                /* for some reason scaling fonts goes too fast compared to widget size */
                float pointsf = *points;
                
                /* for some reason scaling fonts goes too fast compared to widget size */
-               aspect = sqrt(aspect);
+               /* XXX not true anymore? (ton) */
+               //aspect = sqrt(aspect);
                pointsf /= aspect;
                
                if (aspect > 1.0f)
                pointsf /= aspect;
                
                if (aspect > 1.0f)
@@ -1000,7 +1001,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u
        
        ui_block_to_window_fl(ar, block, &rectf.xmin, &rectf.ymin);
        ui_block_to_window_fl(ar, block, &rectf.xmax, &rectf.ymax);
        
        ui_block_to_window_fl(ar, block, &rectf.xmin, &rectf.ymin);
        ui_block_to_window_fl(ar, block, &rectf.xmax, &rectf.ymax);
-
+       
        rectf.xmin -= ar->winrct.xmin;
        rectf.ymin -= ar->winrct.ymin;
        rectf.xmax -= ar->winrct.xmin;
        rectf.xmin -= ar->winrct.xmin;
        rectf.ymin -= ar->winrct.ymin;
        rectf.xmax -= ar->winrct.xmin;
@@ -1015,7 +1016,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u
 /* uses local copy of style, to scale things down, and allow widgets to change stuff */
 void uiDrawBlock(const bContext *C, uiBlock *block)
 {
 /* uses local copy of style, to scale things down, and allow widgets to change stuff */
 void uiDrawBlock(const bContext *C, uiBlock *block)
 {
-       uiStyle style = *UI_GetStyle();  /* XXX pass on as arg */
+       uiStyle style = *UI_GetStyleDraw();  /* XXX pass on as arg */
        ARegion *ar;
        uiBut *but;
        rcti rect;
        ARegion *ar;
        uiBut *but;
        rcti rect;
@@ -2650,7 +2651,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
 
        BLI_assert(width >= 0);
        BLI_assert(height >= 0);
 
        BLI_assert(width >= 0);
        BLI_assert(height >= 0);
-
+       
        /* we could do some more error checks here */
        if ((type & BUTTYPE) == LABEL) {
                BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
        /* we could do some more error checks here */
        if ((type & BUTTYPE) == LABEL) {
                BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
index 4d96ad810d4a0036b154a7c75b7d3ddeb4fa4bf6..792553f842c75fe325385a8a77e0972e355c71e9 100644 (file)
@@ -429,17 +429,18 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
 #else
        ImBuf *ibuf = (ImBuf *)but->poin;
        //GLint scissor[4];
 #else
        ImBuf *ibuf = (ImBuf *)but->poin;
        //GLint scissor[4];
-       //int w, h;
+       int w, h;
 
        if (!ibuf) return;
        
 
        if (!ibuf) return;
        
+       w = BLI_rcti_size_x(rect);
+       h = BLI_rcti_size_y(rect);
+       
        /* scissor doesn't seem to be doing the right thing...? */
 #if 0
        //glColor4f(1.0, 0.f, 0.f, 1.f);
        //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
 
        /* scissor doesn't seem to be doing the right thing...? */
 #if 0
        //glColor4f(1.0, 0.f, 0.f, 1.f);
        //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
 
-       w = BLI_rcti_size_x(rect);
-       h = BLI_rcti_size_y(rect);
        /* prevent drawing outside widget area */
        glGetIntegerv(GL_SCISSOR_BOX, scissor);
        glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
        /* prevent drawing outside widget area */
        glGetIntegerv(GL_SCISSOR_BOX, scissor);
        glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
@@ -448,9 +449,16 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
        glEnable(GL_BLEND);
        glColor4f(0.0, 0.0, 0.0, 0.0);
        
        glEnable(GL_BLEND);
        glColor4f(0.0, 0.0, 0.0, 0.0);
        
+       if (w != ibuf->x || h != ibuf->y) {
+               float facx = (float)w / (float)ibuf->x;
+               float facy = (float)h / (float)ibuf->y;
+               glPixelZoom(facx, facy);
+       }
        glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
        //glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
        
        glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
        //glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
        
+       glPixelZoom(1.0f, 1.0f);
+       
        glDisable(GL_BLEND);
        
 #if 0
        glDisable(GL_BLEND);
        
 #if 0
index 1ac56fd30bbd87c4858204b4ea7cdc3e1cb79431..258775867cc9de7953d9fc689470c2b04105d18c 100644 (file)
@@ -4530,7 +4530,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
        wmKeyMapItem *kmi;
        PointerRNA ptr;
        uiLayout *layout;
        wmKeyMapItem *kmi;
        PointerRNA ptr;
        uiLayout *layout;
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
        int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
 
        IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
        int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
 
@@ -4562,7 +4562,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
        wmKeyMapItem *kmi;
        PointerRNA ptr;
        uiLayout *layout;
        wmKeyMapItem *kmi;
        PointerRNA ptr;
        uiLayout *layout;
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
        int kmi_id;
        
        IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
        int kmi_id;
        
index bb0cc1176d8eaca26c7dfab5f723147f315c9bc5..d78985fa5e20bcf0735b7ba8d03213a9644019bd 100644 (file)
@@ -750,7 +750,7 @@ static DrawInfo *icon_create_drawinfo(void)
        return di;
 }
 
        return di;
 }
 
-/* note!, returns unscaled by DPI, may need to multiply result by UI_DPI_ICON_FAC */
+/* note!, returns unscaled by DPI */
 int UI_icon_get_width(int icon_id)
 {
        Icon *icon = NULL;
 int UI_icon_get_width(int icon_id)
 {
        Icon *icon = NULL;
@@ -887,7 +887,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
                /* first allocate imbuf for scaling and copy preview into it */
                ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
                memcpy(ima->rect, rect, rw * rh * sizeof(unsigned int));
                /* first allocate imbuf for scaling and copy preview into it */
                ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
                memcpy(ima->rect, rect, rw * rh * sizeof(unsigned int));
-               IMB_scaleImBuf(ima, w, h); /* scale it */
+               IMB_scalefastImBuf(ima, w, h); /* scale it */
                rect = ima->rect;
        }
 
                rect = ima->rect;
        }
 
@@ -965,7 +965,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
        Icon *icon = NULL;
        DrawInfo *di = NULL;
        IconImage *iimg;
        Icon *icon = NULL;
        DrawInfo *di = NULL;
        IconImage *iimg;
-       float fdraw_size = is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
+       float fdraw_size = draw_size;
        int w, h;
        
        icon = BKE_icon_get(icon_id);
        int w, h;
        
        icon = BKE_icon_get(icon_id);
@@ -1158,9 +1158,10 @@ void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, cons
        icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE);
 }
 
        icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE);
 }
 
+/* draws icon with dpi scale factor */
 void UI_icon_draw(float x, float y, int icon_id)
 {
 void UI_icon_draw(float x, float y, int icon_id)
 {
-       UI_icon_draw_aspect(x, y, icon_id, 1.0f, 1.0f);
+       UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_ICON_FAC, 1.0f);
 }
 
 void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
 }
 
 void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
index 1dc98639fe75c3b118a619dd429b784eff6afe93..fce431738326c5af6bebdeadc73516baa6eddf9f 100644 (file)
@@ -267,7 +267,7 @@ struct uiBut {
        void *dragpoin;
        struct ImBuf *imb;
        float imb_scale;
        void *dragpoin;
        struct ImBuf *imb;
        float imb_scale;
-
+       
        /* active button data */
        struct uiHandleButtonData *active;
 
        /* active button data */
        struct uiHandleButtonData *active;
 
index c67c64a0540bdff9ac4f565e5cef45def5190b2d..e93ecc72725113bc90f3aea82a07aa58617e06cf 100644 (file)
@@ -65,8 +65,6 @@
 #define RNA_NO_INDEX    -1
 #define RNA_ENUM_VALUE  -2
 
 #define RNA_NO_INDEX    -1
 #define RNA_ENUM_VALUE  -2
 
-#define EM_SEPR_X       6
-#define EM_SEPR_Y       6
 
 // #define USE_OP_RESET_BUT  // we may want to make this optional, disable for now.
 
 
 // #define USE_OP_RESET_BUT  // we may want to make this optional, disable for now.
 
@@ -227,14 +225,16 @@ static int ui_layout_vary_direction(uiLayout *layout)
 /* estimated size of text + icon */
 static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int compact)
 {
 /* estimated size of text + icon */
 static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int compact)
 {
+       float f5 = 0.25f * UI_UNIT_X;
+       float f10 = 0.5f * UI_UNIT_X;
        int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
 
        if (icon && !name[0])
                return UI_UNIT_X;  /* icon only */
        else if (icon)
        int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
 
        if (icon && !name[0])
                return UI_UNIT_X;  /* icon only */
        else if (icon)
-               return (variable) ? UI_GetStringWidth(name) + (compact ? 5 : 10) + UI_UNIT_X : 10 * UI_UNIT_X;  /* icon + text */
+               return (variable) ? UI_GetStringWidth(name) + (compact ? f5 : f10) + UI_UNIT_X : 10 * UI_UNIT_X;  /* icon + text */
        else
        else
-               return (variable) ? UI_GetStringWidth(name) + (compact ? 5 : 10) + UI_UNIT_X : 10 * UI_UNIT_X;  /* text only */
+               return (variable) ? UI_GetStringWidth(name) + (compact ? f5 : f10) + UI_UNIT_X : 10 * UI_UNIT_X;  /* text only */
 }
 
 static void ui_item_size(uiItem *item, int *r_w, int *r_h)
 }
 
 static void ui_item_size(uiItem *item, int *r_w, int *r_h)
@@ -1495,7 +1495,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
        h = UI_UNIT_Y;
 
        if (layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */
        h = UI_UNIT_Y;
 
        if (layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */
-               w -= 10;
+               w -= UI_UNIT_Y/2;
 
        if (name[0] && icon)
                but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
 
        if (name[0] && icon)
                but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
@@ -1610,7 +1610,7 @@ void uiItemS(uiLayout *layout)
        uiBlock *block = layout->root->block;
 
        uiBlockSetCurLayout(block, layout);
        uiBlock *block = layout->root->block;
 
        uiBlockSetCurLayout(block, layout);
-       uiDefBut(block, SEPR, 0, "", 0, 0, EM_SEPR_X, EM_SEPR_Y, NULL, 0.0, 0.0, 0, 0, "");
+       uiDefBut(block, SEPR, 0, "", 0, 0, 0.3f * UI_UNIT_X, 0.3f * UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 }
 
 /* level items */
 }
 
 /* level items */
@@ -2941,7 +2941,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
 
                col = uiLayoutColumn(layout, FALSE);
                block = uiLayoutGetBlock(col);
 
                col = uiLayoutColumn(layout, FALSE);
                block = uiLayoutGetBlock(col);
-               but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20,
+               but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
                                       NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults"));
                uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL);
        }
                                       NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults"));
                uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL);
        }
index 2b170ea546b81dc5ffd85ccab84efb18e6d1b5fc..0bdb39cb58e3e7591ff18e30047bc7cd3ff50234 100644 (file)
@@ -305,7 +305,7 @@ void uiEndPanel(uiBlock *block, int width, int height)
 
 static void ui_offset_panel_block(uiBlock *block)
 {
 
 static void ui_offset_panel_block(uiBlock *block)
 {
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiBut *but;
        int ofsy;
 
        uiBut *but;
        int ofsy;
 
@@ -345,14 +345,18 @@ static void uiPanelPop(uiBlock *UNUSED(block))
 /* triangle 'icon' for panel header */
 void UI_DrawTriIcon(float x, float y, char dir)
 {
 /* triangle 'icon' for panel header */
 void UI_DrawTriIcon(float x, float y, char dir)
 {
+       float f3 = 0.15 * U.widget_unit;
+       float f5 = 0.25 * U.widget_unit;
+       float f7 = 0.35 * U.widget_unit;
+       
        if (dir == 'h') {
        if (dir == 'h') {
-               ui_draw_anti_tria(x - 3, y - 5, x - 3, y + 5, x + 7, y);
+               ui_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y);
        }
        else if (dir == 't') {
        }
        else if (dir == 't') {
-               ui_draw_anti_tria(x - 5, y - 7, x + 5, y - 7, x, y + 3);
+               ui_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3);
        }
        else { /* 'v' = vertical, down */
        }
        else { /* 'v' = vertical, down */
-               ui_draw_anti_tria(x - 5, y + 3, x + 5, y + 3, x, y - 7);
+               ui_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7);
        }
 }
 
        }
 }
 
index b62e634b1ebeeda3579b00b5964d447b1544dcd2..ed619605963a1fa54b0fc1390ddfc9ed93064f9f 100644 (file)
@@ -672,7 +672,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
        }
 
                BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
        }
 
-       wm_window_get_size(CTX_wm_window(C), &winx, &winy);
+       winx = WM_window_pixels_x(CTX_wm_window(C));
+       winy = WM_window_pixels_y(CTX_wm_window(C));
+       //wm_window_get_size(CTX_wm_window(C), &winx, &winy);
 
        if (rect_i.xmax > winx) {
                /* super size */
 
        if (rect_i.xmax > winx) {
                /* super size */
@@ -1185,7 +1187,9 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
 
                BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
 
 
                BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
 
-               wm_window_get_size(CTX_wm_window(C), &winx, &winy);
+               winx = WM_window_pixels_x(CTX_wm_window(C));
+               winy = WM_window_pixels_y(CTX_wm_window(C));
+               //wm_window_get_size(CTX_wm_window(C), &winx, &winy);
                
                if (rect_i.xmax > winx) {
                        /* super size */
                
                if (rect_i.xmax > winx) {
                        /* super size */
@@ -1314,11 +1318,11 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
        /* widget_roundbox_set has this correction too, keep in sync */
        if (but->type != PULLDOWN) {
                if (but->flag & UI_BUT_ALIGN_TOP)
        /* widget_roundbox_set has this correction too, keep in sync */
        if (but->type != PULLDOWN) {
                if (but->flag & UI_BUT_ALIGN_TOP)
-                       butrct.ymax += 1.0f;
+                       butrct.ymax += U.pixelsize;
                if (but->flag & UI_BUT_ALIGN_LEFT)
                if (but->flag & UI_BUT_ALIGN_LEFT)
-                       butrct.xmin -= 1.0f;
+                       butrct.xmin -= U.pixelsize;
        }
        }
-
+       
        /* calc block rect */
        if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
                if (block->buttons.first) {
        /* calc block rect */
        if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
                if (block->buttons.first) {
@@ -1334,7 +1338,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                        block->rect.xmax = block->rect.ymax = 20;
                }
        }
                        block->rect.xmax = block->rect.ymax = 20;
                }
        }
-       
+               
        /* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
        ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
        ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
        /* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
        ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
        ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
@@ -1342,8 +1346,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
        //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
        //block->rect.xmax += 2.0; block->rect.ymax += 2.0;
        
        //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
        //block->rect.xmax += 2.0; block->rect.ymax += 2.0;
        
-       xsize = BLI_rctf_size_x(&block->rect) + 4;  /* 4 for shadow */
-       ysize = BLI_rctf_size_y(&block->rect) + 4;
+       xsize = BLI_rctf_size_x(&block->rect) + 0.2f * UI_UNIT_X;  /* 4 for shadow */
+       ysize = BLI_rctf_size_y(&block->rect) + 0.2f * UI_UNIT_Y;
        /* aspect /= (float)xsize;*/ /*UNUSED*/
 
        {
        /* aspect /= (float)xsize;*/ /*UNUSED*/
 
        {
@@ -1351,7 +1355,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                int winx, winy;
                // int offscreen;
 
                int winx, winy;
                // int offscreen;
 
-               wm_window_get_size(window, &winx, &winy);
+               winx = WM_window_pixels_x(window);
+               winy = WM_window_pixels_y(window);
+               // wm_window_get_size(window, &winx, &winy);
 
                if (block->direction & UI_CENTER) center = ysize / 2;
                else center = 0;
 
                if (block->direction & UI_CENTER) center = ysize / 2;
                else center = 0;
@@ -1523,7 +1529,9 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
                return;
        }
 
                return;
        }
 
-       wm_window_get_size(window, &winx, &winy);
+       winx = WM_window_pixels_x(window);
+       winy = WM_window_pixels_y(window);
+       // wm_window_get_size(window, &winx, &winy);
        
        if (block->rect.xmin < MENU_SHADOW_SIDE)
                block->rect.xmin = MENU_SHADOW_SIDE;
        
        if (block->rect.xmin < MENU_SHADOW_SIDE)
                block->rect.xmin = MENU_SHADOW_SIDE;
@@ -1635,7 +1643,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
        /* if this is being created from a button */
        if (but) {
                block->aspect = but->block->aspect;
        /* if this is being created from a button */
        if (but) {
                block->aspect = but->block->aspect;
-
                ui_block_position(window, butregion, but, block);
                handle->direction = block->direction;
        }
                ui_block_position(window, butregion, but, block);
                handle->direction = block->direction;
        }
@@ -2019,10 +2026,10 @@ static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
        picker_new_hide_reveal(bt->block, colormode);
 }
 
        picker_new_hide_reveal(bt->block, colormode);
 }
 
-#define PICKER_H    150
-#define PICKER_W    150
-#define PICKER_SPACE    6
-#define PICKER_BAR      14
+#define PICKER_H    (7.5f * U.widget_unit)
+#define PICKER_W    (7.5f * U.widget_unit)
+#define PICKER_SPACE    (0.3f * U.widget_unit)
+#define PICKER_BAR      (0.7f * U.widget_unit)
 
 #define PICKER_TOTAL_W  (PICKER_W + PICKER_SPACE + PICKER_BAR)
 
 
 #define PICKER_TOTAL_W  (PICKER_W + PICKER_SPACE + PICKER_BAR)
 
@@ -2066,11 +2073,12 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
        float rgb_gamma[3];
        float min, max, step, precision;
        float *hsv = ui_block_hsv_get(block);
        float rgb_gamma[3];
        float min, max, step, precision;
        float *hsv = ui_block_hsv_get(block);
+       int yco;
        
        ui_block_hsv_get(block);
        
        width = PICKER_TOTAL_W;
        
        ui_block_hsv_get(block);
        
        width = PICKER_TOTAL_W;
-       butwidth = width - UI_UNIT_X - 10;
+       butwidth = width - 1.5f * UI_UNIT_X;
        
        /* existence of profile means storage is in linear color space, with display correction */
        /* XXX That tip message is not use anywhere! */
        
        /* existence of profile means storage is in linear color space, with display correction */
        /* XXX That tip message is not use anywhere! */
@@ -2108,44 +2116,47 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
        }
        
        /* mode */
        }
        
        /* mode */
+       yco = -1.5f * UI_UNIT_Y;
        uiBlockBeginAlign(block);
        uiBlockBeginAlign(block);
-       bt = uiDefButS(block, ROW, 0, IFACE_("RGB"), 0, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 0.0, 0, 0, "");
+       bt = uiDefButS(block, ROW, 0, IFACE_("RGB"), 0, yco, width / 3, UI_UNIT_Y, &colormode, 0.0, 0.0, 0, 0, "");
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
-       bt = uiDefButS(block, ROW, 0, IFACE_("HSV"), width / 3, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 1.0, 0, 0, "");
+       bt = uiDefButS(block, ROW, 0, IFACE_("HSV"), width / 3, yco, width / 3, UI_UNIT_Y, &colormode, 0.0, 1.0, 0, 0, "");
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
-       bt = uiDefButS(block, ROW, 0, IFACE_("Hex"), 2 * width / 3, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 2.0, 0, 0, "");
+       bt = uiDefButS(block, ROW, 0, IFACE_("Hex"), 2 * width / 3, yco, width / 3, UI_UNIT_Y, &colormode, 0.0, 2.0, 0, 0, "");
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
        uiBlockEndAlign(block);
 
        uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
        uiBlockEndAlign(block);
 
+       yco = -3.0f * UI_UNIT_Y;
        if (show_picker) {
        if (show_picker) {
-               bt = uiDefIconButO(block, BUT, "UI_OT_eyedropper", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth + 10, -60, UI_UNIT_X, UI_UNIT_Y, NULL);
+               bt = uiDefIconButO(block, BUT, "UI_OT_eyedropper", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth + 10, yco, UI_UNIT_X, UI_UNIT_Y, NULL);
                uiButSetFunc(bt, close_popup_cb, bt, NULL);
        }
        
        /* RGB values */
        uiBlockBeginAlign(block);
                uiButSetFunc(bt, close_popup_cb, bt, NULL);
        }
        
        /* RGB values */
        uiBlockBeginAlign(block);
-       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("R "),  0, -60, butwidth, UI_UNIT_Y, ptr, prop, 0, 0.0, 0.0, 0, 3, TIP_("Red"));
+       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("R "),  0, yco, butwidth, UI_UNIT_Y, ptr, prop, 0, 0.0, 0.0, 0, 3, TIP_("Red"));
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
-       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("G "),  0, -80, butwidth, UI_UNIT_Y, ptr, prop, 1, 0.0, 0.0, 0, 3, TIP_("Green"));
+       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("G "),  0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, ptr, prop, 1, 0.0, 0.0, 0, 3, TIP_("Green"));
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
-       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("B "),  0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, TIP_("Blue"));
+       bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("B "),  0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, TIP_("Blue"));
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
 
        /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
         * but need to use uiButSetFunc for updating other fake buttons */
        
        /* HSV values */
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
 
        /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
         * but need to use uiButSetFunc for updating other fake buttons */
        
        /* HSV values */
+       yco = -3.0f * UI_UNIT_Y;
        uiBlockBeginAlign(block);
        uiBlockBeginAlign(block);
-       bt = uiDefButF(block, NUMSLI, 0, IFACE_("H "),   0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, TIP_("Hue"));
+       bt = uiDefButF(block, NUMSLI, 0, IFACE_("H "),   0, yco, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, TIP_("Hue"));
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
-       bt = uiDefButF(block, NUMSLI, 0, IFACE_("S "),   0, -80, butwidth, UI_UNIT_Y, hsv + 1, 0.0, 1.0, 10, 3, TIP_("Saturation"));
+       bt = uiDefButF(block, NUMSLI, 0, IFACE_("S "),   0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 1, 0.0, 1.0, 10, 3, TIP_("Saturation"));
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
-       bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "),   0, -100, butwidth, UI_UNIT_Y, hsv + 2, 0.0, max, 10, 3, TIP_("Value"));
+       bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "),   0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 2, 0.0, max, 10, 3, TIP_("Value"));
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
        uiBlockEndAlign(block);
 
        if (rgba[3] != FLT_MAX) {
        uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
        uiBlockEndAlign(block);
 
        if (rgba[3] != FLT_MAX) {
-               bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("A "),  0, -120, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, TIP_("Alpha"));
+               bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("A "),  0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, TIP_("Alpha"));
                uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
        }
        else {
                uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
        }
        else {
@@ -2154,9 +2165,10 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
 
        BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
 
 
        BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
 
-       bt = uiDefBut(block, TEX, 0, IFACE_("Hex: "), 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));
+       yco = -3.0f * UI_UNIT_Y;
+       bt = uiDefBut(block, TEX, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));
        uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
        uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
-       uiDefBut(block, LABEL, 0, IFACE_("(Gamma Corrected)"), 0, -80, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       uiDefBut(block, LABEL, 0, IFACE_("(Gamma Corrected)"), 0, yco - UI_UNIT_Y, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 
        rgb_to_hsv_v(rgba, hsv);
 
 
        rgb_to_hsv_v(rgba, hsv);
 
@@ -2228,7 +2240,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
        uiBlockPicker(block, handle->retvec, &but->rnapoin, but->rnaprop, show_picker);
        
        block->flag = UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1 | UI_BLOCK_MOVEMOUSE_QUIT;
        uiBlockPicker(block, handle->retvec, &but->rnapoin, but->rnaprop, show_picker);
        
        block->flag = UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1 | UI_BLOCK_MOVEMOUSE_QUIT;
-       uiBoundsBlock(block, 10);
+       uiBoundsBlock(block, 0.5 * UI_UNIT_X);
        
        block->block_event_func = ui_picker_small_wheel_cb;
        
        
        block->block_event_func = ui_picker_small_wheel_cb;
        
@@ -2386,7 +2398,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
                }
 
                block->minbounds = minwidth;
                }
 
                block->minbounds = minwidth;
-               uiTextBoundsBlock(block, 50);
+               uiTextBoundsBlock(block, 2.5 * UI_UNIT_X);
        }
 
        /* if menu slides out of other menu, override direction */
        }
 
        /* if menu slides out of other menu, override direction */
@@ -2402,7 +2414,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
                                          uiMenuCreateFunc menu_func, void *arg, char *str)
 {
        wmWindow *window = CTX_wm_window(C);
                                          uiMenuCreateFunc menu_func, void *arg, char *str)
 {
        wmWindow *window = CTX_wm_window(C);
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiPopupBlockHandle *handle;
        uiPopupMenu *pup;
        pup = MEM_callocN(sizeof(uiPopupMenu), __func__);
        uiPopupBlockHandle *handle;
        uiPopupMenu *pup;
        pup = MEM_callocN(sizeof(uiPopupMenu), __func__);
@@ -2466,7 +2478,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
 /* only return handler, and set optional title */
 uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
 {
 /* only return handler, and set optional title */
 uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
 {
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
        uiBut *but;
        
        uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
        uiBut *but;
        
index 7e7db6aeaaa2c669c9db0487206fc252b7e52dd7..7118cbcd8558ebe6e5c5da454eb2bcee202051ef 100644 (file)
@@ -166,7 +166,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
        }
        
        /* clip is very strict, so we give it some space */
        }
        
        /* clip is very strict, so we give it some space */
-       BLF_clipping(fs->uifont_id, rect->xmin - 1, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
+       BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
        BLF_enable(fs->uifont_id, BLF_CLIPPING);
        BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
 
        BLF_enable(fs->uifont_id, BLF_CLIPPING);
        BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
 
@@ -261,6 +261,32 @@ uiStyle *UI_GetStyle(void)
        return (style != NULL) ? style : U.uistyles.first;
 }
 
        return (style != NULL) ? style : U.uistyles.first;
 }
 
+/* for drawing, scaled with DPI setting */
+uiStyle *UI_GetStyleDraw(void)
+{
+       uiStyle *style = UI_GetStyle();
+       static uiStyle _style;
+       
+       _style = *style;
+       
+       _style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
+       _style.paneltitle.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
+       _style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
+       _style.grouplabel.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
+       _style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
+       _style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
+       
+       _style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
+       _style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
+       _style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
+       _style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex);
+       _style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
+       _style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
+       _style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
+       
+       return &_style;
+}
+
 /* temporarily, does widget font */
 int UI_GetStringWidth(const char *str)
 {
 /* temporarily, does widget font */
 int UI_GetStringWidth(const char *str)
 {
@@ -364,9 +390,9 @@ void uiStyleInit(void)
                         * Yes, this build the glyph cache and create
                         * the texture.
                         */
                         * Yes, this build the glyph cache and create
                         * the texture.
                         */
-                       BLF_size(font->blf_id, 11, U.dpi);
-                       BLF_size(font->blf_id, 12, U.dpi);
-                       BLF_size(font->blf_id, 14, U.dpi);
+                       BLF_size(font->blf_id, 11 * U.pixelsize, U.dpi);
+                       BLF_size(font->blf_id, 12 * U.pixelsize, U.dpi);
+                       BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
                }
        }
        
                }
        }
        
@@ -378,19 +404,19 @@ void uiStyleInit(void)
        if (blf_mono_font == -1)
                blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
 
        if (blf_mono_font == -1)
                blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
 
-       BLF_size(blf_mono_font, 12, 72);
+       BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
        
        /* second for rendering else we get threading problems */
        if (blf_mono_font_render == -1)
                blf_mono_font_render = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
 
        
        /* second for rendering else we get threading problems */
        if (blf_mono_font_render == -1)
                blf_mono_font_render = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
 
-       BLF_size(blf_mono_font_render, 12, 72);
+       BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72 );
 }
 
 void uiStyleFontSet(uiFontStyle *fs)
 {
        uiFont *font = uifont_to_blfont(fs->uifont_id);
        
 }
 
 void uiStyleFontSet(uiFontStyle *fs)
 {
        uiFont *font = uifont_to_blfont(fs->uifont_id);
        
-       BLF_size(font->blf_id, fs->points, U.dpi);
+       BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi);
 }
 
 }
 
index f7a53c6bab23f633681cdf8650f4c10f1efac634..0e3c32334b87f4fa1a8a4f4ce7259b34f893f28a 100644 (file)
@@ -179,29 +179,29 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
        
        /* preview thumbnails */
        if (template.prv_rows > 0 && template.prv_cols > 0) {
        
        /* preview thumbnails */
        if (template.prv_rows > 0 && template.prv_cols > 0) {
-               int w = 96 * template.prv_cols;
-               int h = 96 * template.prv_rows + 20;
+               int w = 4 * U.widget_unit * template.prv_cols;
+               int h = 4 * U.widget_unit * template.prv_rows + U.widget_unit;
                
                /* fake button, it holds space for search items */
                uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL);
                
                
                /* fake button, it holds space for search items */
                uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL);
                
-               but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, 19,
-                                    template.prv_rows, template.prv_cols, "");
+               but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y,
+                                                        template.prv_rows, template.prv_cols, "");
                uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
        }
        /* list view */
        else {
                const int searchbox_width  = uiSearchBoxWidth();
                const int searchbox_height = uiSearchBoxHeight();
                uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
        }
        /* list view */
        else {
                const int searchbox_width  = uiSearchBoxWidth();
                const int searchbox_height = uiSearchBoxHeight();
+               
                /* fake button, it holds space for search items */
                uiDefBut(block, LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
                /* fake button, it holds space for search items */
                uiDefBut(block, LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
-               
                but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
                uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
        }
                
        
                but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
                uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
        }
                
        
-       uiBoundsBlock(block, 6);
+       uiBoundsBlock(block, 0.3f * U.widget_unit);
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
@@ -1437,7 +1437,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
        const int line2_y = yoffs + 65;
 
        if (coba == NULL) return;
        const int line2_y = yoffs + 65;
 
        if (coba == NULL) return;
-
+       
        bt = uiDefBut(block, BUT, 0, IFACE_("Add"), 0 + xoffs, line1_y, 40, UI_UNIT_Y, NULL, 0, 0, 0, 0,
                      TIP_("Add a new color stop to the colorband"));
        uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
        bt = uiDefBut(block, BUT, 0, IFACE_("Add"), 0 + xoffs, line1_y, 40, UI_UNIT_Y, NULL, 0, 0, 0, 0,
                      TIP_("Add a new color stop to the colorband"));
        uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
@@ -1547,8 +1547,8 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
        cb->ptr = *ptr;
        cb->prop = prop;
 
        cb->ptr = *ptr;
        cb->prop = prop;
 
-       rect.xmin = 0; rect.xmax = 200;
-       rect.ymin = 0; rect.ymax = 190;
+       rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
+       rect.ymin = 0; rect.ymax = 19.5f * UI_UNIT_X;
 
        block = uiLayoutAbsoluteBlock(layout);
        colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
 
        block = uiLayoutAbsoluteBlock(layout);
        colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
@@ -1579,8 +1579,8 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
        cb->ptr = *ptr;
        cb->prop = prop;
        
        cb->ptr = *ptr;
        cb->prop = prop;
        
-       rect.xmin = 0; rect.xmax = 200;
-       rect.ymin = 0; rect.ymax = 190;
+       rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
+       rect.ymin = 0; rect.ymax = 9.5f * UI_UNIT_Y;
        
        block = uiLayoutAbsoluteBlock(layout);
        //colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
        
        block = uiLayoutAbsoluteBlock(layout);
        //colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
@@ -1589,8 +1589,9 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
 
        hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
 
 
        hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
 
-       bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist,
-                     0, 0, 0, 0, "");
+       bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), UI_DPI_FAC * hist->height,
+                                 hist, 0, 0, 0, 0, "");
+
        uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
 
        MEM_freeN(cb);
        uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
 
        MEM_freeN(cb);
@@ -1620,15 +1621,15 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
        cb->ptr = *ptr;
        cb->prop = prop;
        
        cb->ptr = *ptr;
        cb->prop = prop;
        
-       rect.xmin = 0; rect.xmax = 200;
-       rect.ymin = 0; rect.ymax = 190;
+       rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
+       rect.ymin = 0; rect.ymax = 9.5f * UI_UNIT_Y;
        
        block = uiLayoutAbsoluteBlock(layout);
        
        scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
 
        
        block = uiLayoutAbsoluteBlock(layout);
        
        scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
 
-       bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes,
-                     0, 0, 0, 0, "");
+       bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), UI_DPI_FAC * scopes->wavefrm_height,
+                                 scopes, 0, 0, 0, 0, "");
        (void)bt;  /* UNUSED */
        
        MEM_freeN(cb);
        (void)bt;  /* UNUSED */
        
        MEM_freeN(cb);
@@ -1658,15 +1659,15 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
        cb->ptr = *ptr;
        cb->prop = prop;
        
        cb->ptr = *ptr;
        cb->prop = prop;
        
-       rect.xmin = 0; rect.xmax = 200;
-       rect.ymin = 0; rect.ymax = 190;
+       rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
+       rect.ymin = 0; rect.ymax = 9.5f * UI_UNIT_Y;
        
        block = uiLayoutAbsoluteBlock(layout);
 
        scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
        
        bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect),
        
        block = uiLayoutAbsoluteBlock(layout);
 
        scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
        
        bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect),
-                     scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
+                                 UI_DPI_FAC * scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
        uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
        
        MEM_freeN(cb);
        uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
        
        MEM_freeN(cb);
@@ -2010,7 +2011,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
        /* curve itself */
        size = uiLayoutGetWidth(layout);
        row = uiLayoutRow(layout, FALSE);
        /* curve itself */
        size = uiLayoutGetWidth(layout);
        row = uiLayoutRow(layout, FALSE);
-       uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, "");
+       uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 10.0f * UI_UNIT_X), cumap, 0.0f, 1.0f, bg, 0, "");
 
        /* sliders for selected point */
        for (i = 0; i < cm->totpoint; i++) {
 
        /* sliders for selected point */
        for (i = 0; i < cm->totpoint; i++) {
@@ -2081,7 +2082,7 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
 
 /********************* ColorPicker Template ************************/
 
 
 /********************* ColorPicker Template ************************/
 
-#define WHEEL_SIZE  100
+#define WHEEL_SIZE  (5*U.widget_unit)
 
 /* This template now follows User Preference for type - name is not correct anymore... */
 void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider,
 
 /* This template now follows User Preference for type - name is not correct anymore... */
 void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider,
index c4b80f0a42fe526dc6dd5a180bf252521fb7e2e3..77fbe940c4a8c0334e165d48bd79b18200d9f51e 100644 (file)
@@ -333,10 +333,10 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
 {
        float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2];
        float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
 {
        float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2];
        float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
-       float minxi = minx + 1.0f; /* boundbox inner */
-       float maxxi = maxx - 1.0f;
-       float minyi = miny + 1.0f;
-       float maxyi = maxy - 1.0f;
+       float minxi = minx + U.pixelsize; /* boundbox inner */
+       float maxxi = maxx - U.pixelsize;
+       float minyi = miny + U.pixelsize;
+       float maxyi = maxy - U.pixelsize;
        float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; /* for uv, can divide by zero */
        float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
        int a, tot = 0, minsize;
        float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; /* for uv, can divide by zero */
        float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
        int a, tot = 0, minsize;
@@ -352,7 +352,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
                rad = 0.5f * minsize;
 
        if (2.0f * (radi + 1.0f) > minsize)
                rad = 0.5f * minsize;
 
        if (2.0f * (radi + 1.0f) > minsize)
-               radi = 0.5f * minsize - 1.0f;
+               radi = 0.5f * minsize - U.pixelsize;
        
        /* mult */
        for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
        
        /* mult */
        for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
@@ -481,7 +481,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
 
 static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad)
 {
 
 static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad)
 {
-       round_box__edges(wt, roundboxalign, rect, rad, rad - 1.0f);
+       round_box__edges(wt, roundboxalign, rect, rad, rad - U.pixelsize);
 }
 
 
 }
 
 
@@ -863,7 +863,7 @@ static int ui_but_draw_menu_icon(uiBut *but)
 
 static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
 {
 
 static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
 {
-       int xs = 0, ys = 0;
+       float xs = 0.0f, ys = 0.0f;
        float aspect, height;
        
        if (but->flag & UI_ICON_PREVIEW) {
        float aspect, height;
        
        if (but->flag & UI_ICON_PREVIEW) {
@@ -874,21 +874,13 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
        /* this icon doesn't need draw... */
        if (icon == ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU) == 0) return;
        
        /* this icon doesn't need draw... */
        if (icon == ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU) == 0) return;
        
-       /* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */
-       aspect = but->block->aspect;
-       if (aspect != but->aspect) {
-               /* prevent scaling up icon in pupmenu */
-               if (aspect < 1.0f) {
-                       height = UI_DPI_ICON_SIZE;
-                       aspect = 1.0f;
-                       
-               }
-               else 
-                       height = UI_DPI_ICON_SIZE / aspect;
-       }
-       else
-               height = UI_DPI_ICON_SIZE;
-       
+       /* XXX remove hack when new icons are made */
+       if ( icon == ICON_LAYER_ACTIVE || icon == ICON_LAYER_USED)
+               height = 1.2f * BLI_rcti_size_y(rect); else
+       /* icons are 80% of height of button (16 pixels inside 20 height) */
+       height = 0.8f * BLI_rcti_size_y(rect);
+       aspect = height / ICON_DEFAULT_HEIGHT;
+
        /* calculate blend color */
        if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) {
                if (but->flag & UI_SELECT) {}
        /* calculate blend color */
        if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) {
                if (but->flag & UI_SELECT) {}
@@ -905,45 +897,45 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
                if (but->flag & UI_ICON_LEFT) {
                        if (but->type == BUT_TOGDUAL) {
                                if (but->drawstr[0]) {
                if (but->flag & UI_ICON_LEFT) {
                        if (but->type == BUT_TOGDUAL) {
                                if (but->drawstr[0]) {
-                                       xs = rect->xmin - 1;
+                                       xs = rect->xmin - 1.0f * aspect;
                                }
                                else {
                                }
                                else {
-                                       xs = (rect->xmin + rect->xmax - height) / 2;
+                                       xs = (rect->xmin + rect->xmax - height) / 2.0f;
                                }
                        }
                        else if (but->block->flag & UI_BLOCK_LOOP) {
                                if (but->type == SEARCH_MENU)
                                }
                        }
                        else if (but->block->flag & UI_BLOCK_LOOP) {
                                if (but->type == SEARCH_MENU)
-                                       xs = rect->xmin + 4;
+                                       xs = rect->xmin + 4.0f * aspect;
                                else
                                else
-                                       xs = rect->xmin + 1;
+                                       xs = rect->xmin + 1.0f * aspect;
                        }
                        else if ((but->type == ICONROW) || (but->type == ICONTEXTROW)) {
                        }
                        else if ((but->type == ICONROW) || (but->type == ICONTEXTROW)) {
-                               xs = rect->xmin + 3;
+                               xs = rect->xmin + 3.0f * aspect;
                        }
                        else {
                        }
                        else {
-                               xs = rect->xmin + 4;
+                               xs = rect->xmin + 4.0f * aspect;
                        }
                        }
-                       ys = (rect->ymin + rect->ymax - height) / 2;
+                       ys = (rect->ymin + rect->ymax - height) / 2.0f;
                }
                else {
                }
                else {
-                       xs = (rect->xmin + rect->xmax - height) / 2;
-                       ys = (rect->ymin + rect->ymax - height) / 2;
+                       xs = (rect->xmin + rect->xmax - height) / 2.0f;
+                       ys = (rect->ymin + rect->ymax - height) / 2.0f;
                }
                }
-               
+
                /* to indicate draggable */
                if (but->dragpoin && (but->flag & UI_ACTIVE)) {
                        float rgb[3] = {1.25f, 1.25f, 1.25f};
                /* to indicate draggable */
                if (but->dragpoin && (but->flag & UI_ACTIVE)) {
                        float rgb[3] = {1.25f, 1.25f, 1.25f};
-                       UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb);
+                       UI_icon_draw_aspect_color(xs, ys, icon, 1.0f / aspect, rgb);
                }
                else
                }
                else
-                       UI_icon_draw_aspect(xs, ys, icon, aspect, alpha);
+                       UI_icon_draw_aspect(xs, ys, icon, 1.0f / aspect, alpha);
        }
 
        if (ui_but_draw_menu_icon(but)) {
        }
 
        if (ui_but_draw_menu_icon(but)) {
-               xs = rect->xmax - UI_DPI_ICON_SIZE - 1;
-               ys = (rect->ymin + rect->ymax - height) / 2;
+               xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
+               ys = (rect->ymin + rect->ymax - height) / 2.0f;
                
                
-               UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
+               UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, 1.0f / aspect, alpha);
        }
        
        glDisable(GL_BLEND);
        }
        
        glDisable(GL_BLEND);
@@ -1329,14 +1321,15 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
 
                if (but->flag & UI_HAS_ICON) {
                        widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect);
 
                if (but->flag & UI_HAS_ICON) {
                        widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect);
-
-                       rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC);
+                       
+                       /* icons default draw 0.8f x height */
+                       rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect));
 
                        if (but->editstr || (but->flag & UI_TEXT_LEFT))
 
                        if (but->editstr || (but->flag & UI_TEXT_LEFT))
-                               rect->xmin += 5;
+                               rect->xmin += 0.4f * U.widget_unit;
                }
                else if ((but->flag & UI_TEXT_LEFT))
                }
                else if ((but->flag & UI_TEXT_LEFT))
-                       rect->xmin += 5;
+                       rect->xmin += 0.4f * U.widget_unit;
 
                /* always draw text for textbutton cursor */
                widget_draw_text(fstyle, wcol, but, rect);
 
                /* always draw text for textbutton cursor */
                widget_draw_text(fstyle, wcol, but, rect);
@@ -1816,17 +1809,20 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
        float quad_strip[WIDGET_SIZE_MAX * 2][2];
        
        /* prevent tooltips to not show round shadow */
        float quad_strip[WIDGET_SIZE_MAX * 2][2];
        
        /* prevent tooltips to not show round shadow */
-       if (2.0f * radout > 0.2f * BLI_rcti_size_y(&rect1))
+       if (radout > 0.2f * BLI_rcti_size_y(&rect1))
                rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
        else
                rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
        else
-               rect1.ymax -= 2.0f * radout;
+               rect1.ymax -= radout;
        
        /* inner part */
        totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
 
        /* inverse linear shadow alpha */
        
        /* inner part */
        totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
 
        /* inverse linear shadow alpha */
-       alpha = 0.15;
-       alphastep = 0.67;
+       alpha = 0.15f;
+       if (U.pixelsize > 1.0f)
+               alphastep = 0.78f;
+       else
+               alphastep = 0.67f;
        
        glEnableClientState(GL_VERTEX_ARRAY);
 
        
        glEnableClientState(GL_VERTEX_ARRAY);
 
@@ -1858,17 +1854,17 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
        }
        else if (direction == UI_DOWN) {
                roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
        }
        else if (direction == UI_DOWN) {
                roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
-               rect->ymin -= 4.0;
+               rect->ymin -= 0.1f * U.widget_unit;
        }
        else if (direction == UI_TOP) {
                roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
        }
        else if (direction == UI_TOP) {
                roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
-               rect->ymax += 4.0;
+               rect->ymax += 0.1f * U.widget_unit;
        }
        
        glEnable(GL_BLEND);
        }
        
        glEnable(GL_BLEND);
-       widget_softshadow(rect, roundboxalign, 5.0f, 8.0f);
+       widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit, 0.4f * U.widget_unit);
        
        
-       round_box_edges(&wtb, roundboxalign, rect, 5.0f);
+       round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit);
        wtb.emboss = 0;
        widgetbase_draw(&wtb, wcol);
        
        wtb.emboss = 0;
        widgetbase_draw(&wtb, wcol);
        
@@ -2540,14 +2536,15 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
                fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
                
                /* left part of slider, always rounded */
                fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
                
                /* left part of slider, always rounded */
-               rect1.xmax = rect1.xmin + ceil(offs + 1.0f);
+               rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize);
                round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs);
                wtb1.outline = 0;
                widgetbase_draw(&wtb1, wcol);
                
                /* right part of slider, interpolate roundness */
                rect1.xmax = rect1.xmin + fac + offs;
                round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs);
                wtb1.outline = 0;
                widgetbase_draw(&wtb1, wcol);
                
                /* right part of slider, interpolate roundness */
                rect1.xmax = rect1.xmin + fac + offs;
-               rect1.xmin +=  floor(offs - 1.0f);
+               rect1.xmin +=  floor(offs - U.pixelsize);
+               
                if (rect1.xmax + offs > rect->xmax)
                        offs *= (rect1.xmax + offs - rect->xmax) / offs;
                else 
                if (rect1.xmax + offs > rect->xmax)
                        offs *= (rect1.xmax + offs - rect->xmax) / offs;
                else 
@@ -2577,7 +2574,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
 static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
 {
        uiWidgetBase wtb;
-       float col[4];
+       float rad, col[4];
        int color_profile = but->block->color_profile;
        
        col[3] = 1.0f;
        int color_profile = but->block->color_profile;
        
        col[3] = 1.0f;
@@ -2594,7 +2591,8 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
        widget_init(&wtb);
        
        /* half rounded */
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 5.0f);
+       rad = 0.25f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
                
        ui_get_but_vectorf(but, col);
 
                
        ui_get_but_vectorf(but, col);
 
@@ -2608,7 +2606,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
                rect->ymin += SWATCH_KEYED_BORDER;
                rect->ymax -= SWATCH_KEYED_BORDER;
                
                rect->ymin += SWATCH_KEYED_BORDER;
                rect->ymax -= SWATCH_KEYED_BORDER;
                
-               round_box_edges(&wtb, roundboxalign, rect, 5.0f);
+               round_box_edges(&wtb, roundboxalign, rect, rad);
        }
        
        if (color_profile)
        }
        
        if (color_profile)
@@ -2632,12 +2630,14 @@ static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti
 {
        if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
                uiWidgetBase wtb;
 {
        if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
                uiWidgetBase wtb;
-       
+               float rad;
+               
                widget_init(&wtb);
                wtb.outline = 0;
                
                /* rounded */
                widget_init(&wtb);
                wtb.outline = 0;
                
                /* rounded */
-               round_box_edges(&wtb, UI_CNR_ALL, rect, 10.0f);
+               rad = 0.5f * BLI_rcti_size_y(rect);
+               round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
                widgetbase_draw(&wtb, wcol);
        }
 }
                widgetbase_draw(&wtb, wcol);
        }
 }
@@ -2646,6 +2646,7 @@ static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti
 static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        
        if (state & UI_SELECT)
                SWAP(short, wcol->shadetop, wcol->shadedown);
        
        if (state & UI_SELECT)
                SWAP(short, wcol->shadetop, wcol->shadedown);
@@ -2653,7 +2654,8 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
        widget_init(&wtb);
        
        /* half rounded */
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
 
        
        widgetbase_draw(&wtb, wcol);
 
@@ -2663,11 +2665,13 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
 static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        
        widget_init(&wtb);
        
        /* half rounded */
        
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
        
        /* decoration */
        widget_menu_trias(&wtb.tria1, rect);
        
        /* decoration */
        widget_menu_trias(&wtb.tria1, rect);
@@ -2681,11 +2685,13 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
 static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        
        widget_init(&wtb);
        
        /* half rounded */
        
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
        
        /* decoration */
        widgetbase_draw(&wtb, wcol);
        
        /* decoration */
        widgetbase_draw(&wtb, wcol);
@@ -2696,11 +2702,13 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
        /* silly node link button hacks */
        uiWidgetBase wtb;
        uiWidgetColors wcol_backup = *wcol;
        /* silly node link button hacks */
        uiWidgetBase wtb;
        uiWidgetColors wcol_backup = *wcol;
+       float rad;
        
        widget_init(&wtb);
        
        /* half rounded */
        
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
 
        wcol->inner[0] += 15;
        wcol->inner[1] += 15;
 
        wcol->inner[0] += 15;
        wcol->inner[1] += 15;
@@ -2718,7 +2726,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
 {
        if (state & UI_ACTIVE) {
                uiWidgetBase wtb;
 {
        if (state & UI_ACTIVE) {
                uiWidgetBase wtb;
-               float rad = 0.25f * BLI_rcti_size_y(rect);  /* 4.0f */
+               float rad = 0.2f * U.widget_unit;
 
                widget_init(&wtb);
 
 
                widget_init(&wtb);
 
@@ -2745,12 +2753,14 @@ static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
 static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
 {
        uiWidgetBase wtb;
 static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
 {
        uiWidgetBase wtb;
+       float rad;
        
        widget_init(&wtb);
        
        /* rounded, but no outline */
        wtb.outline = 0;
        
        widget_init(&wtb);
        
        /* rounded, but no outline */
        wtb.outline = 0;
-       round_box_edges(&wtb, UI_CNR_ALL, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
 }
        
        widgetbase_draw(&wtb, wcol);
 }
@@ -2759,6 +2769,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
 {
        uiWidgetBase wtb;
        rcti recttemp = *rect;
 {
        uiWidgetBase wtb;
        rcti recttemp = *rect;
+       float rad;
        int delta;
        
        widget_init(&wtb);
        int delta;
        
        widget_init(&wtb);
@@ -2774,7 +2785,8 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
        recttemp.ymax -= delta;
        
        /* half rounded */
        recttemp.ymax -= delta;
        
        /* half rounded */
-       round_box_edges(&wtb, UI_CNR_ALL, &recttemp, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
        
        /* decoration */
        if (state & UI_SELECT) {
        
        /* decoration */
        if (state & UI_SELECT) {
@@ -2791,11 +2803,13 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
 static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        
        widget_init(&wtb);
        
        /* half rounded */
        
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
 
        
        widgetbase_draw(&wtb, wcol);
 
@@ -2804,6 +2818,7 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
 static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        char old_col[3];
        
        widget_init(&wtb);
        char old_col[3];
        
        widget_init(&wtb);
@@ -2818,7 +2833,8 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
        }
        
        /* half rounded */
        }
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
        
        
        widgetbase_draw(&wtb, wcol);
        
@@ -2833,12 +2849,14 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
 static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
+       float rad;
        
        widget_init(&wtb);
        
        /* half rounded */
        
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
-               
+       rad = 0.2f * U.widget_unit;
+       round_box_edges(&wtb, roundboxalign, rect, rad);
+       
        widgetbase_draw(&wtb, wcol);
 
 }
        widgetbase_draw(&wtb, wcol);
 
 }
@@ -2846,7 +2864,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
 static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
 static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
-       float rad = 5.0f;  /* 0.5f * BLI_rcti_size_y(rect); */
+       float rad = 0.25f * U.widget_unit;
        
        widget_init(&wtb);
        
        
        widget_init(&wtb);
        
@@ -2859,6 +2877,7 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
 static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
 {
        uiWidgetBase wtb;
 static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
 {
        uiWidgetBase wtb;
+       float rad = 0.25f * U.widget_unit;
        unsigned char col[4];
        
        /* state copy! */
        unsigned char col[4];
        
        /* state copy! */
@@ -2874,12 +2893,12 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
                UI_GetThemeColor3ubv(TH_BACK, col);
                glColor3ubv(col);
                
                UI_GetThemeColor3ubv(TH_BACK, col);
                glColor3ubv(col);
                
-               round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, 4.0);
+               round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, rad);
                widgetbase_outline(&wtb);
        }
        
        /* outline */
                widgetbase_outline(&wtb);
        }
        
        /* outline */
-       round_box_edges(&wtb, UI_CNR_ALL, rect, 5.0f);
+       round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
        wtb.outline = 1;
        wtb.inner = 0;
        widgetbase_draw(&wtb, &wt->wcol);
        wtb.outline = 1;
        wtb.inner = 0;
        widgetbase_draw(&wtb, &wt->wcol);
@@ -3068,9 +3087,9 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
                
                /* ui_block_position has this correction too, keep in sync */
                if (but->flag & UI_BUT_ALIGN_TOP)
                
                /* ui_block_position has this correction too, keep in sync */
                if (but->flag & UI_BUT_ALIGN_TOP)
-                       rect->ymax += 1;
+                       rect->ymax += U.pixelsize;
                if (but->flag & UI_BUT_ALIGN_LEFT)
                if (but->flag & UI_BUT_ALIGN_LEFT)
-                       rect->xmin -= 1;
+                       rect->xmin -= U.pixelsize;
                
                switch (but->flag & UI_BUT_ALIGN) {
                        case UI_BUT_ALIGN_TOP:
                
                switch (but->flag & UI_BUT_ALIGN) {
                        case UI_BUT_ALIGN_TOP:
@@ -3381,7 +3400,7 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
        uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
        
        glEnable(GL_BLEND);
        uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
        
        glEnable(GL_BLEND);
-       widget_softshadow(rect, UI_CNR_ALL, 5.0f, 8.0f);
+       widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit, 0.4f * U.widget_unit);
        glDisable(GL_BLEND);
 
        wt->state(wt, 0);
        glDisable(GL_BLEND);
 
        wt->state(wt, 0);
@@ -3408,7 +3427,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
        fstyle->align = UI_STYLE_TEXT_LEFT;
        
        /* text location offset */
        fstyle->align = UI_STYLE_TEXT_LEFT;
        
        /* text location offset */
-       rect->xmin += 5;
+       rect->xmin += 0.25f * UI_UNIT_X;
        if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
 
        /* cut string in 2 parts? */
        if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
 
        /* cut string in 2 parts? */
@@ -3433,10 +3452,16 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
        *rect = _rect;
 
        if (iconid) {
        *rect = _rect;
 
        if (iconid) {
-               int xs = rect->xmin + 4;
+               float height, aspect;
+               int xs = rect->xmin + 0.2f * UI_UNIT_X;
                int ys = 1 + (rect->ymin + rect->ymax - UI_DPI_ICON_SIZE) / 2;
                int ys = 1 + (rect->ymin + rect->ymax - UI_DPI_ICON_SIZE) / 2;
+               
+               /* icons are 80% of height of button (16 pixels inside 20 height) */
+               height = 0.8f * BLI_rcti_size_y(rect);
+               aspect = ICON_DEFAULT_HEIGHT / height;
+
                glEnable(GL_BLEND);
                glEnable(GL_BLEND);
-               UI_icon_draw_aspect(xs, ys, iconid, 1.2f, 0.5f); /* XXX scale weak get from fstyle? */
+               UI_icon_draw_aspect(xs, ys, iconid, aspect, 0.5f); /* XXX scale weak get from fstyle? */
                glDisable(GL_BLEND);
        }
 }
                glDisable(GL_BLEND);
        }
 }
index fa5d5806bb886d6959e72ee5f013c6ed6eece9b3..3a482b97d3747003b12eda7b1a43608a48e72dac 100644 (file)
@@ -1990,7 +1990,7 @@ void init_userdef_do_versions(void)
        if (U.dragthreshold == 0)
                U.dragthreshold = 5;
        if (U.widget_unit == 0)
        if (U.dragthreshold == 0)
                U.dragthreshold = 5;
        if (U.widget_unit == 0)
-               U.widget_unit = (U.dpi * 20 + 36) / 72;
+               U.widget_unit = 20;
        if (U.anisotropic_filter <= 0)
                U.anisotropic_filter = 1;
 
        if (U.anisotropic_filter <= 0)
                U.anisotropic_filter = 1;
 
@@ -2009,6 +2009,23 @@ void init_userdef_do_versions(void)
        if (U.tweak_threshold == 0)
                U.tweak_threshold = 10;
 
        if (U.tweak_threshold == 0)
                U.tweak_threshold = 10;
 
+       if (bmain->versionfile < 265) { /* XXX fix for when you apply */
+               bTheme *btheme;
+               
+               for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+                       /* note: the toggle operator for transparent backdrops limits to these spacetypes */
+                       if (btheme->tnode.button[3] == 255) {
+                               btheme->tv3d.button[3] = 128;
+                               btheme->tnode.button[3] = 128;
+                               btheme->tima.button[3] = 128;
+                               btheme->tseq.button[3] = 128;
+                               btheme->tclip.button[3] = 128;
+                       }
+               }
+       }
+       if (U.pixelsize == 0.0f)
+               U.pixelsize = 1.0f;
+       
        /* funny name, but it is GE stuff, moves userdef stuff to engine */
 // XXX space_set_commmandline_options();
        /* this timer uses U */
        /* funny name, but it is GE stuff, moves userdef stuff to engine */
 // XXX space_set_commmandline_options();
        /* this timer uses U */
index f1a3f59bc22ddab075872f3bdd5a8a630019eaac..356b5a687ff760b07e669456af81638633889c0e 100644 (file)
@@ -1150,7 +1150,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d,
                pixels = (float)BLI_rcti_size_x(&v2d->mask);
                
                if (pixels != 0.0f) {
                pixels = (float)BLI_rcti_size_x(&v2d->mask);
                
                if (pixels != 0.0f) {
-                       grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels);
+                       grid->dx = (U.v2d_min_gridsize * U.pixelsize * space) / (seconddiv * pixels);
                        step_to_grid(&grid->dx, &grid->powerx, xunits);
                        grid->dx *= seconddiv;
                }
                        step_to_grid(&grid->dx, &grid->powerx, xunits);
                        grid->dx *= seconddiv;
                }
@@ -1167,7 +1167,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d,
                space = BLI_rctf_size_y(&v2d->cur);
                pixels = (float)winy;
                
                space = BLI_rctf_size_y(&v2d->cur);
                pixels = (float)winy;
                
-               grid->dy = U.v2d_min_gridsize * space / pixels;
+               grid->dy = U.v2d_min_gridsize * U.pixelsize * space / pixels;
                step_to_grid(&grid->dy, &grid->powery, yunits);
                
                if (yclamp == V2D_GRID_CLAMP) {
                step_to_grid(&grid->dy, &grid->powery, yunits);
                
                if (yclamp == V2D_GRID_CLAMP) {
@@ -1212,7 +1212,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
                vec2[1] = v2d->cur.ymax;
                
                /* minor gridlines */
                vec2[1] = v2d->cur.ymax;
                
                /* minor gridlines */
-               step = (BLI_rcti_size_x(&v2d->mask) + 1) / U.v2d_min_gridsize;
+               step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * U.pixelsize);
                UI_ThemeColor(TH_GRID);
                
                for (a = 0; a < step; a++) {
                UI_ThemeColor(TH_GRID);
                
                for (a = 0; a < step; a++) {
@@ -1246,7 +1246,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
                vec1[0] = grid->startx;
                vec2[0] = v2d->cur.xmax;
                
                vec1[0] = grid->startx;
                vec2[0] = v2d->cur.xmax;
                
-               step = (BLI_rcti_size_y(&v2d->mask) + 1) / U.v2d_min_gridsize;
+               step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * U.pixelsize);
                
                UI_ThemeColor(TH_GRID);
                for (a = 0; a <= step; a++) {
                
                UI_ThemeColor(TH_GRID);
                for (a = 0; a <= step; a++) {
@@ -1427,6 +1427,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
        rcti vert, hor;
        float fac1, fac2, totsize, scrollsize;
        int scroll = view2d_scroll_mapped(v2d->scroll);
        rcti vert, hor;
        float fac1, fac2, totsize, scrollsize;
        int scroll = view2d_scroll_mapped(v2d->scroll);
+       int smaller;
        
        /* scrollers is allocated here... */
        scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
        
        /* scrollers is allocated here... */
        scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
@@ -1435,19 +1436,20 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
        hor = v2d->hor;
        
        /* slider rects need to be smaller than region */
        hor = v2d->hor;
        
        /* slider rects need to be smaller than region */
-       hor.xmin += 4;
-       hor.xmax -= 4;
+       smaller = (int)(0.2f * U.widget_unit);
+       hor.xmin += smaller;
+       hor.xmax -= smaller;
        if (scroll & V2D_SCROLL_BOTTOM)
        if (scroll & V2D_SCROLL_BOTTOM)
-               hor.ymin += 4;
+               hor.ymin += smaller;
        else
        else
-               hor.ymax -= 4;
+               hor.ymax -= smaller;
        
        if (scroll & V2D_SCROLL_LEFT)
        
        if (scroll & V2D_SCROLL_LEFT)
-               vert.xmin += 4;
+               vert.xmin += smaller;
        else
        else
-               vert.xmax -= 4;
-       vert.ymin += 4;
-       vert.ymax -= 4;
+               vert.xmax -= smaller;
+       vert.ymin += smaller;
+       vert.ymax -= smaller;
        
        CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
        CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
        
        CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
        CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
@@ -1621,6 +1623,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                        uiWidgetColors wcol = btheme->tui.wcol_scroll;
                        rcti slider;
                        int state;
                        uiWidgetColors wcol = btheme->tui.wcol_scroll;
                        rcti slider;
                        int state;
+                       unsigned char col[4];
                        
                        slider.xmin = vs->hor_min;
                        slider.xmax = vs->hor_max;
                        
                        slider.xmin = vs->hor_min;
                        slider.xmax = vs->hor_max;
@@ -1643,8 +1646,12 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                                state |= UI_SCROLL_ARROWS;
                        }
                        
                                state |= UI_SCROLL_ARROWS;
                        }
                        
-                       UI_ThemeColor(TH_BACK);
-                       glRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax);
+                       /* clean rect behind slider, but not with transparent background */
+                       UI_GetThemeColor4ubv(TH_BACK, col);
+                       if (col[3] == 255) {
+                               glColor3ub(col[0], col[1],col[2]);
+                               glRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax);
+                       }
                        
                        uiWidgetScrollDraw(&wcol, &hor, &slider, state);
                }
                        
                        uiWidgetScrollDraw(&wcol, &hor, &slider, state);
                }
@@ -1680,12 +1687,12 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                        
                        /* draw numbers in the appropriate range */
                        if (dfac > 0.0f) {
                        
                        /* draw numbers in the appropriate range */
                        if (dfac > 0.0f) {
-                               float h = 2.0f + (float)(hor.ymin);
+                               float h = 0.1f*UI_UNIT_Y + (float)(hor.ymin);
                                
                                
-                               for (; fac < hor.xmax - 10; fac += dfac, val += grid->dx) {
+                               for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) {
                                        
                                        /* make prints look nicer for scrollers */
                                        
                                        /* make prints look nicer for scrollers */
-                                       if (fac < hor.xmin + 10)
+                                       if (fac < hor.xmin + 0.5f * U.widget_unit)
                                                continue;
                                        
                                        switch (vs->xunits) {
                                                continue;
                                        
                                        switch (vs->xunits) {
@@ -1732,6 +1739,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                        uiWidgetColors wcol = btheme->tui.wcol_scroll;
                        rcti slider;
                        int state;
                        uiWidgetColors wcol = btheme->tui.wcol_scroll;
                        rcti slider;
                        int state;
+                       unsigned char col[4];
                        
                        slider.xmin = vert.xmin;
                        slider.xmax = vert.xmax;
                        
                        slider.xmin = vert.xmin;
                        slider.xmax = vert.xmax;
@@ -1753,9 +1761,13 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                        {
                                state |= UI_SCROLL_ARROWS;
                        }
                        {
                                state |= UI_SCROLL_ARROWS;
                        }
-                               
-                       UI_ThemeColor(TH_BACK);
-                       glRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax);
+                       
+                       /* clean rect behind slider, but not with transparent background */
+                       UI_GetThemeColor4ubv(TH_BACK, col);
+                       if (col[3] == 255) {
+                               glColor3ub(col[0], col[1],col[2]);
+                               glRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax);
+                       }
                        
                        uiWidgetScrollDraw(&wcol, &vert, &slider, state);
                }
                        
                        uiWidgetScrollDraw(&wcol, &vert, &slider, state);
                }
index f30e0abb4f3294cdfbb4afbf96a5acc72e8b209b..852ce02fa40e04ffe2c0fcc66477758f8374e05a 100644 (file)
@@ -235,8 +235,8 @@ static void region_draw_azone_icon(AZone *az)
 
 static void draw_azone_plus(float x1, float y1, float x2, float y2)
 {
 
 static void draw_azone_plus(float x1, float y1, float x2, float y2)
 {
-       float width = 2.0f;
-       float pad = 4.0f;
+       float width = 0.05f * U.widget_unit;
+       float pad = 0.2f * U.widget_unit;
        
        glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad);
        glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f);
        
        glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad);
        glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f);
@@ -395,47 +395,14 @@ void ED_area_overdraw(bContext *C)
        
 }
 
        
 }
 
-/* get scissor rect, checking overlapping regions */
-void region_scissor_winrct(ARegion *ar, rcti *winrct)
-{
-       *winrct = ar->winrct;
-       
-       if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT))
-               return;
-
-       while (ar->prev) {
-               ar = ar->prev;
-               
-               if (BLI_rcti_isect(winrct, &ar->winrct, NULL)) {
-                       if (ar->flag & RGN_FLAG_HIDDEN) {
-                               /* pass */
-                       }
-                       else if (ar->alignment & RGN_SPLIT_PREV) {
-                               /* pass */
-                       }
-                       else if (ar->alignment == RGN_OVERLAP_LEFT) {
-                               winrct->xmin = ar->winrct.xmax + 1;
-                       }
-                       else if (ar->alignment == RGN_OVERLAP_RIGHT) {
-                               winrct->xmax = ar->winrct.xmin - 1;
-                       }
-                       else break;
-               }
-       }
-}
-
 /* only exported for WM */
 /* makes region ready for drawing, sets pixelspace */
 void ED_region_set(const bContext *C, ARegion *ar)
 {
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
 /* only exported for WM */
 /* makes region ready for drawing, sets pixelspace */
 void ED_region_set(const bContext *C, ARegion *ar)
 {
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
-       rcti winrct;
        
        
-       /* checks other overlapping regions */
-       region_scissor_winrct(ar, &winrct);
-       
-       ar->drawrct = winrct;
+       ar->drawrct = ar->winrct;
        
        /* note; this sets state, so we can use wmOrtho and friends */
        wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
        
        /* note; this sets state, so we can use wmOrtho and friends */
        wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
@@ -452,24 +419,20 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegionType *at = ar->type;
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegionType *at = ar->type;
-       rcti winrct;
        
        /* see BKE_spacedata_draw_locks() */
        if (at->do_lock)
                return;
        
        
        /* see BKE_spacedata_draw_locks() */
        if (at->do_lock)
                return;
        
-       /* checks other overlapping regions */
-       region_scissor_winrct(ar, &winrct);
-       
        /* if no partial draw rect set, full rect */
        if (ar->drawrct.xmin == ar->drawrct.xmax)
        /* if no partial draw rect set, full rect */
        if (ar->drawrct.xmin == ar->drawrct.xmax)
-               ar->drawrct = winrct;
+               ar->drawrct = ar->winrct;
        else {
                /* extra clip for safety (intersect the rects, could use API func) */
        else {
                /* extra clip for safety (intersect the rects, could use API func) */
-               ar->drawrct.xmin = max_ii(winrct.xmin, ar->drawrct.xmin);
-               ar->drawrct.ymin = max_ii(winrct.ymin, ar->drawrct.ymin);
-               ar->drawrct.xmax = min_ii(winrct.xmax, ar->drawrct.xmax);
-               ar->drawrct.ymax = min_ii(winrct.ymax, ar->drawrct.ymax);
+               ar->drawrct.xmin = max_ii(ar->winrct.xmin, ar->drawrct.xmin);
+               ar->drawrct.ymin = max_ii(ar->winrct.ymin, ar->drawrct.ymin);
+               ar->drawrct.xmax = min_ii(ar->winrct.xmax, ar->drawrct.xmax);
+               ar->drawrct.ymax = min_ii(ar->winrct.ymax, ar->drawrct.ymax);
        }
        
        /* note; this sets state, so we can use wmOrtho and friends */
        }
        
        /* note; this sets state, so we can use wmOrtho and friends */
@@ -500,7 +463,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        uiFreeInactiveBlocks(C, &ar->uiblocks);
 
        if (sa)
        uiFreeInactiveBlocks(C, &ar->uiblocks);
 
        if (sa)
-               region_draw_emboss(ar, &winrct);
+               region_draw_emboss(ar, &ar->winrct);
 }
 
 /* **********************************
 }
 
 /* **********************************
@@ -627,8 +590,8 @@ static void area_azone_initialize(bScreen *screen, ScrArea *sa)
        BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
 }
 
        BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
 }
 
-#define AZONEPAD_EDGE   4
-#define AZONEPAD_ICON   9
+#define AZONEPAD_EDGE   (0.2f * U.widget_unit)
+#define AZONEPAD_ICON   (0.45f * U.widget_unit)
 static void region_azone_edge(AZone *az, ARegion *ar)
 {
        switch (az->edge) {
 static void region_azone_edge(AZone *az, ARegion *ar)
 {
        switch (az->edge) {
@@ -720,8 +683,8 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar)
        }
 }
 
        }
 }
 
-#define AZONEPAD_TAB_PLUSW  14
-#define AZONEPAD_TAB_PLUSH  14
+#define AZONEPAD_TAB_PLUSW  (0.7f * U.widget_unit)
+#define AZONEPAD_TAB_PLUSH  (0.7f * U.widget_unit)
 
 /* region already made zero sized, in shape of edge */
 static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
 
 /* region already made zero sized, in shape of edge */
 static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
@@ -765,8 +728,8 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
 }      
 
 
 }      
 
 
-#define AZONEPAD_TABW   18
-#define AZONEPAD_TABH   7
+#define AZONEPAD_TABW   (0.9f * U.widget_unit)
+#define AZONEPAD_TABH   (0.35f * U.widget_unit)
 
 /* region already made zero sized, in shape of edge */
 static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
 
 /* region already made zero sized, in shape of edge */
 static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
@@ -809,8 +772,8 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
        BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
 }      
 
        BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
 }      
 
-#define AZONEPAD_TRIAW  16
-#define AZONEPAD_TRIAH  9
+#define AZONEPAD_TRIAW  (0.8f * U.widget_unit)
+#define AZONEPAD_TRIAH  (0.45f * U.widget_unit)
 
 
 /* region already made zero sized, in shape of edge */
 
 
 /* region already made zero sized, in shape of edge */
@@ -892,9 +855,9 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
                region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
        else if (alignment == RGN_ALIGN_BOTTOM)
                region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
                region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
        else if (alignment == RGN_ALIGN_BOTTOM)
                region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
-       else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+       else if (alignment == RGN_ALIGN_RIGHT)
                region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
                region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
-       else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
+       else if (alignment == RGN_ALIGN_LEFT)
                region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
 }
 
                region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
 }
 
@@ -909,7 +872,20 @@ static int rct_fits(rcti *rect, char dir, int size)
        }
 }
 
        }
 }
 
-static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
+/* *************************************************************** */
+
+/* overlapping regions only in the following restricted cases */
+static int region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
+{
+       if (U.uiflag2 & USER_REGION_OVERLAP)
+               if (WM_is_draw_triple(win))
+                       if (ELEM5(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ, SPACE_CLIP, SPACE_NODE))
+                               if (ELEM3(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
+                                       return 1;
+       return 0;
+}
+
+static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
 {
        rcti *remainder_prev = remainder;
        int prefsizex, prefsizey;
 {
        rcti *remainder_prev = remainder;
        int prefsizex, prefsizey;
@@ -928,6 +904,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
        
        alignment = ar->alignment & ~RGN_SPLIT_PREV;
        
        
        alignment = ar->alignment & ~RGN_SPLIT_PREV;
        
+       /* set here, assuming userpref switching forces to call this again */
+       ar->overlap = region_is_overlap(win, sa, ar);
+
        /* clear state flags first */
        ar->flag &= ~RGN_FLAG_TOO_SMALL;
        /* user errors */
        /* clear state flags first */
        ar->flag &= ~RGN_FLAG_TOO_SMALL;
        /* user errors */
@@ -935,15 +914,15 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                alignment = RGN_ALIGN_NONE;
        
        /* prefsize, for header we stick to exception */
                alignment = RGN_ALIGN_NONE;
        
        /* prefsize, for header we stick to exception */
-       prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex;
+       prefsizex = ar->sizex ? ar->sizex : UI_DPI_FAC * ar->type->prefsizex;
        if (ar->regiontype == RGN_TYPE_HEADER) {
        if (ar->regiontype == RGN_TYPE_HEADER) {
-               prefsizey = ar->type->prefsizey;
+               prefsizey = ED_area_headersize();
        }
        else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
                prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
        }
        else {
        }
        else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
                prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
        }
        else {
-               prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey;
+               prefsizey = ar->sizey ? ar->sizey : UI_DPI_FAC * ar->type->prefsizey;
        }
 
 
        }
 
 
@@ -985,7 +964,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                        }
                }
        }
                        }
                }
        }
-       else if (ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) {
+       else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
                
                if (rct_fits(remainder, 'h', prefsizex) < 0) {
                        ar->flag |= RGN_FLAG_TOO_SMALL;
                
                if (rct_fits(remainder, 'h', prefsizex) < 0) {
                        ar->flag |= RGN_FLAG_TOO_SMALL;
@@ -998,14 +977,14 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                        
                        ar->winrct = *remainder;
                        
                        
                        ar->winrct = *remainder;
                        
-                       if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) {
+                       if (alignment == RGN_ALIGN_RIGHT) {
                                ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
                                ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
-                               if (alignment == RGN_ALIGN_RIGHT)
+                               if (ar->overlap == 0)
                                        remainder->xmax = ar->winrct.xmin - 1;
                        }
                        else {
                                ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
                                        remainder->xmax = ar->winrct.xmin - 1;
                        }
                        else {
                                ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
-                               if (alignment == RGN_ALIGN_LEFT)
+                               if (ar->overlap == 0)
                                        remainder->xmin = ar->winrct.xmax + 1;
                        }
                }
                                        remainder->xmin = ar->winrct.xmax + 1;
                        }
                }
@@ -1090,9 +1069,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                        ar->winrct.ymin = ar->winrct.ymax;
                else if (alignment == RGN_ALIGN_BOTTOM)
                        ar->winrct.ymax = ar->winrct.ymin;
                        ar->winrct.ymin = ar->winrct.ymax;
                else if (alignment == RGN_ALIGN_BOTTOM)
                        ar->winrct.ymax = ar->winrct.ymin;
-               else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+               else if (alignment == RGN_ALIGN_RIGHT)
                        ar->winrct.xmin = ar->winrct.xmax;
                        ar->winrct.xmin = ar->winrct.xmax;
-               else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
+               else if (alignment == RGN_ALIGN_LEFT)
                        ar->winrct.xmax = ar->winrct.xmin;
                else /* prevent winrct to be valid */
                        ar->winrct.xmax = ar->winrct.xmin;
                        ar->winrct.xmax = ar->winrct.xmin;
                else /* prevent winrct to be valid */
                        ar->winrct.xmax = ar->winrct.xmin;
@@ -1121,12 +1100,12 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                region_azone_add(sa, ar, alignment);
        }
 
                region_azone_add(sa, ar, alignment);
        }
 
-       region_rect_recursive(sa, ar->next, remainder, quad);
+       region_rect_recursive(win, sa, ar->next, remainder, quad);
 }
 
 static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
 {
 }
 
 static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
 {
-       short rt = 0; // CLAMPIS(G.debug_value, 0, 16);
+       short rt = U.pixelsize > 1 ? 1 : 0;
 
        if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + 1 + rt;
        else sa->totrct.xmin = sa->v1->vec.x;
 
        if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + 1 + rt;
        else sa->totrct.xmin = sa->v1->vec.x;
@@ -1229,14 +1208,14 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
                ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
        
        /* area sizes */
                ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
        
        /* area sizes */
-       area_calc_totrct(sa, win->sizex, win->sizey);
+       area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
        
        /* clear all azones, add the area triange widgets */
        area_azone_initialize(win->screen, sa);
 
        /* region rect sizes */
        rect = sa->totrct;
        
        /* clear all azones, add the area triange widgets */
        area_azone_initialize(win->screen, sa);
 
        /* region rect sizes */
        rect = sa->totrct;
-       region_rect_recursive(sa, sa->regionbase.first, &rect, 0);
+       region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
        
        /* default area handlers */
        ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
        
        /* default area handlers */
        ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
@@ -1284,11 +1263,17 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar)
 
        ar->flag ^= RGN_FLAG_HIDDEN;
 
 
        ar->flag ^= RGN_FLAG_HIDDEN;
 
-       if (ar->flag & RGN_FLAG_HIDDEN)
-               WM_event_remove_handlers(C, &ar->handlers);
+       if (ar->overlap) {
+               /* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
+               region_blend_start(C, sa, ar);
+       }
+       else {
+               if (ar->flag & RGN_FLAG_HIDDEN)
+                       WM_event_remove_handlers(C, &ar->handlers);
 
 
-       ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
-       ED_area_tag_redraw(sa);
+               ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
+               ED_area_tag_redraw(sa);
+       }
 }
 
 /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
 }
 
 /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
@@ -1441,7 +1426,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
 {
        SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
 
 {
        SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
 
-       if (sl->next) {
+       if (sl && sl->next) {
                /* workaround for case of double prevspace, render window
                 * with a file browser on top of it */
                if (sl->next->spacetype == SPACE_FILE && sl->next->next)
                /* workaround for case of double prevspace, render window
                 * with a file browser on top of it */
                if (sl->next->spacetype == SPACE_FILE && sl->next->next)
@@ -1565,14 +1550,14 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
 void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
 {
        ScrArea *sa = CTX_wm_area(C);
 void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
 {
        ScrArea *sa = CTX_wm_area(C);
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiBlock *block;
        PanelType *pt;
        Panel *panel;
        View2D *v2d = &ar->v2d;
        View2DScrollers *scrollers;
        int x, y, xco, yco, w, em, triangle, open, newcontext = 0;
        uiBlock *block;
        PanelType *pt;
        Panel *panel;
        View2D *v2d = &ar->v2d;
        View2DScrollers *scrollers;
        int x, y, xco, yco, w, em, triangle, open, newcontext = 0;
-
+       
        if (contextnr >= 0)
                newcontext = UI_view2d_tab_set(v2d, contextnr);
 
        if (contextnr >= 0)
                newcontext = UI_view2d_tab_set(v2d, contextnr);
 
@@ -1653,8 +1638,18 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
        uiEndPanels(C, ar, &x, &y);
 
        /* clear */
        uiEndPanels(C, ar, &x, &y);
 
        /* clear */
-       UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       if (ar->overlap) {
+               /* view should be in pixelspace */
+               UI_view2d_view_restore(C);
+               glEnable(GL_BLEND);
+               UI_ThemeColor4((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+               glRecti(0, 0, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
+               glDisable(GL_BLEND);
+       }
+       else {
+               UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+               glClear(GL_COLOR_BUFFER_BIT);
+       }
        
        /* before setting the view */
        if (vertical) {
        
        /* before setting the view */
        if (vertical) {
@@ -1725,7 +1720,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
 
 void ED_region_header(const bContext *C, ARegion *ar)
 {
 
 void ED_region_header(const bContext *C, ARegion *ar)
 {
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiBlock *block;
        uiLayout *layout;
        HeaderType *ht;
        uiBlock *block;
        uiLayout *layout;
        HeaderType *ht;
@@ -1740,8 +1735,8 @@ void ED_region_header(const bContext *C, ARegion *ar)
        /* set view2d view matrix for scrolling (without scrollers) */
        UI_view2d_view_ortho(&ar->v2d);
 
        /* set view2d view matrix for scrolling (without scrollers) */
        UI_view2d_view_ortho(&ar->v2d);
 
-       xco = maxco = 8;
-       yco = headery - 4;
+       xco = maxco = 0.4f * UI_UNIT_X;
+       yco = headery - floor(0.2f * UI_UNIT_Y);
 
        /* draw all headers types */
        for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
 
        /* draw all headers types */
        for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
@@ -1784,18 +1779,16 @@ void ED_region_header_init(ARegion *ar)
 /* UI_UNIT_Y is defined as U variable now, depending dpi */
 int ED_area_headersize(void)
 {
 /* UI_UNIT_Y is defined as U variable now, depending dpi */
 int ED_area_headersize(void)
 {
-       return UI_UNIT_Y + 6;
+       return (int)(1.3f * UI_UNIT_Y);
 }
 
 void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
 {
 }
 
 void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
 {
-       const int header_height = 18;
-       uiStyle *style = UI_GetStyle();
+       const int header_height = UI_UNIT_Y;
+       uiStyle *style = UI_GetStyleDraw();
        int fontid = style->widget.uifont_id;
        rcti rect;
 
        int fontid = style->widget.uifont_id;
        rcti rect;
 
-       BLF_size(fontid, 11.0f, 72);
-
        /* background box */
        rect = ar->winrct;
        rect.xmin = 0;
        /* background box */
        rect = ar->winrct;
        rect.xmin = 0;
index ce2d045dc807c5040bea20d8659321e5a490ab07..d394743200404d0ed7e23dc061949ce664421ee1 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_userdef_types.h"
 #include "DNA_vec_types.h"
 
 #include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_vec_types.h"
 
 #include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_blender.h"
 #include "BKE_colortools.h"
 
 #include "BLI_math.h"
 #include "BKE_colortools.h"
 
 #include "BLI_math.h"
@@ -292,7 +294,10 @@ void setlinestyle(int nr)
        else {
                
                glEnable(GL_LINE_STIPPLE);
        else {
                
                glEnable(GL_LINE_STIPPLE);
-               glLineStipple(nr, 0xAAAA);
+               if (U.pixelsize > 1.0f)
+                       glLineStipple(nr, 0xCCCC);
+               else
+                       glLineStipple(nr, 0xAAAA);
        }
 }
 
        }
 }
 
index 60aad14efcf1c3b121d037336e53ab3cf1a33542..9a91e9d96cdcc61837f313885f20e76c09a87cb6 100644 (file)
@@ -263,6 +263,9 @@ int scredge_is_horizontal(ScrEdge *se)
 ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
 {
        ScrEdge *se;
 ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
 {
        ScrEdge *se;
+       int safety = U.widget_unit/10;
+       
+       if (safety < 2) safety = 2;
        
        for (se = sc->edgebase.first; se; se = se->next) {
                if (scredge_is_horizontal(se)) {
        
        for (se = sc->edgebase.first; se; se = se->next) {
                if (scredge_is_horizontal(se)) {
@@ -270,7 +273,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
                        min = MIN2(se->v1->vec.x, se->v2->vec.x);
                        max = MAX2(se->v1->vec.x, se->v2->vec.x);
                        
                        min = MIN2(se->v1->vec.x, se->v2->vec.x);
                        max = MAX2(se->v1->vec.x, se->v2->vec.x);
                        
-                       if (abs(my - se->v1->vec.y) <= 2 && mx >= min && mx <= max)
+                       if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
                                return se;
                }
                else {
                                return se;
                }
                else {
@@ -278,7 +281,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
                        min = MIN2(se->v1->vec.y, se->v2->vec.y);
                        max = MAX2(se->v1->vec.y, se->v2->vec.y);
                        
                        min = MIN2(se->v1->vec.y, se->v2->vec.y);
                        max = MAX2(se->v1->vec.y, se->v2->vec.y);
                        
-                       if (abs(mx - se->v1->vec.x) <= 2 && my >= min && my <= max)
+                       if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
                                return se;
                }
        }
                                return se;
                }
        }
@@ -428,9 +431,9 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
        sc->winid = win->winid;
 
        sv1 = screen_addvert(sc, 0, 0);
        sc->winid = win->winid;
 
        sv1 = screen_addvert(sc, 0, 0);
-       sv2 = screen_addvert(sc, 0, win->sizey - 1);
-       sv3 = screen_addvert(sc, win->sizex - 1, win->sizey - 1);
-       sv4 = screen_addvert(sc, win->sizex - 1, 0);
+       sv2 = screen_addvert(sc, 0, WM_window_pixels_y(win) - 1);
+       sv3 = screen_addvert(sc, WM_window_pixels_x(win) - 1, WM_window_pixels_y(win) - 1);
+       sv4 = screen_addvert(sc, WM_window_pixels_x(win) - 1, 0);
        
        screen_addedge(sc, sv1, sv2);
        screen_addedge(sc, sv2, sv3);
        
        screen_addedge(sc, sv1, sv2);
        screen_addedge(sc, sv2, sv3);
@@ -628,7 +631,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
        float facx, facy, tempf, min[2], max[2];
        
        /* calculate size */
        float facx, facy, tempf, min[2], max[2];
        
        /* calculate size */
-       min[0] = min[1] = 10000.0f;
+       min[0] = min[1] = 20000.0f;
        max[0] = max[1] = 0.0f;
        
        for (sv = sc->vertbase.first; sv; sv = sv->next) {
        max[0] = max[1] = 0.0f;
        
        for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -669,6 +672,29 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
 
                        CLAMP(sv->vec.y, 0, winsizey);
                }
 
                        CLAMP(sv->vec.y, 0, winsizey);
                }
+               
+               /* scale prefsizes of regions */
+               for (sa = sc->areabase.first; sa; sa = sa->next) {
+                       ARegion *ar;
+                       
+                       for (ar = sa->regionbase.first; ar; ar = ar->next) {
+                               ar->sizex = (int)((float)ar->sizex * facx);
+                               ar->sizey = (int)((float)ar->sizey * facy);
+                               ar->winx = (int)((float)ar->winx * facx);
+                               ar->winy = (int)((float)ar->winy * facy);
+                       }
+                       if (sa->spacedata.first) {
+                               SpaceLink *sl = sa->spacedata.first;
+                               for (sl = sl->next; sl; sl = sl->next) {
+                                       for (ar = sl->regionbase.first; ar; ar = ar->next) {
+                                               ar->sizex = (int)((float)ar->sizex * facx);
+                                               ar->sizey = (int)((float)ar->sizey * facy);
+                                               ar->winx = (int)((float)ar->winx * facx);
+                                               ar->winy = (int)((float)ar->winy * facy);
+                                       }
+                               }
+                       }
+               }
        }
        
        /* test for collapsed areas. This could happen in some blender version... */
        }
        
        /* test for collapsed areas. This could happen in some blender version... */
@@ -676,7 +702,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
        
        /* make each window at least ED_area_headersize() high */
        for (sa = sc->areabase.first; sa; sa = sa->next) {
        
        /* make each window at least ED_area_headersize() high */
        for (sa = sc->areabase.first; sa; sa = sa->next) {
-               int headery = ED_area_headersize() + 1;
+               int headery = ED_area_headersize() + U.pixelsize;
                
                if (sa->v1->vec.y + headery > sa->v2->vec.y) {
                        /* lower edge */
                
                if (sa->v1->vec.y + headery > sa->v2->vec.y) {
                        /* lower edge */
@@ -907,18 +933,18 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
        short y1 = sa->v1->vec.y;
        short x2 = sa->v3->vec.x;
        short y2 = sa->v3->vec.y;
        short y1 = sa->v1->vec.y;
        short x2 = sa->v3->vec.x;
        short y2 = sa->v3->vec.y;
-       short a, rt;
-       
-       rt = 0; // CLAMPIS(G.debug_value, 0, 16);
        
        if (center == 0) {
        
        if (center == 0) {
-               cpack(0x505050);
-               for (a = -rt; a <= rt; a++)
-                       if (a != 0)
-                               drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a);
+               if (U.pixelsize > 1.0f) {
+               
+                       glColor3ub(0x50, 0x50, 0x50);
+                       glLineWidth(1.5f * U.pixelsize);
+                       drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
+                       glLineWidth(1.0f);
+               }
        }
        else {
        }
        else {
-               cpack(0x0);
+               glColor3ub(0, 0, 0);
                drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
        }
 }
                drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
        }
 }
@@ -1002,10 +1028,10 @@ void ED_screen_draw(wmWindow *win)
                if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
                if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
                if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa;
                if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
                if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
                if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa;
-               drawscredge_area(sa, win->sizex, win->sizey, 0);
+               drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 0);
        }
        for (sa = win->screen->areabase.first; sa; sa = sa->next)
        }
        for (sa = win->screen->areabase.first; sa; sa = sa->next)
-               drawscredge_area(sa, win->sizex, win->sizey, 1);
+               drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 1);
        
        /* blended join arrow */
        if (sa1 && sa2) {
        
        /* blended join arrow */
        if (sa1 && sa2) {
@@ -1078,20 +1104,20 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
                rcti winrct;
        
                winrct.xmin = 0;
                rcti winrct;
        
                winrct.xmin = 0;
-               winrct.xmax = win->sizex - 1;
+               winrct.xmax = WM_window_pixels_x(win) - 1;
                winrct.ymin = 0;
                winrct.ymin = 0;
-               winrct.ymax = win->sizey - 1;
+               winrct.ymax = WM_window_pixels_y(win) - 1;
+               
+               /* header size depends on DPI, let's verify */
+               screen_refresh_headersizes();
                
                
-               screen_test_scale(win->screen, win->sizex, win->sizey);
+               screen_test_scale(win->screen, WM_window_pixels_x(win), WM_window_pixels_y(win));
                
                if (win->screen->mainwin == 0)
                        win->screen->mainwin = wm_subwindow_open(win, &winrct);
                else
                        wm_subwindow_position(win, win->screen->mainwin, &winrct);
                
                
                if (win->screen->mainwin == 0)
                        win->screen->mainwin = wm_subwindow_open(win, &winrct);
                else
                        wm_subwindow_position(win, win->screen->mainwin, &winrct);
                
-               /* header size depends on DPI, let's verify */
-               screen_refresh_headersizes();
-               
                for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                        /* set spacetype and region callbacks, calls init() */
                        /* sets subwindows for regions, adds handlers */
                for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                        /* set spacetype and region callbacks, calls init() */
                        /* sets subwindows for regions, adds handlers */
@@ -1142,6 +1168,9 @@ void ED_region_exit(bContext *C, ARegion *ar)
                MEM_freeN(ar->headerstr);
        ar->headerstr = NULL;
        
 &nb