How do I make my own window frame in egui (eframe) Rust - user-interface

Here is how I start my app and remove the window frame:
let app = RustClicker::default();
let mut native_options = eframe::NativeOptions::default();
native_options.decorated = false; // I remove window frame here
eframe::run_native(Box::new(app), native_options);
I made my own top-panel like this:
egui::TopBottomPanel::top("decoration").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
ui.with_layout(egui::Layout::left_to_right(), |ui| {
ui.label("πŸ–±");
});
ui.with_layout(egui::Layout::right_to_left(), |ui| {
if ui.button("πŸ—™").clicked() {
frame.quit();
}
let change_theme = ui.button("🎨");
if change_theme.clicked() {
if self.dark_theme {
self.dark_theme = false;
}
else {
self.dark_theme = true;
}
}
});
});
});
But I can't move it with holding moue button on, TopPanel is there anyway to fix this?

Found an example https://github.com/emilk/egui/tree/master/examples/custom_window_frame this works and the corners are also rounded

Related

Im trying to make the effect loop with a 'while' and its not working

// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// β€œHello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
import { timeline } from 'wix-animations';
$w.onReady(function () {
var rotate = true;
let timeline1 = timeline();
while ($w('#image1').onMouseIn(() => {
if (rotate == true) {
timeline1.add($w('#box2'), { opacity: 100, duration: 800, rotate: 3600 }).play();
rotate = false;
} else {
timeline1.replay();
rotate = true;
}
let i=0;
});
Adds an event handler that runs when the element is clicked.
Read more
#param {$w.MouseEvent} event
*/
export function image1_click(event) {
// This function was `added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
}

Hyperloop eventlistener example

I try to make a flac file player with Appcelerator and Hyperloopusing the OrigamiEngine
It works as I can play, pause and stop the player. But I can't get the "addEventListener" mode working. I read some examples and something about the delegate methods. But I'm not a native iOS coder and all my tryings failed.
Can anybody tells me how to code the eventlistener for the didChangeState function?
This is my unfortunately not working code
//Application Window Component Constructor
function ApplicationWindow() {
Ti.Media.audioSessionCategory = Ti.Media.AUDIO_SESSION_CATEGORY_PLAYBACK;
var NSURL = require('Foundation/NSURL');
var ORGMEngine = require('OrigamiEngine/ORGMEngine');
var audioPlayer = new ORGMEngine();
var self = Ti.UI.createWindow({
backgroundColor : '#ffffff'
});
var startStopButton = Ti.UI.createButton({
title : 'Start/Stop Streaming',
top : 100,
width : 200,
height : 40
});
var pauseResumeButton = Ti.UI.createButton({
title : 'Pause/Resume Streaming',
top : 140,
width : 200,
height : 40,
enabled : false
});
self.add(startStopButton);
self.add(pauseResumeButton);
startStopButton.addEventListener('click', function() {
console.log('audioPlayer.currentState: ' + audioPlayer.currentState);
// When paused, playing returns false.
// If both are false, playback is stopped.
if (audioPlayer.currentState == 1) {
audioPlayer.stop();
audioPlayer.release();
pauseResumeButton.enabled = false;
} else {
var url = NSURL.URLWithString('http://faq.fantasticlibrary.de/test.flac');
audioPlayer.playUrl(url);
setTimeout(function(){
console.log(audioPlayer.metadata());
}, 10000);
pauseResumeButton.enabled = true;
}
});
pauseResumeButton.addEventListener('click', function() {
console.log('audioPlayer.currentState: ' + audioPlayer.currentState);
if (audioPlayer.currentState == 1) {
audioPlayer.pause();
} else {
audioPlayer.resume();
}
});
var StateChangeDelegate = Hyperloop.defineClass('MyDelegate', 'NSObject', ['ORGMEngineDelegate']);
StateChangeDelegate.addMethod({
selector: 'engine:didChangeState:',
instance: true,
arguments: ['ORGMEngine', 'ORGMEngineState'],
callback: function (engine, state) {
if (this.didChangeState) {
this.didChangeState(engine, state);
}
}
});
var delegate = new StateChangeDelegate();
delegate.didChangeState = function(ORMEngine,state) {
console.log('does the state change???');
};
self.addEventListener('close', function() {
audioPlayer.stop();
audioPlayer.release();
});
return self;
}
module.exports = ApplicationWindow;
Running demo project to download: http://lightapps.de/files/flactest.zip
Try it:
delegate.on('didChangeState', function(ORMEngine,state){
console.log('does the state change???');
});
I can't test this in the moment, but i think that will work for you.

ZXing is not scanning on Android (Xamarin app)

I am using below code to scan a QR code in my Xamarin. I am currently testing it on Samsung Galaxy (Android) and I am able to view the camera streaming but it is not scanning any QR code.
How can I fix this please to get the result of the QR scanned?
public void Scan()
{
try
{
scanner.Options = new MobileBarcodeScanningOptions()
{
UseFrontCameraIfAvailable = false, //update later to come from settings
PossibleFormats = new List(),
TryHarder = true,
AutoRotate = false,
TryInverted = true,
DelayBetweenContinuousScans = 2000,
};
scanner.VerticalOptions = LayoutOptions.FillAndExpand;
scanner.HorizontalOptions = LayoutOptions.FillAndExpand;
// scanner.IsVisible = false;
scanner.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);
// scanner.Options.PossibleFormats.Add(BarcodeFormat.DATA_MATRIX);
// scanner.Options.PossibleFormats.Add(BarcodeFormat.EAN_13);
scanner.OnScanResult += (result) => {
// Stop scanning
scanner.IsAnalyzing = false;
scanner.IsScanning = false;
if (scanner.IsScanning)
{
scanner.AutoFocus();
}
// Pop the page and show the result
Device.BeginInvokeOnMainThread(async () => {
if (result != null)
{
await DisplayAlert("Scan Value", result.Text, "OK");
}
});
};
mainGrid.Children.Add(scanner, 0, 1);
}
catch (Exception ex)
{
DisplayAlert("Scan Value", ex.ToString(), "Error");
}
}
Maybe you are using the wrong event handler, or missing an event, also the camera never focuses:
the condition is never true, due to this fragment of code:
scanner.IsScanning = false;
if (scanner.IsScanning)
{
scanner.AutoFocus();
}

How To Exit app by double tap on back button in NativeScript Apps

Exit app on double tap on back button in Nativescript
Please help me with snippet of code
Here is the solution that I have found:
var frameModule = require("ui/frame");
var application = require("application")
var activity = application.android.startActivity ||
application.android.foregroundActivity ||
frameModule.topmost().android.currentActivity ||
frameModule.topmost().android.activity;
var lastPress;
activity.onBackPressed = function() {
var timeDelay = 500
if (lastPress + timeDelay > java.lang.System.currentTimeMillis()) {
var startMain = new android.content.Intent(android.content.Intent.ACTION_MAIN);
startMain.addCategory(android.content.Intent.CATEGORY_HOME);
startMain.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(startMain);
// If you want to kill the app totally, use these codes instead of above
// activity.finish();
// java.lang.System.exit(0);
} else {
frameModule.topmost().goBack();
}
lastPress = java.lang.System.currentTimeMillis();
}
Hope this helps.
for Angular
import * as application from 'tns-core-modules/application';
exitapp=0
ngOnInit() {
application.android.on(application.AndroidApplication.activityBackPressedEvent, this.handleBackButton, this);
}
handleBackButton(args: any) {
this.ngZone.run(() => {
args.cancel = true;
if (this.routerExtensions.canGoBack()) {
this.routerExtensions.back();
}else{
this.exitapp++
this.getData.toast('Press again to exit')
if(this.exitapp==2){
application.android.foregroundActivity.finish();
}
setTimeout(()=>{
this.exitapp=0
},2000)
}
})
}

Activate (or not) jQuery plugin depending on screen width

So I got this jQuery plugin to active a sliding menu tab:
$(document).ready(function() {
var closeAll,
$parentItem = $('div#tabWrapper'),
slideAmt = $('div#tabBG').width(),
direction;
$('a#toggle').click(function() {
if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
direction = '+=';
$(this).addClass('expanded');
}
else {
$(this).removeClass('expanded');
direction = '-=';
}
$parentItem.animate({marginLeft: direction + slideAmt}, 400)
return false;
});
$parentItem.mouseleave(function() {
closeAll = setTimeout(function() {
$('a#toggle').removeClass('expanded').parent().animate({marginLeft: -slideAmt}, 300);
return false;
}, 600);
})
.mouseenter(function() {
clearTimeout(closeAll);
}) });
But I only want this animation to work on a higher screen width than 1024px.
How would make this happen?
Thanks all!
You can get the screen resolution using
screen.height;
screen.width;
Then do what you want to do depending on these values

Resources