Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a linking problem by moving Stroke::save() and load() into header #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 0 additions & 36 deletions gesture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "gesture.h"
#include "prefdb.h"

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
Expand All @@ -35,41 +34,6 @@ RTriple create_triple(float x, float y, Time t) {
return e;
}

template<class Archive> void Stroke::save(Archive & ar, const unsigned int version) const {
std::vector<Point> ps;
for (unsigned int i = 0; i < size(); i++)
ps.push_back(points(i));
ar & ps;
ar & button;
ar & trigger;
ar & timeout;
ar & modifiers;
}

template<class Archive> void Stroke::load(Archive & ar, const unsigned int version) {
std::vector<Point> ps;
ar & ps;
if (ps.size()) {
stroke_t *s = stroke_alloc(ps.size());
for (std::vector<Point>::iterator i = ps.begin(); i != ps.end(); ++i)
stroke_add_point(s, i->x, i->y);
stroke_finish(s);
stroke.reset(s, &stroke_free);
}
if (version == 0) return;
ar & button;
if (version >= 2)
ar & trigger;
if (version < 4 && (!button || trigger == (int)prefs.button.get().button))
trigger = 0;
if (version < 3)
return;
ar & timeout;
if (version < 5)
return;
ar & modifiers;
}

Stroke::Stroke(PreStroke &ps, int trigger_, int button_, unsigned int modifiers_, bool timeout_) : trigger(trigger_), button(button_), modifiers(modifiers_), timeout(timeout_) {
if (ps.valid()) {
stroke_t *s = stroke_alloc(ps.size());
Expand Down
37 changes: 35 additions & 2 deletions gesture.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef __GESTURE_H__
#define __GESTURE_H__

#include "prefdb.h"
#include "stroke.h"
#include <gdkmm.h>
#include <vector>
Expand Down Expand Up @@ -83,8 +84,40 @@ class Stroke {
static Glib::RefPtr<Gdk::Pixbuf> pbEmpty;

BOOST_SERIALIZATION_SPLIT_MEMBER()
template<class Archive> void load(Archive & ar, const unsigned int version);
template<class Archive> void save(Archive & ar, const unsigned int version) const;
template<class Archive> void load(Archive & ar, const unsigned int version) {
std::vector<Point> ps;
ar & ps;
if (ps.size()) {
stroke_t *s = stroke_alloc(ps.size());
for (std::vector<Point>::iterator i = ps.begin(); i != ps.end(); ++i)
stroke_add_point(s, i->x, i->y);
stroke_finish(s);
stroke.reset(s, &stroke_free);
}
if (version == 0) return;
ar & button;
if (version >= 2)
ar & trigger;
if (version < 4 && (!button || trigger == (int)prefs.button.get().button))
trigger = 0;
if (version < 3)
return;
ar & timeout;
if (version < 5)
return;
ar & modifiers;

}
template<class Archive> void save(Archive & ar, const unsigned int version) const {
std::vector<Point> ps;
for (unsigned int i = 0; i < size(); i++)
ps.push_back(points(i));
ar & ps;
ar & button;
ar & trigger;
ar & timeout;
ar & modifiers;
}
public:
int trigger;
int button;
Expand Down