Skip to content

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

License

Notifications You must be signed in to change notification settings

ZFFrameworkDist/ZFFramework

 
 

Repository files navigation

Introduction

welcome to ZFFramework, a cross-platform and powerful 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:

Quick overview

cpp hello world

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() // app starts from here
{
    // show a hello world to log output
    zfLogT() << "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()->layoutAlign(ZFUIAlign::e_LeftInner);
    textView->text("hello world");

    // button and click (as observer)
    zfblockedAlloc(ZFUIButtonBasic, button);
    window->childAdd(button);
    button->layoutParam()->layoutAlign(ZFUIAlign::e_RightInner);
    button->buttonLabelText("click me");
    ZFLISTENER_LOCAL(onClick, {
        ZFUIButtonBasic *button = userData->objectHolded();
        zfLogTrimT() << "button clicked:" << button;
        zfLogTrimT() << "sender:" << listenerData.sender();
    })
    button->onClick(onClick, button->objectHolder());
}

lua hello world

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():layoutAlign(ZFUIAlign.e_LeftInner())
textView:text('hello wolrd')

local button = ZFUIButtonBasic.ClassData():newInstance()
window:childAdd(button)
button:layoutParam():layoutAlign(ZFUIAlign.e_RightInner())
button:buttonLabelText('click me')
button:onClick(
    function (listenerData, userData)
        zfLog('button clicked: %s', userData:objectHolded())
        zfLog('sender: %s', listenerData:sender())
    end,
    button:objectHolder())

powerful dynamic register

this piece of code shows the powerful dynamic register logic

#include "ZFLua.h"
ZFMAIN_ENTRY()
{
    ZFDynamic()
        .classBegin("MyBaseView", "ZFUIView")
            .method(ZFListenerForLambda({
                zfLogTrimT() << "MyBaseView::testFunc() called";
            }), zfnull, "void", "testFunc")
        .classEnd();

    ZFLuaExecute(
        "ZFDynamic()\n"
        "    :classBegin('MyChildView', 'MyBaseView')\n"
        "        :methodBegin('void', 'testFunc')\n"
        "        :methodEnd(function(listenerData, userData)\n"
        "            listenerData:param0():callSuper()\n"
        "            zfLog('MyChildView::testFunc() called')\n"
        "        end)\n"
        "    :classEnd()\n"
        "\n"
        "local myView = MyChildView()\n"
        "myView:testFunc()\n"
    );

    zfautoObject obj = ZFClass::classForName("MyChildView")->newInstance();
    obj->invoke("testFunc");
}

Getting started

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

Detailed

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

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 serialization
    • enhanced global event observer and event filter
  • 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

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, you may simply drag and drop all src files to your build system
  • fully dynamic, extensible

License

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

if you like my work, buy me a coffee?

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 80.1%
  • C 7.4%
  • Java 3.7%
  • Objective-C++ 2.5%
  • QMake 2.5%
  • Shell 1.9%
  • Other 1.9%