<commit_before>//
//  View.h
//  Cinder-ControlRoom
//
//  Created by <NAME> on 02 Jul 2014.
//  Copyright 2014 Chorded Constructions. All rights reserved.
//

#pragma once

#include "cinder/app/App.h"

namespace Cinder { namespace ControlRoom {

using namespace ci;
using namespace ci::app;

typedef std::shared_ptr<class View> ViewRef;

class View : public std::enable_shared_from_this<View> {
public:
    ~View();

    inline void setFrame(const Rectf& frame) {
        mFrame = frame;
    }
    inline Rectf getFrame() const {
        return mFrame;
    }
    inline Rectf getBounds() const {
        return Rectf(Vec2f(0.0f, 0.0f), mFrame.getSize());
    }

    inline ViewRef getSuperview() const {
        return mSuperview;
    }
    inline std::vector<ViewRef> getSubviews() const {
        return mSubviews;
    }
    inline void addSubview(const ViewRef& view) {
        mSubviews.push_back(view);
        view->setSuperview(shared_from_this());
    }
    inline void removeFromSuperview() {
        mSuperview->removeSubview(shared_from_this());
    }
    bool isDescendantOfView(const ViewRef& view);

    inline void setBackgroundColor(const Color& color) {
        mBackgroundColor = color;
    }
    inline Color getBackgroundColor() const {
        return mBackgroundColor;
    }

    inline void setHidden(bool hidden) {
        mHidden = hidden;
    }
    inline bool isHidden() const {
        return mHidden;
    }

    virtual void draw();

    virtual void mouseDown(MouseEvent event) {}
    virtual void mouseDrag(MouseEvent event) {}
    virtual void mouseUp(MouseEvent event) {}

    Vec2i convertPointFromView(const Vec2f& point, const ViewRef& view);
    Vec2i convertPointToView(const Vec2i& point, const ViewRef& view);

protected:
    View(const Rectf& frame);

    inline void setSuperview(const ViewRef& view) {
        mSuperview = view;
    }
    inline void removeSubview(const ViewRef& view) {
        mSubviews.erase(std::find(mSubviews.begin(), mSubviews.end(), view));
        view->setSuperview(nullptr);
    }

    Rectf mFrame;

    ViewRef mSuperview;
    std::vector<ViewRef> mSubviews;

    Color mBackgroundColor;
    bool mHidden;
};<commit_msg>fix destructor crash on bad weak pointer, oups.<commit_after>//
//  View.h
//  Cinder-ControlRoom
//
//  Created by <NAME> on 02 Jul 2014.
//  Copyright 2014 Chorded Constructions. All rights reserved.
//

#pragma once

#include "cinder/app/App.h"

namespace Cinder { namespace ControlRoom {

using namespace ci;
using namespace ci::app;

typedef std::shared_ptr<class View> ViewRef;

class View : public std::enable_shared_from_this<View> {
public:
    ~View();

    inline void setFrame(const Rectf& frame) {
        mFrame = frame;
    }
    inline Rectf getFrame() const {
        return mFrame;
    }
    inline Rectf getBounds() const {
        return Rectf(Vec2f(0.0f, 0.0f), mFrame.getSize());
    }

    inline ViewRef getSuperview() const {
        return mSuperview;
    }
    inline std::vector<ViewRef> getSubviews() const {
        return mSubviews;
    }
    inline void addSubview(const ViewRef& view) {
        mSubviews.push_back(view);
        view->setSuperview(shared_from_this());
    }
    inline void removeFromSuperview() {
        if (!mSuperview) {
            return;
        }
        mSuperview->removeSubview(shared_from_this());
    }
    bool isDescendantOfView(const ViewRef& view);

    inline void setBackgroundColor(const Color& color) {
        mBackgroundColor = color;
    }
    inline Color getBackgroundColor() const {
        return mBackgroundColor;
    }

    inline void setHidden(bool hidden) {
        mHidden = hidden;
    }
    inline bool isHidden() const {
        return mHidden;
    }

    virtual void draw();

    virtual void mouseDown(MouseEvent event) {}
    virtual void mouseDrag(MouseEvent event) {}
    virtual void mouseUp(MouseEvent event) {}

    Vec2i convertPointFromView(const Vec2f& point, const ViewRef& view);
    Vec2i convertPointToView(const Vec2i& point, const ViewRef& view);

protected:
    View(const Rectf& frame);

    inline void setSuperview(const ViewRef& view) {
        mSuperview = view;
    }
    inline void removeSubview(const ViewRef& view) {
        if (!view) {
            return;
        }
        mSubviews.erase(std::find(mSubviews.begin(), mSubviews.end(), view));
        view->setSuperview(nullptr);
    }

    Rectf mFrame;

    ViewRef mSuperview;
    std::vector<ViewRef> mSubviews;

    Color mBackgroundColor;
    bool mHidden;
};
{'fraction_non_alphanumeric': 0.10247349823321555, 'fraction_numerical': 0.008392226148409895, 'mean_word_length': 2.854468085106383, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5056464', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1374, 'n_words': 359}