Skip to content

Commit d331293

Browse files
committed
Merge branch 'master' of https://github.com/pxscene/pxCore
2 parents 7e9ce66 + d0efbbb commit d331293

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+720
-397
lines changed

examples/pxScene2d/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
>Setup Windows 10
4545
> * Windows 10
4646
> * Visual Studio 2017 community with `Desktop development with C++` workload
47-
> * [windows sdk 10.0.16299 and windows sdk 10.0.17134(aka 1803)] (https://developer.microsoft.com/en-us/windows/downloads/sdk-archive)
47+
> * [windows sdk 10.0.15063.0, windows sdk 10.0.16299 and windows sdk 10.0.17134(aka 1803)] (https://developer.microsoft.com/en-us/windows/downloads/sdk-archive)
4848
> * python 2.7.x , make sure python can work in cmd (setup environment variables depending on install location)
49-
> * git for windows , make sure git can work in cmd (setup environment variables depending on install location)
49+
> * git for windows , make sure git can work in cmd (setup environment variables depending on install location). While installing git, make sure that **"Use Git and optional Unix tools from the Windows Command Prompt"** option is checked.
5050
> * patch utility for windows (this comes with git. setup environment variables depending on install location of patch.exe)
5151
> * Download and install cmake for windows from https://cmake.org/download/
5252
> * Download and install NSIS installer from http://nsis.sourceforge.net/Download

examples/pxScene2d/external/build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ if [ ! -e ./uWebSockets/libuWS.dylib ] ||
148148
then
149149

150150
cd uWebSockets
151-
mv Makefile.build Makefile
151+
152+
if [ -e Makefile.build ]
153+
then
154+
mv Makefile.build Makefile
155+
fi
156+
152157
make
153158
cd ..
154159

examples/pxScene2d/src/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ option(SPARK_ENABLE_LRU_TEXTURE_EJECTION "SPARK_ENABLE_LRU_TEXTURE_EJECTION" ON)
6363
option(SPARK_BACKGROUND_TEXTURE_CREATION "SPARK_BACKGROUND_TEXTURE_CREATION" OFF)
6464
option(SPARK_ENABLE_ALPHA_FBO_SUPPORT "SPARK_ENABLE_ALPHA_FBO_SUPPORT" ON)
6565
option(SPARK_ENABLE_CURSOR_SUPPORT "SPARK_ENABLE_CURSOR_SUPPORT" OFF)
66+
option(BUILD_WITH_PXOBJECT_TRACKING "BUILD_WITH_PXOBJECT_TRACKING" OFF)
6667

6768
if(WIN32)
6869
option(PXSCENE_COMPILE_WARNINGS_AS_ERRORS "PXSCENE_COMPILE_WARNINGS_AS_ERRORS" OFF)
@@ -151,8 +152,6 @@ elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
151152

152153
set(PXSCENE_APP_LIBRARIES ${PXSCENE_APP_LIBRARIES} pxCore rtCore_s)
153154

154-
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/mime/pxMimeTypes.js ${CMAKE_CURRENT_SOURCE_DIR})
155-
156155
if (HOSTNAME STREQUAL "raspberrypi")
157156
message("building pxscene for raspberrypi")
158157
set(PX_PLATFORM PX_PLATFORM_GENERIC_EGL)
@@ -468,6 +467,11 @@ if (BUILD_WITH_TEXTURE_USAGE_MONITORING)
468467
set(PXSCENE_DEFINITIONS ${PXSCENE_DEFINITIONS} -DENABLE_PX_SCENE_TEXTURE_USAGE_MONITORING)
469468
endif (BUILD_WITH_TEXTURE_USAGE_MONITORING)
470469

470+
if (BUILD_WITH_PXOBJECT_TRACKING)
471+
message("building spark with pxobject tracking enabled")
472+
set(PXSCENE_DEFINITIONS ${PXSCENE_DEFINITIONS} -DENABLE_PXOBJECT_TRACKING)
473+
endif (BUILD_WITH_PXOBJECT_TRACKING)
474+
471475
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${PXSCENE_LINKER_OPTIONS})
472476
link_directories(${PXSCENE_LINK_DIRECTORIES})
473477

@@ -502,13 +506,11 @@ if (BUILD_PXSCENE_APP)
502506
if (SUPPORT_DUKTAPE)
503507
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rcvrcore/" DESTINATION rcvrcore COMPONENT pxscene)
504508
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/duk_modules/" DESTINATION duk_modules COMPONENT pxscene)
505-
file(GLOB PXSCENE_INSTALL_FILES_JS "${CMAKE_CURRENT_SOURCE_DIR}/*.js"
506-
"${CMAKE_CURRENT_SOURCE_DIR}/mime/pxMimeTypes.js")
509+
file(GLOB PXSCENE_INSTALL_FILES_JS "${CMAKE_CURRENT_SOURCE_DIR}/*.js")
507510
file(GLOB PXSCENE_INSTALL_FILES_JS2 "${CMAKE_CURRENT_SOURCE_DIR}/duktape/*.js")
508511
else ()
509512
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rcvrcore DESTINATION . COMPONENT pxscene)
510-
file(GLOB PXSCENE_INSTALL_FILES_JS "${CMAKE_CURRENT_SOURCE_DIR}/*.js"
511-
"${CMAKE_CURRENT_SOURCE_DIR}/mime/pxMimeTypes.js")
513+
file(GLOB PXSCENE_INSTALL_FILES_JS "${CMAKE_CURRENT_SOURCE_DIR}/*.js")
512514
endif (SUPPORT_DUKTAPE)
513515

514516
file(GLOB PXSCENE_INSTALL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/FreeSans.ttf"

examples/pxScene2d/src/Spark.cpp

Lines changed: 120 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,31 @@ class sceneWindow : public pxWindow, public pxIViewContainer
150150
{
151151
pxWindow::init(x,y,w,h);
152152

153+
setUrl(url);
154+
}
155+
156+
void* getInterface(const char* /*name*/)
157+
{
158+
return NULL;
159+
}
160+
161+
rtError setView(pxIView* v)
162+
{
163+
mView = v;
164+
165+
if (v)
166+
{
167+
ENTERSCENELOCK()
168+
v->setViewContainer(this);
169+
v->onSize(mWidth, mHeight);
170+
EXITSCENELOCK()
171+
}
172+
173+
return RT_OK;
174+
}
175+
176+
rtError setUrl(const char* url)
177+
{
153178
// escape url begin
154179
std::string escapedUrl;
155180
std::string origUrl = url;
@@ -192,25 +217,6 @@ class sceneWindow : public pxWindow, public pxIViewContainer
192217
uv_async_send(&asyncNewScript);
193218
setView(scriptView);
194219
#endif
195-
}
196-
197-
void* getInterface(const char* /*name*/)
198-
{
199-
return NULL;
200-
}
201-
202-
rtError setView(pxIView* v)
203-
{
204-
mView = v;
205-
206-
if (v)
207-
{
208-
ENTERSCENELOCK()
209-
v->setViewContainer(this);
210-
v->onSize(mWidth, mHeight);
211-
EXITSCENELOCK()
212-
}
213-
214220
return RT_OK;
215221
}
216222

@@ -464,6 +470,94 @@ void handleAbrt(int)
464470
#endif //WIN32
465471
}
466472

473+
#ifdef ENABLE_OPTIMUS_SUPPORT
474+
namespace OptimusClient
475+
{
476+
class rtOptimusSpark : public rtOptimus
477+
{
478+
public:
479+
480+
static rtError onSceneReadyCallback(int numArgs, const rtValue* args, rtValue* /*result*/, void* context)
481+
{
482+
rtError rc = RT_FAIL;
483+
if (context == NULL)
484+
{
485+
return rc;
486+
}
487+
rtOptimusSpark* optimusSpark = (rtOptimusSpark*)context;
488+
if (numArgs >= 3)
489+
{
490+
rtObjectRef scene = args[0].toObject();
491+
rtString url = args[1].toString();
492+
bool success = args[2].toBool();
493+
rtString optimusUrl;
494+
optimusSpark->url(optimusUrl);
495+
if (url.compare(optimusUrl) == 0)
496+
{
497+
optimusSpark->sceneReady(success);
498+
}
499+
rc = RT_OK;
500+
}
501+
return rc;
502+
}
503+
504+
rtDeclareObject(rtOptimusSpark, rtOptimus);
505+
506+
rtOptimusSpark(rtString url) : mUrl(url), mSceneReadyCallback()
507+
{
508+
mSceneReadyCallback = new rtFunctionCallback(onSceneReadyCallback, this);
509+
pxScriptView::addListener("onSceneReady", mSceneReadyCallback);
510+
}
511+
512+
~rtOptimusSpark()
513+
{
514+
if (mSceneReadyCallback.getPtr() != NULL)
515+
{
516+
pxScriptView::delListener("onSceneReady", mSceneReadyCallback);
517+
mSceneReadyCallback = NULL;
518+
}
519+
}
520+
521+
rtProperty(url, url, setUrl, rtString);
522+
523+
rtError url(rtString& v) const
524+
{
525+
v = mUrl;
526+
return RT_OK;
527+
}
528+
rtError setUrl(rtString v)
529+
{
530+
mUrl = v;
531+
const char* url = v.cString();
532+
if (mSceneReadyCallback.getPtr() != NULL)
533+
{
534+
pxScriptView::delListener("onSceneReady", mSceneReadyCallback);
535+
mSceneReadyCallback = NULL;
536+
}
537+
mSceneReadyCallback = new rtFunctionCallback(onSceneReadyCallback, this);
538+
pxScriptView::addListener("onSceneReady", mSceneReadyCallback);
539+
return win.setUrl(url);
540+
}
541+
542+
rtError sceneReady(bool success)
543+
{
544+
pxScriptView::delListener("onSceneReady", mSceneReadyCallback);
545+
mSceneReadyCallback = NULL;
546+
rtObjectRef e = new rtMapObject;
547+
e.set("success", success);
548+
mEmit.send("onApplicationLoaded", e);
549+
return RT_OK;
550+
}
551+
552+
protected:
553+
rtString mUrl;
554+
rtFunctionRef mSceneReadyCallback;
555+
};
556+
rtDefineObject(rtOptimusSpark, rtOptimus);
557+
rtDefineProperty(rtOptimusSpark, url);
558+
}
559+
#endif //ENABLE_OPTIMUS_SUPPORT
560+
467561
int pxMain(int argc, char* argv[])
468562
{
469563
#ifdef HAS_LINUX_BREAKPAD
@@ -620,6 +714,11 @@ if (s && (strcmp(s,"1") == 0))
620714
if (RT_OK == rtSettings::instance()->value("screenHeight", screenHeight))
621715
windowHeight = screenHeight.toInt32();
622716

717+
extern bool gDirtyRectsEnabled;
718+
rtValue dirtyRectsSetting;
719+
if (RT_OK == rtSettings::instance()->value("enableDirtyRects", dirtyRectsSetting))
720+
gDirtyRectsEnabled = dirtyRectsSetting.toString().compare("true") == 0;
721+
623722
// OSX likes to pass us some weird parameter on first launch after internet install
624723
rtLogInfo("window width = %d height = %d", windowWidth, windowHeight);
625724
win.init(10, 10, windowWidth, windowHeight, url);
@@ -713,8 +812,8 @@ if (s && (strcmp(s,"1") == 0))
713812
#endif
714813

715814
#ifdef ENABLE_OPTIMUS_SUPPORT
716-
rtObjectRef tempObject;
717-
OptimusClient::registerApi(tempObject);
815+
rtObjectRef optimusObject = new OptimusClient::rtOptimusSpark(url);
816+
OptimusClient::registerApi(optimusObject);
718817
#endif //ENABLE_OPTIMUS_SUPPORT
719818

720819
#ifdef PX_SERVICE_MANAGER_LINKED

examples/pxScene2d/src/browser.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var homeUrl = "https://www.pxscene.org/examples/px-reference/text/sample.md";
2020

2121
px.configImport({"browser:" : /*px.getPackageBaseFilePath() + */ "browser/"});
2222

23-
2423
px.import({ scene: 'px:scene.1.js',
2524
keys: 'px:tools.keys.js',
2625
ListBox: 'browser:listbox.js',
@@ -80,15 +79,6 @@ px.import({ scene: 'px:scene.1.js',
8079
return "allow"; // allow request to bubble to parent
8180
});
8281

83-
scene.on('onClose', function(e) {
84-
keys = null;
85-
for (var key in inputBox) { delete inputBox[key]; }
86-
listBox = null;
87-
browser = null
88-
inputBox = null;
89-
scene = null;
90-
});
91-
9282
var currentGen = 0
9383
function reload(u, keepHistory)
9484
{

examples/pxScene2d/src/browser/editbox.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ px.import({ scene: 'px:scene.1.js',
286286
var now = new Date().getTime();
287287
if( buttonDownTime !== undefined)
288288
{
289-
if((now - buttonDownTime) < 200)
289+
if((now - buttonDownTime) < 400)
290290
{
291291
// DOUBLE CLICKED
292292
selectAll();
@@ -921,7 +921,10 @@ px.import({ scene: 'px:scene.1.js',
921921

922922
function showCursor()
923923
{
924-
cursor.a = 1;
924+
if(selection_text.length == 0)
925+
{
926+
cursor.a = 1;
927+
}
925928
animateCursor();
926929
}
927930

examples/pxScene2d/src/macstuff/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>1.3.0.2</string>
22+
<string>1.4.0.0</string>
2323
<key>CFBundleSignature</key>
2424
<string>????</string>
2525
<key>CFBundleVersion</key>

examples/pxScene2d/src/mime/pxMimeTypes.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

examples/pxScene2d/src/optimus_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ namespace OptimusClient
4949

5050
protected:
5151
rtError shutdown();
52+
rtEmitRef mEmit;
5253

5354
private:
54-
rtEmitRef mEmit;
5555
rtObjectRef mRemoteObject;
5656
rtObjectRef mTestObj;
5757
};

examples/pxScene2d/src/pxImage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ rtError pxImage::setResource(rtObjectRef o)
9191
removeResourceListener();
9292
mResource = o;
9393
imageLoaded = false;
94-
pxObject::createNewPromise();
94+
createNewPromise();
9595
mListenerAdded = true;
9696
getImageResource()->addListener(this);
9797
}
@@ -142,7 +142,7 @@ rtError pxImage::setUrl(const char* s)
142142
{
143143
imageLoaded = false;
144144
//rtLogDebug("pxImage calling pxObject::createPromise for %s\n",resourceObj->getUrl().cString());
145-
pxObject::createNewPromise();
145+
createNewPromise();
146146
}
147147
// ToDo Need to cancel the download if url is reassigned before its done
148148
/*else if(!imageLoaded)

examples/pxScene2d/src/pxImage.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ class pxImage: public pxObject, pxResourceListener
5252
virtual void update(double t) { pxObject::update(t);}
5353
virtual void onInit();
5454
virtual void sendPromise();
55-
virtual void createNewPromise() { rtLogDebug("pxImage ignoring createNewPromise\n"); }
55+
56+
void createNewPromise() {
57+
// Only create a new promise if the existing one has been
58+
// resolved or rejected already.
59+
if(((rtPromise*)mReady.getPtr())->status())
60+
{
61+
rtLogDebug("CREATING NEW PROMISE\n");
62+
mReady = new rtPromise();
63+
}
64+
}
5665

5766
rtError url(rtString& s) const;
5867
rtError setUrl(const char* s);

0 commit comments

Comments
 (0)