Skip to content

Commit

Permalink
Introduced libtiledquick (mapeditor#2867)
Browse files Browse the repository at this point in the history
This moves the C++ types out of tiledquickplugin into a standalone
library so that other projects can link to them.
  • Loading branch information
mitchcurtis authored Jul 19, 2020
1 parent 390f383 commit 1d005ed
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 15 deletions.
74 changes: 74 additions & 0 deletions src/libtiledquick/libtiledquick.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import qbs 1.0

DynamicLibrary {
targetName: "tiledquick"

Depends { name: "libtiled" }
Depends { name: "cpp" }
Depends { name: "Qt"; submodules: ["quick"]; versionAtLeast: "5.6" }

cpp.cxxLanguageVersion: "c++14"
cpp.visibility: "minimal"
cpp.defines: [
"TILED_QUICK_LIBRARY",
"QT_NO_CAST_FROM_ASCII",
"QT_NO_CAST_TO_ASCII",
"QT_NO_URL_CAST_FROM_STRING",
"QT_DEPRECATED_WARNINGS",
"QT_DISABLE_DEPRECATED_BEFORE=0x050900",
"QT_NO_FOREACH"
]

Properties {
condition: qbs.targetOS.contains("macos")
cpp.cxxFlags: ["-Wno-unknown-pragmas"]
}

Properties {
condition: qbs.targetOS.contains("darwin")
bundle.isBundle: false
cpp.sonamePrefix: "@rpath"
}

files: [
"mapitem.h",
"mapitem.cpp",
"maploader.h",
"maploader.cpp",
"mapref.h",
"tilelayeritem.h",
"tilelayeritem.cpp",
"tiledquick_global.h",
"tilesnode.h",
"tilesnode.cpp"
]

Group {
condition: project.installHeaders
qbs.install: true
qbs.installDir: "include/tiledquick"
fileTagsFilter: "hpp"
}

Export {
Depends { name: "cpp" }
Depends {
name: "Qt"
submodules: ["quick"]
}

cpp.includePaths: "."
}

Group {
condition: !qbs.targetOS.contains("darwin")
qbs.install: true
qbs.installDir: {
if (qbs.targetOS.contains("windows"))
return ""
else
return "lib"
}
fileTagsFilter: "dynamiclibrary"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "mapref.h"
#include "tiledquick_global.h"

#include <QQuickItem>

Expand All @@ -38,7 +39,7 @@ class TileLayerItem;
/**
* A declarative item that displays a map.
*/
class MapItem : public QQuickItem
class TILEDQUICK_SHARED_EXPORT MapItem : public QQuickItem
{
Q_OBJECT

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "mapref.h"
#include "tiledquick_global.h"

#include <QObject>
#include <QUrl>
Expand All @@ -29,7 +30,7 @@

namespace TiledQuick {

class MapLoader : public QObject
class TILEDQUICK_SHARED_EXPORT MapLoader : public QObject
{
Q_OBJECT

Expand Down
4 changes: 3 additions & 1 deletion src/tiledquickplugin/mapref.h → src/libtiledquick/mapref.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

#include <QObject>

#include "tiledquick_global.h"

namespace Tiled {
class Map;
}

namespace TiledQuick {

class MapRef
class TILEDQUICK_SHARED_EXPORT MapRef
{
Q_GADGET

Expand Down
37 changes: 37 additions & 0 deletions src/libtiledquick/tiledquick_global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* tiledquick_global.h
* Copyright 2020, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
*
* This file is part of libtiledquick.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include <QtCore/qglobal.h>

#if defined(TILED_QUICK_LIBRARY)
# define TILEDQUICK_SHARED_EXPORT Q_DECL_EXPORT
#else
# define TILEDQUICK_SHARED_EXPORT Q_DECL_IMPORT
#endif
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QQuickItem>

#include "tilelayer.h"
#include "tiledquick_global.h"

namespace Tiled {
class MapRenderer;
Expand All @@ -35,7 +36,7 @@ class MapItem;
/**
* A graphical item displaying a tile layer in a Qt Quick scene.
*/
class TileLayerItem : public QQuickItem
class TILEDQUICK_SHARED_EXPORT TileLayerItem : public QQuickItem
{
Q_OBJECT

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <QSGGeometryNode>
#include <QSGTextureMaterial>

#include "tiledquick_global.h"

namespace TiledQuick {

struct TileData {
Expand All @@ -36,7 +38,7 @@ struct TileData {
bool flippedVertically;
};

class TilesNode : public QSGGeometryNode
class TILEDQUICK_SHARED_EXPORT TilesNode : public QSGGeometryNode
{
public:
enum {
Expand Down
12 changes: 2 additions & 10 deletions src/tiledquickplugin/tiledquickplugin.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DynamicLibrary {
builtByDefault: false

Depends { name: "libtiled" }
Depends { name: "libtiledquick" }
Depends {
name: "Qt"; submodules: ["qml", "quick"]
versionAtLeast: "5.6"
Expand All @@ -26,17 +27,8 @@ DynamicLibrary {
}

files: [
"mapitem.cpp",
"mapitem.h",
"maploader.cpp",
"maploader.h",
"mapref.h",
"tiledquickplugin.cpp",
"tiledquickplugin.h",
"tilelayeritem.cpp",
"tilelayeritem.h",
"tilesnode.cpp",
"tilesnode.h",
"tiledquickplugin.h"
]

property string installBase: qbs.targetOS.contains("darwin") ? "Tiled Quick.app/Contents/" : ""
Expand Down
1 change: 1 addition & 0 deletions tiled.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Project {
"dist/win/installer.qbs",
"docs",
"src/libtiled",
"src/libtiledquick",
"src/plugins",
"src/qtpropertybrowser",
"src/qtsingleapplication",
Expand Down

0 comments on commit 1d005ed

Please sign in to comment.