Holiday coding log :)

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)
This commit is contained in:
Ton Roosendaal 2012-12-12 18:58:11 +00:00
parent 26ae649b01
commit 12b642062c
91 changed files with 1893 additions and 913 deletions

@ -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
}

@ -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

@ -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();
}

@ -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;
}

@ -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

@ -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,

@ -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

@ -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];

@ -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);

@ -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

@ -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);

@ -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;

@ -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

@ -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 */

@ -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;

@ -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);

@ -80,8 +80,11 @@
#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;
}
#if 0
else if (!G.relbase_valid) {
/* otherwise, use an empty string as filename, rather than <memory2> */
filepath = "";
}
#endif
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);
}
/* 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;
}

@ -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));

@ -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"

@ -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

@ -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);
}
}

@ -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;
}

@ -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);

@ -33,9 +33,12 @@
#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);

@ -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;
}
}

@ -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);
}
}

@ -45,8 +45,10 @@
#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"

@ -35,6 +35,14 @@
#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

@ -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 -------------------- */

@ -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);

@ -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);

@ -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 ----- */

@ -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);

@ -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

@ -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;

@ -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)

@ -267,7 +267,7 @@ struct uiBut {
void *dragpoin;
struct ImBuf *imb;
float imb_scale;
/* active button data */
struct uiHandleButtonData *active;

@ -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);
}

@ -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);
}
}

@ -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;

@ -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);
}

@ -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,

@ -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);
}
}

@ -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 */

@ -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);
}

@ -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;

@ -33,11 +33,13 @@
#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);
}
}

@ -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;
screen_test_scale(win->screen, win->sizex, win->sizey);
/* header size depends on DPI, let's verify */
screen_refresh_headersizes();
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);
}

@ -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__ */

@ -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);

@ -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;

@ -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;

@ -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;

@ -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 {

@ -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);

@ -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 */

@ -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

@ -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];

@ -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);

@ -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);

@ -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)

@ -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)

@ -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.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.xmin = -256.0f;
ar->v2d.cur.ymin = -256.0f;
ar->v2d.cur.xmax = 768.0f;
ar->v2d.cur.ymax = 768.0f;
ar->v2d.cur = ar->v2d.tot;
ar->v2d.min[0] = 1.0f;
ar->v2d.min[1] = 1.0f;

@ -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;
}

@ -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_wrapped(st, tmp->line, x, y, winx - x, tmp->format, wrap_skip);
y -= lines * (st->lheight + TXT_LINE_SPACING);
y -= lines * (st->lheight_dpi + TXT_LINE_SPACING);
}
else {
/* draw unwrapped text */
text_draw(st, tmp->line, st->left, ar->winx / st->cwidth, 1, x, y, tmp->format);
y -= st->lheight + TXT_LINE_SPACING;
y -= st->lheight_dpi + TXT_LINE_SPACING;
}
wrap_skip = 0;

@ -54,12 +54,11 @@ void text_scroll_to_cursor(struct SpaceText *st, struct ScrArea *sa);
void text_update_cursor_moved(struct bContext *C);
/* TXT_OFFSET used to be 35 when the scrollbar was on the left... */
#define TXT_OFFSET 15
#define TXT_SCROLL_WIDTH 20
#define TXT_SCROLL_SPACE 2
#define TXT_LINE_SPACING 4 /* space between lines */
#define TEXTXLOC (st->cwidth * st->linenrs_tot)
#define TXT_OFFSET ((int)(0.75f * U.widget_unit))
#define TXT_SCROLL_WIDTH U.widget_unit
#define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit))
#define TXT_LINE_SPACING ((int)(0.2f * U.widget_unit)) /* space between lines */
#define TEXTXLOC (st->cwidth * st->linenrs_tot)
#define SUGG_LIST_SIZE 7
#define SUGG_LIST_WIDTH 20

@ -2106,10 +2106,10 @@ static void text_scroll_apply(bContext *C, wmOperator *op, wmEvent *event)
if (!tsc->scrollbar) {
txtdelta[0] = -tsc->delta[0] / st->cwidth;
txtdelta[1] = tsc->delta[1] / (st->lheight + TXT_LINE_SPACING);
txtdelta[1] = tsc->delta[1] / (st->lheight_dpi + TXT_LINE_SPACING);
tsc->delta[0] %= st->cwidth;
tsc->delta[1] %= (st->lheight + TXT_LINE_SPACING);
tsc->delta[1] %= (st->lheight_dpi + TXT_LINE_SPACING);
}
else {
txtdelta[1] = -tsc->delta[1] * st->pix_per_line;
@ -2204,7 +2204,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, wmEvent *event)
tsc->old[1] = event->y;
/* Sensitivity of scroll set to 4pix per line/char */
tsc->delta[0] = (event->x - event->prevx) * st->cwidth / 4;
tsc->delta[1] = (event->y - event->prevy) * st->lheight / 4;
tsc->delta[1] = (event->y - event->prevy) * st->lheight_dpi / 4;
tsc->first = 0;
tsc->scrollbar = 0;
text_scroll_apply(C, op, event);
@ -2503,7 +2503,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int
{
Text *text = st->text;
text_update_character_width(st);
y = (ar->winy - 2 - y) / (st->lheight + TXT_LINE_SPACING);
y = (ar->winy - 2 - y) / (st->lheight_dpi + TXT_LINE_SPACING);
if (st->showlinenrs) x -= TXT_OFFSET + TEXTXLOC;
else x -= TXT_OFFSET;

@ -36,7 +36,9 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "DNA_userdef_types.h"
#include "BKE_blender.h"
#include "BKE_suggestions.h"
#include "BKE_text.h"
@ -78,10 +80,10 @@ int text_do_suggest_select(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;
w = SUGG_LIST_WIDTH * st->cwidth + 20;
h = SUGG_LIST_SIZE * st->lheight + 8;
w = SUGG_LIST_WIDTH * st->cwidth + U.widget_unit;
h = SUGG_LIST_SIZE * st->lheight_dpi + 0.4f * U.widget_unit;
// XXX getmouseco_areawin(mval);
@ -92,7 +94,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) ;
/* Work out the target item index in the visible list */
tgti = (y - mval[1] - 4) / st->lheight;
tgti = (y - mval[1] - 4) / st->lheight_dpi;
if (tgti < 0 || tgti > SUGG_LIST_SIZE)
return 1;

@ -117,7 +117,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
BLI_insertlinkafter(&sa->regionbase, arhead, artool);
artool->regiontype = RGN_TYPE_TOOLS;
artool->alignment = RGN_ALIGN_LEFT; //RGN_OVERLAP_LEFT;
artool->alignment = RGN_ALIGN_LEFT;
artool->flag = RGN_FLAG_HIDDEN;
}

@ -563,35 +563,60 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
if (v3d->zbuf && scene->obedit) glDepthMask(1);
}
/* checks overlapping region for labels, axes, icons */
static int draw_name_offset(ARegion *ar)
{
ARegion *arn = ar;
/* too lazy to pass on area listbase */
while (arn->prev)
arn = arn->prev;
/* check if a region overlaps with the current one */
for (; arn; arn= arn->next) {
if (ar != arn)
if (ar->winrct.xmin == arn->winrct.xmin)
if (ar->winrct.ymin == arn->winrct.ymin)
return arn->winrct.xmax - arn->winrct.xmin;
}
return 0;
}
static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
{
int co[2];
/* we don't want the clipping for cursor */
if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
float f5 = 0.25f * U.widget_unit;
float f10 = 0.5f * U.widget_unit;
float f20 = U.widget_unit;
setlinestyle(0);
cpack(0xFF);
circ((float)co[0], (float)co[1], 10.0);
setlinestyle(4);
circ((float)co[0], (float)co[1], f10);
setlinestyle(4);
cpack(0xFFFFFF);
circ((float)co[0], (float)co[1], 10.0);
circ((float)co[0], (float)co[1], f10);
setlinestyle(0);
cpack(0x0);
sdrawline(co[0] - 20, co[1], co[0] - 5, co[1]);
sdrawline(co[0] + 5, co[1], co[0] + 20, co[1]);
sdrawline(co[0], co[1] - 20, co[0], co[1] - 5);
sdrawline(co[0], co[1] + 5, co[0], co[1] + 20);
sdrawline(co[0] - f20, co[1], co[0] - f5, co[1]);
sdrawline(co[0] + f5, co[1], co[0] + f20, co[1]);
sdrawline(co[0], co[1] - f20, co[0], co[1] - f5);
sdrawline(co[0], co[1] + f5, co[0], co[1] + f20);
}
}
/* Draw a live substitute of the view icon, which is always shown
* colors copied from transform_manipulator.c, we should keep these matching. */
static void draw_view_axis(RegionView3D *rv3d)
static void draw_view_axis(ARegion *ar, RegionView3D *rv3d)
{
const float k = U.rvisize; /* axis size */
const float toll = 0.5; /* used to see when view is quasi-orthogonal */
const float start = k + 1.0f; /* axis center in screen coordinates, x=y */
const float startx = k + 1.0f + draw_name_offset(ar); /* axis center in screen coordinates, x=y */
const float starty = k + 1.0f;
float ydisp = 0.0; /* vertical displacement to allow obj info text */
int bright = 25 * (float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */
@ -613,12 +638,12 @@ static void draw_view_axis(RegionView3D *rv3d)
UI_ThemeColorShadeAlpha(TH_AXIS_X, 0, bright);
glBegin(GL_LINES);
glVertex2f(start, start + ydisp);
glVertex2f(start + dx, start + dy + ydisp);
glVertex2f(startx, starty + ydisp);
glVertex2f(startx + dx, starty + dy + ydisp);
glEnd();
if (fabsf(dx) > toll || fabsf(dy) > toll) {
BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x", 1);
BLF_draw_default_ascii(startx + dx + 2, starty + dy + ydisp + 2, 0.0f, "x", 1);
}
/* BLF_draw_default disables blending */
@ -633,12 +658,12 @@ static void draw_view_axis(RegionView3D *rv3d)
UI_ThemeColorShadeAlpha(TH_AXIS_Y, 0, bright);
glBegin(GL_LINES);
glVertex2f(start, start + ydisp);
glVertex2f(start + dx, start + dy + ydisp);
glVertex2f(startx, starty + ydisp);
glVertex2f(startx + dx, starty + dy + ydisp);
glEnd();
if (fabsf(dx) > toll || fabsf(dy) > toll) {
BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y", 1);
BLF_draw_default_ascii(startx + dx + 2, starty + dy + ydisp + 2, 0.0f, "y", 1);
}
glEnable(GL_BLEND);
@ -652,12 +677,12 @@ static void draw_view_axis(RegionView3D *rv3d)
UI_ThemeColorShadeAlpha(TH_AXIS_Z, 0, bright);
glBegin(GL_LINES);
glVertex2f(start, start + ydisp);
glVertex2f(start + dx, start + dy + ydisp);
glVertex2f(startx, starty + ydisp);
glVertex2f(startx + dx, starty + dy + ydisp);
glEnd();
if (fabsf(dx) > toll || fabsf(dy) > toll) {
BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z", 1);
BLF_draw_default_ascii(startx + dx + 2, starty + dy + ydisp + 2, 0.0f, "z", 1);
}
/* restore line-width */
@ -770,7 +795,7 @@ static void draw_rotation_guide(RegionView3D *rv3d)
glDepthMask(1);
}
static void draw_view_icon(RegionView3D *rv3d)
static void draw_view_icon(ARegion *ar, RegionView3D *rv3d)
{
BIFIconID icon;
@ -785,7 +810,7 @@ static void draw_view_icon(RegionView3D *rv3d)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_icon_draw(5.0, 5.0, icon);
UI_icon_draw(5.0 + draw_name_offset(ar), 5.0, icon);
glDisable(GL_BLEND);
}
@ -853,17 +878,17 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d)
if (name) {
UI_ThemeColor(TH_TEXT_HI);
BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, name, sizeof(tmpstr));
BLF_draw_default_ascii(U.widget_unit + draw_name_offset(ar), ar->winy - U.widget_unit, 0.0f, name, sizeof(tmpstr));
}
}
/* draw info beside axes in bottom left-corner:
* framenum, object name, bone name (if available), marker name (if available)
*/
static void draw_selected_name(Scene *scene, Object *ob)
static void draw_selected_name(ARegion *ar, Scene *scene, Object *ob)
{
char info[256], *markern;
short offset = 30;
short offset = 30 + draw_name_offset(ar);
/* get name of marker on current frame (if available) */
markern = BKE_scene_find_marker_name(scene, CFRA);
@ -946,9 +971,9 @@ static void draw_selected_name(Scene *scene, Object *ob)
}
if (U.uiflag & USER_SHOW_ROTVIEWICON)
offset = 14 + (U.rvisize * 2);
offset = U.widget_unit + (U.rvisize * 2) + draw_name_offset(ar);
BLF_draw_default(offset, 10, 0.0f, info, sizeof(info));
BLF_draw_default(offset, 0.5f * U.widget_unit, 0.0f, info, sizeof(info));
}
static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@ -1289,7 +1314,6 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
RegionView3D *rv3d = ar->regiondata;
struct Base *base = scene->basact;
int multisample_enabled;
rcti winrct;
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
@ -1338,8 +1362,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
if (multisample_enabled)
glDisable(GL_MULTISAMPLE_ARB);
region_scissor_winrct(ar, &winrct);
glScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct));
glScissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
glClearColor(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
@ -2846,7 +2869,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps + 0.5f));
}
BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, printable, sizeof(printable));
BLF_draw_default_ascii(U.widget_unit, ar->winy - U.widget_unit, 0.0f, printable, sizeof(printable));
}
static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit);
@ -3181,13 +3204,13 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
drawcursor(scene, ar, v3d);
if (U.uiflag & USER_SHOW_ROTVIEWICON)
draw_view_axis(rv3d);
draw_view_axis(ar, rv3d);
else
draw_view_icon(rv3d);
draw_view_icon(ar, rv3d);
ob = OBACT;
if (U.uiflag & USER_DRAWVIEWINFO)
draw_selected_name(scene, ob);
draw_selected_name(ar, scene, ob);
}
if (rv3d->render_engine) {
@ -3211,7 +3234,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
}
BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f,
BLF_draw_default_ascii(U.widget_unit, ar->winy - (USER_SHOW_VIEWPORTNAME ? 2 * U.widget_unit : U.widget_unit), 0.0f,
numstr[0] ? numstr : grid_unit, sizeof(numstr));
}
}

@ -1911,7 +1911,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
viewzoom_exec(C, op);
}
else {
if (event->type == MOUSEZOOM) {
if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
/* Bypass Zoom invert flag for track pads (pass FALSE always) */
if (U.uiflag & USER_ZOOM_HORIZ) {

@ -39,6 +39,10 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@ -48,10 +52,75 @@
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_transform.h"
#include "view3d_intern.h"
/* ************************** copy paste ***************************** */
static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
{
char str[FILE_MAX];
BKE_copybuffer_begin();
/* context, selection, could be generalized */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
BKE_copybuffer_tag_ID(&ob->id);
}
CTX_DATA_END;
BLI_make_file_string("/", str, BLI_temporary_dir(), "copybuffer.blend");
BKE_copybuffer_save(str, op->reports);
return OPERATOR_FINISHED;
}
static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy Selection to Buffer";
ot->idname = "VIEW3D_OT_copybuffer";
ot->description = "Selected objects are saved in a temp file";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = view3d_copybuffer_exec;
ot->poll = ED_operator_view3d_active;
}
static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
{
char str[FILE_MAX];
BLI_make_file_string("/", str, BLI_temporary_dir(), "copybuffer.blend");
BKE_copybuffer_paste(C, str, op->reports);
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Paste Selection from Buffer";
ot->idname = "VIEW3D_OT_pastebuffer";
ot->description = "Contents of copybuffer gets pasted";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = view3d_pastebuffer_exec;
ot->poll = ED_operator_view3d_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************************** registration **********************************/
@ -97,6 +166,8 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_game_start);
WM_operatortype_append(VIEW3D_OT_fly);
WM_operatortype_append(VIEW3D_OT_layers);
WM_operatortype_append(VIEW3D_OT_copybuffer);
WM_operatortype_append(VIEW3D_OT_pastebuffer);
WM_operatortype_append(VIEW3D_OT_properties);
WM_operatortype_append(VIEW3D_OT_toolshelf);
@ -153,6 +224,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
/*numpad +/-*/
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
@ -359,6 +431,13 @@ void view3d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
#ifdef __APPLE__
WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_OSKEY, 0);
#endif
WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_CTRL, 0);
/* context ops */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");

@ -1530,7 +1530,7 @@ float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3])
rv3d->persmat[0][3] * co[0] +
rv3d->persmat[1][3] * co[1] +
rv3d->persmat[2][3] * co[2])
) * rv3d->pixsize;
) * rv3d->pixsize * U.pixelsize;
}
float ED_view3d_radius_to_persp_dist(const float angle, const float radius)

@ -113,6 +113,7 @@
#include "WM_types.h"
#include "UI_view2d.h"
#include "UI_interface.h"
#include "RNA_access.h"
@ -2229,7 +2230,12 @@ void flushTransNodes(TransInfo *t)
/* flush to 2d vector from internally used 3d vector */
for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
bNode *node = td->extra;
add_v2_v2v2(&node->locx, td2d->loc, td2d->ih1);
float vec[2];
/* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
add_v2_v2v2(vec, td2d->loc, td2d->ih1);
node->locx = vec[0] / UI_DPI_FAC;
node->locy = vec[1] / UI_DPI_FAC;
}
/* handle intersection with noodles */
@ -5626,7 +5632,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
/* hold original location */
float locxy[2] = {BLI_rctf_cent_x(&node->totr),
BLI_rctf_cent_y(&node->totr)};
float nodeloc[2];
copy_v2_v2(td2d->loc, locxy);
td2d->loc[2] = 0.0f;
td2d->loc2d = td2d->loc; /* current location */
@ -5651,7 +5658,10 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
unit_m3(td->mtx);
unit_m3(td->smtx);
sub_v2_v2v2(td2d->ih1, &node->locx, locxy);
/* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
nodeloc[0] = UI_DPI_FAC * node->locx;
nodeloc[1] = UI_DPI_FAC * node->locy;
sub_v2_v2v2(td2d->ih1, nodeloc, locxy);
td->extra = node;
}

@ -159,7 +159,8 @@ typedef struct ARegion {
short do_draw; /* private, cached notifier events */
short do_draw_overlay; /* private, cached notifier events */
short swap; /* private, indicator to survive swap-exchange */
short pad[3];
short overlap; /* private, set for indicate drawing overlapped */
short pad[2];
struct ARegionType *type; /* callbacks for this region type */
@ -167,6 +168,8 @@ typedef struct ARegion {
ListBase panels; /* Panel */
ListBase handlers; /* wmEventHandler */
struct wmTimer *regiontimer; /* blend in/out */
char *headerstr; /* use this string to draw info */
void *regiondata; /* XXX 2.50, need spacedata equivalent? */
} ARegion;
@ -235,10 +238,6 @@ enum {
#define RGN_ALIGN_VSPLIT 6
#define RGN_ALIGN_FLOAT 7
#define RGN_ALIGN_QSPLIT 8
#define RGN_OVERLAP_TOP 9
#define RGN_OVERLAP_BOTTOM 10
#define RGN_OVERLAP_LEFT 11
#define RGN_OVERLAP_RIGHT 12
#define RGN_SPLIT_PREV 32

@ -797,7 +797,7 @@ typedef struct SpaceText {
int top, viewlines;
short flags, menunr;
short lheight; /* user preference */
short lheight; /* user preference, is font_size! */
char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */
int left;
int showlinenrs;
@ -816,8 +816,9 @@ typedef struct SpaceText {
char findstr[256]; /* ST_MAX_FIND_STR */
char replacestr[256]; /* ST_MAX_FIND_STR */
short margin_column; /* column number to show right margin at */
char pad[6];
short margin_column; /* column number to show right margin at */
short lheight_dpi; /* actual lineheight, dpi controlled */
char pad[4];
void *drawcache; /* cache for faster drawing */
} SpaceText;
@ -886,7 +887,7 @@ typedef struct SpaceNode {
struct ID *id, *from; /* context, no need to save in file? well... pinning... */
short flag, pad1; /* menunr: browse id block in header */
float aspect, aspect_sqrt;
float aspect, pad2; /* internal state variables */
float xof, yof; /* offset for drawing the backdrop */
float zoom; /* zoom for backdrop */

@ -359,9 +359,10 @@ typedef struct UserDef {
short versions;
short dbl_click_time;
int gameflags;
int wheellinescroll;
int uiflag, language;
short gameflags;
short wheellinescroll;
int uiflag, uiflag2;
int language;
short userpref, viewzoom;
int mixbufsize;
@ -412,7 +413,7 @@ typedef struct UserDef {
short scrcastfps; /* frame rate for screencast to be played back */
short scrcastwait; /* milliseconds between screencast snapshots */
short widget_unit; /* defaults to 20 for 72 DPI setting */
short widget_unit; /* private, defaults to 20 for 72 DPI setting */
short anisotropic_filter;
short use_16bit_textures, use_gpu_mipmap;
@ -443,7 +444,7 @@ typedef struct UserDef {
int compute_device_id;
float fcu_inactive_alpha; /* opacity of inactive F-Curves in F-Curve Editor */
float pad;
float pixelsize; /* private, set by GHOST, to multiply DPI with */
} UserDef;
extern UserDef U; /* from blenkernel blender.c */
@ -539,6 +540,12 @@ typedef enum eUserpref_UI_Flag {
USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31)
} eUserpref_UI_Flag;
/* uiflag2 */
typedef enum eUserpref_UI_Flag2 {
USER_KEEP_SESSION = (1 << 0),
USER_REGION_OVERLAP = (1 << 1)
} eUserpref_UI_Flag2;
/* Auto-Keying mode */
typedef enum eAutokey_Mode {
/* AUTOKEY_ON is a bitflag */

@ -62,6 +62,7 @@ static EnumPropertyItem compute_device_type_items[] = {
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "BKE_blender.h"
#include "BKE_DerivedMesh.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
@ -83,9 +84,10 @@ static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
WM_main_add_notifier(NC_WINDOW, NULL);
}
/* also used by buffer swap switching */
static void rna_userdef_dpi_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
U.widget_unit = (U.dpi * 20 + 36) / 72;
BKE_userdef_state();
WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */
}
@ -840,7 +842,7 @@ static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
/* buttons */
/* if (! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) { */
prop = RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Region Background", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@ -3275,7 +3277,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "wmdrawmethod");
RNA_def_property_enum_items(prop, draw_method_items);
RNA_def_property_ui_text(prop, "Window Draw Method", "Drawing method used by the window manager");
RNA_def_property_update(prop, 0, "rna_userdef_update");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "audio_mixing_buffer", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mixbufsize");
@ -3329,6 +3331,13 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_enum_items(prop, multi_sample_levels);
RNA_def_property_ui_text(prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it, requires restart");
prop = RNA_def_property(srna, "use_region_overlap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_REGION_OVERLAP);
RNA_def_property_ui_text(prop, "Region Overlap",
"Draw tool/property regions over the main region, when using Triple Buffer");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
#ifdef WITH_CYCLES
prop = RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT);
@ -3664,6 +3673,11 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
"The time (in minutes) to wait between automatic temporary saves");
RNA_def_property_update(prop, 0, "rna_userdef_autosave_update");
prop = RNA_def_property(srna, "use_keep_session", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_KEEP_SESSION);
RNA_def_property_ui_text(prop, "Keep Session",
"Always load session recovery and save it after quitting Blender");
prop = RNA_def_property(srna, "recent_files", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 0, 30);
RNA_def_property_ui_text(prop, "Recent Files", "Maximum number of recently opened files to remember");

@ -68,6 +68,7 @@ typedef struct wmJob wmJob;
void WM_init_state_size_set (int stax, int stay, int sizx, int sizy);
void WM_init_state_fullscreen_set(void);
void WM_init_state_normal_set(void);
void WM_init_native_pixels(int do_it);
void WM_init (struct bContext *C, int argc, const char **argv);
void WM_exit_ext (struct bContext *C, const short do_python);
@ -92,21 +93,23 @@ void WM_check (struct bContext *C);
struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
int WM_window_pixels_x (struct wmWindow *win);
int WM_window_pixels_y (struct wmWindow *win);
/* defines for 'type' WM_window_open_temp */
#define WM_WINDOW_RENDER 0
#define WM_WINDOW_USERPREFS 1
#define WM_WINDOW_FILESEL 2
void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
/* returns true if draw method is triple buffer */
int WM_is_draw_triple(struct wmWindow *win);
/* files */
int WM_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int WM_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory);
int WM_homefile_write_exec(struct bContext *C, struct wmOperator *op);
void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);
int WM_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
void WM_autosave_init(struct wmWindowManager *wm);
/* mouse cursors */

@ -49,6 +49,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "GHOST_C-api.h"
@ -431,22 +432,22 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
triple->target = GL_TEXTURE_RECTANGLE_ARB;
triple->nx = 1;
triple->ny = 1;
triple->x[0] = win->sizex;
triple->y[0] = win->sizey;
triple->x[0] = WM_window_pixels_x(win);
triple->y[0] = WM_window_pixels_y(win);
}
else if (GPU_non_power_of_two_support()) {
triple->target = GL_TEXTURE_2D;
triple->nx = 1;
triple->ny = 1;
triple->x[0] = win->sizex;
triple->y[0] = win->sizey;
triple->x[0] = WM_window_pixels_x(win);
triple->y[0] = WM_window_pixels_y(win);
}
else {
triple->target = GL_TEXTURE_2D;
triple->nx = 0;
triple->ny = 0;
split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx);
split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny);
split_width(WM_window_pixels_x(win), MAX_N_TEX, triple->x, &triple->nx);
split_width(WM_window_pixels_y(win), MAX_N_TEX, triple->y, &triple->ny);
}
/* generate texture names */
@ -491,7 +492,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
return 1;
}
static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha)
{
float halfx, halfy, ratiox, ratioy;
int x, y, sizex, sizey, offx, offy;
@ -500,8 +501,8 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
sizex = (x == triple->nx - 1) ? WM_window_pixels_x(win) - offx : triple->x[x];
sizey = (y == triple->ny - 1) ? WM_window_pixels_y(win) - offy : triple->y[y];
/* wmOrtho for the screen has this same offset */
ratiox = sizex;
@ -519,7 +520,7 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glColor3f(1.0f, 1.0f, 1.0f);
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glBegin(GL_QUADS);
glTexCoord2f(halfx, halfy);
glVertex2f(offx, offy);
@ -546,8 +547,8 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
sizex = (x == triple->nx - 1) ? WM_window_pixels_x(win) - offx : triple->x[x];
sizey = (y == triple->ny - 1) ? WM_window_pixels_y(win) - offy : triple->y[y];
glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey);
@ -557,6 +558,20 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
glBindTexture(triple->target, 0);
}
static void wm_draw_region_blend(wmWindow *win, ARegion *ar)
{
float fac = ED_region_blend_factor(ar);
/* region blend always is 1, except when blend timer is running */
if (fac < 1.0f) {
wmSubWindowScissorSet(win, win->screen->mainwin, &ar->winrct);
glEnable(GL_BLEND);
wm_triple_draw_textures(win, win->drawdata, 1.0f - fac);
glDisable(GL_BLEND);
}
}
static void wm_method_draw_triple(bContext *C, wmWindow *win)
{
wmWindowManager *wm = CTX_wm_manager(C);
@ -572,7 +587,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
wmSubWindowSet(win, screen->mainwin);
wm_triple_draw_textures(win, win->drawdata);
wm_triple_draw_textures(win, win->drawdata, 1.0f);
}
else {
win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
@ -591,11 +606,13 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid && ar->do_draw) {
CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar);
ED_area_overdraw_flush(sa, ar);
CTX_wm_region_set(C, NULL);
copytex = 1;
if (ar->overlap == 0) {
CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar);
ED_area_overdraw_flush(sa, ar);
CTX_wm_region_set(C, NULL);
copytex = 1;
}
}
}
@ -610,10 +627,28 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
wm_triple_copy_textures(win, triple);
}
/* draw overlapping area regions (always like popups) */
for (sa = screen->areabase.first; sa; sa = sa->next) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid && ar->overlap) {
CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar);
ED_area_overdraw_flush(sa, ar);
CTX_wm_region_set(C, NULL);
wm_draw_region_blend(win, ar);
}
}
CTX_wm_area_set(C, NULL);
}
/* after area regions so we can do area 'overlay' drawing */
ED_screen_draw(win);
/* draw overlapping regions */
/* draw floating regions (menus) */
for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) {
CTX_wm_menu_set(C, ar);
@ -652,9 +687,9 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
if (wm->drags.first) {
wm_drags_draw(C, win, NULL);
}
}
/****************** main update call **********************/
/* quick test to prevent changing window drawable */
@ -734,6 +769,14 @@ static int wm_automatic_draw_method(wmWindow *win)
return win->drawmethod;
}
int WM_is_draw_triple(wmWindow *win)
{
/* function can get called before this variable is set in drawing code below */
if (win->drawmethod != U.wmdrawmethod)
win->drawmethod = U.wmdrawmethod;
return USER_DRAW_TRIPLE == wm_automatic_draw_method(win);
}
void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
{
/* for draw triple gestures, paint cursors don't need region redraw */

@ -2738,11 +2738,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
{
GHOST_TEventCursorData *cd = customdata;
wmEvent *lastevent = win->queue.last;
int cx, cy;
GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
evt->x = cx;
evt->y = (win->sizey - 1) - cy;
evt->x = cd->x;
evt->y = cd->y;
event.x = evt->x;
event.y = evt->y;
@ -2790,13 +2788,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
break;
}
{
int cx, cy;
GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy);
event.x = evt->x = cx;
event.y = evt->y = (win->sizey - 1) - cy;
}
event.x = evt->x = pd->x;
event.y = evt->y = pd->y;
event.val = 0;
/* Use prevx/prevy so we can calculate the delta later */

@ -283,7 +283,9 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* in case UserDef was read, we re-initialize all, and do versioning */
static void wm_init_userdef(bContext *C)
{
/* versioning is here */
UI_init_userdef();
MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
sound_init(CTX_data_main(C));
@ -300,6 +302,10 @@ static void wm_init_userdef(bContext *C)
/* update tempdir from user preferences */
BLI_init_temporary_dir(U.tempdir);
/* displays with larger native pixels, like Macbook. Used to scale dpi with */
U.pixelsize = GHOST_GetNativePixelSize();
BKE_userdef_state();
}
@ -388,6 +394,8 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* also exit screens and editors */
wm_window_match_init(C, &wmbase);
/* confusing this global... */
G.relbase_valid = 1;
retval = BKE_read_file(C, filepath, reports);
G.save_over = 1;
@ -408,7 +416,6 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
if (retval != BKE_READ_FILE_FAIL) {
G.relbase_valid = 1;
if (do_history) {
write_history();
}
@ -485,11 +492,12 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* called on startup, (context entirely filled with NULLs) */
/* or called for 'New File' */
/* op can be NULL */
int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory)
/* both startup.blend and userpref.blend are checked */
int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory)
{
ListBase wmbase;
char tstr[FILE_MAX];
char startstr[FILE_MAX];
char prefstr[FILE_MAX];
int success = 0;
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE);
@ -498,10 +506,12 @@ int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
if (!from_memory) {
char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
if (cfgdir) {
BLI_make_file_string(G.main->name, tstr, cfgdir, BLENDER_STARTUP_FILE);
BLI_make_file_string(G.main->name, startstr, cfgdir, BLENDER_STARTUP_FILE);
BLI_make_file_string(G.main->name, prefstr, cfgdir, BLENDER_USERPREF_FILE);
}
else {
tstr[0] = '\0';
startstr[0] = '\0';
prefstr[0] = '\0';
from_memory = 1;
}
}
@ -512,14 +522,20 @@ int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
/* put aside screens to match with persistent windows later */
wm_window_match_init(C, &wmbase);
if (!from_memory && BLI_exists(tstr)) {
success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
if (!from_memory && BLI_exists(startstr)) {
success = (BKE_read_file(C, startstr, NULL) != BKE_READ_FILE_FAIL);
if (U.themes.first == NULL) {
printf("\nError: No valid "STRINGIFY (BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
success = 0;
}
}
if (!from_memory && BLI_exists(prefstr)) {
success = BKE_read_file_userdef(prefstr, NULL);
if (success) printf("read new prefs: %s\n", prefstr);
}
if (U.themes.first == NULL) {
printf("\nError: No valid "STRINGIFY (BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
success = 0;
}
if (success == 0) {
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
if (wmbase.first == NULL) wm_clear_default_size(C);
@ -584,13 +600,13 @@ int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
return TRUE;
}
int WM_homefile_read_exec(bContext *C, wmOperator *op)
int wm_homefile_read_exec(bContext *C, wmOperator *op)
{
int from_memory = strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0;
return WM_homefile_read(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
return wm_homefile_read(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void WM_read_history(void)
void wm_read_history(void)
{
char name[FILE_MAX];
LinkNode *l, *lines;
@ -630,6 +646,10 @@ static void write_history(void)
FILE *fp;
int i;
/* no write history for recovered startup files */
if (G.main->name[0] == 0)
return;
/* will be NULL in background mode */
user_config_dir = BLI_get_folder_create(BLENDER_USER_CONFIG, NULL);
if (!user_config_dir)
@ -762,12 +782,11 @@ int write_crash_blend(void)
}
}
int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *reports)
int wm_file_write(bContext *C, const char *target, int fileflags, ReportList *reports)
{
Library *li;
int len;
char filepath[FILE_MAX];
int *thumb = NULL;
ImBuf *ibuf_thumb = NULL;
@ -861,7 +880,7 @@ int WM_file_write(bContext *C, const char *target, int fileflags, ReportList *re
}
/* operator entry */
int WM_homefile_write_exec(bContext *C, wmOperator *op)
int wm_homefile_write_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@ -881,7 +900,7 @@ int WM_homefile_write_exec(bContext *C, wmOperator *op)
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) {
if (BLO_write_file(CTX_data_main(C), filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
@ -893,6 +912,28 @@ int WM_homefile_write_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
/* Only save the prefs block. operator entry */
int wm_userpref_write_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
char filepath[FILE_MAX];
/* update keymaps in user preferences */
WM_keyconfig_update(wm);
BLI_make_file_string("/", filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_USERPREF_FILE);
printf("trying to save userpref at %s ", filepath);
if (BKE_write_file_userdef(filepath, op->reports) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
printf("ok\n");
return OPERATOR_FINISHED;
}
/************************ autosave ****************************/
void wm_autosave_location(char *filepath)
@ -936,7 +977,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
wmWindow *win;
wmEventHandler *handler;
char filepath[FILE_MAX];
int fileflags;
Scene *scene = CTX_data_scene(C);
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
@ -960,12 +1001,17 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
wm_autosave_location(filepath);
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
/* no error reporting to console */
BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
if (U.uiflag & USER_GLOBALUNDO) {
/* fast save of last undobuffer, now with UI */
BKE_undo_save_file(C, filepath);
}
else {
/* save as regular blend file */
int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
/* no error reporting to console */
BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
}
/* do timer after file write, just in case file write takes a long time */
wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0);
}
@ -1002,3 +1048,6 @@ void wm_autosave_read(bContext *C, ReportList *reports)
WM_file_read(C, filename, reports);
}

@ -48,6 +48,7 @@
#include "DNA_windowmanager_types.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@ -128,6 +129,7 @@ int wm_start_with_console = 0; /* used in creator.c */
/* only called once, for startup */
void WM_init(bContext *C, int argc, const char **argv)
{
if (!G.background) {
wm_ghost_init(C); /* note: it assigns C to ghost! */
wm_init_cursor_data();
@ -149,8 +151,8 @@ void WM_init(bContext *C, int argc, const char **argv)
BLF_lang_init();
/* get the default database, plus a wm */
WM_homefile_read(C, NULL, G.factory_startup);
wm_homefile_read(C, NULL, G.factory_startup);
BLF_lang_set(NULL);
/* note: there is a bug where python needs initializing before loading the
@ -158,7 +160,7 @@ void WM_init(bContext *C, int argc, const char **argv)
* initializing space types and other internal data.
*
* However cant redo this at the moment. Solution is to load python
* before WM_homefile_read() or make py-drivers check if python is running.
* before wm_homefile_read() or make py-drivers check if python is running.
* Will try fix when the crash can be repeated. - campbell. */
#ifdef WITH_PYTHON
@ -195,7 +197,7 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_preview_init_dbase();
WM_read_history();
wm_read_history();
/* allow a path of "", this is what happens when making a new file */
#if 0
@ -211,6 +213,10 @@ void WM_init(bContext *C, int argc, const char **argv)
COM_linker_hack = COM_execute;
}
#endif
/* load last session, uses regular file reading so it has to be in end (after init py etc) */
if (U.uiflag2 & USER_KEEP_SESSION)
wm_recover_last_session(C, NULL);
}
void WM_init_splash(bContext *C)
@ -372,6 +378,18 @@ void WM_exit_ext(bContext *C, const short do_python)
if (C && wm) {
wmWindow *win;
if (!G.background) {
if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_valid(NULL)) {
/* save the undo state as quit.blend */
char filename[FILE_MAX];
BLI_make_file_string("/", filename, BLI_temporary_dir(), "quit.blend");
if (BKE_undo_save_file(C, filename))
printf("Saved session recovery to '%s'\n", filename);
}
}
WM_jobs_kill_all(wm);
for (win = wm->windows.first; win; win = win->next) {
@ -454,9 +472,6 @@ void WM_exit_ext(bContext *C, const short do_python)
GPU_free_unused_buffers();
GPU_extensions_exit();
if (!G.background) {
BKE_undo_save_quit(); /* saves quit.blend if global undo is on */
}
BKE_reset_undo();
ED_file_exit(); /* for fsmenu */

@ -103,6 +103,7 @@
#include "wm_draw.h"
#include "wm_event_system.h"
#include "wm_event_types.h"
#include "wm_files.h"
#include "wm_subwindow.h"
#include "wm_window.h"
@ -1452,9 +1453,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
"%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev);
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 5;
rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5;
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 0.5f * U.widget_unit;
rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 0.5f * U.widget_unit;
#endif /* WITH_BUILDINFO */
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
@ -1464,16 +1465,17 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
* ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
/* XXX splash scales with pixelsize, should become widget-units */
but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.pixelsize * 501, U.pixelsize *282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
uiButSetFunc(but, wm_block_splash_close, block, NULL);
uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL);
#ifdef WITH_BUILDINFO
uiDefBut(block, LABEL, 0, version_buf, 494 - ver_width, 282 - 24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, LABEL, 0, revision_buf, 494 - rev_width, 282 - 36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, LABEL, 0, version_buf, U.pixelsize * 494 - ver_width, U.pixelsize * 258, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, LABEL, 0, revision_buf, U.pixelsize * 494 - rev_width, U.pixelsize * 246, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
#endif /* WITH_BUILDINFO */
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, style);
uiBlockSetEmboss(block, UI_EMBOSS);
/* show the splash menu (containing interaction presets), using python */
@ -1675,12 +1677,23 @@ static void WM_OT_window_duplicate(wmOperatorType *ot)
static void WM_OT_save_homefile(wmOperatorType *ot)
{
ot->name = "Save User Settings";
ot->name = "Save Startup File";
ot->idname = "WM_OT_save_homefile";
ot->description = "Make the current file the default .blend file";
ot->description = "Make the current file the default .blend file, includes preferences";
ot->invoke = WM_operator_confirm;
ot->exec = WM_homefile_write_exec;
ot->exec = wm_homefile_write_exec;
ot->poll = WM_operator_winactive;
}
static void WM_OT_save_userpref(wmOperatorType *ot)
{
ot->name = "Save User Settings";
ot->idname = "WM_OT_save_userpref";
ot->description = "Save user preferences separately, overrides startup file preferences";
ot->invoke = WM_operator_confirm;
ot->exec = wm_userpref_write_exec;
ot->poll = WM_operator_winactive;
}
@ -1691,7 +1704,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
ot->description = "Open the default file (doesn't save the current file)";
ot->invoke = WM_operator_confirm;
ot->exec = WM_homefile_read_exec;
ot->exec = wm_homefile_read_exec;
/* ommit poll to run in background mode */
}
@ -1702,7 +1715,7 @@ static void WM_OT_read_factory_settings(wmOperatorType *ot)
ot->description = "Load default file and user preferences";
ot->invoke = WM_operator_confirm;
ot->exec = WM_homefile_read_exec;
ot->exec = wm_homefile_read_exec;
/* ommit poll to run in background mode */
}
@ -2003,21 +2016,33 @@ static void WM_OT_link_append(wmOperatorType *ot)
/* *************** recover last session **************** */
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
void wm_recover_last_session(bContext *C, ReportList *reports)
{
char filename[FILE_MAX];
G.fileflags |= G_FILE_RECOVER;
/* XXX wm in context is not set correctly after WM_file_read -> crash */
/* do it before for now, but is this correct with multiple windows? */
WM_event_add_notifier(C, NC_WINDOW, NULL);
/* load file */
BLI_make_file_string("/", filename, BLI_temporary_dir(), "quit.blend");
WM_file_read(C, filename, op->reports);
/* if reports==NULL, it's called directly without operator, we add a quick check here */
if (reports || BLI_exists(filename)) {
G.fileflags |= G_FILE_RECOVER;
/* XXX wm in context is not set correctly after WM_file_read -> crash */
/* do it before for now, but is this correct with multiple windows? */
WM_event_add_notifier(C, NC_WINDOW, NULL);
/* load file */
WM_file_read(C, filename, reports);
G.fileflags &= ~G_FILE_RECOVER;
/* XXX bad global... fixme */
if (G.main->name[0])
G.file_loaded = 1; /* prevents splash to show */
}
}
G.fileflags &= ~G_FILE_RECOVER;
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
{
wm_recover_last_session(C, op->reports);
return OPERATOR_FINISHED;
}
@ -2158,7 +2183,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
G_FILE_MESH_COMPAT);
#endif
if (WM_file_write(C, path, fileflags, op->reports) != 0)
if (wm_file_write(C, path, fileflags, op->reports) != 0)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL);
@ -3787,6 +3812,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_read_homefile);
WM_operatortype_append(WM_OT_read_factory_settings);
WM_operatortype_append(WM_OT_save_homefile);
WM_operatortype_append(WM_OT_save_userpref);
WM_operatortype_append(WM_OT_window_fullscreen_toggle);
WM_operatortype_append(WM_OT_quit_blender);
WM_operatortype_append(WM_OT_open_mainfile);

@ -217,10 +217,10 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
* fixed it). - zr (2001!)
*/
if (swin->winrct.xmax > win->sizex)
swin->winrct.xmax = win->sizex;
if (swin->winrct.ymax > win->sizey)
swin->winrct.ymax = win->sizey;
if (swin->winrct.xmax > WM_window_pixels_x(win))
swin->winrct.xmax = WM_window_pixels_x(win);
if (swin->winrct.ymax > WM_window_pixels_y(win))
swin->winrct.ymax = WM_window_pixels_y(win);
/* extra service */
wmSubWindowSet(win, swinid);
@ -257,8 +257,8 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) {
width = BLI_rcti_size_x(srct) + 1;
height = BLI_rcti_size_y(srct) + 1;
int width = BLI_rcti_size_x(srct) + 1; /* only here */
int height = BLI_rcti_size_y(srct) + 1;
glScissor(srct->xmin, srct->ymin, width, height);
}
else

@ -91,7 +91,9 @@ static struct WMInitStruct {
int windowstate;
WinOverrideFlag override_flag;
} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0};
int native_pixels;
} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, 1};
/* ******** win open & close ************ */
@ -241,7 +243,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
win->screen->do_refresh = TRUE;
win->screen->do_draw = TRUE;
win->drawmethod = -1;
win->drawmethod = U.wmdrawmethod;
win->drawdata = NULL;
return win;
@ -251,51 +253,50 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{
wmWindow *tmpwin;
bScreen *screen = win->screen;
int do_exit = 0;
/* first check if we have to quit (there are non-temp remaining windows) */
for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
if (tmpwin == win)
continue;
if (tmpwin->screen->temp == 0)
break;
}
if (tmpwin == NULL)
do_exit = 1;
/* first check if we have any non-temp remaining windows */
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) {
if (wm->windows.first) {
for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
if (tmpwin == win)
continue;
if (tmpwin->screen->temp == 0)
break;
}
if (tmpwin == NULL) {
if (!GHOST_confirmQuit(win->ghostwin))
return;
}
if (do_exit) {
if (!GHOST_confirmQuit(win->ghostwin))
return;
}
}
BLI_remlink(&wm->windows, win);
wm_draw_window_clear(win);
CTX_wm_window_set(C, win); /* needed by handlers */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, win->screen);
wm_window_free(C, wm, win);
/* if temp screen, delete it after window free (it stops jobs that can access it) */
if (screen->temp) {
Main *bmain = CTX_data_main(C);
BKE_libblock_free(&bmain->screen, screen);
}
/* check remaining windows */
if (wm->windows.first) {
for (win = wm->windows.first; win; win = win->next)
if (win->screen->temp == 0)
break;
/* in this case we close all */
if (win == NULL)
WM_exit(C);
}
else
/* let WM_exit do all freeing, for correct quit.blend save */
if (do_exit) {
WM_exit(C);
}
else {
bScreen *screen = win->screen;
BLI_remlink(&wm->windows, win);
wm_draw_window_clear(win);
CTX_wm_window_set(C, win); /* needed by handlers */
WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, win->screen);
wm_window_free(C, wm, win);
/* if temp screen, delete it after window free (it stops jobs that can access it) */
if (screen->temp) {
Main *bmain = CTX_data_main(C);
BKE_libblock_free(&bmain->screen, screen);
}
}
}
void wm_window_title(wmWindowManager *wm, wmWindow *win)
@ -309,7 +310,8 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
/* this is set to 1 if you don't have startup.blend open */
if (G.save_over && G.main->name[0]) {
char str[sizeof(G.main->name) + 12];
BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "" : "*", G.main->name);
BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", G.main->name,
G.main->recovered ? " (Recovered)" : "");
GHOST_SetTitle(win->ghostwin, str);
}
else
@ -344,8 +346,6 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
wm_get_screensize(&scr_w, &scr_h);
posy = (scr_h - win->posy - win->sizey);
/* Disable AA for now, as GL_SELECT (used for border, lasso, ... select)
* doesn't work well when AA is initialized, even if not used. */
ghostwin = GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey,
(GHOST_TWindowState)win->windowstate,
@ -354,6 +354,8 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
multisamples /* AA */);
if (ghostwin) {
GHOST_RectangleHandle bounds;
/* needed so we can detect the graphics card below */
GPU_extensions_init();
@ -372,7 +374,19 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
glClear(GL_COLOR_BUFFER_BIT);
}
/* displays with larger native pixels, like Macbook. Used to scale dpi with */
/* needed here, because it's used before it reads userdef */
U.pixelsize = GHOST_GetNativePixelSize();
BKE_userdef_state();
/* store actual window size in blender window */
bounds = GHOST_GetClientBounds(win->ghostwin);
win->sizex = GHOST_GetWidthRectangle(bounds);
win->sizey = GHOST_GetHeightRectangle(bounds);
GHOST_DisposeRectangle(bounds);
wm_window_swap_buffers(win);
//GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
@ -468,7 +482,7 @@ wmWindow *WM_window_open(bContext *C, rcti *rect)
win->sizex = BLI_rcti_size_x(rect);
win->sizey = BLI_rcti_size_y(rect);
win->drawmethod = -1;
win->drawmethod = U.wmdrawmethod;
win->drawdata = NULL;
WM_check(C);
@ -578,6 +592,23 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
/* ************ events *************** */
static void wm_convert_cursor_position(wmWindow *win, int *x, int *y)
{
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
*x *= GHOST_GetNativePixelSize();
*y = (win->sizey - 1) - *y;
*y *= GHOST_GetNativePixelSize();
}
void wm_get_cursor_position(wmWindow *win, int *x, int *y)
{
GHOST_GetCursorPosition(g_system, x, y);
wm_convert_cursor_position(win, x, y);
}
typedef enum {
SHIFT = 's',
CONTROL = 'c',
@ -633,6 +664,7 @@ void wm_window_make_drawable(bContext *C, wmWindow *win)
}
/* called by ghost, here we handle events for windows themselves or send to event system */
/* mouse coordinate converversion happens here */
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr)
{
bContext *C = C_void_ptr;
@ -673,7 +705,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
GHOST_TEventKeyData kdata;
wmEvent event;
int cx, cy, wx, wy;
int wx, wy;
wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
@ -703,11 +735,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
win->eventstate->keymodifier = 0;
/* entering window, update mouse pos. but no event */
GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x = cx;
win->eventstate->y = (win->sizey - 1) - cy;
wm_get_cursor_position(win, &wx, &wy);
win->eventstate->x = wx;
win->eventstate->y = wy;
win->addmousemove = 1; /* enables highlighted buttons */
@ -857,14 +888,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
{
wmEvent event;
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
int cx, cy, wx, wy;
int wx, wy;
/* entering window, update mouse pos */
GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x = cx;
win->eventstate->y = (win->sizey - 1) - cy;
wm_get_cursor_position(win, &wx, &wy);
win->eventstate->x = wx;
win->eventstate->y = wy;
event = *(win->eventstate); /* copy last state, like mouse coords */
@ -907,11 +936,24 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
}
break;
}
case GHOST_kEventTrackpad:
{
GHOST_TEventTrackpadData *pd = data;
wm_convert_cursor_position(win, &pd->x, &pd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
}
case GHOST_kEventCursorMove:
{
GHOST_TEventCursorData *cd = data;
wm_convert_cursor_position(win, &cd->x, &cd->y);
wm_event_add_ghostevent(wm, win, type, time, data);
break;
}
default:
wm_event_add_ghostevent(wm, win, type, time, data);
break;
@ -1017,6 +1059,10 @@ void wm_ghost_init(bContext *C)
g_system = GHOST_CreateSystem();
GHOST_AddEventConsumer(g_system, consumer);
if (wm_init_state.native_pixels) {
GHOST_UseNativePixels();
}
}
}
@ -1068,6 +1114,8 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
if (wt == timer)
break;
if (wt) {
wmWindow *win;
if (wm->reports.reporttimer == wt)
wm->reports.reporttimer = NULL;
@ -1075,6 +1123,16 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
if (wt->customdata)
MEM_freeN(wt->customdata);
MEM_freeN(wt);
/* there might be events in queue with this timer as customdata */
for (win = wm->windows.first; win; win = win->next) {
wmEvent *event;
for (event = win->queue.first; event; event = event->next) {
if (event->customdata == wt) {
event->customdata = NULL;
}
}
}
}
}
@ -1158,23 +1216,6 @@ void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r)
*posy_r = win->posy;
}
void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
{
*width_r = win->sizex;
*height_r = win->sizey;
}
/* exceptional case: - splash is called before events are processed
* this means we don't actually know the window size so get this from GHOST */
void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r)
{
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
*width_r = GHOST_GetWidthRectangle(bounds);
*height_r = GHOST_GetHeightRectangle(bounds);
GHOST_DisposeRectangle(bounds);
}
void wm_window_set_size(wmWindow *win, int width, int height)
{
GHOST_SetClientSize(win->ghostwin, width, height);
@ -1202,12 +1243,6 @@ void wm_window_swap_buffers(wmWindow *win)
#endif
}
void wm_get_cursor_position(wmWindow *win, int *x, int *y)
{
GHOST_GetCursorPosition(g_system, x, y);
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
*y = (win->sizey - 1) - *y;
}
/* ******************* exported api ***************** */
@ -1217,8 +1252,8 @@ void WM_init_state_size_set(int stax, int stay, int sizx, int sizy)
{
wm_init_state.start_x = stax; /* left hand pos */
wm_init_state.start_y = stay; /* bottom pos */
wm_init_state.size_x = sizx;
wm_init_state.size_y = sizy;
wm_init_state.size_x = sizx < 640 ? 640 : sizx;
wm_init_state.size_y = sizy < 480 ? 480 : sizy;
wm_init_state.override_flag |= WIN_OVERRIDE_GEOM;
}
@ -1235,12 +1270,20 @@ void WM_init_state_normal_set(void)
wm_init_state.override_flag |= WIN_OVERRIDE_WINSTATE;
}
void WM_init_native_pixels(int do_it)
{
wm_init_state.native_pixels = do_it;
}
/* This function requires access to the GHOST_SystemHandle (g_system) */
void WM_cursor_warp(wmWindow *win, int x, int y)
{
if (win && win->ghostwin) {
float f = GHOST_GetNativePixelSize();
int oldx = x, oldy = y;
x = x / f;
y = y / f;
y = win->sizey - y - 1;
GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y);
@ -1251,3 +1294,19 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
}
}
/* support for native pixel size */
/* mac retina opens window in size X, but it has up to 2 x more pixels */
int WM_window_pixels_x(wmWindow *win)
{
float f = GHOST_GetNativePixelSize();
return (int)(f * (float)win->sizex);
}
int WM_window_pixels_y(wmWindow *win)
{
float f = GHOST_GetNativePixelSize();
return (int)(f * (float)win->sizey);
}

@ -107,5 +107,8 @@ void wm_dropbox_free(void);
void wm_drags_check_ops(bContext *C, wmEvent *event);
void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
/* wm_operators.c */
void wm_recover_last_session(bContext *C, ReportList *reports);
#endif /* __WM_EVENT_SYSTEM_H__ */

@ -148,6 +148,7 @@ enum {
#define TIMERJOBS 0x0114 /* timer event, jobs system */
#define TIMERAUTOSAVE 0x0115 /* timer event, autosave */
#define TIMERREPORT 0x0116 /* timer event, reports */
#define TIMERREGION 0x0117 /* timer event, region slide in/out */
#define TIMERF 0x011F /* last timer */
/* test whether the event is timer event */

@ -31,7 +31,13 @@
#ifndef __WM_FILES_H__
#define __WM_FILES_H__
void WM_read_history(void);
void wm_read_history(void);
int wm_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
int wm_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int wm_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory);
int wm_homefile_write_exec(struct bContext *C, struct wmOperator *op);
int wm_userpref_write_exec(struct bContext *C, struct wmOperator *op);
#endif /* __WM_FILES_H__ */

@ -55,8 +55,6 @@ void wm_window_make_drawable(bContext *C, wmWindow *win);
void wm_window_raise (wmWindow *win);
void wm_window_lower (wmWindow *win);
void wm_window_set_size (wmWindow *win, int width, int height);
void wm_window_get_size (wmWindow *win, int *width_r, int *height_r);
void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r);
void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r);
void wm_window_swap_buffers (wmWindow *win);

@ -481,6 +481,12 @@ static int prefsize(int argc, const char **argv, void *UNUSED(data))
return 4;
}
static int native_pixels(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
{
WM_init_native_pixels(0);
return 0;
}
static int with_borders(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
{
WM_init_state_normal_set();
@ -1159,6 +1165,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set)", start_with_console, NULL);
BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL);
BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba);
BLI_argsAdd(ba, 2, NULL, "--no-native-pixels", "\n\tDo not use native pixel size, for high resolution displays (MacBook 'Retina')", native_pixels, ba);
/* third pass: disabling things and forcing settings */
BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle);