From 07c3d31d38bb7dc1550b2b280af416a686d7ed62 Mon Sep 17 00:00:00 2001 From: Inventor Xtreme Date: Sun, 29 Mar 2026 03:00:16 -0400 Subject: [PATCH] ui rewrite --- Makefile | 6 +- src/main.cpp | 364 ++++++++++++++++++++++------------------- src/summarymanager.cpp | 45 +++++ src/summarymanager.hpp | 18 ++ 4 files changed, 265 insertions(+), 168 deletions(-) create mode 100644 src/summarymanager.cpp create mode 100644 src/summarymanager.hpp diff --git a/Makefile b/Makefile index 156fdd0..49715ae 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ CC = gcc CXX = g++ -CPPFLAGS = -g -CFLAGS = -g -LDFLAGS = -g +CPPFLAGS = -g #-O3 -ffast-math +CFLAGS = -g #-O3 -ffast-math +LDFLAGS = -g #-O3 -ffast-math LDLIBS = -lfltk -lcurl -lfltk_images diff --git a/src/main.cpp b/src/main.cpp index 51b70f1..6c22e51 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,255 +1,289 @@ #include +#include #include #include #include - -#include "testcpp.hpp" #include "curlwrap.hpp" #include "images.h" +#include "summarymanager.hpp" +#include "testcpp.hpp" -#include -#include -#include #include +#include #include +#include +#include #include -#include -#include +#include +#include +#include #include #include #include using namespace std; - struct Person { - std::string year; - std::string name; + std::string year; + std::string name; - Person(std::string& y, std::string& n) : year(y), name(n) {} - std::string toString() const { - return "{(Person): " + year + ", " + name + "}"; - } + Person(std::string &y, std::string &n) : year(y), name(n) {} + std::string toString() const { + return "{(Person): " + year + ", " + name + "}"; + } }; -std::ostream& operator<<(std::ostream& os, const Person& e) { - //os << "{(Person): " << e.year << ", " << e.name << "}"; - os << e.toString(); - return os; +std::ostream &operator<<(std::ostream &os, const Person &e) { + // os << "{(Person): " << e.year << ", " << e.name << "}"; + os << e.toString(); + return os; } - struct BasicEntry { - Person A; - Person B; + Person A; + Person B; - std::string matchlink; + std::string matchlink; - int Apercent; - int Bpercent; - - std::string toString() const { - return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + + ", " + std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}"; - } + int Apercent; + int Bpercent; + std::string toString() const { + return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + +", " + + std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}"; + } }; -std::ostream& operator<<(std::ostream& os, const BasicEntry& e) { - //os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}"; - os << e.toString(); - return os; +std::ostream &operator<<(std::ostream &os, const BasicEntry &e) { + // os << "{(BasicEntry): " << e.A << ", " << e.B << ", " << e.matchlink << "}"; + os << e.toString(); + return os; } - - struct Selected { - Fl_Multi_Browser& browser; - Selected(Fl_Multi_Browser& browser_in) : browser(browser_in) {} + Fl_Multi_Browser &browser; + Selected(Fl_Multi_Browser &browser_in) : browser(browser_in) {} }; -void show_callback(Fl_Widget *w, void * data) { - Selected * rdata = (Selected *) data; +void show_callback(Fl_Widget *w, void *data) { + Selected *rdata = (Selected *)data; - auto s = rdata->browser.size() + 1; - - for (size_t i = 0; i < s; i++) { - if (rdata->browser.selected(i)) { - fl_alert("%s", rdata->browser.text(i)); - } - } + auto s = rdata->browser.size() + 1; + for (size_t i = 0; i < s; i++) { + if (rdata->browser.selected(i)) { + fl_alert("%s", rdata->browser.text(i)); + } + } } - std::vector MakeEntires(std::string filename) { - std::vector out; - - std::ifstream matches(filename); + std::vector out; - if (!matches.is_open()) { - std::cout << "Err reading " <" || line == "" ) break; - } else if ( (linenum - 15) % 3 == 1) { - line2 = line; + std::string line1; + std::string line2; - // std::cout << "Debug: L1: " << line1 << std::endl; - // std::cout << "Debug: L2: " << line2 << std::endl; + size_t linenum = 1; // One indexed like devtools + while (std::getline(matches, line)) { + if (linenum < 15) { - - auto firstquote = line1.find("\""); - // printf("fq: %ld\n", firstquote); - auto secondquote = line1.find("\"", firstquote+1); - // printf("sq: %ld\n", secondquote); - auto matchlink = line1.substr(firstquote+1, secondquote - (firstquote+1)); + } else { + if ((linenum - 15) % 3 == 0) { + line1 = line; + if (line == "" || line == "") + break; + } else if ((linenum - 15) % 3 == 1) { + line2 = line; - auto firstslash = line1.find("/", secondquote+ 1); - auto secondslash = line1.find("/", firstslash+1); - auto thirdslash = line1.find("/", secondslash+1); + // std::cout << "Debug: L1: " << line1 << std::endl; + // std::cout << "Debug: L2: " << line2 << std::endl; - auto firstpar = line1.find("(", thirdslash+1); - auto secondpar = line1.find(")", firstpar+1); - - auto p1class = line1.substr(firstslash+1, secondslash - firstslash - 1); - auto p1name = line1.substr(secondslash+1, thirdslash - secondslash -1); + auto firstquote = line1.find("\""); + // printf("fq: %ld\n", firstquote); + auto secondquote = line1.find("\"", firstquote + 1); + // printf("sq: %ld\n", secondquote); + auto matchlink = line1.substr(firstquote + 1, secondquote - (firstquote + 1)); - auto p1match = line1.substr(firstpar+1, secondpar - firstpar - 2); + auto firstslash = line1.find("/", secondquote + 1); + auto secondslash = line1.find("/", firstslash + 1); + auto thirdslash = line1.find("/", secondslash + 1); - std::cout << p1match << std::endl; + auto firstpar = line1.find("(", thirdslash + 1); + auto secondpar = line1.find(")", firstpar + 1); - firstquote = line2.find("\""); - secondquote = line2.find("\"", firstquote+1); - firstslash = line2.find("/", secondquote+1); - secondslash = line2.find("/", firstslash+1); - thirdslash = line2.find("/", secondslash+1); - firstpar = line2.find("(", thirdslash+1); - secondpar = line2.find(")", firstpar+1); + auto p1class = line1.substr(firstslash + 1, secondslash - firstslash - 1); + auto p1name = line1.substr(secondslash + 1, thirdslash - secondslash - 1); + auto p1match = line1.substr(firstpar + 1, secondpar - firstpar - 2); - auto p2class = line2.substr(firstslash+1, secondslash - (firstslash+1)); - auto p2name = line2.substr(secondslash+1, thirdslash - (secondslash+1)); + std::cout << p1match << std::endl; - auto p2match = line2.substr(firstpar+1, secondpar - firstpar - 2); - std::cout << p2match << std::endl; + firstquote = line2.find("\""); + secondquote = line2.find("\"", firstquote + 1); + firstslash = line2.find("/", secondquote + 1); + secondslash = line2.find("/", firstslash + 1); + thirdslash = line2.find("/", secondslash + 1); + firstpar = line2.find("(", thirdslash + 1); + secondpar = line2.find(")", firstpar + 1); - auto p1 = Person(p1class, p1name); + auto p2class = line2.substr(firstslash + 1, secondslash - (firstslash + 1)); + auto p2name = line2.substr(secondslash + 1, thirdslash - (secondslash + 1)); - auto p2 = Person(p2class, p2name); + auto p2match = line2.substr(firstpar + 1, secondpar - firstpar - 2); + std::cout << p2match << std::endl; - BasicEntry finent = {.A = p1, .B = p2, .matchlink = matchlink, .Apercent = std::stoi(p1match), .Bpercent = std::stoi(p2match) }; + auto p1 = Person(p1class, p1name); - out.push_back(finent); + auto p2 = Person(p2class, p2name); - } - } - linenum++; + BasicEntry finent = {.A = p1, + .B = p2, + .matchlink = matchlink, + .Apercent = std::stoi(p1match), + .Bpercent = std::stoi(p2match)}; - } - return out; + out.push_back(finent); + } + } + linenum++; + } + return out; } struct State { - std::vector entries; + std::vector entries; }; - -void changelayout(Fl_Widget * w, void * meow) { - std::pair * in = (std::pair* ) meow; - in->second.show(); - // in->second.parent()->redraw(); - // in->first.window()->redraw(); - //in->first.init_sizes(); - in->first.layout(); - //in->first.redraw(); +void changelayout(Fl_Widget *w, void *meow) { + std::pair *in = (std::pair *)meow; + in->second.show(); + // in->second.parent()->redraw(); + // in->first.window()->redraw(); + // in->first.init_sizes(); + in->first.layout(); + in->second.redraw(); + // in->first.redraw(); } -int main (int argc, char ** argv) { - if (argc < 2) { - std::cout << "Not enough args" << std::endl; - exit(1); - } +struct Topbar : Fl_Group { - - State s; - s.entries = MakeEntires(argv[1]); + Fl_PNG_Image inspectIcon; + Fl_Box *titleText; + Fl_Button *inspect; + Topbar(int x, int y, int w, int h) + : Fl_Group(x, y, w, h), + inspectIcon("Inspect", icon_inspect_file_png, icon_inspect_file_png_len) { - for (auto e : s.entries) { - std::cout << e << std::endl; - } + titleText = new Fl_Box(0, 0, 100, 50, "MossMan"); + titleText->labelsize(36); + titleText->labelfont(FL_TIMES | FL_BOLD); + titleText->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT); + inspect = new Fl_Button(950, 0, 50, 50); + resizable(titleText); + inspect->image(inspectIcon); + inspect->tooltip("Inspect Entr(ies)"); - Fl::scheme("base"); - auto window = std::make_unique(300, 300, 300, 300, "MossMan :D"); + end(); + } +}; - auto group = std::make_unique(0,0,300,300); - auto group2 = std::make_unique(0, 0, 300, 50); - auto box = std::make_unique(0,0,100,50,"MossMan"); - box->labelsize(36); - box->labelfont(FL_TIMES | FL_BOLD); - box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT); - auto button = std::make_unique(250, 0, 50, 50); - auto button2 = std::make_unique(200,0, 50, 50); - group2->resizable(*box); - group2->end(); +struct MainGui : Fl_Window { + Topbar *topbar; + Fl_Tile *tilebox; + Fl_Multi_Browser *list; + SummaryManager *summaryEditor; + MainGui() : Fl_Window(0, 0, 1000, 750, "MossMan :3") { + topbar = new Topbar(0, 0, 1000, 50); - auto group3 = std::make_unique(0,51,300, 250, Fl_Flex::HORIZONTAL); - // auto browser = std::make_unique(0,51,300,250); - // auto browser2 = std::make_unique(0,51,300,250); - auto browser = std::make_unique(0,0,0,0); - auto browser2 = std::make_unique(0,0,0,0); - browser2->hide(); - group3->end(); - std::pair saved(*group3, *browser2); - button2->callback(changelayout,&saved); + tilebox = new Fl_Tile(0, 50, 1000, 700); // parent is maingui, will be freed at decon + list = new Fl_Multi_Browser(0, 50, 150, 700); + summaryEditor = new SummaryManager(150, 50, 850, 700); - auto icon = std::make_unique("Inspect", icon_inspect_file_png, icon_inspect_file_png_len); - button->image(*icon); - button->tooltip("Inspect Entr(ies)"); - + tilebox->end(); - for (auto e : s.entries) { - auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name) + " (" + std::to_string(e.Apercent) + "%, " + std::to_string(e.Bpercent) + "%)"); - browser->add(h.c_str()); - } - + end(); - group->resizable(*group3); - group->end(); - + resizable(tilebox); + } +}; - window->resizable(*group); - window->end(); +int main(int argc, char **argv) { + if (argc < 2) { + std::cout << "Not enough args" << std::endl; + exit(1); + } + State s; + s.entries = MakeEntires(argv[1]); + for (auto e : s.entries) { + std::cout << e << std::endl; + } + Fl::scheme("base"); + // auto window = std::make_unique(300, 300, 300, 300, "MossMan :D"); + // auto group = std::make_unique(0,0,300,300); + // auto group2 = std::make_unique(0, 0, 300, 50); + // auto box = std::make_unique(0,0,100,50,"MossMan"); + // box->labelsize(36); + // box->labelfont(FL_TIMES | FL_BOLD); + // box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT); + // auto button = std::make_unique(250, 0, 50, 50); + // auto button2 = std::make_unique(200,0, 50, 50); + // group2->resizable(*box); + // group2->end(); - Selected callbackdata(*browser); + // auto group3 = std::make_unique(0,51,300, 250, Fl_Flex::HORIZONTAL); + // // auto browser = std::make_unique(0,51,300,250); + // // auto browser2 = std::make_unique(0,51,300,250); + // auto browser = std::make_unique(0,0,0,0); + // auto tabs = std::make_unique(0,0,300,300); + // //auto browser2 = std::make_unique(0,0,0,0); + // tabs->hide(); + // group3->end(); + // std::pair saved(*group3, *tabs); + // button2->callback(changelayout,&saved); - button->callback(show_callback, (void*) &callbackdata); + // auto icon = std::make_unique("Inspect", icon_inspect_file_png, + // icon_inspect_file_png_len); button->image(*icon); button->tooltip("Inspect Entr(ies)"); - window->show(); + // for (auto e : s.entries) { + // auto h = ((e.A.year + "/" + e.A.name) + " and " + (e.B.year + "/" + e.B.name) + " (" + + // std::to_string(e.Apercent) + "%, " + std::to_string(e.Bpercent) + "%)"); + // browser->add(h.c_str()); + // } + // group->resizable(*group3); + // group->end(); + // window->resizable(*group); + // window->end(); - - return Fl::run(); + // MainGui x; + + // Selected callbackdata(*browser); + + // button->callback(show_callback, (void*) &callbackdata); + + // window->show(); + + MainGui x; + x.show(); + + return Fl::run(); } diff --git a/src/summarymanager.cpp b/src/summarymanager.cpp new file mode 100644 index 0000000..6a4ae35 --- /dev/null +++ b/src/summarymanager.cpp @@ -0,0 +1,45 @@ +#include "summarymanager.hpp" +#include +#include +#include +#include +#include +#include + +SummaryManager::SummaryManager(int x, int y, int w, int h) + : Fl_Group(x, y, w, h), tabs(x, y, w, h) { + + Fl_Group *grp1 = new Fl_Group(x, y + 30, w, h - 30, "Tab1"); + { + Fl_Window *win1 = new Fl_Window(x, y + 30, w, h - 30, "Tab1W"); + std::cout << "here" << std::endl; + { + auto butt = new Fl_Button(0, 0, 100, 200, "test"); + } + win1->end(); + auto butt = new Fl_Button(0, 30, 100, 200, "nyaaa"); + } + grp1->end(); + // Fl_Group *grp2 = new Fl_Group(20, 30, 280, 170, "Tab2"); + // { + // } + // grp2->end(); + // Fl_Group *grp3 = new Fl_Group(20, 30, 280, 170, "Tab3"); + // { + // } + // grp3->end(); + // Fl_Group *grp4 = new Fl_Group(20, 30, 280, 170, "Tab4"); + // { + // } + // grp4->end(); + // Fl_Group *grp5 = new Fl_Group(20, 30, 280, 170, "Tab5"); + // { + // } + // grp5->end(); + tabs.end(); + tabs.handle_overflow(Fl_Tabs::OVERFLOW_DRAG); + + tabs.resizable(grp1); + + end(); +} diff --git a/src/summarymanager.hpp b/src/summarymanager.hpp new file mode 100644 index 0000000..c0672d4 --- /dev/null +++ b/src/summarymanager.hpp @@ -0,0 +1,18 @@ +#ifndef SUMMARYMANAGER_HEADER +#define SUMMARYMANAGER_HEADER + +#include +#include +#include +#include +#include + + +struct SummaryManager : Fl_Group { + SummaryManager(int x, int y, int w, int h); + Fl_Tabs tabs; + std::vector items; + +}; + +#endif