Application.Current.Host.Content.ActualHeight
contains 800, the actual screen height in pixels. I'd like to know how many of these pixels are used by the status bar for whatever device is running our app. Anybody know how to get that value?
Update-
Added these to my PhoneApplicationPage
int _statusBarThicknessPortrait = 32;
int _statusBarThicknessLandscape = 72;
PageOrientation[] portraitOrientations = { PageOrientation.Portrait, PageOrientation.PortraitDown, PageOrientation.PortraitUp };
bool PortraitOrientation {
get { return portraitOrientations.FirstOrDefault(x => x == Orientation) != PageOrientation.None; }
}
double AppWidth {
get { return Application.Current.Host.Content.ActualWidth - (PortraitOrientation ? 0 : _statusBarThicknessLandscape); }
}
double AppHeight {
get { return Application.Current.Host.Content.ActualHeight - (PortraitOrientation ? _statusBarThicknessPortrait : 0); }
}
It's a fixed value. From http://msdn.microsoft.com/en-us/library/windowsphone/design/hh202905(v=vs.105).aspx#BKMK_Statusbar
The Status Bar grows from 32 pixels in portrait view to 72 pixels in both landscape views, as measured from the side of the phone that has the power button toward the center of the screen.
Related
What is the best strategy to choose camera for qrcode scanning?
Currently modern devices have few back cameras.
For example huawei mate 20 have 4 camera (3 physical and 1 virtual based on physical ones)
Currently my algorithm just selecting first camera with "back" in label.
Is there any better strategy for best readability of qr code?
Here is my code:
this.qrScannerComponent.getMediaDevices().then(devices => {
// this.info = devices.map((dev, i) => `${i}. ${dev.label}`).join('\n');
const videoDevices: MediaDeviceInfo[] = [];
for (const device of devices) {
if (device.kind.toString() === 'videoinput') {
videoDevices.push(device);
}
}
if (videoDevices.length > 0) {
let choosenDev;
for (const dev of videoDevices) {
if (dev.label.includes('back')) {
choosenDev = dev;
break;
}
}
if (choosenDev) {
this.qrScannerComponent.chooseCamera.next(choosenDev);
} else {
this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
}
}
});
The issue only happens on the iPhone XR, it works well on all other iPhone devices.
And I used the original UITabBar component, not the customized one
tabBarItem.titlePositionAdjustment.vertical = -10.0
tabBarItem.selectedImage = UIImage(named: imageName)
tabBarItem.title = barTitle
tabBarItem.image = UIImage(named: unSelectedImage)
Upate:
The issue can't be reproduced on the simulator, only on the physical device
The interesting things is, it works well on the one iPhone XR, has the issue on another iPhone XR
Update:
The user who has the issue open the Display Zoom feature
It works well when the use choose the Standard display
The solution is;
extension UIDevice {
var modelName: String {
var modelID = ""
#if targetEnvironment(simulator)
modelID = ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] ?? ""
#else
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
modelID = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
#endif
return modelID
}
}
I use the nativeScale and scale parameter to detect if the user open the Display zoom feature.
if UIScreen.main.nativeScale > UIScreen.main.scale, UIDevice.current.modelName == "iPhone11,8" {
// "iPhone11,8" for iPhone XR
// do nothing here
} else {
// for other devices
tabBarItem.titlePositionAdjustment.vertical = -10.0
}
I've seen questions about the LWJGL window flickering during rendering, but I'm talking about the full screen flickering here, not just the window. The flickers are ~1.5 seconds long of the normal computer screen, then ~1.5 seconds of full black.
I'm not trying to run the app in full screen.
I'm using the code from this tutorial, that I rewrote in Kotlin:
fun main(args: Array<String>){
SharedLibraryLoader.load()
thread {
Main.run()
}
}
object Main: Runnable {
val window: Long
init {
if (glfwInit() != GL_TRUE)
throw RuntimeException("Couldn't initialize GLFW...")
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE)
window = glfwCreateWindow(800, 600, "Test", NULL, NULL)
if (window == NULL)
throw RuntimeException("Couldn't create the window...")
val videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor())
glfwSetWindowPos(window, 100, 100)
glfwMakeContextCurrent(window)
glfwShowWindow(window)
}
fun update() {
glfwPollEvents()
}
fun render() {
glfwSwapBuffers(window)
}
override fun run() {
while (glfwWindowShouldClose(window) != GL_TRUE){
update()
render()
}
}
}
with the Gradle dependencies:
val lwjglVersion = "3.0.0a"
compile("org.lwjgl:lwjgl:${lwjglVersion}")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-windows")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-linux")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-osx")
I'm on a Debian 9 machine (Linux). Is this a graphics card problem? Or is the code just wrong?
I have a Letter class like this:
class Letter : Label {
val char: Char
var interactable = true
constructor(char: Char) : super(""+char, H.letterStyle()) {
this.char = char
}
fun animateSelect() {
addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f))
}
fun animateUnselect() {
addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f))
}
}
In my touch listener, I have this:
override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean {
var currentInteractingLetter: Letter? = null
for (letter in letterList) {
if (letter.bound.contains(x, y)) {
currentInteractingLetter = letter
break
}
}
if (currentInteractingLetter == null) {
} else {
selectedLetters.add(currentInteractingLetter)
currentInteractingLetter.animateSelect()
currentInteractingLetter.interactable = false
}
return true
}
The logic is quite straightforward. When user touch any one of the letters, I will invoke animateSelect() function.
When I run it, animateSelect did get called, but there is no scaleUp effect. I have tried to clear all actions before addAction but still the same.
Labels don't directly support scaling.
The easy way to solve this is put the label in a Container, setTransform(true) on the Container, and add your scale action to the Container.
val container= Container<Label>().apply {
isTransform=true
actor=label // Set your Label to container
}
container.addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f))
game seem run too quickly in some scene,
I wanna limit fps at 30.
I am using pure-cpp d3d.
I find SetWaitableTimer is not available in WP8 (which i use to limit fps in desktop)
SleepConditionVariableCS is available in WP8 here is the code for sleep
struct WaitTimeData
{
CONDITION_VARIABLE conditionVariable;
CRITICAL_SECTION criticalSection;
WaitTimeData()
{
InitializeConditionVariable(&conditionVariable);
memset(&criticalSection , 0 , sizeof(CRITICAL_SECTION));
//InitializeCriticalSection(&_CriticalSection); wp8 has no this func
criticalSection.DebugInfo = (PRTL_CRITICAL_SECTION_DEBUG)-1;
criticalSection.LockCount = -1;
}
};
int WPSleep(unsigned int ms)
{
static WaitTimeData s_wtd;
SleepConditionVariableCS(
&s_wtd.conditionVariable,
&s_wtd.criticalSection,
ms
);
if (GetLastError() == ERROR_TIMEOUT)
{
SetLastError(0);
}
return 0;
}