Commit 51bf7aa2 by Jessica Hawkwell

Made it build

1 parent 2ae5f937
...@@ -18,5 +18,5 @@ include_directories(AFTER SYSTEM ${CMAKE_BINARY_DIR}/deps/resvg/capi/include/) ...@@ -18,5 +18,5 @@ include_directories(AFTER SYSTEM ${CMAKE_BINARY_DIR}/deps/resvg/capi/include/)
add_subdirectory(deps) add_subdirectory(deps)
add_subdirectory(src/libnde) add_subdirectory(src/libnde)
#add_subdirectory(src/libntk) add_subdirectory(src/libntk)
add_subdirectory(src/NitroWin) add_subdirectory(src/NitroWin)
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: SettingsManager.cpp
* Author: jlhawkwell
*
* Created on March 29, 2018, 9:59 PM
*/
#include "SettingsManager.h"
namespace nitrogen {
SettingsManager::SettingsManager() {
}
}
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: SettingsManager.h
* Author: jlhawkwell
*
* Created on March 29, 2018, 9:59 PM
*/
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include <nde.h>
namespace nitrogen {
class SettingsManager : public gc {
public:
SettingsManager();
private:
};
}
#endif /* SETTINGSMANAGER_H */
...@@ -15,6 +15,8 @@ nitrogen/nwt/Border.cpp ...@@ -15,6 +15,8 @@ nitrogen/nwt/Border.cpp
nitrogen/nwt/Color.cpp nitrogen/nwt/Color.cpp
nitrogen/nwt/Component.cpp nitrogen/nwt/Component.cpp
nitrogen/nwt/ComponentEvent.cpp nitrogen/nwt/ComponentEvent.cpp
nitrogen/nwt/ComponentRenderer.cpp
nitrogen/nwt/ComponentRendererSVG.cpp
nitrogen/nwt/Container.cpp nitrogen/nwt/Container.cpp
nitrogen/nwt/Dimension.cpp nitrogen/nwt/Dimension.cpp
nitrogen/nwt/EmptyBorder.cpp nitrogen/nwt/EmptyBorder.cpp
...@@ -32,10 +34,8 @@ nitrogen/nwt/MouseAdapter.cpp ...@@ -32,10 +34,8 @@ nitrogen/nwt/MouseAdapter.cpp
nitrogen/nwt/MouseEvent.cpp nitrogen/nwt/MouseEvent.cpp
nitrogen/nwt/MouseListener.cpp nitrogen/nwt/MouseListener.cpp
nitrogen/nwt/NWTEvent.cpp nitrogen/nwt/NWTEvent.cpp
nitrogen/nwt/NativeGraphics.cpp
nitrogen/nwt/Point.cpp nitrogen/nwt/Point.cpp
nitrogen/nwt/Rectangle.cpp nitrogen/nwt/Rectangle.cpp
nitrogen/util/ComponentRenderer.cpp
) )
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "Component.h" #include "Component.h"
#include <nitrogen/nwt/ComponentRenderer.h>
namespace nitrogen { namespace nitrogen {
namespace nwt { namespace nwt {
...@@ -50,7 +52,7 @@ namespace nitrogen { ...@@ -50,7 +52,7 @@ namespace nitrogen {
parent = nullptr; parent = nullptr;
preferredSize = new Rectangle(0, 0); preferredSize = new Rectangle(0, 0);
renderer = new nitrogen::util::ComponentRenderer(new std::string("Component"), this); renderer = ComponentRenderer::create(new std::string("Component"), this);
} }
Border* Component::getBorder() { Border* Component::getBorder() {
......
...@@ -46,23 +46,20 @@ ...@@ -46,23 +46,20 @@
#include <nitrogen/nwt/MouseListener.h> #include <nitrogen/nwt/MouseListener.h>
#include <nitrogen/nwt/NWTEvent.h> #include <nitrogen/nwt/NWTEvent.h>
#include <nitrogen/nwt/Rectangle.h> #include <nitrogen/nwt/Rectangle.h>
#include <nitrogen/util/ComponentRenderer.h>
#include <vector> #include <vector>
namespace nitrogen { namespace nitrogen {
namespace util {
}
namespace nwt { namespace nwt {
class Border; class Border;
//class nitrogen::util::ComponentRenderer; class ComponentRenderer;
class Graphics; class Graphics;
class NWTEvent; class NWTEvent;
class MouseEvent; class MouseEvent;
class MouseListener; class MouseListener;
class Component : public Object { class Component : public Object {
friend class nitrogen::util::ComponentRenderer; friend class ComponentRenderer;
friend class Container; friend class Container;
public: public:
virtual Border* getBorder(); virtual Border* getBorder();
...@@ -110,7 +107,7 @@ namespace nitrogen { ...@@ -110,7 +107,7 @@ namespace nitrogen {
std::vector<MouseListener*>* ml_list; std::vector<MouseListener*>* ml_list;
Rectangle* preferredSize; Rectangle* preferredSize;
nitrogen::util::ComponentRenderer* renderer; ComponentRenderer* renderer;
Component(); Component();
virtual void processEvent(NWTEvent *e); virtual void processEvent(NWTEvent *e);
......
...@@ -33,19 +33,26 @@ ...@@ -33,19 +33,26 @@
#include "ComponentRenderer.h" #include "ComponentRenderer.h"
namespace nitrogen { #include <nitrogen/nwt/Color.h>
namespace util { #include <nitrogen/nwt/Component.h>
ComponentRenderer::ComponentRenderer(std::string* componentName, nwt::Component* component) { namespace nitrogen {
name = componentName; namespace nwt {
comp = component; class Component;
init();
ComponentRenderer* ComponentRenderer::create(std::string* componentName, Component* component) {
ComponentRenderer* cr = new ComponentRenderer();
cr->name = componentName;
cr->comp = component;
if (cr->name != nullptr && cr->name->length() > 0) {
cr->init();
cr->init2();
}
return cr;
} }
ComponentRenderer::ComponentRenderer(std::string& componentName, nwt::Component* component) { ComponentRenderer* ComponentRenderer::create(std::string& componentName, Component* component) {
name = &componentName; return create(&componentName, component);
comp = component;
init();
} }
void ComponentRenderer::init() { void ComponentRenderer::init() {
...@@ -72,14 +79,6 @@ namespace nitrogen { ...@@ -72,14 +79,6 @@ namespace nitrogen {
} }
window = XCreateSimpleWindow(nitrogen::disp, *w, x, y, width, height, 0, 0, nwt::Color::BLUE->getARGB()); window = XCreateSimpleWindow(nitrogen::disp, *w, x, y, width, height, 0, 0, nwt::Color::BLUE->getARGB());
XWindowAttributes attrs;
XGetWindowAttributes(nitrogen::disp, window, &attrs);
XRenderPictFormat *pf = XRenderFindVisualFormat(nitrogen::disp, attrs.visual);
surface = cairo_xlib_surface_create_with_xrender_format(nitrogen::disp, window, attrs.screen, pf, width, height);
cairo = cairo_create(surface);
/*svg_handle = */resvg_init();
} }
std::string* ComponentRenderer::getName() { std::string* ComponentRenderer::getName() {
...@@ -95,16 +94,6 @@ namespace nitrogen { ...@@ -95,16 +94,6 @@ namespace nitrogen {
} }
void ComponentRenderer::renderComponent() { void ComponentRenderer::renderComponent() {
//void resvg_cairo_render_to_canvas(const resvg_render_tree* rtree, const resvg_options* opt, resvg_size size, cairo_t* cr)
resvg_options ro;
ro.dpi = 96;
ro.draw_background = false;
ro.fit_to.type = resvg_fit_to_type::RESVG_FIT_TO_ZOOM;
resvg_size rs;
rs.width = comp->getSize()->getWidth();
rs.height = comp->getSize()->getWidth();
resvg_cairo_render_to_canvas(svg_tree, &ro, rs, cairo);
} }
} }
} }
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <ntk.h> #include <ntk.h>
#include <nitrogen/nwt/Component.h> //#include <nitrogen/nwt/Component.h>
#define RESVG_CAIRO_BACKEND #define RESVG_CAIRO_BACKEND
...@@ -49,12 +49,13 @@ ...@@ -49,12 +49,13 @@
#include <resvg.h> #include <resvg.h>
namespace nitrogen { namespace nitrogen {
namespace util { namespace nwt {
class Component;
class ComponentRenderer : public Object { class ComponentRenderer : public Object {
public: public:
ComponentRenderer(std::string* componentName, nwt::Component* component); static ComponentRenderer* create(std::string* componentName, Component* component);
ComponentRenderer(std::string& componentName, nwt::Component* component); static ComponentRenderer* create(std::string& componentName, Component* component);
std::string* getName(); std::string* getName();
Window* getWindow(); Window* getWindow();
...@@ -64,15 +65,16 @@ namespace nitrogen { ...@@ -64,15 +65,16 @@ namespace nitrogen {
protected: protected:
std::string* name; std::string* name;
Window window; Window window;
nwt::Component* comp; Component* comp;
cairo_t* cairo; cairo_t* cairo;
cairo_surface_t* surface; cairo_surface_t* surface;
//resvg_handle* svg_handle; //resvg_handle* svg_handle;
resvg_render_tree* svg_tree; resvg_render_tree* svg_tree;
ComponentRenderer();
void init(); void init();
virtual void init2();
private: private:
}; };
} }
} }
......
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: ComponentRendererSVG.cpp
* Author: jlhawkwell
*
* Created on March 29, 2018, 9:14 PM
*/
#include "ComponentRendererSVG.h"
namespace nitrogen {
namespace nwt {
void ComponentRendererSVG::init2() {
unsigned int width = comp->getSize()->getWidth();
unsigned int height = comp->getSize()->getHeight();
XWindowAttributes attrs;
XGetWindowAttributes(nitrogen::disp, window, &attrs);
XRenderPictFormat *pf = XRenderFindVisualFormat(nitrogen::disp, attrs.visual);
surface = cairo_xlib_surface_create_with_xrender_format(nitrogen::disp, window, attrs.screen, pf, width, height);
cairo = cairo_create(surface);
}
void ComponentRendererSVG::renderComponent() {
//void resvg_cairo_render_to_canvas(const resvg_render_tree* rtree, const resvg_options* opt, resvg_size size, cairo_t* cr)
resvg_options ro;
ro.dpi = 96;
ro.draw_background = false;
ro.fit_to.type = resvg_fit_to_type::RESVG_FIT_TO_ZOOM;
resvg_size rs;
rs.width = comp->getSize()->getWidth();
rs.height = comp->getSize()->getWidth();
resvg_cairo_render_to_canvas(svg_tree, &ro, rs, cairo);
}
}
}
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: ComponentRendererSVG.h
* Author: jlhawkwell
*
* Created on March 29, 2018, 9:14 PM
*/
#ifndef COMPONENTRENDERERSVG_H
#define COMPONENTRENDERERSVG_H
#include <ntk.h>
#include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/ComponentRenderer.h>
namespace nitrogen {
namespace nwt {
class ComponentRendererSVG : public ComponentRenderer {
public:
void renderComponent() override;
protected:
virtual void init2() override;
private:
ComponentRendererSVG();
};
}
}
#endif /* COMPONENTRENDERERSVG_H */
...@@ -165,6 +165,7 @@ namespace nitrogen { ...@@ -165,6 +165,7 @@ namespace nitrogen {
Container::Container() { Container::Container() {
lst = new std::vector<Component*>(); lst = new std::vector<Component*>();
renderer = ComponentRenderer::create(new std::string("Container"), this);
} }
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <ntk.h> #include <ntk.h>
#include <nitrogen/nwt/Component.h> #include <nitrogen/nwt/Component.h>
#include <nitrogen/nwt/ComponentRenderer.h>
#include <nitrogen/nwt/Graphics.h> #include <nitrogen/nwt/Graphics.h>
#include <nitrogen/nwt/LayoutManager.h> #include <nitrogen/nwt/LayoutManager.h>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!