Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "wobbly/third_party/allow_move_optional"]
path = wobbly/third_party/allow_move_optional
url = git://github.com/smspillaz/CopyMoveConstrainedOptional
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably split out this change into a separate commit

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo RUN apt-get update >> Dockerfile; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo RUN apt-get install -y meson ninja-build build-essential git pkg-config libglib2.0-dev gir1.2-glib-2.0 gobject-introspection libgirepository1.0-dev >> Dockerfile; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t withgit .; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "cd /root && TRAVIS=true CC=$CC CXX=$CXX meson -Db_sanitize=address,undefined -Dwerror=true builddir && ninja -C builddir && G_SLICE=always-malloc ./builddir/tests/windowfx_wobbly_test --gtest_color=yes"; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "cd /root && TRAVIS=true CC=$CC CXX=$CXX meson -Db_sanitize=address,undefined -Dwerror=true builddir && ninja -C builddir && G_SLICE=always-malloc ./builddir/tests/animation_test --gtest_color=yes"; fi

81 changes: 81 additions & 0 deletions animation-glib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# /animation-glib/meson.build
#
# Build the libanimation-glib library.
#
# Copyright (C) 2017, 2018 Endless Mobile, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

api_version = '0'

animation_glib_toplevel_headers = ['vector.h']
animation_glib_toplevel_introspectable_sources = ['vector.cpp']

animation_glib_introspectable_sources = []
animation_glib_private_sources = []
animation_glib_headers = []
animation_glib_headers_subdir = 'animation-glib'

subdir('wobbly')

animation_glib_introspectable_sources += files(animation_glib_toplevel_introspectable_sources)
animation_glib_headers += files(animation_glib_toplevel_headers)

install_headers(animation_glib_toplevel_headers, subdir: animation_glib_headers_subdir)

animation_glib_sources = animation_glib_introspectable_sources + animation_glib_private_sources

glib = dependency('glib-2.0')
gobject = dependency('gobject-2.0')

animation_glib_lib = shared_library(
'animation-glib',
animation_glib_sources,
soversion: api_version,
install: true,
include_directories: [ animation_inc ],
dependencies: [ glib, gobject, animation_dep ]
)

animation_glib_dep = declare_dependency(
link_with: animation_glib_lib,
include_directories: [ animation_inc ],
)

introspection_sources = [ animation_glib_introspectable_sources, animation_glib_headers ]

gnome = import('gnome')
gnome.generate_gir(
animation_glib_lib,
extra_args: ['--warn-all', '--warn-error'],
identifier_prefix: 'Animation',
include_directories: animation_inc,
includes: ['GLib-2.0', 'GObject-2.0'],
install: true,
namespace: 'Animation',
nsversion: api_version,
sources: introspection_sources,
symbol_prefix: 'animation'
)

pkg = import('pkgconfig')
pkg.generate(
description: 'Library to provide 2D surface animations (GObject Binding)',
name: 'libanimation-glib',
filebase: 'libanimation-glib-' + api_version,
version: meson.project_version(),
libraries: animation_glib_lib,
install_dir: join_paths(get_option('libdir'), 'pkgconfig')
)
22 changes: 11 additions & 11 deletions wobbly-glib/vector.cpp → animation-glib/vector.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* wobbly-glib/vector.cpp
* animation-glib/vector.cpp
*
* Copyright 2018 Endless Mobile, Inc.
*
* libwobbly is free software: you can redistribute it and/or
* libanimation is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* libwobbly is distributed in the hope that it will be useful,
* libanimation is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
Expand All @@ -21,20 +21,20 @@
* type implementation.
*/

#include <wobbly-glib/vector.h>
#include <animation-glib/vector.h>

static gpointer
wobbly_vector_copy (gpointer ptr)
animation_vector_copy (gpointer ptr)
{
WobblyVector *src = reinterpret_cast <WobblyVector *> (ptr);
WobblyVector *dst = g_new0 (WobblyVector, 1);
AnimationVector *src = reinterpret_cast <AnimationVector *> (ptr);
AnimationVector *dst = g_new0 (AnimationVector, 1);

*dst = *src;

return reinterpret_cast <gpointer> (dst);
}

G_DEFINE_BOXED_TYPE (WobblyVector,
wobbly_vector,
wobbly_vector_copy,
g_free)
G_DEFINE_BOXED_TYPE (AnimationVector,
animation_vector,
animation_vector_copy,
g_free);
37 changes: 37 additions & 0 deletions animation-glib/vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* animation-glib/vector.h
*
* Copyright 2018 Endless Mobile, Inc.
*
* libanimation is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* libanimation is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with eos-companion-app-service. If not, see
* <http://www.gnu.org/licenses/>.
*
* GObject Interface for "wobbly" textures, 2D vector type.
*/
#pragma once

#include <glib-object.h>

G_BEGIN_DECLS

typedef struct {
double x;
double y;
} AnimationVector;

#define ANIMATION_TYPE_VECTOR animation_vector_get_type ()

GType animation_vector_get_type (void);

G_END_DECLS
118 changes: 118 additions & 0 deletions animation-glib/wobbly/anchor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* animation-glib/wobbly/anchor.cpp
*
* Copyright 2018 Endless Mobile, Inc.
*
* libanimation is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* libanimation is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with eos-companion-app-service. If not, see
* <http://www.gnu.org/licenses/>.
*
* GObject Interface for "wobbly" textures, Anchor
* type implementation.
*/

#include <animation-glib/wobbly/anchor.h>

#include <animation/wobbly/wobbly.h>

#include "wobbly-anchor-private.h"

struct _AnimationWobblyAnchor
{
GObject parent_instance;
};

typedef struct _AnimationWobblyAnchorPrivate
{
wobbly::Anchor *anchor;
} AnimationWobblyAnchorPrivate;

G_DEFINE_TYPE_WITH_PRIVATE (AnimationWobblyAnchor,
animation_wobbly_anchor,
G_TYPE_OBJECT);

/**
* animation_wobbly_anchor_move_by:
* @anchor: A #AnimationWobblyAnchor
* @vector: A #AnimationVector to move the anchor by
*
* Move the anchor by @vector, causing force to be exerted
* on the underlying anchor's model.
*/
void
animation_wobbly_anchor_move_by (AnimationWobblyAnchor *anchor,
AnimationVector vector)
{
AnimationWobblyAnchorPrivate *priv =
reinterpret_cast <AnimationWobblyAnchorPrivate *> (animation_wobbly_anchor_get_instance_private (anchor));

if (priv->anchor != nullptr)
priv->anchor->MoveBy (animation::Point (vector.x, vector.y));
}


/**
* animation_wobbly_anchor_release:
* @anchor: A #AnimationWobblyAnchor
*
* Release the anchor, allowing the relevant control points
* to move freely and have force exerted on them. Attempting
* to move the anchor past this point is inert.
*/
void
animation_wobbly_anchor_release (AnimationWobblyAnchor *anchor)
{
AnimationWobblyAnchorPrivate *priv =
reinterpret_cast <AnimationWobblyAnchorPrivate *> (animation_wobbly_anchor_get_instance_private (anchor));

if (priv->anchor != nullptr)
{
delete priv->anchor;
priv->anchor = nullptr;
}
}

static void
animation_wobbly_anchor_finalize (GObject *object)
{
AnimationWobblyAnchor *anchor = ANIMATION_WOBBLY_ANCHOR (object);

animation_wobbly_anchor_release (anchor);
}

static void
animation_wobbly_anchor_init (AnimationWobblyAnchor *store)
{
}


static void
animation_wobbly_anchor_class_init (AnimationWobblyAnchorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);

object_class->finalize = animation_wobbly_anchor_finalize;
}

AnimationWobblyAnchor *
animation_wobbly_anchor_new_for_native_anchor_rvalue (wobbly::Anchor &&anchor)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to specify the rvalue in the function name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, though I guess I just wanted to make it clear that it wants an rvalue reference in case anyone was wondering why things might not compile when they pass it an lvalue :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this as is for now

{
AnimationWobblyAnchor *anchor_object =
ANIMATION_WOBBLY_ANCHOR (g_object_new (ANIMATION_TYPE_WOBBLY_ANCHOR, NULL));
AnimationWobblyAnchorPrivate *priv =
reinterpret_cast <AnimationWobblyAnchorPrivate *> (animation_wobbly_anchor_get_instance_private (anchor_object));

priv->anchor = new wobbly::Anchor (std::move (anchor));

return anchor_object;
}
43 changes: 43 additions & 0 deletions animation-glib/wobbly/anchor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* animation-glib/wobbly/anchor.h
*
* Copyright 2018 Endless Mobile, Inc.
*
* libanimation is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* libanimation is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with eos-companion-app-service. If not, see
* <http://www.gnu.org/licenses/>.
*
* GObject Interface for "wobbly" textures, Anchor type.
*
* An anchor is an object type privately holding an
* anchor. The owner can release the anchor, which happens
* implicitly when its ref-count drops to zero or when
* the release() method is called.
*/
#pragma once

#include <glib-object.h>

#include <animation-glib/vector.h>

G_BEGIN_DECLS

#define ANIMATION_TYPE_WOBBLY_ANCHOR animation_wobbly_anchor_get_type ()
G_DECLARE_FINAL_TYPE (AnimationWobblyAnchor, animation_wobbly_anchor, ANIMATION, WOBBLY_ANCHOR, GObject)

void animation_wobbly_anchor_move_by (AnimationWobblyAnchor *anchor,
AnimationVector vector);

void animation_wobbly_anchor_release (AnimationWobblyAnchor *anchor);

G_END_DECLS
21 changes: 21 additions & 0 deletions animation-glib/wobbly/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# /animation-glib/wobbly/meson.build
#
# Build the libanimation-glib library, wobbly component.
#
# See /LICENCE.md for Copyright information.

wobbly_introspectable_sources = [
'anchor.cpp',
'model.cpp'
]
wobbly_private_sources = ['wobbly-anchor-private.h']
wobbly_headers = [
'anchor.h',
'model.h'
]

animation_glib_introspectable_sources += files(wobbly_introspectable_sources)
animation_glib_private_sources += files(wobbly_private_sources)
animation_glib_headers += files(wobbly_headers)

install_headers(wobbly_headers, subdir: join_paths(animation_glib_headers_subdir, 'wobbly'))
Loading