Skip to content

Commit

Permalink
adds ImGuiStyle to AgsImGui api
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Jun 6, 2020
1 parent 1feeea6 commit cfa92aa
Show file tree
Hide file tree
Showing 4 changed files with 767 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -52,6 +52,8 @@ add_library(agsimgui SHARED
agsimgui/AgsImVec2.h
agsimgui/AgsImVec4.cpp
agsimgui/AgsImVec4.h
agsimgui/AgsImGuiStyle.cpp
agsimgui/AgsImGuiStyle.h
agsimgui/SerialHelper.cpp
agsimgui/SerialHelper.h
agsimgui/agsimgui.cpp
Expand Down
59 changes: 59 additions & 0 deletions agsimgui/AgsImGuiStyle.cpp
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2020 Érico Vieira Porto
*
* This program is free software. You can use and redistribute it
* under the terms and conditions of the MIT License (see LICENCE).
*/

#include <cmath>
#include "AgsImGuiStyle.h"


//------------------------------------------------------------------------------

extern IAGSEngine* engine;

AgsImGuiStyleInterface AgsImGuiStyle_Interface;
AgsImGuiStyleReader AgsImGuiStyle_Reader;

const char* AgsImGuiStyleInterface::name = "ImGuiStyle";

//------------------------------------------------------------------------------
#include "SerialHelper.h"
using namespace SerialHelper;

int AgsImGuiStyleInterface::Dispose(const char* address, bool force)
{
delete ((AgsImGuiStyle*)address);
return (1);
}

//------------------------------------------------------------------------------

int AgsImGuiStyleInterface::Serialize(const char* address, char* buffer, int bufsize)
{
AgsImGuiStyle* agsImGuiStyle = (AgsImGuiStyle*)address;
char* ptr = buffer;
char* end = buffer + bufsize;


return (ptr - buffer);
}

//------------------------------------------------------------------------------

void AgsImGuiStyleReader::Unserialize(int key, const char* serializedData, int dataSize)
{
char* ptr = (char*) serializedData;

float val_x;
float val_y;


AgsImGuiStyle* agsImGuiStyle = new AgsImGuiStyle(key);

engine->RegisterUnserializedObject(key, agsImGuiStyle, &AgsImGuiStyle_Interface);
}

//..............................................................................

67 changes: 67 additions & 0 deletions agsimgui/AgsImGuiStyle.h
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2020 Érico Vieira Porto
*
* This program is free software. You can use and redistribute it
* under the terms and conditions of the MIT License (see LICENCE).
*/

#pragma once

#ifndef _AGSIMGUISTYLE_H
#define _AGSIMGUISTYLE_H

#include "plugin/agsplugin.h"
#include "imgui/imgui.h"

struct AgsImGuiStyle: ImGuiStyle {
public :
int id;
AgsImGuiStyle()
: ImGuiStyle(){
id = -1;
}

AgsImGuiStyle(int _id)
: ImGuiStyle(){
id = _id;
}
};

//------------------------------------------------------------------------------
// AGS interface instances

class AgsImGuiStyleInterface : public IAGSScriptManagedObject
{
public:
static const char* name;

AgsImGuiStyleInterface() {};

virtual int Dispose(const char* address, bool force);
virtual const char* GetType() { return (name); }
virtual int Serialize(const char* address, char* buffer, int bufsize);

};

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

class AgsImGuiStyleReader : public IAGSManagedObjectReader
{
public:

AgsImGuiStyleReader() {}

virtual void Unserialize(int key, const char* serializedData, int dataSize);

};

//------------------------------------------------------------------------------

extern AgsImGuiStyleInterface AgsImGuiStyle_Interface;
extern AgsImGuiStyleReader AgsImGuiStyle_Reader;

//------------------------------------------------------------------------------

#endif /* _AGSIMGUISTYLE_H */

//............

0 comments on commit cfa92aa

Please sign in to comment.