ui rewrite

This commit is contained in:
Inventor Xtreme 2026-03-29 03:00:16 -04:00
parent dad0aefa78
commit 07c3d31d38
4 changed files with 265 additions and 168 deletions

View file

@ -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

View file

@ -1,28 +1,29 @@
#include <FL/Enumerations.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Widget.H>
#include <fstream>
#include <iostream>
#include "testcpp.hpp"
#include "curlwrap.hpp"
#include "images.h"
#include "summarymanager.hpp"
#include "testcpp.hpp"
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Multi_Browser.H>
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/fl_ask.H>
#include <FL/Fl_Flex.H>
#include <FL/Fl_Multi_Browser.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Window.H>
#include <FL/fl_ask.H>
#include <memory>
#include <string>
#include <vector>
using namespace std;
struct Person {
std::string year;
std::string name;
@ -39,7 +40,6 @@ std::ostream& operator<<(std::ostream& os, const Person& e) {
return os;
}
struct BasicEntry {
Person A;
Person B;
@ -50,9 +50,9 @@ struct BasicEntry {
int Bpercent;
std::string toString() const {
return "{(BasicEntry): " + A.toString() + ", " + B.toString() + ", " + matchlink + + ", " + std::to_string(Apercent) + "%, " + std::to_string(Bpercent) + "%}";
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 << "}";
@ -60,8 +60,6 @@ std::ostream& operator<<(std::ostream& os, const BasicEntry& e) {
return os;
}
struct Selected {
Fl_Multi_Browser &browser;
Selected(Fl_Multi_Browser &browser_in) : browser(browser_in) {}
@ -77,10 +75,8 @@ void show_callback(Fl_Widget *w, void * data) {
fl_alert("%s", rdata->browser.text(i));
}
}
}
std::vector<BasicEntry> MakeEntires(std::string filename) {
std::vector<BasicEntry> out;
@ -104,14 +100,14 @@ std::vector<BasicEntry> MakeEntires(std::string filename) {
} else {
if ((linenum - 15) % 3 == 0) {
line1 = line;
if (line == "</td></tr></tbody></table>" || line == "</TABLE>" ) break;
if (line == "</td></tr></tbody></table>" || line == "</TABLE>")
break;
} else if ((linenum - 15) % 3 == 1) {
line2 = line;
// std::cout << "Debug: L1: " << line1 << std::endl;
// std::cout << "Debug: L2: " << line2 << std::endl;
auto firstquote = line1.find("\"");
// printf("fq: %ld\n", firstquote);
auto secondquote = line1.find("\"", firstquote + 1);
@ -140,7 +136,6 @@ std::vector<BasicEntry> MakeEntires(std::string filename) {
firstpar = line2.find("(", thirdslash + 1);
secondpar = line2.find(")", firstpar + 1);
auto p2class = line2.substr(firstslash + 1, secondslash - (firstslash + 1));
auto p2name = line2.substr(secondslash + 1, thirdslash - (secondslash + 1));
@ -151,14 +146,16 @@ std::vector<BasicEntry> MakeEntires(std::string filename) {
auto p2 = Person(p2class, p2name);
BasicEntry finent = {.A = p1, .B = p2, .matchlink = matchlink, .Apercent = std::stoi(p1match), .Bpercent = std::stoi(p2match) };
BasicEntry finent = {.A = p1,
.B = p2,
.matchlink = matchlink,
.Apercent = std::stoi(p1match),
.Bpercent = std::stoi(p2match)};
out.push_back(finent);
}
}
linenum++;
}
return out;
}
@ -167,89 +164,126 @@ struct State {
std::vector<BasicEntry> entries;
};
void changelayout(Fl_Widget *w, void *meow) {
std::pair<Fl_Flex&, Fl_Multi_Browser&> * in = (std::pair<Fl_Flex&, Fl_Multi_Browser&>* ) meow;
std::pair<Fl_Flex &, SummaryManager &> *in = (std::pair<Fl_Flex &, SummaryManager &> *)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();
}
struct Topbar : Fl_Group {
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) {
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)");
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);
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);
tilebox->end();
end();
resizable(tilebox);
}
};
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<Fl_Window>(300, 300, 300, 300, "MossMan :D");
// auto window = std::make_unique<Fl_Window>(300, 300, 300, 300, "MossMan :D");
auto group = std::make_unique<Fl_Group>(0,0,300,300);
auto group2 = std::make_unique<Fl_Group>(0, 0, 300, 50);
auto box = std::make_unique<Fl_Box>(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<Fl_Button>(250, 0, 50, 50);
auto button2 = std::make_unique<Fl_Button>(200,0, 50, 50);
group2->resizable(*box);
group2->end();
// auto group = std::make_unique<Fl_Group>(0,0,300,300);
// auto group2 = std::make_unique<Fl_Group>(0, 0, 300, 50);
// auto box = std::make_unique<Fl_Box>(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<Fl_Button>(250, 0, 50, 50);
// auto button2 = std::make_unique<Fl_Button>(200,0, 50, 50);
// group2->resizable(*box);
// group2->end();
// auto group3 = std::make_unique<Fl_Flex>(0,51,300, 250, Fl_Flex::HORIZONTAL);
// // auto browser = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
// // auto browser2 = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
// auto browser = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
// auto tabs = std::make_unique<SummaryManager>(0,0,300,300);
// //auto browser2 = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
// tabs->hide();
// group3->end();
// std::pair<Fl_Flex&, SummaryManager&> saved(*group3, *tabs);
// button2->callback(changelayout,&saved);
auto group3 = std::make_unique<Fl_Flex>(0,51,300, 250, Fl_Flex::HORIZONTAL);
// auto browser = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
// auto browser2 = std::make_unique<Fl_Multi_Browser>(0,51,300,250);
auto browser = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
auto browser2 = std::make_unique<Fl_Multi_Browser>(0,0,0,0);
browser2->hide();
group3->end();
std::pair<Fl_Flex&, Fl_Multi_Browser&> saved(*group3, *browser2);
button2->callback(changelayout,&saved);
// auto icon = std::make_unique<Fl_PNG_Image>("Inspect", icon_inspect_file_png,
// icon_inspect_file_png_len); button->image(*icon); button->tooltip("Inspect Entr(ies)");
auto icon = std::make_unique<Fl_PNG_Image>("Inspect", icon_inspect_file_png, icon_inspect_file_png_len);
button->image(*icon);
button->tooltip("Inspect Entr(ies)");
// 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();
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());
}
// window->resizable(*group);
// window->end();
// MainGui x;
group->resizable(*group3);
group->end();
window->resizable(*group);
window->end();
Selected callbackdata(*browser);
button->callback(show_callback, (void*) &callbackdata);
window->show();
// Selected callbackdata(*browser);
// button->callback(show_callback, (void*) &callbackdata);
// window->show();
MainGui x;
x.show();
return Fl::run();
}

45
src/summarymanager.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "summarymanager.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Window.H>
#include <iostream>
#include <memory>
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();
}

18
src/summarymanager.hpp Normal file
View file

@ -0,0 +1,18 @@
#ifndef SUMMARYMANAGER_HEADER
#define SUMMARYMANAGER_HEADER
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tabs.H>
#include <memory>
#include <vector>
struct SummaryManager : Fl_Group {
SummaryManager(int x, int y, int w, int h);
Fl_Tabs tabs;
std::vector<Fl_Button*> items;
};
#endif