Skip to content

cnsuhao/ZFFramework

 
 

Repository files navigation

Introduction

welcome to ZFFramework, a cross-platform, lightweight, mid-level application framework in C++

everything here starts with "ZF", which stands for "Zero Framework"

  • it's not a traditional framework, can be loaded like a dynamic library, plug and play
  • designed to be able to run at any platform that supplies C++03 compatible implementation

Homepage:

Main features

  • minimum requirement

  • powerful reflection, serialzation, styleable logic

    • for how powerful ZFFramework is, you may refer to Feature page
    • automatic lua binding, no extra bind code or config are necessary
    • automatic UI serialization
    • stateful property animation
    • enhanced global event observer
  • fully modularization, "core + protocol + dynamic implementation" design

    support any platform if you are able to supply a native C++ implementation, most of implementation can be replaced easily, and implementation is required only if its owner module being used

  • easy to communicate with native code

    even to embed UI elements and native UI elements with each other

  • UI module to write cross-platform UI easily

  • built-in auto scale logic to support multiple screen size

    you have no need to write size-dependent code in both app and implementation

Quick overview

  • this piece of code shows how to show a hello world on UI and log output
    #include "ZFUIWidget.h" // for common UI module
    ZFMAIN_ENTRY(params) // app starts from here
    {
        // show a hello world to log output
        zfLogT() << zfText("hello wolrd");

        // show a window (full screen by default)
        zfblockedAlloc(ZFUIWindow, window);
        window->windowShow();

        // show a hello world as a text view
        zfblockedAlloc(ZFUITextView, textView);
        window->childAdd(textView);
        textView->layoutParam()->layoutAlignSet(ZFUIAlign::e_LeftInner);
        textView->textSet(zfText("hello world"));

        // button and click (as observer)
        zfblockedAlloc(ZFUIButtonBasic, button);
        window->childAdd(button);
        button->layoutParam()->layoutAlignSet(ZFUIAlign::e_RightInner);
        button->buttonLabelTextSet(zfText("click me"));
        ZFLISTENER_LOCAL(onClick, {
            ZFUIButtonBasic *button = userData->objectHolded();
            zfLogTrimT() << zfText("button clicked:") << button;
        })
        button->observerAdd(ZFUIButton::EventButtonOnClick(), onClick, button->objectHolder());

        return 0;
    }
  • this piece of code shows equivalent lua code to use ZFFramework, all the lua bindings are automatically done by reflection!
    zfLog('hello world')

    local window = ZFUIWindow()
    window:windowShow()

    local textView = zfAlloc('ZFUITextView')
    window:childAdd(textView)
    textView:layoutParam():layoutAlignSet(ZFUIAlign.e_LeftInner())
    textView:textSet('hello wolrd')

    local button = ZFUIButtonBasic.ClassData():newInstance()
    window:childAdd(button)
    button:layoutParam():layoutAlignSet(ZFUIAlign.e_RightInner())
    button:buttonLabelTextSet('click me')
    button:observerAdd(
        ZFUIButton.EventButtonOnClick(),
        function (listenerData, userData)
            zfLog('button clicked: %s', userData:objectHolded())
        end,
        button:objectHolder())
  • and here are screenshot of demo 2048 game built by ZFFramework:

Requirement

  • for the core modlue:

    • C++03 compatible compiler (require templates, no boost/RTTI/exceptions required)
    • STL containers (require: map/unordered_map/vector/deque/list), or supply custom wrapper
  • for the implementation module:

    • depends on the actual platform implementation

Current status

  • finished
    • core module (memory management, reflection, serialization)
    • basic UI module (view, window, label, image view, button, layout, scroll view, list view)
    • basic algorithm (xml, json, regexp, md5, base64, crc32, encryption, compression)
    • common platform implementations (iOS, Android, Qt)
    • auto lua binding by reflection
  • working
    • more useful UI modules
    • basic network module
    • basic database module
  • future
    • standalone visual UI editor
    • more IDE / compile env integrations
    • more platform implementations

What we do

  • aiming to be portable and can be ported easily, aiming to be lightweighted and able to be embeded easily, aiming to use 20% code to do 80% work
  • supply Java-like / ObjectC-like app level APIs to build up small/medium sized app easily

Getting started

  • Download necessary files
  • Setup set up necessary environment for ZFFramework
  • Tutorial quick tutorial to code with ZFFramework
  • FAQ

License

ZFFramework is under MIT license (see here), feel free to copy or modify or use it

if you like my work, please consider donate:

contact master@zsaber.com (Chinese or English only) before donate, we would really appreciate for your help

About

cross-platform C++ application framework, do 80% work at 20% cost

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 85.3%
  • C 3.6%
  • Java 3.2%
  • Objective-C++ 2.4%
  • QMake 2.3%
  • Shell 1.7%
  • Other 1.5%