Added MacOS SDK
This commit is contained in:
@@ -0,0 +1 @@
|
||||
add_app(Sample5 main.cpp)
|
||||
@@ -0,0 +1,102 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
* { -webkit-user-select: none; }
|
||||
body {
|
||||
background: url('background.jpg');
|
||||
background-size: 450px 700px;
|
||||
color: white;
|
||||
font-family: -apple-system, 'Segoe UI Light', Arial, sans-serif;
|
||||
font-weight: 200;
|
||||
padding-top: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
div {
|
||||
text-align: center;
|
||||
}
|
||||
#time { font-size: 78px; }
|
||||
#date { font-size: 22px; }
|
||||
#bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
/* Royalty Free Photo from: https://unsplash.com/photos/DYGNNwkfx_Y */
|
||||
background: url('background.jpg') no-repeat center center;
|
||||
background-size: cover;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function updateTime() {
|
||||
const dayNames = ["Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday"]
|
||||
const monthNames = ["January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"];
|
||||
var date = new Date();
|
||||
var h = (date.getHours() + 24) % 12 || 12;
|
||||
var m = date.getMinutes();
|
||||
m = m < 10 ? "0" + m : m;
|
||||
var timeStr = h + ":" + m;
|
||||
var dateStr = dayNames[date.getDay()] + ", " +
|
||||
monthNames[date.getMonth()] + " " + date.getDate();
|
||||
document.getElementById('time').innerText = timeStr;
|
||||
document.getElementById('date').innerText = dateStr;
|
||||
var t = setTimeout(updateTime, 500);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var lFollowX = 0,
|
||||
lFollowY = 0,
|
||||
x = 0,
|
||||
y = 0,
|
||||
range = 500,
|
||||
friction = 1 / 6;
|
||||
|
||||
function moveBackground() {
|
||||
x += (lFollowX - x) * friction;
|
||||
y += (lFollowY - y) * friction;
|
||||
translate = 'translate(' + x + 'px, ' + y + 'px) scale(1.1)';
|
||||
document.getElementById('bg').style.transform = translate;
|
||||
window.requestAnimationFrame(moveBackground);
|
||||
}
|
||||
|
||||
function handleMouseMove(e) {
|
||||
var lMouseX = Math.max(-range,
|
||||
Math.min(range, window.innerWidth / 2 - e.clientX));
|
||||
var lMouseY = Math.max(-range,
|
||||
Math.min(range, window.innerHeight / 2 - e.clientY));
|
||||
lFollowX = (20 * lMouseX) / range;
|
||||
lFollowY = (20 * lMouseY) / range;
|
||||
}
|
||||
|
||||
function load() {
|
||||
updateTime();
|
||||
window.onmousemove = handleMouseMove;
|
||||
moveBackground();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="load();">
|
||||
<div id="bg"></div>
|
||||
<div id="time"></div>
|
||||
<div id="date"></div>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 257 KiB |
@@ -0,0 +1,101 @@
|
||||
#include <AppCore/App.h>
|
||||
#include <AppCore/Window.h>
|
||||
#include <AppCore/Overlay.h>
|
||||
#include <AppCore/JSHelpers.h>
|
||||
|
||||
using namespace ultralight;
|
||||
|
||||
///
|
||||
/// Welcome to Sample 5!
|
||||
///
|
||||
/// In this sample we'll show how to load assets from the local file system.
|
||||
///
|
||||
/// __FileSystem API__
|
||||
///
|
||||
/// Ultralight uses the FileSystem interface (part of the Platform API) to load file:/// URLs and
|
||||
/// handle JavaScript FileSystem API requests.
|
||||
///
|
||||
/// AppCore provides default FileSystem implementations for Windows, macOS, and Linux
|
||||
/// out-of-the-box.
|
||||
///
|
||||
/// * On Windows/Linux, it will use ./assets/ as the base file path.
|
||||
/// * On macOS, it will use the app bundle's @resource_path
|
||||
///
|
||||
/// You can configure the base file system path by passing your own Settings to App::Create.
|
||||
///
|
||||
/// When building your application, it's best to use a CMake script to copy these assets to your
|
||||
/// application's output folder/bundle. Look at the CMakeLists.txt of this sample for an example.
|
||||
///
|
||||
/// __Custom FileSystem API__
|
||||
///
|
||||
/// You can provide your own FileSystem implementation in case you need greater control over file
|
||||
/// loading. This is useful if you're using your own data format and/or need to encrypt or
|
||||
/// compress resources.
|
||||
///
|
||||
/// See <Ultralight/platform/FileSystem.h> for more information.
|
||||
///
|
||||
class MyApp : public WindowListener {
|
||||
RefPtr<App> app_;
|
||||
RefPtr<Window> window_;
|
||||
RefPtr<Overlay> overlay_;
|
||||
public:
|
||||
MyApp() {
|
||||
///
|
||||
/// Create our main App instance.
|
||||
///
|
||||
app_ = App::Create();
|
||||
|
||||
///
|
||||
/// Create our Window using default window flags.
|
||||
///
|
||||
window_ = Window::Create(app_->main_monitor(), 450, 700, false, kWindowFlags_Titled);
|
||||
|
||||
///
|
||||
/// Set the title of our window.
|
||||
///
|
||||
window_->SetTitle("Ultralight Sample 5 - File Loading");
|
||||
|
||||
window_->set_listener(this);
|
||||
|
||||
///
|
||||
/// Create an Overlay using the same dimensions as our Window.
|
||||
///
|
||||
overlay_ = Overlay::Create(window_, window_->width(), window_->height(), 0, 0);
|
||||
|
||||
///
|
||||
/// Load a file from the FileSystem.
|
||||
///
|
||||
/// **IMPORTANT**: Make sure `file:///` has three (3) forward slashes.
|
||||
///
|
||||
overlay_->view()->LoadURL("file:///app.html");
|
||||
}
|
||||
|
||||
virtual ~MyApp() {}
|
||||
|
||||
///
|
||||
/// Inherited from WindowListener, called when the Window is closed.
|
||||
///
|
||||
/// We exit the application when the window is closed.
|
||||
///
|
||||
virtual void OnClose(ultralight::Window* window) override {
|
||||
app_->Quit();
|
||||
}
|
||||
|
||||
///
|
||||
/// Inherited from WindowListener, called when the Window is resized.
|
||||
///
|
||||
/// (Not used in this sample)
|
||||
///
|
||||
virtual void OnResize(ultralight::Window* window, uint32_t width, uint32_t height) override {}
|
||||
|
||||
void Run() {
|
||||
app_->Run();
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
MyApp app;
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user