Automatic OS detection and screen scale factors. #101

Closed
avaidyam opened this Issue Mar 3, 2012 · 2 comments

Projects

None yet

2 participants

avaidyam commented Mar 3, 2012

Wouldn't it be far better to do something like:

TUIKit.h:

// Test for Lion support.
extern BOOL isAtleastLion(void);

// Set and get global screen scale factor.
extern float screenScale(void);
extern void setScreenScale(float);

TUIKit.m:

static BOOL initialized = NO;
static float screen_scale = 0.0;
static BOOL is_lion = NO;

BOOL isAtleastLion() {
if(!initialized) {
SInt32 major = 0;
SInt32 minor = 0;
Gestalt(gestaltSystemVersionMajor, &major);
Gestalt(gestaltSystemVersionMinor, &minor);
if((major == 10 && minor >= 7) || major >= 11) {
is_lion = YES;
} else is_lion = NO;

    initialized = YES;
} return is_lion;

}

float screenScale() {
if(screen_scale <= CGFLOAT_MIN)
screen_scale = [[NSScreen mainScreen] userSpaceScaleFactor];

return screen_scale;

}

void setScreenScale(float scale) {
if((scale > CGFLOAT_MIN)) {
screen_scale = scale;
}
}

To abstract the screen scaling and OS detection away from the end developer?
What I did was move all TUIGraphics* functions into a new .h/.m TUIGraphics.m, and add those functions into TUIKit.h/.m. Then I proceeded to remove #import "TUIKit.h"'s and replaced them with #import "TUIGraphics.h" to make more sense.

Contributor

This is greatly improved after merging #107.

@joshaber joshaber closed this May 11, 2012

Wow, #107 is a beast of an update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment