Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Automatic OS detection and screen scale factors. #101

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

Automatic OS detection and screen scale factors. #101

avaidyam opened this issue Mar 3, 2012 · 2 comments

Comments

@avaidyam
Copy link

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.

@joshaber
Copy link
Contributor

This is greatly improved after merging #107.

@avaidyam
Copy link
Author

Wow, #107 is a beast of an update.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants