Fixed minimum cmake version, added licence headers and formatted example + xoverlay
This commit is contained in:
parent
289cba707a
commit
c05ca050e7
@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# libpdraw
|
# libpdraw
|
||||||
cmake_minimum_required (VERSION 3.0.2)
|
cmake_minimum_required (VERSION 3.20)
|
||||||
project (libpdraw VERSION 1.0.0 LANGUAGES CXX)
|
project (libpdraw VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
@ -1,42 +1,61 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Libpdraw: A Versitile GUI for use with a primitive drawing system!
|
||||||
|
* Copyright (C) 2022 Rebekah Rowe
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <embed_resources.hpp>
|
|
||||||
#include "lib/xoverlay.h"
|
#include "lib/xoverlay.h"
|
||||||
|
#include "libpdraw/gui/gui.hpp"
|
||||||
|
#include <embed_resources.hpp>
|
||||||
|
#include <glez/detail/render.hpp>
|
||||||
#include <glez/draw.hpp>
|
#include <glez/draw.hpp>
|
||||||
#include <glez/glez.hpp>
|
#include <glez/glez.hpp>
|
||||||
#include <glez/detail/render.hpp>
|
|
||||||
#include "libpdraw/gui/gui.hpp"
|
|
||||||
|
|
||||||
//xorg conflict
|
// xorg conflict
|
||||||
#undef RootWindow
|
#undef RootWindow
|
||||||
|
|
||||||
#include "libpdraw/gui/widgets/slider.hpp"
|
#include "libpdraw/gui/widgets/slider.hpp"
|
||||||
#include "libpdraw/gui/widgets/titlebar.hpp"
|
#include "libpdraw/gui/widgets/titlebar.hpp"
|
||||||
//#include "gui/csplitcontainer.hpp"
|
//#include "gui/csplitcontainer.hpp"
|
||||||
#include "libpdraw/gui/widgets/textinput.hpp"
|
|
||||||
#include "libpdraw/gui/canvas.hpp"
|
#include "libpdraw/gui/canvas.hpp"
|
||||||
|
#include "libpdraw/gui/widgets/basebutton.hpp"
|
||||||
|
#include "libpdraw/gui/widgets/basewindow.hpp"
|
||||||
|
#include "libpdraw/gui/widgets/checkbox.hpp"
|
||||||
#include "libpdraw/gui/widgets/dropdown.hpp"
|
#include "libpdraw/gui/widgets/dropdown.hpp"
|
||||||
#include "libpdraw/gui/widgets/keyinput.hpp"
|
#include "libpdraw/gui/widgets/keyinput.hpp"
|
||||||
#include "libpdraw/gui/widgets/basebutton.hpp"
|
#include "libpdraw/gui/widgets/textinput.hpp"
|
||||||
#include "libpdraw/gui/widgets/checkbox.hpp"
|
|
||||||
#include "libpdraw/gui/widgets/basewindow.hpp"
|
|
||||||
|
|
||||||
#include "libpdraw/gui/listmenu/list.hpp"
|
|
||||||
#include "libpdraw/gui/listmenu/itemvariable.hpp"
|
|
||||||
#include "libpdraw/gui/listmenu/itemsublist.hpp"
|
#include "libpdraw/gui/listmenu/itemsublist.hpp"
|
||||||
#include "libpdraw/gui/listmenu/itemtitle.hpp"
|
#include "libpdraw/gui/listmenu/itemtitle.hpp"
|
||||||
|
#include "libpdraw/gui/listmenu/itemvariable.hpp"
|
||||||
|
#include "libpdraw/gui/listmenu/list.hpp"
|
||||||
#include "libpdraw/gui/tabbedmenu/cvarcontainer.hpp"
|
#include "libpdraw/gui/tabbedmenu/cvarcontainer.hpp"
|
||||||
#include "libpdraw/gui/tabbedmenu/menucontainer.hpp"
|
#include "libpdraw/gui/tabbedmenu/menucontainer.hpp"
|
||||||
#include "libpdraw/gui/tabbedmenu/menuwindow.hpp"
|
#include "libpdraw/gui/tabbedmenu/menuwindow.hpp"
|
||||||
|
|
||||||
#include "input.hpp"
|
#include "input.hpp"
|
||||||
|
|
||||||
static ui::Var<int> text({"nonya"}, "Editable Text", 1);
|
static ui::Var<int> text({ "nonya" }, "Editable Text", 1);
|
||||||
|
|
||||||
class TestWindow : public CBaseWindow {
|
class TestWindow : public CBaseWindow {
|
||||||
public:
|
public:
|
||||||
TestWindow() : CBaseWindow("root_test", nullptr) {
|
TestWindow()
|
||||||
|
: CBaseWindow("root_test", nullptr) {
|
||||||
Props()->SetBool("always_visible", false);
|
Props()->SetBool("always_visible", false);
|
||||||
Props()->SetBool("hover", false);
|
Props()->SetBool("hover", false);
|
||||||
SetMaxSize(1270, 1000);
|
SetMaxSize(1270, 1000);
|
||||||
@ -47,7 +66,7 @@ public:
|
|||||||
Props()->SetBool("visable", true);
|
Props()->SetBool("visable", true);
|
||||||
|
|
||||||
AddChild(new CTextLabel("button_label", this, "Button widget:"));
|
AddChild(new CTextLabel("button_label", this, "Button widget:"));
|
||||||
AddChild(new CBaseButton("button", this, "I'm Clickable!", [this](CBaseButton*){
|
AddChild(new CBaseButton("button", this, "I'm Clickable!", [this](CBaseButton*) {
|
||||||
std::cout << "Hey hey I was pressed!" << std::endl;
|
std::cout << "Hey hey I was pressed!" << std::endl;
|
||||||
this->button_clicked = !this->button_clicked;
|
this->button_clicked = !this->button_clicked;
|
||||||
}));
|
}));
|
||||||
@ -75,11 +94,8 @@ public:
|
|||||||
|
|
||||||
AddChild(new CTextLabel("key_input_label", this, "Key widget:"));
|
AddChild(new CTextLabel("key_input_label", this, "Key widget:"));
|
||||||
auto key_input = new CKeyInput("key_input");
|
auto key_input = new CKeyInput("key_input");
|
||||||
key_input->SetSize(78,10);
|
key_input->SetSize(78, 10);
|
||||||
AddChild(key_input);
|
AddChild(key_input);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual void Update() override {
|
virtual void Update() override {
|
||||||
this->CBaseWindow::Update();
|
this->CBaseWindow::Update();
|
||||||
@ -120,24 +136,23 @@ int main() {
|
|||||||
glez::init(xoverlay_library.width, xoverlay_library.height);
|
glez::init(xoverlay_library.width, xoverlay_library.height);
|
||||||
|
|
||||||
{
|
{
|
||||||
input::RefreshInput();
|
input::RefreshInput();
|
||||||
xoverlay_draw_begin();
|
xoverlay_draw_begin();
|
||||||
glez::begin();
|
glez::begin();
|
||||||
|
|
||||||
g_pGUI = new CatGUI();
|
g_pGUI = new CatGUI();
|
||||||
g_pGUI->Setup();
|
g_pGUI->Setup();
|
||||||
|
|
||||||
glez::end();
|
|
||||||
xoverlay_draw_end();
|
|
||||||
|
|
||||||
|
glez::end();
|
||||||
|
xoverlay_draw_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto test_window = new TestWindow();
|
auto test_window = new TestWindow();
|
||||||
|
|
||||||
g_pGUI->m_pRootWindow->AddChild(test_window);
|
g_pGUI->m_pRootWindow->AddChild(test_window);
|
||||||
|
|
||||||
using namespace menu::ncc;
|
using namespace menu::ncc;
|
||||||
//auto* list_menu = List::FromString(menu_list);
|
// auto* list_menu = List::FromString(menu_list);
|
||||||
auto* list_menu = new List();
|
auto* list_menu = new List();
|
||||||
list_menu->Fill(ui::BaseVar::GetList());
|
list_menu->Fill(ui::BaseVar::GetList());
|
||||||
list_menu->Props()->SetBool("brackets3", true);
|
list_menu->Props()->SetBool("brackets3", true);
|
||||||
@ -145,7 +160,6 @@ int main() {
|
|||||||
list_menu->Show();
|
list_menu->Show();
|
||||||
g_pGUI->m_pRootWindow->AddChild(list_menu);
|
g_pGUI->m_pRootWindow->AddChild(list_menu);
|
||||||
|
|
||||||
|
|
||||||
auto* tabbedmenu = new CMenuWindow("menu_window", g_pGUI->m_pRootWindow);
|
auto* tabbedmenu = new CMenuWindow("menu_window", g_pGUI->m_pRootWindow);
|
||||||
tabbedmenu->SetMaxSize(912, 410);
|
tabbedmenu->SetMaxSize(912, 410);
|
||||||
|
|
||||||
@ -157,23 +171,24 @@ int main() {
|
|||||||
tabbedmenu->AddTab("esp2", "Sub2");
|
tabbedmenu->AddTab("esp2", "Sub2");
|
||||||
tabbedmenu->AddTab("esp3", "Sub3");
|
tabbedmenu->AddTab("esp3", "Sub3");
|
||||||
|
|
||||||
//tabbedmenu->SetOffset((draw::width - 912) / 2, (draw::height - 410) / 2);
|
// tabbedmenu->SetOffset((draw::width - 912) / 2, (draw::height - 410) / 2);
|
||||||
g_pGUI->m_pRootWindow->AddChild(tabbedmenu);
|
g_pGUI->m_pRootWindow->AddChild(tabbedmenu);
|
||||||
|
|
||||||
for (auto& i : ui::BaseVar::GetList())
|
for (auto& i : ui::BaseVar::GetList())
|
||||||
printf("ui::BaseVar: %s\n", i->command_name.c_str());
|
printf("ui::BaseVar: %s\n", i->command_name.c_str());
|
||||||
xoverlay_show();
|
xoverlay_show();
|
||||||
while (1) {
|
while (1) {
|
||||||
input::RefreshInput();
|
input::RefreshInput();
|
||||||
// Must be called in that order.
|
// Must be called in that order.
|
||||||
xoverlay_draw_begin();
|
xoverlay_draw_begin();
|
||||||
glez::begin(); {
|
glez::begin();
|
||||||
|
{
|
||||||
|
|
||||||
//glez::draw::rect(100, 300, 200, 100, glez::rgba(255, 0, 128));
|
// glez::draw::rect(100, 300, 200, 100, glez::rgba(255, 0, 128));
|
||||||
//auto mouse = input::GetMouse();
|
// auto mouse = input::GetMouse();
|
||||||
//glez::draw::rect(mouse.first - 6, mouse.second - 6, 12, 12, glez::rgba(255, 0, 128));
|
// glez::draw::rect(mouse.first - 6, mouse.second - 6, 12, 12, glez::rgba(255, 0, 128));
|
||||||
g_pGUI->m_pRootWindow->Update();
|
g_pGUI->m_pRootWindow->Update();
|
||||||
//glez::draw::rect_textured(50, 50, 100, 100, g_pGUI->m_pRootWindow->GetColor(), dispenser, 0, 10, 40, 94, 7);
|
// glez::draw::rect_textured(50, 50, 100, 100, g_pGUI->m_pRootWindow->GetColor(), dispenser, 0, 10, 40, 94, 7);
|
||||||
/*bool pressed = input::GetKey(CatKey::CATKEY_MOUSE_1);
|
/*bool pressed = input::GetKey(CatKey::CATKEY_MOUSE_1);
|
||||||
if (!click) {
|
if (!click) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
@ -186,7 +201,8 @@ int main() {
|
|||||||
} else if (!pressed) {
|
} else if (!pressed) {
|
||||||
click = false;
|
click = false;
|
||||||
}*/
|
}*/
|
||||||
} glez::end();
|
}
|
||||||
|
glez::end();
|
||||||
xoverlay_draw_end();
|
xoverlay_draw_end();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* overlay.hpp
|
* Copyright (C) 2017 nullifiedcat
|
||||||
*
|
*
|
||||||
* Created on: Nov 8, 2017
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* Author: nullifiedcat
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
Loading…
x
Reference in New Issue
Block a user