Skip to content

Commit

Permalink
Added drag and drop support
Browse files Browse the repository at this point in the history
Fixed UTF8 search
Improved playlist loading
MilkDrop now put in it's own DLL - first step in plugin system
Cleaned up code a little bit
  • Loading branch information
las3rlars committed Jun 16, 2016
1 parent 87f3f55 commit 089f80d
Show file tree
Hide file tree
Showing 22 changed files with 1,531 additions and 977 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MilkDropVisualizer : public wxGLCanvas
~MilkDropVisualizer();
void updatePCM(short *data);


protected:
void OnPaint(wxPaintEvent &event);
void OnSize(wxSizeEvent &event);
Expand Down
189 changes: 189 additions & 0 deletions projectMPlugin/ProjectMPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#include "ProjectMPlugin.h"

#include <wx/window.h>
#include <wx/glcanvas.h>
#include <wx/frame.h>
#include <wx/thread.h>
#include <wx/dynlib.h>

#include <process.h>

#include "MilkDropVisualizer.h"

IMPLEMENT_APP_NO_MAIN(ProjectMPluginApp)

wxDEFINE_EVENT(PLUGIN_CLOSE_EVENT, wxCommandEvent);
wxDEFINE_EVENT(PLUGIN_LOADED_EVENT, wxCommandEvent);

wxCriticalSection gs_wxStartupCS;
HANDLE gs_wxMainThread = nullptr;

static const int CMD_SHOW_WINDOW = wxNewId();
static const int CMD_TERMINATE = wxNewId();


unsigned wxSTDCALL ProjectMPluginAppLauncher(void *event)
{
const HINSTANCE hInstance = wxDynamicLibrary::MSWGetModuleHandle
("projectMPlugin", &gs_wxMainThread);

if (!hInstance)
return 0;

wxDISABLE_DEBUG_SUPPORT();

wxInitializer wxInit;
if (!wxInit.IsOk())
return 0;

HANDLE hEvent = *(static_cast<HANDLE*>(event));

if (!SetEvent(hEvent))
return 0;

wxEntry(hInstance);

return 1;
}

extern "C"
{

void start(wxWindow *parent)
{
wxCriticalSectionLocker lock(gs_wxStartupCS);
if (!gs_wxMainThread) {
HANDLE hEvent = CreateEvent
(
NULL,
FALSE,
FALSE,
NULL
);

if (!hEvent) {
return;
}

gs_wxMainThread = (HANDLE)_beginthreadex
(
NULL,
0,
&ProjectMPluginAppLauncher,
&hEvent,
0,
NULL
);

if (!gs_wxMainThread) {
CloseHandle(hEvent);
return;
}

WaitForSingleObject(hEvent, INFINITE);
CloseHandle(hEvent);
}


wxThreadEvent *event = new wxThreadEvent(wxEVT_THREAD, CMD_SHOW_WINDOW);
event->SetString("projectMPlugin");
event->SetPayload(parent);
wxQueueEvent(wxApp::GetInstance(), event);
}

void stop()
{
wxCriticalSectionLocker lock(gs_wxStartupCS);

if (!gs_wxMainThread) {
return;
}

wxThreadEvent *event = new wxThreadEvent(wxEVT_THREAD, CMD_TERMINATE);
wxQueueEvent(wxApp::GetInstance(), event);

WaitForSingleObject(gs_wxMainThread, INFINITE);
CloseHandle(gs_wxMainThread);
gs_wxMainThread = NULL;
}

const char *getName()
{
return "projectM";
}

Plugin *getPlugin()
{
return static_cast<ProjectMPluginApp*>(wxApp::GetInstance());
}
}

ProjectMPluginApp::ProjectMPluginApp()
{
SetExitOnFrameDelete(false);

Connect(CMD_SHOW_WINDOW,
wxEVT_THREAD,
wxThreadEventHandler(ProjectMPluginApp::OnShowWindow));
Connect(CMD_TERMINATE,
wxEVT_THREAD,
wxThreadEventHandler(ProjectMPluginApp::OnTerminate));
}
void ProjectMPluginApp::OnShowWindow(wxThreadEvent &event)
{
wxWindow *parent = event.GetPayload<wxWindow*>();
start(parent);
}

void ProjectMPluginApp::OnTerminate(wxThreadEvent &event)
{
ExitMainLoop();
}


/*ProjectMPlugin::ProjectMPlugin() : milkDropFrame(nullptr), milkDropVisualizer(nullptr)
{
}*/

wxWindow *ProjectMPluginApp::start(wxWindow *parent)
{
// Only allow one window at the time
//if (milkDropFrame != nullptr) return;
this->parent = parent;
milkDropFrame = new wxFrame(nullptr, wxID_ANY, wxString("wxSpot - MilkDrop"), wxDefaultPosition, wxSize(512, 288));


int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 0, 0 };

milkDropFrame->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) {
wxThreadEvent *terminateEvent = new wxThreadEvent(PLUGIN_CLOSE_EVENT, wxID_ANY);
wxQueueEvent(parent, terminateEvent);
event.Skip();
});

milkDropVisualizer = new MilkDropVisualizer(milkDropFrame, args);

milkDropVisualizer->Bind(wxEVT_KEY_DOWN, [=](wxKeyEvent &event) {
if (event.GetModifiers() == wxMOD_ALT && event.GetKeyCode() == WXK_RETURN) {
milkDropFrame->ShowFullScreen(!milkDropFrame->IsFullScreen());
}
else if (event.GetKeyCode() == WXK_SPACE) {
//next();
}
});
SetTopWindow(milkDropFrame);
milkDropFrame->Show();
wxThreadEvent *terminateEvent = new wxThreadEvent(PLUGIN_LOADED_EVENT, wxID_ANY);
wxQueueEvent(parent, terminateEvent);

return milkDropFrame;

//plugin->start(NULL);
}

void ProjectMPluginApp::updatePCM(short *data)
{
if (milkDropVisualizer)
milkDropVisualizer->updatePCM(data);
}
30 changes: 30 additions & 0 deletions projectMPlugin/ProjectMPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include "../wxSpot/Plugin.h"

class MilkDropVisualizer;
class SoundManager;
class ProjectMPlugin;
class MainFrame;

class ProjectMPluginApp : public Plugin
{
public:
ProjectMPluginApp();
//ProjectMPlugin *plugin;

private:
wxWindow *start(wxWindow *parent);

void OnShowWindow(wxThreadEvent &event);
void OnTerminate(wxThreadEvent &event);

virtual void updatePCM(short *data);

wxWindow *parent;
wxFrame *milkDropFrame;
MilkDropVisualizer *milkDropVisualizer;


};


91 changes: 91 additions & 0 deletions projectMPlugin/projectMPlugin.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2C913758-8F8D-4A69-BD92-6E397F7BDA0A}</ProjectGuid>
<RootNamespace>projectMPlugin</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>D:\projekt\sdk\wxWidgets-3.0.2\include;D:\projekt\sdk\wxWidgets-3.0.2\lib\vc_lib\mswud;D:\Download\Web\projectM-complete-2.1.0-Source\projectM-complete-2.1.0-Source\src\libprojectM</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_HAS_EXCEPTIONS=0;DLLFUNCTIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>projectM.lib;wxmsw30ud_core.lib;wxbase30ud.lib;wxmsw30ud_gl.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\projekt\sdk\wxWidgets-3.0.2\lib\vc_lib;D:\Download\Web\projectM-complete-2.1.0-Source\projectM-complete-2.1.0-Source\out\src\libprojectM\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AssemblyDebug>true</AssemblyDebug>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>D:\projekt\sdk\wxWidgets-3.0.2\include;D:\projekt\sdk\wxWidgets-3.0.2\lib\vc_lib\mswu;D:\Download\Web\projectM-complete-2.1.0-Source\projectM-complete-2.1.0-Source\src\libprojectM</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<MinimalRebuild>true</MinimalRebuild>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>projectM.lib;wxmsw30u_core.lib;wxbase30u.lib;wxmsw30u_gl.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\projekt\sdk\wxWidgets-3.0.2\lib\vc_lib;D:\Download\Web\projectM-complete-2.1.0-Source\projectM-complete-2.1.0-Source\out\src\libprojectM\Release</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="MilkDropVisualizer.h" />
<ClInclude Include="ProjectMPlugin.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="MilkDropVisualizer.cpp" />
<ClCompile Include="ProjectMPlugin.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 089f80d

Please sign in to comment.