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 f886dfd..ab5feb2 100644 (file)
@@ -852,6 +852,16 @@ extern int GHOST_toggleConsole(int action);
  */
 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
 }
index ad5d237..dfe0152 100644 (file)
@@ -294,6 +294,13 @@ public:
         * \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
index 88d02c4..ba0a6eb 100644 (file)
@@ -878,3 +878,16 @@ int GHOST_confirmQuit(GHOST_WindowHandle 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 8c6491b..a008d22 100644 (file)
@@ -373,3 +373,16 @@ int GHOST_System::confirmQuit(GHOST_IWindow *window) const
 {
        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 d2e3377..5060f22 100644 (file)
@@ -167,6 +167,16 @@ public:
         */
        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
@@ -350,6 +360,7 @@ protected:
 
        /** Settings of the display before the display went fullscreen. */
        GHOST_DisplaySetting m_preFullScreenSetting;
+       
 };
 
 inline GHOST_TimerManager *GHOST_System::getTimerManager() const
index 16edb4a..7f6b69d 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)));
-                                       m_ignoreWindowSizedMessages = true;
+                                       //m_ignoreWindowSizedMessages = true;
                                }
                                break;
                        default:
@@ -1450,13 +1450,22 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 {
        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) {
-               //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:
@@ -1509,7 +1518,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                                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;
@@ -1555,9 +1564,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                        default:
                                        {
                                                //Normal cursor operation: send mouse position in window
-                                               NSPoint mousePos = [event locationInWindow];
+                                               NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                                GHOST_TInt32 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 {
-                                       NSPoint mousePos = [event locationInWindow];
+                                       NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
                                        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:
                        {
-                               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,
@@ -1626,7 +1635,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 
                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,
index 46c71f5..9f62ed7 100644 (file)
@@ -782,8 +782,8 @@ GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
 
 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
index a483c03..2c833fc 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
-       minSize.width = 320;
-       minSize.height = 240;
+       minSize.width = 640;
+       minSize.height = 480;
        [m_window setContentMinSize:minSize];
        
        setTitle(title);
@@ -579,6 +579,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
        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];
@@ -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 setContentMinSize:NSMakeSize(320, 240)];
+                               [tmpWindow setContentMinSize:NSMakeSize(640, 480)];
                                
                                //Assign the openGL view to the new window
                                [tmpWindow setContentView:m_openGLView];
index 156bc86..3440e3c 100644 (file)
@@ -363,8 +363,8 @@ GHOST_WindowX11(
        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);
index 0bb25e9..42d6407 100644 (file)
@@ -84,7 +84,7 @@ class USERPREF_HT_header(Header):
         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'
 
@@ -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.prop(system, "use_region_overlap")
         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, "use_keep_session")
         col.prop(paths, "use_auto_save_temporary_files")
         sub = col.column()
         sub.active = paths.use_auto_save_temporary_files
index 6f348cc..25b55ea 100644 (file)
@@ -37,6 +37,7 @@ struct ColorManagedDisplay;
 
 int BLF_init(int points, int dpi);
 void BLF_exit(void);
+void BLF_default_dpi(int dpi);
 
 void BLF_cache_clear(void);
 
index 778b6c1..1675676 100644 (file)
@@ -87,6 +87,11 @@ int BLF_init(int points, int dpi)
        return blf_font_init();
 }
 
+void BLF_default_dpi(int dpi)
+{
+       global_font_dpi = dpi;
+}
+
 void BLF_exit(void)
 {
        FontBLF *font;
index cd75749..ffdbc9c 100644 (file)
@@ -62,6 +62,7 @@ struct bContext;
 struct ReportList;
 struct Scene;
 struct Main;
+struct ID;
 
 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_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);
-
+/* 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);
@@ -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 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);
 
+       /* 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
index f6276a6..38a8860 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_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 */
index cfdcf14..b49c5fd 100644 (file)
@@ -53,7 +53,8 @@ typedef struct Main {
        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;
index 9927c7a..3be07e7 100644 (file)
@@ -47,7 +47,7 @@ struct RenderData;
 struct SceneRenderLayer;
 struct Scene;
 struct Text;
-struct Text;
+struct Main;
 
 #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);
+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);
index f0d201e..3aa425b 100644 (file)
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
 #include "BKE_sound.h"
+
 #include "RE_pipeline.h"
 
+#include "BLF_api.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;
+               /* 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 */
 
@@ -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);
-               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);
@@ -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 (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;
+               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));
 
@@ -334,7 +341,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        }
 
        MEM_freeN(bfd);
-
+       
        (void)curscene; /* quiet warning */
 }
 
@@ -393,6 +400,14 @@ void BKE_userdef_free(void)
        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;
@@ -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);
-       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>");
+       }
        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 ************* */
 
@@ -728,48 +786,39 @@ char *BKE_undo_menu_string(void)
        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;
-       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) {
-               return;
+               return 0;
        }
 
        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;
-       file = BLI_open(str, flag, 0666);
+       file = BLI_open(filename, flag, 0666);
        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",
-                       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) {
@@ -777,16 +826,15 @@ void BKE_undo_save_quit(void)
                        break;
                }
        }
-
+       
        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 */
@@ -806,3 +854,131 @@ Main *BKE_undo_get_main(Scene **scene)
        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 9bb2fb2..47f0da1 100644 (file)
@@ -372,9 +372,8 @@ void BKE_scene_free(Scene *sce)
        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;
@@ -605,6 +604,16 @@ Scene *BKE_scene_add(const char *name)
        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));
index 5e47adf..43724d8 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_USERPREF_FILE   "userpref.blend"
 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
 #define BLENDER_HISTORY_FILE    "recent-files.txt"
 
index 16a4d8d..2ee5dec 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_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);
-
+       
 /* 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
index 203af1d..cf4deb7 100644 (file)
@@ -2981,7 +2981,7 @@ static void direct_link_text(FileData *fd, Text *text)
        if (text->flags & TXT_ISEXT) {
                BKE_text_reload(text);
                }
-               else {
+               /* else { */
 #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->active = 0;
        }
        
        wm->timers.first = wm->timers.last = NULL;
@@ -5231,27 +5232,6 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 
 /* ****************** 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)
@@ -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);
-                                               sbuts->mainbo = sbuts->mainb;
-                                               sbuts->mainbuser = sbuts->mainb;
-                                               if (main->versionfile < 132)
-                                                       butspace_version_132(sbuts);
                                        }
                                        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;
@@ -5348,12 +5319,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                 */
                                                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;
@@ -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);
-                                               st->drawcache= NULL;
                                        }
                                        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;
                                                
-                                               so->tree.first = so->tree.last= NULL;
                                                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);
-                                               snode->edittree = NULL;
                                                
                                                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);
                                                }
-                                               
-                                               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);
-                                               
-                                               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;
@@ -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->regiontimer = NULL;
        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->tree.first = soops->tree.last= NULL;
                        }
                        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->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;
@@ -5965,6 +5929,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                }
                        }
                        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
                                 *
@@ -5973,17 +5939,26 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                 * 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
+                               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;
+                               
                                sbuts->path= NULL;
                                sbuts->texuser= NULL;
+                               sbuts->mainbo = sbuts->mainb;
+                               sbuts->mainbuser = sbuts->mainb;
                        }
                        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);
                        }
+                       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;
@@ -8401,8 +8384,11 @@ static void lib_link_all(FileData *fd, Main *main)
 {
        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);
@@ -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));
 }
 
-static void expand_doit(FileData *fd, Main *mainvar, void *old)
+static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
 {
        BHead *bhead;
+       FileData *fd = fdhandle;
        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)
@@ -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];
+       FileData *fd = fdhandle;
        ID *id;
        int a, do_it = TRUE;
        
-       if (fd == NULL) return;
-       
        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;
@@ -9701,6 +9695,28 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons
        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);
@@ -9805,8 +9821,11 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
        Main *mainvar;
        Library *curlib;
        
+       /* expander now is callback function */
+       BLO_main_expander(expand_doit_library);
+       
        /* make main consistent */
-       expand_main(*fd, mainl);
+       BLO_expand_main(*fd, mainl);
        
        /* 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;
        
+       /* expander now is callback function */
+       BLO_main_expander(expand_doit_library);
+       
        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 b010cae..cee6185 100644 (file)
@@ -2515,6 +2515,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
 
                sc= sc->id.next;
        }
+       
+       /* flush helps the compression for undo-save */
+       mywrite(wd, MYWRITE_FLUSH, 0);
 }
 
 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;
-       fg.curscene= screen->scene;
+       fg.curscene= screen? screen->scene : NULL;
        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));
-
        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);
 
-       /* 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);
@@ -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)
 {
-       char userfilename[FILE_MAX];
        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 */
@@ -3151,3 +3148,4 @@ int BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int wr
        if (err==0) return 1;
        return 0;
 }
+
index 9ceecd6..f5c9bfb 100644 (file)
@@ -82,7 +82,7 @@
 #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
@@ -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) {
-                       offset += 21;
+                       offset += U.widget_unit;
                }
                /* 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)
-                       offset += 14;
+                       offset += (short)(0.7f * U.widget_unit);
                        
                /* 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)
@@ -2937,12 +2937,11 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
-        *      7 is hardcoded factor for half-height of icons
         */
        y = (ymaxc - yminc) / 2 + yminc;
-       ymid = y - 7;
+       ymid = y - 0.5f * ICON_WIDTH;
        /* 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))
@@ -2989,10 +2988,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                                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... */
@@ -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
                 */
@@ -3365,12 +3362,9 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
                offset = 0;
                
        /* calculate appropriate y-coordinates for icon buttons 
-        *      7 is hardcoded factor for half-height of icons
         */
        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);
index 0f0584a..d83d180 100644 (file)
 #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 "BKE_blender.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;
-       y = 18;
+       y = 0.9f * U.widget_unit;
        
        /* 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);
-       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);
index 1b98079..f684e57 100644 (file)
@@ -395,7 +395,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
                          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);
        
@@ -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);
-                       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)) {
-                               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 {
-                               x = xpos * xscale + 4.0f;
-                               y = 17.0f;
+                               x = xpos * xscale + 8.0f * UI_DPI_FAC;
+                               y = 17.0f * UI_DPI_FAC;
                        }
                }
 
index e520a95..d9d2180 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;
-       
+       float iconsize = U.widget_unit / 4.0f;
        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);
                                
-                               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_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 11e0758..3e092ed 100644 (file)
 #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 "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
index 479e0b6..cdf9b71 100644 (file)
 
 #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
index 8d7ae3a..551d304 100644 (file)
@@ -300,34 +300,34 @@ typedef enum eAnimFilter_Flags {
 /* -------------- 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_NAMEWIDTH      200
+#define ACHANNEL_NAMEWIDTH      (10 * U.widget_unit)
 
 /* 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?
-#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_NAMEWIDTH        200
+#define NLACHANNEL_NAMEWIDTH                   (10 * U.widget_unit)
 
 /* channel toggle-buttons */
-#define NLACHANNEL_BUTTON_WIDTH 16
+#define NLACHANNEL_BUTTON_WIDTH                        (0.8f * U.widget_unit)
 
 /* ---------------- API  -------------------- */
 
index 860d176..f7a42d5 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    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);
+float  ED_region_blend_factor(struct ARegion *ar);
 
 /* spaces */
 void    ED_spacetypes_init(void);
index 2dc552d..abd1782 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 */
 
-/* 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)
 
@@ -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);
-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);
 
index 24759fa..3b94291 100644 (file)
@@ -102,11 +102,11 @@ enum {
 /* ------ 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 */
-#define V2D_SCROLLER_HANDLE_SIZE    12
+#define V2D_SCROLLER_HANDLE_SIZE    (0.6f * U.widget_unit)
 
 /* ------ Define for UI_view2d_sync ----- */
 
index ce82e06..3a377ad 100644 (file)
@@ -69,7 +69,6 @@
 #include "WM_api.h"
 #include "WM_types.h"
 #include "wm_subwindow.h"
-#include "wm_window.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 */
 
-       // 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);
@@ -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);
        
-       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);
@@ -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) {
-                       block->bounds = 50;
+                       block->bounds = 2.5f * UI_UNIT_X;
                        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 */
-               aspect = sqrt(aspect);
+               /* XXX not true anymore? (ton) */
+               //aspect = sqrt(aspect);
                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);
-
+       
        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)
 {
-       uiStyle style = *UI_GetStyle();  /* XXX pass on as arg */
+       uiStyle style = *UI_GetStyleDraw();  /* XXX pass on as arg */
        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);
-
+       
        /* 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 4d96ad8..792553f 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];
-       //int w, h;
+       int w, h;
 
        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)
 
-       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);
@@ -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);
        
+       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);
        
+       glPixelZoom(1.0f, 1.0f);
+       
        glDisable(GL_BLEND);
        
 #if 0
index 1ac56fd..2587758 100644 (file)
@@ -4530,7 +4530,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
        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);
 
@@ -4562,7 +4562,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
        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;
        
index bb0cc11..d78985f 100644 (file)
@@ -750,7 +750,7 @@ static DrawInfo *icon_create_drawinfo(void)
        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;
@@ -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));
-               IMB_scaleImBuf(ima, w, h); /* scale it */
+               IMB_scalefastImBuf(ima, w, h); /* scale it */
                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;
-       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);
@@ -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);
 }
 
+/* draws icon with dpi scale factor */
 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)
index 1dc9863..fce4317 100644 (file)
@@ -267,7 +267,7 @@ struct uiBut {
        void *dragpoin;
        struct ImBuf *imb;
        float imb_scale;
-
+       
        /* active button data */
        struct uiHandleButtonData *active;
 
index c67c64a..e93ecc7 100644 (file)
@@ -65,8 +65,6 @@
 #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.
 
@@ -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)
 {
+       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)
-               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
-               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)
@@ -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 .. */
-               w -= 10;
+               w -= UI_UNIT_Y/2;
 
        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);
-       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 */
@@ -2941,7 +2941,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
 
                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);
        }
index 2b170ea..0bdb39c 100644 (file)
@@ -305,7 +305,7 @@ void uiEndPanel(uiBlock *block, int width, int height)
 
 static void ui_offset_panel_block(uiBlock *block)
 {
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        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)
 {
+       float f3 = 0.15 * U.widget_unit;
+       float f5 = 0.25 * U.widget_unit;
+       float f7 = 0.35 * U.widget_unit;
+       
        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') {
-               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 */
-               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 b62e634..ed61960 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);
        }
 
-       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 */
@@ -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);
 
-               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 */
@@ -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)
-                       butrct.ymax += 1.0f;
+                       butrct.ymax += U.pixelsize;
                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) {
@@ -1334,7 +1338,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                        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);
@@ -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;
        
-       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*/
 
        {
@@ -1351,7 +1355,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                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;
@@ -1523,7 +1529,9 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
                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;
@@ -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;
-
                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);
 }
 
-#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)
 
@@ -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);
+       int yco;
        
        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! */
@@ -2108,44 +2116,47 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
        }
        
        /* mode */
+       yco = -1.5f * UI_UNIT_Y;
        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);
-       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);
-       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);
 
+       yco = -3.0f * UI_UNIT_Y;
        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);
-       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);
-       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);
-       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 */
+       yco = -3.0f * UI_UNIT_Y;
        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);
-       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);
-       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) {
-               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 {
@@ -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]));
 
-       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);
-       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);
 
@@ -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;
-       uiBoundsBlock(block, 10);
+       uiBoundsBlock(block, 0.5 * UI_UNIT_X);
        
        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;
-               uiTextBoundsBlock(block, 50);
+               uiTextBoundsBlock(block, 2.5 * UI_UNIT_X);
        }
 
        /* 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);
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        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)
 {
-       uiStyle *style = UI_GetStyle();
+       uiStyle *style = UI_GetStyleDraw();
        uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
        uiBut *but;
        
index 7e7db6a..7118cbc 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 */
-       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);
 
@@ -261,6 +261,32 @@ uiStyle *UI_GetStyle(void)
        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)
 {
@@ -364,9 +390,9 @@ void uiStyleInit(void)
                         * 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);
 
-       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);
 
-       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);
        
-       BLF_size(font->blf_id, fs->points, U.dpi);
+       BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi);
 }
 
index f7a53c6..0e3c323 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) {
-               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);
                
-               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();
+               
                /* 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);
        }
                
        
-       uiBoundsBlock(block, 6);
+       uiBoundsBlock(block, 0.3f * U.widget_unit);
        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;
-
+       
        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;
 
-       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);
@@ -1579,8 +1579,8 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
        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);
@@ -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;
 
-       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);
@@ -1620,15 +1621,15 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
        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;
 
-       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);
@@ -1658,15 +1659,15 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
        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),
-                     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);
@@ -2010,7 +2011,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
        /* 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++) {
@@ -2081,7 +2082,7 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
 
 /********************* 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,
index c4b80f0..77fbe94 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 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;
@@ -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)
-               radi = 0.5f * minsize - 1.0f;
+               radi = 0.5f * minsize - U.pixelsize;
        
        /* 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)
 {
-       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)
 {
-       int xs = 0, ys = 0;
+       float xs = 0.0f, ys = 0.0f;
        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;
        
-       /* 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) {}
@@ -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]) {
-                                       xs = rect->xmin - 1;
+                                       xs = rect->xmin - 1.0f * aspect;
                                }
                                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)
-                                       xs = rect->xmin + 4;
+                                       xs = rect->xmin + 4.0f * aspect;
                                else
-                                       xs = rect->xmin + 1;
+                                       xs = rect->xmin + 1.0f * aspect;
                        }
                        else if ((but->type == ICONROW) || (but->type == ICONTEXTROW)) {
-                               xs = rect->xmin + 3;
+                               xs = rect->xmin + 3.0f * aspect;
                        }
                        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 {
-                       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};
-                       UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb);
+                       UI_icon_draw_aspect_color(xs, ys, icon, 1.0f / aspect, rgb);
                }
                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)) {
-               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);
@@ -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);
-
-                       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))
-                               rect->xmin += 5;
+                               rect->xmin += 0.4f * U.widget_unit;
                }
                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);
@@ -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 */
-       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 -= 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 */
-       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);
 
@@ -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);
-               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;
-               rect->ymax += 4.0;
+               rect->ymax += 0.1f * U.widget_unit;
        }
        
        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);
        
@@ -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 */
-               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;
-               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 
@@ -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;
-       float col[4];
+       float rad, col[4];
        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 */
-       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);
 
@@ -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;
                
-               round_box_edges(&wtb, roundboxalign, rect, 5.0f);
+               round_box_edges(&wtb, roundboxalign, rect, rad);
        }
        
        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;
-       
+               float rad;
+               
                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);
        }
 }
@@ -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;
+       float rad;
        
        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 */
-       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);
 
@@ -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;
+       float rad;
        
        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);
@@ -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;
+       float rad;
        
        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);
@@ -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;
+       float rad;
        
        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;
@@ -2718,7 +2726,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
 {
        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);
 
@@ -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;
+       float rad;
        
        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);
 }
@@ -2759,6 +2769,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
 {
        uiWidgetBase wtb;
        rcti recttemp = *rect;
+       float rad;
        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 */
-       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) {
@@ -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;
+       float rad;
        
        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);
 
@@ -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;
+       float rad;
        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 */
-       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);
        
@@ -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;
+       float rad;
        
        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);
 
 }
@@ -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;
-       float rad = 5.0f;  /* 0.5f * BLI_rcti_size_y(rect); */
+       float rad = 0.25f * U.widget_unit;
        
        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;
+       float rad = 0.25f * U.widget_unit;
        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);
                
-               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 */
-       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);
@@ -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)
-                       rect->ymax += 1;
+                       rect->ymax += U.pixelsize;
                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:
@@ -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);
-       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);
@@ -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 */
-       rect->xmin += 5;
+       rect->xmin += 0.25f * UI_UNIT_X;
        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) {
-               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;
+               
+               /* 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);
-               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);
        }
 }
index fa5d580..3a482b9 100644 (file)
@@ -1990,7 +1990,7 @@ void init_userdef_do_versions(void)
        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;
 
@@ -2009,6 +2009,23 @@ void init_userdef_do_versions(void)
        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 */
index f1a3f59..356b5a6 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) {
-                       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;
                }
@@ -1167,7 +1167,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d,
                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) {
@@ -1212,7 +1212,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
                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++) {
@@ -1246,7 +1246,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
                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++) {
@@ -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);
+       int smaller;
        
        /* 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.xmin += 4;
-       hor.xmax -= 4;
+       smaller = (int)(0.2f * U.widget_unit);
+       hor.xmin += smaller;
+       hor.xmax -= smaller;
        if (scroll & V2D_SCROLL_BOTTOM)
-               hor.ymin += 4;
+               hor.ymin += smaller;
        else
-               hor.ymax -= 4;
+               hor.ymax -= smaller;
        
        if (scroll & V2D_SCROLL_LEFT)
-               vert.xmin += 4;
+               vert.xmin += smaller;
        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);
@@ -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;
+                       unsigned char col[4];
                        
                        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;
                        }
                        
-                       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);
                }
@@ -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) {
-                               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 */
-                                       if (fac < hor.xmin + 10)
+                                       if (fac < hor.xmin + 0.5f * U.widget_unit)
                                                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;
+                       unsigned char col[4];
                        
                        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;
                        }
-                               
-                       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);
                }
index f30e0ab..852ce02 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)
 {
-       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);
@@ -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);
-       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);
@@ -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;
-       rcti winrct;
        
        /* 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)
-               ar->drawrct = winrct;
+               ar->drawrct = ar->winrct;
        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 */
@@ -500,7 +463,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        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);
 }
 
-#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) {
@@ -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)
@@ -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)
@@ -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);
 }      
 
-#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 */
@@ -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);
-       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);
-       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);
 }
 
@@ -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;
@@ -928,6 +904,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
        
        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 */
@@ -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 */
-       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) {
-               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 {
-               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;
@@ -998,14 +977,14 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                        
                        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;
-                               if (alignment == RGN_ALIGN_RIGHT)
+                               if (ar->overlap == 0)
                                        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;
                        }
                }
@@ -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;
-               else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+               else if (alignment == RGN_ALIGN_RIGHT)
                        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;
@@ -1121,12 +1100,12 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                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)
 {
-       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;
@@ -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 */
-       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;
-       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);
@@ -1284,11 +1263,17 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar)
 
        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 */
@@ -1441,7 +1426,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
 {
        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)
@@ -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);
-       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;
-
+       
        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 */
-       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) {
@@ -1725,7 +1720,7 @@ void ED_region_panels_init(wmWindowManager *wm, 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;
@@ -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);
 
-       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) {
@@ -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)
 {
-       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)
 {
-       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;
 
-       BLF_size(fontid, 11.0f, 72);
-
        /* background box */
        rect = ar->winrct;
        rect.xmin = 0;
index ce2d045..d394743 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_userdef_types.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"
@@ -292,7 +294,10 @@ void setlinestyle(int nr)
        else {
                
                glEnable(GL_LINE_STIPPLE);
-               glLineStipple(nr, 0xAAAA);
+               if (U.pixelsize > 1.0f)
+                       glLineStipple(nr, 0xCCCC);
+               else
+                       glLineStipple(nr, 0xAAAA);
        }
 }
 
index 60aad14..9a91e9d 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;
+       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)) {
@@ -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);
                        
-                       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 {
@@ -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);
                        
-                       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;
                }
        }
@@ -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);
-       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);
@@ -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 */
-       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) {
@@ -669,6 +672,29 @@ static void screen_test_scale(bScreen *sc, int winsizex, int 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... */
@@ -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) {
-               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 */
@@ -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 a, rt;
-       
-       rt = 0; // CLAMPIS(G.debug_value, 0, 16);
        
        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 {
-               cpack(0x0);
+               glColor3ub(0, 0, 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;
-               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)
-               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) {
@@ -1078,20 +1104,20 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
                rcti winrct;
        
                winrct.xmin = 0;
-               winrct.xmax = win->sizex - 1;
+               winrct.xmax = WM_window_pixels_x(win) - 1;
                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);
                
-               /* 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 */
@@ -1142,6 +1168,9 @@ void ED_region_exit(bContext *C, ARegion *ar)
                MEM_freeN(ar->headerstr);
        ar->headerstr = NULL;
        
+       if (ar->regiontimer)
+               WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ar->regiontimer);
+
        CTX_wm_region_set(C, prevar);
 }
 
index 86d9977..2e2b53f 100644 (file)
@@ -35,7 +35,7 @@
 struct wmWindow;
 struct Scene;
 
-#define AZONESPOT       12
+#define AZONESPOT       (0.6f * U.widget_unit)
 
 /* area.c */
 void        area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space);
@@ -57,12 +57,16 @@ ScrEdge    *screen_find_active_scredge(bScreen *sc, int mx, int my);
 struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]);
 
 /* screen_context.c */
-int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);
+int            ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);
 
 extern const char *screen_context_dir[]; /* doc access */
 
 /* screendump.c */
-void SCREEN_OT_screenshot(struct wmOperatorType *ot);
-void SCREEN_OT_screencast(struct wmOperatorType *ot);
+void   SCREEN_OT_screenshot(struct wmOperatorType *ot);
+void   SCREEN_OT_screencast(struct wmOperatorType *ot);
+
+/* screen_ops.c */
+void   region_blend_start(struct bContext *C, struct ScrArea *sa, struct ARegion *ar);
+
 
 #endif /* __SCREEN_INTERN_H__ */
index 67d4af9..269cc67 100644 (file)
@@ -965,7 +965,7 @@ typedef struct sAreaMoveData {
 static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller)
 {
        ScrArea *sa;
-       int areaminy = ED_area_headersize() + 1;
+       int areaminy = ED_area_headersize() + U.pixelsize;      // pixelsize is used as area divider
        
        /* we check all areas and test for free space with MINSIZE */
        *bigger = *smaller = 100000;
@@ -1038,19 +1038,19 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int
        for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
                if (v1->flag) {
                        /* that way a nice AREAGRID  */
-                       if ((dir == 'v') && v1->vec.x > 0 && v1->vec.x < win->sizex - 1) {
+                       if ((dir == 'v') && v1->vec.x > 0 && v1->vec.x < WM_window_pixels_x(win) - 1) {
                                v1->vec.x = origval + delta;
                                if (delta != bigger && delta != -smaller) v1->vec.x -= (v1->vec.x % AREAGRID);
                        }
-                       if ((dir == 'h') && v1->vec.y > 0 && v1->vec.y < win->sizey - 1) {
+                       if ((dir == 'h') && v1->vec.y > 0 && v1->vec.y < WM_window_pixels_y(win) - 1) {
                                v1->vec.y = origval + delta;
                                
                                v1->vec.y += AREAGRID - 1;
                                v1->vec.y -= (v1->vec.y % AREAGRID);
                                
                                /* prevent too small top header */
-                               if (v1->vec.y > win->sizey - areaminy)
-                                       v1->vec.y = win->sizey - areaminy;
+                               if (v1->vec.y > WM_window_pixels_y(win) - areaminy)
+                                       v1->vec.y = WM_window_pixels_y(win) - areaminy;
                        }
                }
        }
@@ -1720,9 +1720,9 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
                
                /* if not set we do now, otherwise it uses type */
                if (rmd->ar->sizex == 0)
-                       rmd->ar->sizex = rmd->ar->type->prefsizex;
+                       rmd->ar->sizex = rmd->ar->winx;
                if (rmd->ar->sizey == 0)
-                       rmd->ar->sizey = rmd->ar->type->prefsizey;
+                       rmd->ar->sizey = rmd->ar->winy;
                
                /* now copy to regionmovedata */
                if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
@@ -1734,7 +1734,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
                
                /* limit headers to standard height for now */
                if (rmd->ar->regiontype == RGN_TYPE_HEADER)
-                       maxsize = rmd->ar->type->prefsizey;
+                       maxsize = ED_area_headersize();
                else
                        maxsize = 1000;
                
@@ -2797,7 +2797,6 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot)
 }
 
 
-
 /* ************** region flip operator ***************************** */
 
 /* flip a region alignment */
@@ -3583,6 +3582,146 @@ static void SCENE_OT_delete(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/* ***************** region alpha blending ***************** */
+
+/* implementation note: a disapplearing region needs at least 1 last draw with 100% backbuffer
+    texture over it- then triple buffer will clear it entirely. 
+    This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */
+
+typedef struct RegionAlphaInfo {
+       ScrArea *sa;
+       ARegion *ar, *child_ar; /* other region */
+       int hidden;
+} RegionAlphaInfo;
+
+#define TIMEOUT                0.3f
+#define TIMESTEP       0.04
+
+float ED_region_blend_factor(ARegion *ar)
+{
+       /* check parent too */
+       if(ar->regiontimer == NULL && (ar->alignment & RGN_SPLIT_PREV) && ar->prev)
+               ar = ar->prev;
+       
+       if (ar->regiontimer) {
+               RegionAlphaInfo *rgi = ar->regiontimer->customdata;
+               float alpha;
+                       
+               alpha = (float)ar->regiontimer->duration / TIMEOUT;
+               /* makes sure the blend out works 100% - without area redraws */
+               if (rgi->hidden) alpha = 0.9 - TIMESTEP - alpha;
+               
+               CLAMP(alpha, 0.0f, 1.0f);
+               return alpha;
+       }
+       return 1.0f;
+}
+
+/* assumes region has running region-blend timer */
+static void region_blend_end(bContext *C, ARegion *ar, int is_running)
+{
+       RegionAlphaInfo *rgi = ar->regiontimer->customdata;
+       
+       /* always send redraw */
+       ED_region_tag_redraw(ar);
+       if (rgi->child_ar)
+               ED_region_tag_redraw(rgi->child_ar);
+       
+       /* if running timer was hiding, the flag toggle went wrong */
+       if (is_running) {
+               if (rgi->hidden)
+                       rgi->ar->flag &= ~RGN_FLAG_HIDDEN;
+       }
+       else {
+               if (rgi->hidden) {
+                       rgi->ar->flag |= rgi->hidden;
+                       ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->sa);
+               }
+               /* area decoration needs redraw in end */
+               ED_area_tag_redraw(rgi->sa);
+       }
+       WM_event_remove_timer(CTX_wm_manager(C), NULL, ar->regiontimer); /* frees rgi */
+       ar->regiontimer = NULL;
+
+}
+/* assumes that *ar itself is not a splitted version from previous region */
+void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar)
+{
+       wmWindowManager *wm = CTX_wm_manager(C);
+       wmWindow *win = CTX_wm_window(C);
+       RegionAlphaInfo *rgi;
+       
+       /* end running timer */
+       if (ar->regiontimer) {
+
+               region_blend_end(C, ar, 1);
+       }
+       rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
+       
+       rgi->hidden = ar->flag & RGN_FLAG_HIDDEN;
+       rgi->sa = sa;
+       rgi->ar = ar;
+       ar->flag &= ~RGN_FLAG_HIDDEN;
+
+       /* blend in, reinitialize regions because it got unhidden */
+       if (rgi->hidden == 0)
+               ED_area_initialize(wm, win, sa);
+       else
+               WM_event_remove_handlers(C, &ar->handlers);
+
+       if(ar->next)
+               if (ar->next->alignment & RGN_SPLIT_PREV)
+                       rgi->child_ar = ar->next;
+       
+       /* new timer */
+       ar->regiontimer = WM_event_add_timer(wm, win, TIMERREGION, TIMESTEP);
+       ar->regiontimer->customdata = rgi;
+
+}
+
+/* timer runs in win->handlers, so it cannot use context to find area/region */
+static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+{
+       RegionAlphaInfo *rgi;
+       wmTimer *timer = event->customdata;
+       
+       /* event type is TIMERREGION, but we better check */
+       if (event->type != TIMERREGION || timer == NULL)
+               return OPERATOR_PASS_THROUGH;
+       
+       rgi = timer->customdata;
+       
+       /* always send redraws */
+       ED_region_tag_redraw(rgi->ar);
+       if (rgi->child_ar)
+               ED_region_tag_redraw(rgi->child_ar);
+       
+       /* end timer? */
+       if (rgi->ar->regiontimer->duration > TIMEOUT) {
+               region_blend_end(C, rgi->ar, 0);
+               return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
+       }
+
+       return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
+}
+
+static void SCREEN_OT_region_blend(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Region Alpha";
+       ot->idname = "SCREEN_OT_region_blend";
+       ot->description = "Blend in and out overlapping region";
+       
+       /* api callbacks */
+       ot->invoke = region_blend_invoke;
+       
+       /* flags */
+       ot->flag = 0;
+       
+       /* properties */
+}
+
+
 /* ****************  Assigning operatortypes to global list, adding handlers **************** */
 
 
@@ -3615,6 +3754,7 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_screenshot);
        WM_operatortype_append(SCREEN_OT_screencast);
        WM_operatortype_append(SCREEN_OT_userpref_show);
+       WM_operatortype_append(SCREEN_OT_region_blend);
        
        /*frame changes*/
        WM_operatortype_append(SCREEN_OT_frame_offset);
@@ -3717,6 +3857,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
        
        /* standard timers */
        WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_region_blend", TIMERREGION, KM_ANY, KM_ANY, 0);
        
        
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
index a215b47..5da3081 100644 (file)
@@ -50,6 +50,7 @@
 #include "ED_datafiles.h"
 #include "ED_types.h"
 
+#include "UI_interface.h"
 #include "UI_resources.h"
 
 #include "console_intern.h"
@@ -119,7 +120,7 @@ void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dumm
 static int console_textview_begin(TextViewContext *tvc)
 {
        SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
-       tvc->lheight = sc->lheight;
+       tvc->lheight = sc->lheight * UI_DPI_FAC;
        tvc->sel_start = sc->sel_start;
        tvc->sel_end = sc->sel_end;
        
@@ -217,7 +218,7 @@ static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar,
        /* view */
        tvc.sel_start = sc->sel_start;
        tvc.sel_end = sc->sel_end;
-       tvc.lheight = sc->lheight;
+       tvc.lheight = sc->lheight * UI_DPI_FAC;
        tvc.ymin = v2d->cur.ymin;
        tvc.ymax = v2d->cur.ymax;
        tvc.winx = ar->winx;
index f665b97..256c90a 100644 (file)
@@ -516,7 +516,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
         */
        /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
        /* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
-       samplefreq = dx / U.v2d_min_gridsize;
+       samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
        if (samplefreq < 0.00001f) samplefreq = 0.00001f;
        
        
index 5830c45..cd12b93 100644 (file)
@@ -56,6 +56,7 @@
 #include "ED_types.h"
 
 #include "UI_resources.h"
+#include "UI_interface.h"
 
 #include "info_intern.h"
 #include "../space_info/textview.h"
@@ -139,7 +140,7 @@ static int report_textview_begin(TextViewContext *tvc)
        // SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
        ReportList *reports = (ReportList *)tvc->arg2;
 
-       tvc->lheight = 14; //sc->lheight;
+       tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight;
        tvc->sel_start = 0;
        tvc->sel_end = 0;
 
@@ -269,7 +270,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re
        /* view */
        tvc.sel_start = 0;
        tvc.sel_end = 0;
-       tvc.lheight = 14; //sc->lheight;
+       tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight;
        tvc.ymin = v2d->cur.ymin;
        tvc.ymax = v2d->cur.ymax;
        tvc.winx = ar->winx;
index f454b1d..f2c2bbf 100644 (file)
@@ -45,7 +45,8 @@
 
 static void console_font_begin(TextViewContext *sc)
 {
-       BLF_size(blf_mono_font, sc->lheight - 2, 72);
+       /* 0.875 is based on: 16 pixels lines get 14 pixel text */
+       BLF_size(blf_mono_font, 0.875 * sc->lheight, 72);
 }
 
 typedef struct ConsoleDrawContext {
index 5a8a7ce..0074506 100644 (file)
@@ -2270,11 +2270,11 @@ void logic_buttons(bContext *C, ARegion *ar)
        
        /* ****************** Controllers ****************** */
        
-       xco= 420; yco= -10; width= 300;
+       xco= 21 * U.widget_unit; yco= - U.widget_unit / 2; width= 15 * U.widget_unit;
        layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
        row = uiLayoutRow(layout, TRUE);
        
-       uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco-10, yco, 300, UI_UNIT_Y, "");            /* replace this with uiLayout stuff later */
+       uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco - U.widget_unit / 2, yco, width, UI_UNIT_Y, "");         /* replace this with uiLayout stuff later */
        
        uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
        uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE);
@@ -2301,7 +2301,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT);
 
                row = uiLayoutRow(split, TRUE);
-               uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers"));
+               uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers"));
 
                RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
                uiLayoutSetContextPointer(row, "object", &object_ptr);
@@ -2377,11 +2377,11 @@ void logic_buttons(bContext *C, ARegion *ar)
        
        /* ****************** Sensors ****************** */
        
-       xco= 10; yco= -10; width= 340;
+       xco= U.widget_unit / 2; yco= -U.widget_unit / 2; width= 17 * U.widget_unit;
        layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
        row = uiLayoutRow(layout, TRUE);
        
-       uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco-10, yco, 300, UI_UNIT_Y, "");            /* replace this with uiLayout stuff later */
+       uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, "");            /* replace this with uiLayout stuff later */
        
        uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
        uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE);
@@ -2398,7 +2398,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                if ((ob->scavisflag & OB_VIS_SENS) == 0) continue;
 
                row = uiLayoutRow(layout, TRUE);
-               uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors"));
+               uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors"));
 
                RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
                uiLayoutSetContextPointer(row, "object", &object_ptr);
@@ -2446,11 +2446,11 @@ void logic_buttons(bContext *C, ARegion *ar)
        
        /* ****************** Actuators ****************** */
        
-       xco= 800; yco= -10; width= 340;
+       xco= 40 * U.widget_unit; yco= -U.widget_unit / 2; width= 17 * U.widget_unit;
        layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle());
        row = uiLayoutRow(layout, TRUE);
        
-       uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco-10, yco, 300, UI_UNIT_Y, "");                /* replace this with uiLayout stuff later */
+       uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, "");                /* replace this with uiLayout stuff later */
        
        uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
        uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE);
@@ -2469,7 +2469,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                }
 
                row = uiLayoutRow(layout, TRUE);
-               uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators"));
+               uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators"));
 
                RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
                uiLayoutSetContextPointer(row, "object", &object_ptr);
@@ -2516,7 +2516,7 @@ void logic_buttons(bContext *C, ARegion *ar)
        uiBlockLayoutResolve(block, NULL, &yco);        /* stores final height in yco */
        height = MIN2(height, yco);
 
-       UI_view2d_totRect_set(&ar->v2d, 1150, height);
+       UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height);
        
        /* set the view */
        UI_view2d_view_ortho(&ar->v2d);
index fd999bf..beabd44 100644 (file)
@@ -632,7 +632,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
        for (ale = anim_data->first; ale; ale = ale->next) {
                const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
                const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
-               const float ydatac = (float)(y - 7);
+               const float ydatac = (float)(y - 0.35f * U.widget_unit);
                
                /* check if visible */
                if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
@@ -716,7 +716,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                if (ale->id) {
                                        /* special exception for textures */
                                        if (GS(ale->id->name) == ID_TE) {
-                                               offset = 14;
+                                               offset = 0.7f * U.widget_unit;
                                                indent = 1;
                                        }
                                        /* special exception for nodetrees */
@@ -727,7 +727,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                                        case NTREE_SHADER:
                                                        {
                                                                /* same as for textures */
-                                                               offset = 14;
+                                                               offset = 0.7f * U.widget_unit;
                                                                indent = 1;
                                                        }
                                                        break;
@@ -735,19 +735,19 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                                        case NTREE_TEXTURE:
                                                        {
                                                                /* even more */
-                                                               offset = 21;
+                                                               offset = U.widget_unit;
                                                                indent = 1;
                                                        }
                                                        break;
                                                                
                                                        default:
                                                                /* normal will do */
-                                                               offset = 14;
+                                                               offset = 0.7f * U.widget_unit;
                                                                break;
                                                }
                                        }
                                        else {
-                                               offset = 14;
+                                               offset = 0.7f * U.widget_unit;
                                        }
                                }
                                else {
@@ -779,7 +779,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                                glColor4f(color[0], color[1], color[2], alpha);
                                        }
                                        
-                                       offset += 7 * indent;
+                                       offset += 0.35f * U.widget_unit * indent;
                                        
                                        /* only on top two corners, to show that this channel sits on top of the preceding ones */
                                        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
@@ -797,7 +797,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                        UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20));
                                        
                                        indent += group;
-                                       offset += 7 * indent;
+                                       offset += 0.35f * U.widget_unit * indent;
                                        glBegin(GL_QUADS);
                                        glVertex2f(x + offset, yminc);
                                        glVertex2f(x + offset, ymaxc);
@@ -809,14 +809,14 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                /* draw expand/collapse triangle */
                                if (expand > 0) {
                                        UI_icon_draw(x + offset, ydatac, expand);
-                                       offset += 17;
+                                       offset += 0.85f * U.widget_unit;
                                }
                                
                                /* draw special icon indicating certain data-types */
                                if (special > -1) {
                                        /* for normal channels */
                                        UI_icon_draw(x + offset, ydatac, special);
-                                       offset += 17;
+                                       offset += 0.85f * U.widget_unit;
                                }
                                glDisable(GL_BLEND);
                                
@@ -837,19 +837,19 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                
                                /* draw protect 'lock' */
                                if (protect > -1) {
-                                       offset = 16;
+                                       offset =  0.8f * U.widget_unit;
                                        UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, protect);
                                }
                                
                                /* draw mute 'eye' */
                                if (mute > -1) {
-                                       offset += 16;
+                                       offset += 0.8f * U.widget_unit;
                                        UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute);
                                }
                                
                                /* draw NLA-action line 'status-icons' - only when there's an action */
                                if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
-                                       offset += 16;
+                                       offset += 0.8f * U.widget_unit;
                                        
                                        /* now draw some indicator icons  */
                                        if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
@@ -862,7 +862,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                                
                                                fdrawline((float)(v2d->cur.xmax - offset), yminc,
                                                          (float)(v2d->cur.xmax - offset), ymaxc);
-                                               offset += 16;
+                                               offset += 0.8f * U.widget_unit;
                                                
                                                /* 'tweaking action' indicator - not a button */
                                                UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT);
@@ -870,10 +870,10 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
                                        else {
                                                /* XXX firstly draw a little rect to help identify that it's different from the toggles */
                                                glBegin(GL_LINE_LOOP);
-                                               glVertex2f((float)v2d->cur.xmax - offset - 1, y - 7);
-                                               glVertex2f((float)v2d->cur.xmax - offset - 1, y + 9);
-                                               glVertex2f((float)v2d->cur.xmax - 1, y + 9);
-                                               glVertex2f((float)v2d->cur.xmax - 1, y - 7);
+                                               glVertex2f((float)v2d->cur.xmax - offset - 1, y - 0.35f * U.widget_unit);
+                                               glVertex2f((float)v2d->cur.xmax - offset - 1, y + 0.45 * U.widget_unit);
+                                               glVertex2f((float)v2d->cur.xmax - 1, y +  0.45f * U.widget_unit);
+                                               glVertex2f((float)v2d->cur.xmax - 1, y - 0.35f * U.widget_unit);
                                                glEnd(); // GL_LINES
                                                
                                                /* 'push down' icon for normal active-actions */
index 381393e..e3078d3 100644 (file)
@@ -123,10 +123,10 @@ static void node_socket_button_string(const bContext *C, uiBlock *block,
                float slen;
 
                UI_ThemeColor(TH_TEXT);
-               slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+               slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect;    /* XXX, check for dpis */
                while (slen > (width * 0.5f) && *ui_name) {
                        ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
-                       slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+                       slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect;
                }
 
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
@@ -229,19 +229,18 @@ static void node_draw_input_default(const bContext *C, uiBlock *block,
                node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
 }
 
-static void node_draw_output_default(const bContext *C, uiBlock *block,
+static void node_draw_output_default(const bContext *UNUSED(C), uiBlock *block,
                                      bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock,
                                      const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
 {
-       SpaceNode *snode = CTX_wm_space_node(C);
        const char *ui_name = IFACE_(name);
        float slen;
 
        UI_ThemeColor(TH_TEXT);
-       slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
-       while (slen > node->width && *ui_name) {
+       slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) ;
+       while (slen > NODE_WIDTH(node) && *ui_name) {
                ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
-               slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
+               slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X);
        }
        
        if (*ui_name) {
@@ -509,14 +508,14 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
                bNodeSocket *sock, *gsock;
                float locx, locy;
                rctf *rect = &gnode->totr;
-               const float dpi_fac = UI_DPI_ICON_FAC;
+               const float dpi_fac = UI_DPI_FAC;
                const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
                const float group_header = 26 * dpi_fac;
                int counter;
                int dy;
                
                /* get "global" coords */
-               nodeToView(gnode, 0.0f, 0.0f, &locx, &locy);
+               node_to_view(gnode, 0.0f, 0.0f, &locx, &locy);
                
                /* center them, is a bit of abuse of locx and locy though */
                node_update_nodetree(C, ngroup, locx, locy);
@@ -688,7 +687,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
 static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
                               bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
 {
-       const float dpi_fac = UI_DPI_ICON_FAC;
+       const float dpi_fac = 1.0f;
        bNodeTree *ngroup = (bNodeTree *)gnode->id;
        bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
        uiBut *bt;
@@ -800,7 +799,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                uiLayout *layout;
                PointerRNA ptr;
                rctf rect = gnode->totr;
-               const float dpi_fac = UI_DPI_ICON_FAC;
+               const float dpi_fac = 1.0f;
                const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
                const float group_header = 26 * dpi_fac;
                
@@ -925,7 +924,7 @@ static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
  */
 static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
 {
-       const float margin = 30.0f;
+       const float margin = 1.5f * U.widget_unit;
        NodeFrame *data = (NodeFrame *)node->storage;
        int bbinit;
        bNode *tnode;
@@ -933,8 +932,8 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode
        float xmax, ymax;
        
        /* init rect from current frame size */
-       nodeToView(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
-       nodeToView(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
+       node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
+       node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
        
        /* frame can be resized manually only if shrinking is disabled or no children are attached */
        data->flag |= NODE_FRAME_RESIZEABLE;
@@ -963,8 +962,8 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode
        }
        
        /* now adjust the frame size from view-space bounding box */
-       nodeFromView(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
-       nodeFromView(node, rect.xmax, rect.ymin, &xmax, &ymax);
+       node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
+       node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax);
        node->width = xmax - node->offsetx;
        node->height = -ymax + node->offsety;
        
@@ -1101,7 +1100,7 @@ static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntr
        float size = NODE_REROUTE_SIZE;
        
        /* get "global" coords */
-       nodeToView(node, 0.0f, 0.0f, &locx, &locy);
+       node_to_view(node, 0.0f, 0.0f, &locx, &locy);
        
        /* reroute node has exactly one input and one output, both in the same place */
        nsock = node->outputs.first;
@@ -3532,7 +3531,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
                glDisable(GL_LINE_SMOOTH);
                
                /* restore previuos linewidth */
-               glLineWidth(linew);
+               glLineWidth(1.0f);
        }
 }
 
@@ -3618,7 +3617,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
        glDisable(GL_LINE_SMOOTH);
        
        /* restore previuos linewidth */
-       glLineWidth(linew);
+       glLineWidth(1.0f);
 }
 #endif
 
index 96ac716..509e326 100644 (file)
@@ -76,10 +76,14 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene,
        if (node) {
                node_select(node);
 
+               /* node location is mapped */
+               locx /= UI_DPI_FAC;
+               locy /= UI_DPI_FAC;
+               
                gnode = node_tree_get_editgroup(snode->nodetree);
                // arbitrary y offset of 60 so its visible
                if (gnode) {
-                       nodeFromView(gnode, locx, locy + 60.0f, &node->locx, &node->locy);
+                       node_from_view(gnode, locx, locy + 60.0f, &node->locx, &node->locy);
                }
                else {
                        node->locx = locx;
@@ -215,7 +219,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi
                mul_v2_fl(insert_point, 1.0f / num_links);
                
                if (gnode) {
-                       nodeFromView(gnode, insert_point[0], insert_point[1], &reroute_node->locx, &reroute_node->locy);
+                       node_from_view(gnode, insert_point[0], insert_point[1], &reroute_node->locx, &reroute_node->locy);
                }
                else {
                        reroute_node->locx = insert_point[0];
index 72461cf..704bc70 100644 (file)
@@ -278,6 +278,21 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
        }
 }
 
+void node_to_view(struct bNode *node, float x, float y, float *rx, float *ry)
+{
+       nodeToView(node, x, y, rx, ry);
+       *rx *= UI_DPI_FAC;
+       *ry *= UI_DPI_FAC;
+}
+
+void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry)
+{
+       x /= UI_DPI_FAC;
+       y /= UI_DPI_FAC;
+       nodeFromView(node, x, y, rx, ry);
+}
+
+
 /* based on settings in node, sets drawing rect info. each redraw! */
 static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
 {
@@ -289,7 +304,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
        int buty;
        
        /* get "global" coords */
-       nodeToView(node, 0.0f, 0.0f, &locx, &locy);
+       node_to_view(node, 0.0f, 0.0f, &locx, &locy);
        dy = locy;
        
        /* header */
@@ -302,14 +317,14 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
        /* output sockets */
        for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
                if (!nodeSocketIsHidden(nsock)) {
-                       nsock->locx = locx + node->width;
+                       nsock->locx = locx + NODE_WIDTH(node);
                        nsock->locy = dy - NODE_DYS;
                        dy -= NODE_DY;
                }
        }
 
        node->prvr.xmin = locx + NODE_DYS;
-       node->prvr.xmax = locx + node->width - NODE_DYS;
+       node->prvr.xmax = locx + NODE_WIDTH(node) - NODE_DYS;
 
        /* preview rect? */
        if (node->flag & NODE_PREVIEW) {
@@ -323,12 +338,13 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                        node->prvr.ymax = dy;
                        
                        if (aspect <= 1.0f)
-                               node->prvr.ymin = dy - aspect * (node->width - NODE_DY);
+                               node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
                        else {
                                /* width correction of image */
-                               float dx = (node->width - NODE_DYS) - (node->width - NODE_DYS) / aspect;
+                               /* XXX huh? (ton) */
+                               float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect;
                                
-                               node->prvr.ymin = dy - (node->width - NODE_DY);
+                               node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY);
                                
                                node->prvr.xmin += 0.5f * dx;
                                node->prvr.xmax -= 0.5f * dx;
@@ -343,7 +359,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                else {
                        float oldh = BLI_rctf_size_y(&node->prvr);
                        if (oldh == 0.0f)
-                               oldh = 0.6f * node->width - NODE_DY;
+                               oldh = 0.6f * NODE_WIDTH(node) - NODE_DY;
                        dy -= NODE_DYS / 2;
                        node->prvr.ymax = dy;
                        node->prvr.ymin = dy - oldh;
@@ -357,21 +373,22 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
 
                /* set this for uifunc() that don't use layout engine yet */
                node->butr.xmin = 0;
-               node->butr.xmax = node->width - 2 * NODE_DYS;
+               node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS;
                node->butr.ymin = 0;
                node->butr.ymax = 0;
                
                RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
                
+                       
                layout = uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
-                                      locx + NODE_DYS, dy, node->butr.xmax, NODE_DY, UI_GetStyle());
+                                      locx + NODE_DYS, dy, node->butr.xmax, 0, UI_GetStyle());
                uiLayoutSetContextPointer(layout, "node", &ptr);
                
                node->typeinfo->uifunc(layout, (bContext *)C, &ptr);
                
                uiBlockEndAlign(node->block);
                uiBlockLayoutResolve(node->block, NULL, &buty);
-               
+                       
                dy = buty - NODE_DYS / 2;
        }
 
@@ -389,7 +406,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                dy -= NODE_DYS / 2;
 
        node->totr.xmin = locx;
-       node->totr.xmax = locx + node->width;
+       node->totr.xmax = locx + NODE_WIDTH(node);
        node->totr.ymax = locy;
        node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY);
        
@@ -412,7 +429,7 @@ static void node_update_hidden(bNode *node)
        int totin = 0, totout = 0, tot;
        
        /* get "global" coords */
-       nodeToView(node, 0.0f, 0.0f, &locx, &locy);
+       node_to_view(node, 0.0f, 0.0f, &locx, &locy);
 
        /* calculate minimal radius */
        for (nsock = node->inputs.first; nsock; nsock = nsock->next)
@@ -700,7 +717,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        uiRoundBox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
        
        /* show/hide icons */
-       iconofs = rct->xmax - 7.0f;
+       iconofs = rct->xmax - 0.35f * U.widget_unit;
        
        /* preview */
        if (node->typeinfo->flag & NODE_PREVIEW) {
@@ -742,13 +759,13 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                /* XXX button uses a custom triangle draw below, so make it invisible without icon */
                uiBlockSetEmboss(node->block, UI_EMBOSSN);
                but = uiDefBut(node->block, TOGBUT, B_REDR, "",
-                              rct->xmin + 10.0f - but_size / 2, rct->ymax - NODE_DY / 2.0f - but_size / 2,
+                              rct->xmin + 0.5f * U.widget_unit - but_size / 2, rct->ymax - NODE_DY / 2.0f - but_size / 2,
                               but_size, but_size, NULL, 0, 0, 0, 0, "");
                uiButSetFunc(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
                uiBlockSetEmboss(node->block, UI_EMBOSS);
                
                /* custom draw function for this button */
-               UI_DrawTriIcon(rct->xmin + 10.0f, rct->ymax - NODE_DY / 2.0f, 'v');
+               UI_DrawTriIcon(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v');
        }
        
        /* this isn't doing anything for the label, so commenting out */
@@ -765,7 +782,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        //      BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
        
        uiDefBut(node->block, LABEL, 0, showname,
-                (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(rct->ymax - NODE_DY),
+                (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY),
                 (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY,
                 NULL, 0, 0, 0, 0, "");
 
@@ -808,8 +825,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
                
                node->typeinfo->drawinputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
-                                             sock->locx + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS,
-                                             node->width - NODE_DY);
+                                             sock->locx + (NODE_DYS), sock->locy - NODE_DYS,
+                                             NODE_WIDTH(node) - NODE_DY);
        }
        
        /* socket outputs */
@@ -820,8 +837,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
                
                node->typeinfo->drawoutputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
-                                              sock->locx - node->width + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS,
-                                              node->width - NODE_DY);
+                                              sock->locx - NODE_WIDTH(node) + (NODE_DYS), sock->locy - NODE_DYS,
+                                              NODE_WIDTH(node) - NODE_DY);
        }
        
        /* preview */
@@ -843,7 +860,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
        rctf *rct = &node->totr;
        float dx, centy = BLI_rctf_cent_y(rct);
        float hiddenrad = BLI_rctf_size_y(rct) / 2.0f;
-       float socket_size = NODE_SOCKSIZE * UI_DPI_ICON_FAC;
+       float socket_size = NODE_SOCKSIZE;
        int color_id = node_get_colorid(node);
        char showname[128]; /* 128 is used below */
        
@@ -920,7 +937,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
                //      BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */
 
                uiDefBut(node->block, LABEL, 0, showname,
-                        (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
+                        (int)(rct->xmin + (NODE_MARGIN_X)), (int)(centy - 10),
                         (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
                         NULL, 0, 0, 0, 0, "");
        }
@@ -1011,7 +1028,7 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree, float offsetx, fl
        
        /* update nodes front to back, so children sizes get updated before parents */
        for (node = ntree->nodes.last; node; node = node->prev) {
-               /* XXX little hack */
+               /* XXX little hack (not used anyore?) */
                node->locx += offsetx;
                node->locy += offsety;
                
@@ -1082,7 +1099,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
        SpaceNode *snode = CTX_wm_space_node(C);
        bNodeLinkDrag *nldrag;
        LinkData *linkdata;
-       
+
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
 
@@ -1098,11 +1115,10 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
 
        /* aspect+font, set each time */
        snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx;
-       snode->aspect_sqrt = sqrtf(snode->aspect);
        // XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
 
        /* grid */
-       UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2);
+       UI_view2d_multi_grid_draw(v2d, U.widget_unit, 5, 2);
 
        /* backdrop */
        draw_nodespace_back_pix(C, ar, snode);
index f757345..ae95d9a 100644 (file)
@@ -874,8 +874,8 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event)
                case MOUSEMOVE:
                        
                        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
-                       dx = mx - nsw->mxstart;
-                       dy = my - nsw->mystart;
+                       dx = (mx - nsw->mxstart) / UI_DPI_FAC;
+                       dy = (my - nsw->mystart) / UI_DPI_FAC;
                        
                        if (node) {
                                if (node->flag & NODE_HIDDEN) {
@@ -894,8 +894,8 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event)
                                        }
                                }
                                else {
-                                       float widthmin = UI_DPI_FAC * node->typeinfo->minwidth;
-                                       float widthmax = UI_DPI_FAC * node->typeinfo->maxwidth;
+                                       float widthmin = node->typeinfo->minwidth;
+                                       float widthmax = node->typeinfo->maxwidth;
                                        if (nsw->directions & NODE_RESIZE_RIGHT) {
                                                node->width = nsw->oldwidth + dx;
                                                CLAMP(node->width, widthmin, widthmax);
@@ -1967,7 +1967,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
 
        /* get group node offset */
        if (gnode)
-               nodeToView(gnode, 0.0f, 0.0f, &gnode_x, &gnode_y);
+               node_to_view(gnode, 0.0f, 0.0f, &gnode_x, &gnode_y);
        
        for (node = ntree->nodes.first; node; node = node->next) {
                if (node->flag & SELECT) {
@@ -2080,7 +2080,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
 
        /* get group node offset */
        if (gnode) {
-               nodeToView(gnode, 0.0f, 0.0f, &gnode_center[0], &gnode_center[1]);
+               node_to_view(gnode, 0.0f, 0.0f, &gnode_center[0], &gnode_center[1]);
        }
        else {
                zero_v2(gnode_center);
index 671c4fd..e8dd1cf 100644 (file)
@@ -48,6 +48,7 @@ struct bNode;
 struct bNodeSocket;
 struct bNodeLink;
 struct Main;
+struct wmKeyConfig;
 
 /* temp data to pass on to modal */
 typedef struct bNodeLinkDrag {
@@ -82,6 +83,9 @@ void node_draw_nodetree(const struct bContext *C, struct ARegion *ar, struct Spa
 void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d);
 
 void node_set_cursor(struct wmWindow *win, struct SpaceNode *snode);
+       /* DPI scaled coords */
+void node_to_view(struct bNode *node, float x, float y, float *rx, float *ry);
+void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry);
 
 /* node_buttons.c */
 void node_buttons_register(struct ARegionType *art);
@@ -93,7 +97,7 @@ void NODE_OT_toolbar(struct wmOperatorType *ot);
 
 /* node_ops.c */
 void node_operatortypes(void);
-void node_keymap(wmKeyConfig *keyconf);
+void node_keymap(struct wmKeyConfig *keyconf);
 
 /* node_select.c */
 void node_select(struct bNode *node);
@@ -108,14 +112,14 @@ int node_select_same_type_np(struct SpaceNode *snode, int dir);
 void node_select_single(struct bContext *C, struct bNode *node);
 
 void NODE_OT_select(struct wmOperatorType *ot);
-void NODE_OT_select_all(wmOperatorType *ot);
-void NODE_OT_select_linked_to(wmOperatorType *ot);
-void NODE_OT_select_linked_from(wmOperatorType *ot);
+void NODE_OT_select_all(struct wmOperatorType *ot);
+void NODE_OT_select_linked_to(struct wmOperatorType *ot);
+void NODE_OT_select_linked_from(struct wmOperatorType *ot);
 void NODE_OT_select_border(struct wmOperatorType *ot);
 void NODE_OT_select_lasso(struct wmOperatorType *ot);
 void NODE_OT_select_same_type(struct wmOperatorType *ot);
-void NODE_OT_select_same_type_next(wmOperatorType *ot);
-void NODE_OT_select_same_type_prev(wmOperatorType *ot);
+void NODE_OT_select_same_type_next(struct wmOperatorType *ot);
+void NODE_OT_select_same_type_prev(struct wmOperatorType *ot);
 
 /* node_view.c */
 void NODE_OT_view_all(struct wmOperatorType *ot);
@@ -123,14 +127,14 @@ void NODE_OT_view_selected(struct wmOperatorType *ot);
 
 void NODE_OT_backimage_move(struct wmOperatorType *ot);
 void NODE_OT_backimage_zoom(struct wmOperatorType *ot);
-void NODE_OT_backimage_sample(wmOperatorType *ot);
+void NODE_OT_backimage_sample(struct wmOperatorType *ot);
 
 /* drawnode.c */
-void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
-void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3);
-int node_link_bezier_points(View2D * v2d, SpaceNode * snode, bNodeLink * link, float coord_array[][2], int resol);
+void node_draw_link(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link);
+void node_draw_link_bezier(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3);
+int node_link_bezier_points(struct View2D * v2d, struct SpaceNode * snode, struct bNodeLink * link, float coord_array[][2], int resol);
 // void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
-void draw_nodespace_back_pix(const struct bContext *C, ARegion *ar, SpaceNode *snode);
+void draw_nodespace_back_pix(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode);
 
 
 /* node_add.c */
@@ -172,10 +176,10 @@ void NODE_OT_link_viewer(struct wmOperatorType *ot);
 
 /* node_edit.c */
 void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype);
-void snode_notify(bContext *C, SpaceNode *snode);
-void snode_dag_update(bContext *C, SpaceNode *snode);
-void snode_set_context(SpaceNode *snode, Scene *scene);
-void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
+void snode_notify(struct bContext *C, struct SpaceNode *snode);
+void snode_dag_update(struct bContext *C, struct SpaceNode *snode);
+void snode_set_context(struct SpaceNode *snode, Scene *scene);
+void snode_make_group_editable(struct SpaceNode *snode, struct bNode *gnode);
 
 bNode *node_tree_get_editgroup(bNodeTree *ntree);
 void snode_update(struct SpaceNode *snode, struct bNode *node);
@@ -184,7 +188,7 @@ int composite_node_active(struct bContext *C);
 
 int node_has_hidden_sockets(bNode *node);
 void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set);
-int node_render_changed_exec(bContext *, wmOperator *);
+int node_render_changed_exec(bContext *, struct wmOperator *);
 int node_find_indicated_socket(struct SpaceNode *snode, struct bNode **nodep, struct bNodeSocket **sockp, int in_out);
 
 void NODE_OT_duplicate(struct wmOperatorType *ot);
@@ -217,13 +221,14 @@ extern const char *node_context_dir[];
 
 // XXXXXX
 
-// XXX from BSE_node.h
-#define HIDDEN_RAD      15.0f
-#define BASIS_RAD       8.0f
+// nodes draw without dpi - the view zoom is flexible
+#define HIDDEN_RAD      (0.75f * U.widget_unit)
+#define BASIS_RAD       (0.4f * U.widget_unit)
 #define NODE_DYS        (U.widget_unit / 2)
 #define NODE_DY         U.widget_unit
-#define NODE_MARGIN_X   15
-#define NODE_SOCKSIZE   5
+#define NODE_WIDTH(node)       (node->width * UI_DPI_FAC)
+#define NODE_MARGIN_X   (0.75f * U.widget_unit)
+#define NODE_SOCKSIZE   (0.25f * U.widget_unit)
 #define NODE_LINK_RESOL 12
 
 // XXX button events (butspace)
index 23f4e94..ca85415 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "DNA_node_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_space_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_string.h"
@@ -52,6 +53,8 @@
 
 #include "ED_util.h"
 
+#include "node_intern.h"
+
 /************************* Node Socket Manipulation **************************/
 
 static void node_tag_recursive(bNode *node)
index 0e015a4..fe880a7 100644 (file)
@@ -142,15 +142,12 @@ static SpaceLink *node_new(const bContext *UNUSED(C))
        BLI_addtail(&snode->regionbase, ar);
        ar->regiontype = RGN_TYPE_WINDOW;
 
-       ar->v2d.tot.xmin =  -256.0f;
-       ar->v2d.tot.ymin =  -256.0f;
-       ar->v2d.tot.xmax = 768.0f;
-       ar->v2d.tot.ymax = 768.0f;
-
-       ar->v2d.cur.xmin =  -256.0f;
-       ar->v2d.cur.ymin =  -256.0f;
-       ar->v2d.cur.xmax = 768.0f;
-       ar->v2d.cur.ymax = 768.0f;
+       ar->v2d.tot.xmin =  -12.8f * U.widget_unit;
+       ar->v2d.tot.ymin =  -12.8f * U.widget_unit;
+       ar->v2d.tot.xmax = 38.4f * U.widget_unit;
+       ar->v2d.tot.ymax = 38.4f * U.widget_unit;
+
+       ar->v2d.cur =  ar->v2d.tot;
 
        ar->v2d.min[0] = 1.0f;
        ar->v2d.min[1] = 1.0f;
index d37cb4b..911902d 100644 (file)
@@ -893,7 +893,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
 struct DrawIconArg {
        uiBlock *block;
        ID *id;
-       int xmax, x, y;
+       float xmax, x, y, xb, yb;
        float alpha;
 };
 
@@ -902,13 +902,11 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
        /* restrict column clip... it has been coded by simply overdrawing, doesnt work for buttons */
        if (arg->x >= arg->xmax) {
                glEnable(GL_BLEND);
-               UI_icon_draw_aspect(arg->x, arg->y, icon, 1.0f, arg->alpha);
+               UI_icon_draw_aspect(arg->x, arg->y, icon, 1.0f / UI_DPI_ICON_FAC, arg->alpha);
                glDisable(GL_BLEND);
        }
        else {
-               /* XXX investigate: button placement of icons is way different than UI_icon_draw? */
-               float ufac = UI_UNIT_X / 20.0f;
-               uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x - 3.0f * ufac, arg->y, UI_UNIT_X - 4.0f * ufac, UI_UNIT_Y - 4.0f * ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+               uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->xb, arg->yb, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
                
                if (arg->id)
                        uiButSetDragID(but, arg->id);
@@ -919,15 +917,24 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
 static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, float alpha)
 {
        struct DrawIconArg arg;
+       float aspect;
+       
+       /* icons tiny bit away from text */
+       x -= 0.15f * UI_UNIT_Y;
        
        /* make function calls a bit compacter */
        arg.block = block;
        arg.id = tselem->id;
        arg.xmax = xmax;
-       arg.x = x;
-       arg.y = y;
+       arg.xb = x;     /* for ui buttons */
+       arg.yb = y;
        arg.alpha = alpha;
        
+       /* placement of icons, copied from interface_widgets.c */
+       aspect = (0.8f * UI_UNIT_Y) / ICON_DEFAULT_HEIGHT;
+       arg.x = x = x + 4.0f * aspect;
+       arg.y = y = y + 0.1f * UI_UNIT_Y;
+
        if (tselem->type) {
                switch (tselem->type) {
                        case TSE_ANIM_DATA:
@@ -1220,10 +1227,10 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
 
                                uiSetRoundBox(UI_CNR_ALL);
                                glColor4ub(255, 255, 255, 100);
-                               uiRoundBox((float) *offsx - 0.5f * ufac,
-                                          (float)ys - 1.0f * ufac,
-                                          (float)*offsx + UI_UNIT_Y - 3.0f * ufac,
-                                          (float)ys + UI_UNIT_Y - 3.0f * ufac,
+                               uiRoundBox((float) *offsx - 1.5f * ufac,
+                                          (float)ys + 2.0f * ufac,
+                                          (float)*offsx + UI_UNIT_X - 3.0f * ufac,
+                                          (float)ys + UI_UNIT_Y - 1.0f * ufac,
                                           (float)UI_UNIT_Y / 2.0f - 2.0f * ufac);
                                glEnable(GL_BLEND); /* roundbox disables */
                        }
@@ -1355,9 +1362,9 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                /* active circle */
                if (active) {
                        uiSetRoundBox(UI_CNR_ALL);
-                       uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac,
+                       uiRoundBox((float)startx + UI_UNIT_X - 1.5f * ufac,
                                   (float)*starty + 2.0f * ufac,
-                                  (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac,
+                                  (float)startx + 2.0f * UI_UNIT_X - 3.0f * ufac,
                                   (float)*starty + UI_UNIT_Y - 1.0f * ufac,
                                   UI_UNIT_Y / 2.0f - 2.0f * ufac);
                        glEnable(GL_BLEND); /* roundbox disables it */
@@ -1384,8 +1391,8 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                /* datatype icon */
                
                if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) {
-                       // icons a bit higher
-                       tselem_draw_icon(block, xmax, (float)startx + offsx - 0.5f * ufac, (float)*starty + 2.0f * ufac, tselem, te, 1.0f);
+                       
+                       tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, 1.0f);
                        
                        offsx += UI_UNIT_X;
                }
@@ -1425,12 +1432,12 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                                        
                                        /* divider */
                                        UI_ThemeColorShade(TH_BACK, -40);
-                                       glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4);
+                                       glRecti(tempx - 10.0 * ufac, *starty + 4.0f * ufac, tempx - 8.0f * ufac, *starty + UI_UNIT_Y - 4.0f * ufac);
                                        
                                        glEnable(GL_BLEND);
                                        glPixelTransferf(GL_ALPHA_SCALE, 0.5);
                                        
-                                       outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty + 2);
+                                       outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty);
                                        
                                        glPixelTransferf(GL_ALPHA_SCALE, 1.0);
                                        glDisable(GL_BLEND);
@@ -1625,7 +1632,7 @@ static void outliner_draw_restrictcols(ARegion *ar)
 
 /* ****************************************************** */
 /* Main Entrypoint - Draw contents of Outliner editor */
+
 void draw_outliner(const bContext *C)
 {
        Main *mainvar = CTX_data_main(C);
@@ -1635,8 +1642,8 @@ void draw_outliner(const bContext *C)
        SpaceOops *soops = CTX_wm_space_outliner(C);
        uiBlock *block;
        int sizey = 0, sizex = 0, sizex_rna = 0;
-       
-       outliner_build_tree(mainvar, scene, soops); // always 
+
+       outliner_build_tree(mainvar, scene, soops); // always
        
        /* get extents of data */
        outliner_height(soops, &soops->tree, &sizey);
@@ -1709,7 +1716,7 @@ void draw_outliner(const bContext *C)
 
        uiEndBlock(C, block);
        uiDrawBlock(C, block);
-       
+
        /* clear flag that allows quick redraws */
        soops->storeflag &= ~SO_TREESTORE_REDRAW;
 } 
index 46ab2d9..9a448cf 100644 (file)
@@ -65,7 +65,7 @@
 
 static void text_font_begin(SpaceText *st)
 {
-       BLF_size(mono, st->lheight, 72);
+       BLF_size(mono, st->lheight_dpi, 72);
 }
 
 static void text_font_end(SpaceText *UNUSED(st))
@@ -734,7 +734,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
                                if (st->showsyntax && format) format_draw_color(format[a]);
                                x += text_font_draw_character_utf8(st, x, y, str + ma);
                        }
-                       y -= st->lheight + TXT_LINE_SPACING;
+                       y -= st->lheight_dpi + TXT_LINE_SPACING;
                        x = basex;
                        lines++;
                        start = end; mstart = mend;
@@ -852,7 +852,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
        full_update |= drawcache->wordwrap != st->wordwrap;       /* word-wrapping option was toggled */
        full_update |= drawcache->showlinenrs != st->showlinenrs; /* word-wrapping option was toggled */
        full_update |= drawcache->tabnumber != st->tabnumber;     /* word-wrapping option was toggled */
-       full_update |= drawcache->lheight != st->lheight;         /* word-wrapping option was toggled */
+       full_update |= drawcache->lheight != st->lheight_dpi;         /* word-wrapping option was toggled */
        full_update |= drawcache->cwidth != st->cwidth;           /* word-wrapping option was toggled */
        full_update |= strncmp(drawcache->text_id, txt->id.name, MAX_ID_NAME); /* text datablock was changed */
 
@@ -928,7 +928,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
        /* store settings */
        drawcache->winx        = ar->winx;
        drawcache->wordwrap    = st->wordwrap;
-       drawcache->lheight     = st->lheight;
+       drawcache->lheight     = st->lheight_dpi;
        drawcache->cwidth      = st->cwidth;
        drawcache->showlinenrs = st->showlinenrs;
        drawcache->tabnumber   = st->tabnumber;
@@ -1237,9 +1237,9 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
                x += SUGG_LIST_WIDTH * st->cwidth + 50;
        }
 
-       /* top = */ /* UNUSED */ y = ar->winy - st->lheight * l - 2;
+       /* top = */ /* UNUSED */ y = ar->winy - st->lheight_dpi * l - 2;
        boxw = DOC_WIDTH * st->cwidth + 20;
-       boxh = (DOC_HEIGHT + 1) * st->lheight;
+       boxh = (DOC_HEIGHT + 1) * st->lheight_dpi;
 
        /* Draw panel */
        UI_ThemeColor(TH_BACK);
@@ -1271,7 +1271,7 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
                else if (*p == '\n') {
                        buf[i] = '\0';
                        if (lines >= 0) {
-                               y -= st->lheight;
+                               y -= st->lheight_dpi;
                                text_draw(st, buf, 0, 0, 1, x + 4, y - 3, NULL);
                        }
                        i = 0; br = DOC_WIDTH; lines++;
@@ -1280,7 +1280,7 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
                if (i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */
                        buf[br] = '\0';
                        if (lines >= 0) {
-                               y -= st->lheight;
+                               y -= st->lheight_dpi;
                                text_draw(st, buf, 0, 0, 1, x + 4, y - 3, NULL);
                        }
                        p -= i - br - 1; /* Rewind pointer to last break */
@@ -1326,10 +1326,10 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
        else {
                x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4;
        }
-       y = ar->winy - st->lheight * l - 2;
+       y = ar->winy - st->lheight_dpi * l - 2;
 
        boxw = SUGG_LIST_WIDTH * st->cwidth + 20;
-       boxh = SUGG_LIST_SIZE * st->lheight + 8;
+       boxh = SUGG_LIST_SIZE * st->lheight_dpi + 8;
        
        UI_ThemeColor(TH_SHADE1);
        glRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1);
@@ -1341,7 +1341,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
 
        for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
 
-               y -= st->lheight;
+               y -= st->lheight_dpi;
 
                BLI_strncpy(str, item->name, SUGG_LIST_WIDTH);
 
@@ -1349,7 +1349,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
                
                if (item == sel) {
                        UI_ThemeColor(TH_SHADE2);
-                       glRecti(x + 16, y - 3, x + 16 + w, y + st->lheight - 3);
+                       glRecti(x + 16, y - 3, x + 16 + w, y + st->lheight_dpi - 3);
                }
                b = 1; /* b=1 color block, text is default. b=0 no block, color text */
                switch (item->type) {
@@ -1376,7 +1376,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
        Text *text = st->text;
        int vcurl, vcurc, vsell, vselc, hidden = 0;
        int x, y, w, i;
-       int lheight = st->lheight + TXT_LINE_SPACING;
+       int lheight = st->lheight_dpi + TXT_LINE_SPACING;
 
        /* Draw the selection */
        if (text->curl != text->sell || text->curc != text->selc) {
@@ -1588,7 +1588,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
 
        UI_ThemeColor(TH_HILITE);
        x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
-       y = ar->winy - st->lheight;
+       y = ar->winy - st->lheight_dpi;
 
        /* draw opening bracket */
        ch = startl->line[startc];
@@ -1598,8 +1598,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
        if (viewc >= 0) {
                viewl = txt_get_span(text->lines.first, startl) - st->top + offl;
 
-               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight + TXT_LINE_SPACING), ch);
-               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
        }
 
        /* draw closing bracket */
@@ -1610,8 +1610,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
        if (viewc >= 0) {
                viewl = txt_get_span(text->lines.first, endl) - st->top + offl;
 
-               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight + TXT_LINE_SPACING), ch);
-               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
        }
 }
 
@@ -1627,7 +1627,10 @@ void draw_text_main(SpaceText *st, ARegion *ar)
        int wraplinecount = 0, wrap_skip = 0;
        int margin_column_x;
 
-       if (st->lheight) st->viewlines = (int)ar->winy / (st->lheight + TXT_LINE_SPACING);
+       /* dpi controlled line height and font size */
+       st->lheight_dpi = (U.widget_unit * st->lheight) / 20;
+       
+       if (st->lheight_dpi) st->viewlines = (int)ar->winy / (st->lheight_dpi + TXT_LINE_SPACING);
        else st->viewlines = 0;
 
        /* if no text, nothing to do */
@@ -1686,7 +1689,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
                st->linenrs_tot = 0; /* not used */
                x = TXT_OFFSET;
        }
-       y = ar->winy - st->lheight;
+       y = ar->winy - st->lheight_dpi;
        winx = ar->winx - TXT_SCROLL_WIDTH;
        
        /* draw cursor */
@@ -1716,12 +1719,12 @@ void draw_text_main(SpaceText *st, ARegion *ar)
                if (st->wordwrap) {
                        /* draw word wrapped text */
                        int lines = text_draw_w