Giter VIP home page Giter VIP logo

slibio / slib Goto Github PK

View Code? Open in Web Editor NEW
131.0 131.0 53.0 53.28 MB

SLib - A universal, efficient, light-weight framework for building cross-platform applications on Android/iOS/macOS/Tizen/Win32/Linux platforms, developed by SLIBIO. Based on C++, provides desktop/mobile widgets, OpenGL rendering and networking solutions.

License: MIT License

C 1.63% C++ 84.79% Objective-C 0.13% Java 3.90% CMake 0.24% Objective-C++ 6.06% Shell 0.05% Batchfile 0.12% SourcePawn 0.18% PHP 2.89%
android cpp11 cross-platform game-development ios macos rendering-engine slib tizen ui win32

slib's People

Contributors

bay-pavel avatar borys-duda-biz avatar canton32 avatar fred1218zh avatar georgi-ant avatar karoly-vig avatar lucasleongit avatar pmijailovic avatar vasylshumskyi avatar wille-hansson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slib's Issues

How to set button in vertical layout?

For example:
Some words under a icon/image in center of button.

m_bButton2->setText("Test Title");
m_bButton2->setMultiLine(true);
m_bButton2->setMargin(30, 5, 5, 5);
m_bButton2->setSize(this->dprToPx(150), this->dprToPx(90));
m_bButton2->setBorder(false);
m_bButton2->setTextColor(slib::Color(54,142,244,255));
m_bButton2->setTextAlignment(slib::Alignment::BottomCenter);
m_bButton2->setIconMargin(10, 10, 10, 0);
m_bButton2->setIconSize(this->dprToPx(50), this->dprToPx(50));
m_bButton2->setIconAlignment(slib::Alignment::TopCenter);
m_bButton2->setIcon(slib::PlatformDrawable::loadFromAsset("images/images/homebg1.png"));

How to make background's alpha?

now,I can't set background's alpha by setAlpha();
eg.
m_view = new View;
m_view->setWidthFilling();
m_view->setHeight(150);//It's px? I advise to use dp.
m_view->setTop(0);
m_view->setBorderColor(slib::Color::Red); // test Color
m_view->setBorderWidth(2);
//m_view->setAlwaysOnDrawBackground(true);
m_view->setBackgroundColor(slib::Color::Blue);
m_view->setAlpha(0.8);

ChromiumView is empty when start the window by sapp.untill resized the window.

A bug in ChromiumView on mac.
I was added ChromiumView into linear in sapp.
but webview can not show in window,untill I have been resized the window.

It's normal without sapp(example project).
[SAPP]

[CPP]

void MainWindow::onCreate()
{
Ref m_webView;
this->setResizable(true);
m_webView = new ChromiumView;
m_webView->setWidthFilling();
m_webView->setHeightFilling();
m_webView->loadURL("https://bing.com");
mainLinear->addChild(m_webView);
}

webview is error

the webview is null when open a url/page.
code:

m_webView = new WebView();
m_webView->setWidthFilling();
m_webView->setHeightFilling();

m_webView->loadURL("http://mozilla.org/MPL/2.0/");

Console::println("Error:%s",m_webView->getErrorMessage());

addViewToContent(m_webView);

new attribute is required (cornerRound)

Among View attributes, it'll be better to define cornerRound to specify round size at corners.
It will be useful to create round buttons.

In this case, there will be conflict between boundShape attribute.
boundShape can be one of rectangle, ellipseor roundRect.
My request is related to roundRect but more edge-case.

So I suggest following forms of solution based on removing boundShape.

<View
   ...
   width="dimenWidth"
   height="dimenHeight"
   cornerRound="dimenCorner"
   ...
/>

Let's assume that dimenWidth > dimenHeight.

  • if dimenCorner=0, same result of boundShape=rectangle.
  • if dimenCorner<dimenHeight/2, similar to boundShape=roundRect but more accurate.
  • if dimenHeight/2<=dimenCorner<dimenWidth/2, round sides but linear top/bottom lines.
  • otherwise, same result of boundShape=ellipse.

Example for iOS and Android

Would it be possible to have any example on how to use SLib for iOS/Android via a tableview/list sample app ?

Production use

Has SLib been used in production ? If yes, for which platform and in which context ?

B.

Layouting issue

When I use the aspect ratio mode for layouting and wrapping, it doesn't work properly for linear view.

<sapp version='1'>
	<layout
		type='page'
		name='WelcomePage'
		background='@drawable/background'
		backgroundScale='cover'
		>
		
		<linear orientation='vertical'
			width='wrap'
			height='wrap'
			alignCenter='true'
			background='red'>

			<image src='@drawable/slib_icon'
				width='15%sw'
				centerHorizontal='true'/>
			
			<label text='Welcome to SLib.io'
				width='wrap'
				height='wrap'
				marginTop='5%sh'/>

		</linear>

 	</layout>
</sapp>

java.lang.UnsatisfiedLinkError: No implementation found for void slib.platform.android.Android.nativeOnCreateActivity(android.app.Activity)

Me again.
As I am waiting for the iOS example, I've been trying to at least test the Android part as I saw there was a JNI example in the examples folder.
So the basic example does run. But as soon as I try to use the SLibActivity on the Java side I end up with the error specified in the title
Here is the full bug report:

What steps will reproduce the problem?

  1. Build and run the JNI example
  2. JNI example runs without any error
  3. In MainActivity, add
Intent intent = new Intent(this, VideoActivity.class);
this.startActivity(intent);

to onCreate

with VideoActivity as follows:

public class VideoActivity extends SlibActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        Log.d("VideoActivity", "onCreate");

    }
}
  1. The app crashes

What is the expected result?

The app should not crash

What do you see instead?

  1. The app crashes with:
Java_slib_platform_android_Android_nativeOnCreateActivity and Java_slib_platform_android_Android_nativeOnCreateActivity__Landroid_app_Activity_2)
                                                       at slib.platform.android.Android.nativeOnCreateActivity(Native Method)
                                                       at slib.platform.android.Android.onCreateActivity(Android.java:42)
                                                       at slib.platform.android.SlibActivity.onCreate(SlibActivity.java:39)
                                                       at android.app.Activity.performCreate(Activity.java:6813)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1121)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
                                                       at android.os.Handler.dispatchMessage(Handler.java:110)
                                                       at android.os.Looper.loop(Looper.java:203)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6251)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

What version of the product are you using? On what operating system?

Version v0.1.4 - Android 7.0

Please provide any additional information below.

  1. I am not sure what is going on, why the linking error happens as thenative-lib.so gets loaded properly but then at runtime, calling Android.nativeOnCreateActivity crashes

Hope you will be able to help out, I'm just trying to get a camera feed.

suggest about headers

hi, thanks for so nice lib!!!
i have some suggest about headers.

  1. rename the root dir "inc" to "include"
  2. change the include rule "../../../inc/slib/xxx/xxx.h" to "slib/xxx/xxx.h"
    do it to all header and src,just as google c++ guide.

example: SLib/src/slib/core/base.cpp
#include "../../../inc/slib/core/base.h" ==> #include "slib/core/base.h"

example:SLib/inc/slib/core/base.h
#include "definition.h" ==> #include "slib/core/definition.h"

Follow the C++ standard rules regarding reserved names

The C++ Standard, [reserved.names] [ISO/IEC 14882-2014], specifies the following rules regarding reserved names:

  • ...
  • Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.
  • Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
  • ...

For more information, visit https://www.securecoding.cert.org/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier

multiple definition of `slib::Console::readLine()' In Android Studio

Build command failed.
Error while executing process /Users/rareli/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/Android/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-lib}
[1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/3] Building CXX object CMakeFiles/native-lib.dir/Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/src/app.cpp.o
[3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so
FAILED: : && /Users/rareli/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/Users/rareli/Library/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/rareli/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/rareli/Library/Android/sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /Users/rareli/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/src/app.cpp.o -L/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a -lslib -llog -lGLESv2 -latomic -lm "/Users/rareli/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && :
/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a/libslib.a(log.cpp.o): In function slib::Console::readLine()': /Users/rareli/Documents/SLIB/SLib/src/slib/core/log.cpp:36: multiple definition of slib::Console::readLine()'
/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a/libslib.a(system.cpp.o):/Users/rareli/Documents/SLIB/SLib/src/slib/core/system.cpp:160: first defined here
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Localization for string values

Is it possible to support multi-language?
For example, native Android provides strings-xx.xml file inside value... and all values defined in this file are used for localization.
In other words, we can get different texts according to language preference by using just one id.
This is valid in iOS even if the method is different.

Is it possible such usage in SLib? If not, this is elementary requirement, I think.

DeviceInformation::getDevicePPI() ERROR

IOS:OK
Android:Error

Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System: Daemon delayGCRequest, sDelayGCRequest=false, delay=true, sPendingGCRequest=false
I/Console: Width:1080
PPI:4294967295(Error value)

code:
Console::print("PPI:%d",DeviceInformation::getDevicePPI());

Tracking animation steps

In following example, maybe the dev needs to track while animating, how much the value has been changed as the time being.

Ref<Animation> animation = view->createTranslateAnimationTo(Vector2(300, 300), 3);
animation->setRepeatCount(5);
animation->start();

So, how about following solution?

Ref<Animation> animation = view->createTranslateAnimationTo(Vector2(300, 300), 3);
animation->setRepeatCount(5);

// suggestion //////
animation->setTracker([](deltaTime, state) {
    // deltaTime is 0-based and limited to 3s x 5(repeat)
    // state is related to Vector2(300,300)
    do_some(deltaTime, state);
}); 
/////////////////////////

animation->start();

UI: values need to be predefined in xml

<image
    name='img1'
    src='@drawable/ui_img1'
    scale='contain'
    width='40%sw'
    height='40%sh'
    centerHorizontal='true'
    top='15%sh'
/>
...
<image
    name='img2'
    src='@drawable/ui_img2'
    scale='contain'
    width='40%sw'
    height='40%sh'
    centerHorizontal='true'
    top='15%sh'
/>

Here, it's not convenient to write 40%sp every time and will be more annoying for update/revision.
Such problems happen in working with values like

  • dimension
  • color
  • number
  • animation
  • shape

There's already string value implemented in desirable way.

Xml layout property - alignTop/alignLeft/alignRight/alignBottom name refine.

I'm reading document, but I think it would be good if you can change alignBottom to alignParentBottom.
It's a bit complicated, because if you didn't provided screenshot, I couldn't notice that it's
a layout_gravity option.
I thought it's a gravity option at the first time before I check the screenshot.

Undefined symbols for architecture x86_64: "ExampleCameraViewApp::DEVPPI"

Error Information:
Undefined symbols for architecture x86_64:
"ExampleCameraViewApp::DEVPPI", referenced from:
ExampleCameraViewApp::onStart() in app.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When:

#ifdef SLIB_PLATFORM_IS_MOBILE
DEVPPI = slib::DeviceInformation::getDevicePPI();
Console::println("\r\nPPI:%ld\r\n",DEVPPI);//Show PPI
#else
DEVPPI = 163;//Show ppi
#endif

"Image::loadFromAsset" error in extended class on Android

FILE:loginForm.h
CODE:
class loginFormApp : public ViewPage
{
public:
loginFormApp(MobileApp* p_hanlde);//创建初始化对象
Ref pHanlde;
...
}

FILE:loginForm.cpp
CODE:
loginFormApp::loginFormApp(MobileApp* p_hanlde)
{
pHanlde = p_hanlde;
Ref imageView1 = new ImageView;
imageView1->setWidthFilling();
imageView1->setHeightFilling();
imageView1->setSource(Image::loadFromAsset("images/logo.png"));
...
pHanlde->addViewToContent(mlogin_main_view);
}

Android:Image::loadFromAsset can not show image.
IOS:OK

In app.cpp:
CODE:
Ref imageView1 = new ImageView;
imageView1->setWidthFilling();
imageView1->setHeightFilling();
imageView1->setSource(Image::loadFromAsset("images/logo.png"));

"Image::loadFromAsset" is ok.
Android:OK
IOS:OK

UrlRequest::post use https

Request to https website.
Error:D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection

LOG:
Client not ready yet..Waiting for process to come online
Connected to process 6963 on device smartisan-od103-ce88d86d
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System: Daemon delayGCRequest, sDelayGCRequest=true, delay=false, sPendingGCRequest=false
I/chromium: [INFO:CONSOLE(4)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: file:///android_asset/images/js/jquery-2.1.4.min.js (4)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
D/INFO: Keyboard is disappeared
I/Activity: Paused

Flash back in android

Device: Mobile Phone
Android Version: 23(6.x)
Bug: Exit app as soon as possible when starting.

Debug Information:

$ adb push /Users/rareli/Documents/WORKSPACE/SLib/examples/UI/CameraView/Android/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/io.slib.examplecameraview
$ adb shell pm install -t -r "/data/local/tmp/io.slib.examplecameraview"
pkg: /data/local/tmp/io.slib.examplecameraview
Success

$ adb shell am start -n "io.slib.examplecameraview/io.slib.examplecameraview.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "io.slib.examplecameraview/io.slib.examplecameraview.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.slib.examplecameraview/.MainActivity }
Error type 3

Error: Activity class {io.slib.examplecameraview/io.slib.examplecameraview.MainActivity} does not exist.

Error while Launching activity

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.