<commit_before>// Copyright (c) 2015, <NAME>.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#include "MeterWnd.h"
#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")
#include <VersionHelpers.h>
#include <sstream>

#include "Animation.h"
#include "AnimationFactory.h"
#include "../DisplayManager.h"

MeterWnd::MeterWnd(LPCWSTR className, LPCWSTR title, HINSTANCE hInstance) :
LayeredWnd(className, title, hInstance, NULL, WINDOW_STYLES) {

}

MeterWnd::~MeterWnd() {
    delete _hideAnimation;
    delete _composite;
    DeleteClones();
}

void MeterWnd::Update() {
    CLOG(L"Updating meter window");
    using namespace Gdiplus;

    bool dirty = (_composite == NULL);

    for (Meter *meter : _meters) {
        if (meter->Dirty() == true) {
            dirty = true;
            break;
        }
    }

    if (dirty) {
        QCLOG(L"Contents have changed; redrawing");

        if (_composite) {
            delete _composite;
        }

        Rect bgRect(0, 0, _background->GetWidth(), _background->GetHeight());
        _composite = _background->Clone(bgRect, PixelFormat32bppARGB);
        Graphics graphics(_composite);

        for (Meter *meter : _meters) {
            CLOG(L"Drawing meter:\n%s", meter->ToString().c_str());
            meter->Draw(_composite, &graphics);
        }
    }

    Bitmap(_composite);
    UpdateClones();
}

void MeterWnd::AddMeter(Meter *meter) {
    _meters.push_back(meter);
}

void MeterWnd::MeterLevels(float value) {
    for (Meter *meter : _meters) {
        meter->Value(value);
    }
}

void MeterWnd::HideAnimation(AnimationTypes::HideAnimation anim, int speed) {
    delete _hideAnimation;
    _hideAnimation = AnimationFactory::Create(anim, speed);
}

void MeterWnd::VisibleDuration(int duration) {
    _visibleDuration = duration;
}

bool MeterWnd::DisableFullscreen() {
    return _disableFullscreen;
}

void MeterWnd::DisableFullscreen(bool disable) {
    _disableFullscreen = disable;
}

bool MeterWnd::DisableDirectX() {
    return _disableDirectX;
}

void MeterWnd::DisableDirectX(bool disable) {
    _disableDirectX = disable;
    if (disable == true) {
        _d3dDevice = new D3DDevice(Window::Handle());
    }
}

void MeterWnd::BackgroundImage(Gdiplus::Bitmap *background) {
    _background = background;
}

bool MeterWnd::EnableGlass(Gdiplus::Bitmap *mask) {
    bool result = LayeredWnd::EnableGlass(mask);
    ApplyClonesGlass();
    return result;
}

void MeterWnd::Show(bool animate) {
    if (_visible == false) {
        UpdateWindowPosition();

        bool disabled = false;
        if (_disableFullscreen
                && DisplayManager::IsFullscreen(Window::Handle())) {
            CLOG(L"not showing (fs)");
            disabled = true;
        }<commit_msg>Remove D3D/FS method implementations<commit_after>// Copyright (c) 2015, <NAME>.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#include "MeterWnd.h"
#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")
#include <VersionHelpers.h>
#include <sstream>

#include "Animation.h"
#include "AnimationFactory.h"
#include "../DisplayManager.h"

MeterWnd::MeterWnd(LPCWSTR className, LPCWSTR title, HINSTANCE hInstance) :
LayeredWnd(className, title, hInstance, NULL, WINDOW_STYLES) {

}

MeterWnd::~MeterWnd() {
    delete _hideAnimation;
    delete _composite;
    DeleteClones();
}

void MeterWnd::Update() {
    CLOG(L"Updating meter window");
    using namespace Gdiplus;

    bool dirty = (_composite == NULL);

    for (Meter *meter : _meters) {
        if (meter->Dirty() == true) {
            dirty = true;
            break;
        }
    }

    if (dirty) {
        QCLOG(L"Contents have changed; redrawing");

        if (_composite) {
            delete _composite;
        }

        Rect bgRect(0, 0, _background->GetWidth(), _background->GetHeight());
        _composite = _background->Clone(bgRect, PixelFormat32bppARGB);
        Graphics graphics(_composite);

        for (Meter *meter : _meters) {
            CLOG(L"Drawing meter:\n%s", meter->ToString().c_str());
            meter->Draw(_composite, &graphics);
        }
    }

    Bitmap(_composite);
    UpdateClones();
}

void MeterWnd::AddMeter(Meter *meter) {
    _meters.push_back(meter);
}

void MeterWnd::MeterLevels(float value) {
    for (Meter *meter : _meters) {
        meter->Value(value);
    }
}

void MeterWnd::HideAnimation(AnimationTypes::HideAnimation anim, int speed) {
    delete _hideAnimation;
    _hideAnimation = AnimationFactory::Create(anim, speed);
}

void MeterWnd::VisibleDuration(int duration) {
    _visibleDuration = duration;
}

void MeterWnd::BackgroundImage(Gdiplus::Bitmap *background) {
    _background = background;
}

bool MeterWnd::EnableGlass(Gdiplus::Bitmap *mask) {
    bool result = LayeredWnd::EnableGlass(mask);
    ApplyClonesGlass();
    return result;
}

void MeterWnd::Show(bool animate) {
    if (_visible == false) {
        UpdateWindowPosition();

        bool disabled = false;
        if (_disableFullscreen
                && DisplayManager::IsFullscreen(Window::Handle())) {
            CLOG(L"not showing (fs)");
            disabled = true;
        }
{'fraction_non_alphanumeric': 0.1294866846777306, 'fraction_numerical': 0.004052489386337322, 'mean_word_length': 3.2379394930498773, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '2235292', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1672, 'n_words': 349}