Skip to content

Commit

Permalink
Merge pull request #134 from bluecadet/feature/clang-format
Browse files Browse the repository at this point in the history
Create Cinder app template; integrate ClangFormat
  • Loading branch information
shi-weili authored Nov 8, 2018
2 parents 9aa29ad + 4ee371a commit 8cf18c3
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions cinderblock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@

<includePath>src</includePath>
</block>
<template>templates/Bluecadet App/template.xml</template>
</cinder>
58 changes: 58 additions & 0 deletions templates/Bluecadet App/src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'true'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: 'false'
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: AfterColon
BreakStringLiterals: 'true'
ColumnLimit: '95'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
FixNamespaceComments: 'true'
IndentCaseLabels: 'false'
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
NamespaceIndentation: None
PointerAlignment: Right
ReflowComments: 'false'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '4'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Always

...
69 changes: 69 additions & 0 deletions templates/Bluecadet App/src/_TBOX_PREFIX_App.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Cinder
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"

// Bluecadet
#include "bluecadet/core/BaseApp.h"
#include "bluecadet/views/TouchView.h"

using namespace std;
using namespace ci;
using namespace ci::app;
using namespace bluecadet::core;
using namespace bluecadet::views;
using namespace bluecadet::touch;

class _TBOX_PREFIX_App : public BaseApp {
public:
static void prepareSettings(ci::app::App::Settings *settings);
void setup() override;
void update() override;
void draw() override;
};

void _TBOX_PREFIX_App::prepareSettings(ci::app::App::Settings *settings) {
// Optional: Override the shared settings manager instance with your subclass
// SettingsManager::setInstance(myApp::MyAppSettingsManager::getInstance());

// Initialize the settings manager with the cinder app settings and the settings json
SettingsManager::getInstance()->setup(
settings,
ci::app::getAssetPath("settings.json"),
[](SettingsManager *manager) {
// Optional: Override json defaults at runtime
manager->mFullscreen = false;
manager->mWindowSize = ivec2(1280, 720);
});
}

void _TBOX_PREFIX_App::setup() {
BaseApp::setup();

// Optional: configure your root view
getRootView()->setBackgroundColor(Color::gray(0.5f));

// Sample content
auto button = make_shared<TouchView>();
button->setPosition(vec2(400, 300));
button->setSize(vec2(200, 100));
button->setBackgroundColor(Color(1, 0, 0));
button->getSignalTapped().connect(
[=](bluecadet::touch::TouchEvent e) { CI_LOG_I("Button tapped"); });
getRootView()->addChild(button);
}

void _TBOX_PREFIX_App::update() {
// Optional override. BaseApp::update() will update all views.
BaseApp::update();
}

void _TBOX_PREFIX_App::draw() {
// Optional override. BaseApp::draw() will draw all views.
BaseApp::draw();
}

// Make sure to pass a reference to prepareSettings to configure the app correctly. MSAA and other render options are optional.
CINDER_APP(_TBOX_PREFIX_App,
RendererGl(RendererGl::Options().msaa(4)),
_TBOX_PREFIX_App::prepareSettings);
8 changes: 8 additions & 0 deletions templates/Bluecadet App/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<cinder>
<template name="Bluecadet App" parent="org.libcinder.apptemplates.basicopengl">
<requires>com.bluecadet.cinder.views</requires>
<source replaceContents="true" replaceName="true">src/_TBOX_PREFIX_App.cpp</source>
<file>src/.clang-format</file>
</template>
</cinder>

0 comments on commit 8cf18c3

Please sign in to comment.