Complete Modern desktop widgets and file libraries (by Codex)
This commit is contained in:
1 parent
db89d889f7
commit
31bcf93205
43 files changed
+3134
-484
No files matched your search
+34
-6
@@ -22,12 +22,15 @@
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include "modern/ui/ui_preferences.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
#include "modern/ui/ticket_popover.hpp"
|
||||
#include "modern/ui/view.hpp"
|
||||
#include "version.hpp"
|
||||
#include <RmlUi/Core.h>
|
||||
#include <cstring>
|
||||
#include <RmlUi/Core/Elements/ElementFormControl.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlInput.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
|
||||
@@ -171,6 +174,15 @@ public:
|
||||
const auto &r = entries_.at(token).raster;
|
||||
return {token, r.width, r.height};
|
||||
}
|
||||
Picture generated_png(const std::string &slot,const std::string &png){
|
||||
const auto token="modern-generated-"+slot+".png",digest=content::sha256(png);
|
||||
auto found=entries_.find(token);
|
||||
if(found==entries_.end()||found->second.key!=digest){
|
||||
if(auto loaded=loaded_sources_.find(token);loaded!=loaded_sources_.end()){Rml::ReleaseTexture(loaded->second,this);loaded_sources_.erase(loaded);}
|
||||
entries_[token]={digest,false,1280,editor::images::decode(png,".png")};
|
||||
}
|
||||
const auto &r=entries_.at(token).raster;return {token,r.width,r.height};
|
||||
}
|
||||
Picture local_image(const fs::path &file, int pixels) {
|
||||
const auto identity =
|
||||
editor::utf8(file) + ":" +
|
||||
@@ -393,6 +405,7 @@ class App final : public Rml::EventListener {
|
||||
std::string id;
|
||||
float x = 0, y = 0;
|
||||
double left = 0, top = 0;
|
||||
bool pinned=false;
|
||||
};
|
||||
Drag drag_;
|
||||
bool suppress_click_ = false;
|
||||
@@ -411,6 +424,8 @@ class App final : public Rml::EventListener {
|
||||
bool draw_playing_ = true;
|
||||
uint64_t draw_at_ = 0;
|
||||
#include "modern/ui/settings_state.inc"
|
||||
#include "modern/ui/widgets_state.inc"
|
||||
#include "modern/ui/files_state.inc"
|
||||
std::map<std::string, std::string> selections_;
|
||||
Rml::Element *element(const std::string &id) const {
|
||||
return doc_->GetElementById(id);
|
||||
@@ -438,7 +453,7 @@ class App final : public Rml::EventListener {
|
||||
fs::path user_dir() const {
|
||||
const auto id = world_ ? world_->manifest().value("id", std::string("none"))
|
||||
: std::string("none");
|
||||
return root_ / "userdata" / "ui-demo" / content::sha256(id);
|
||||
return (config_.userdata.empty() ? root_ / "userdata" : config_.userdata) / "ui-demo" / content::sha256(id);
|
||||
}
|
||||
std::string img(const std::string &key, double w, double h,
|
||||
bool world = false, bool cover = false, int pixels = 512) {
|
||||
@@ -587,6 +602,7 @@ class App final : public Rml::EventListener {
|
||||
}
|
||||
void load_world(const fs::path &file) {
|
||||
reset_settings();
|
||||
reset_files();
|
||||
auto next = Catalog::open(file);
|
||||
auto demo = std::make_unique<DemoSource>(next);
|
||||
ticket_.reset();
|
||||
@@ -621,6 +637,8 @@ class App final : public Rml::EventListener {
|
||||
almanac_match_.clear();
|
||||
almanac_tab_ = "lineups";
|
||||
desktop_ = Json::object();
|
||||
working_desktop_initialized_=false;working_desktop_base_=Json();
|
||||
files_default_key_.clear();files_default_picture_=Picture();files_default_pending_=false;
|
||||
ticket_ =
|
||||
std::make_unique<TicketPopover>(*context_, *doc_, *source_, [this] {
|
||||
focus_ticket_ = true;
|
||||
@@ -787,8 +805,6 @@ class App final : public Rml::EventListener {
|
||||
const std::string &player = {}, int size = 56,
|
||||
int gap = 10, bool overtraining = false);
|
||||
std::string render_settings();
|
||||
std::string render_save(bool save);
|
||||
std::string render_desktop_tools(const std::string &);
|
||||
void render_context();
|
||||
void context_menu(const std::string &id, int x, int y);
|
||||
void drag_event(Rml::Event &);
|
||||
@@ -854,6 +870,8 @@ class App final : public Rml::EventListener {
|
||||
almanac_list_width_ = -1.f;
|
||||
// A window-close save prompt can leave a menu while its local dialog is
|
||||
// open. Never keep that menu's modal/input gate in the destination view.
|
||||
if(menu_=="widgets" && last_rendered_menu_=="widgets")widget_remember_scroll();
|
||||
files_before_render();
|
||||
if (menu_ != last_rendered_menu_) {
|
||||
if(last_rendered_menu_=="settings")reset_settings();
|
||||
statistics_trophy_ = Json::object();
|
||||
@@ -1042,6 +1060,8 @@ class App final : public Rml::EventListener {
|
||||
ticket_->update();
|
||||
if (needs_render_)
|
||||
render();
|
||||
if(files_default_pending_&&!files_capturing_){update_files_default_thumbnail();render();}
|
||||
persist_working_desktop();
|
||||
render_popup();
|
||||
render_context();
|
||||
context_->Update();
|
||||
@@ -1076,6 +1096,8 @@ class App final : public Rml::EventListener {
|
||||
if (menu_ == "scorers" || menu_ == "fairplay") rankings_restore_scroll();
|
||||
if (menu_ == "statistics") statistics_restore_scroll();
|
||||
if (menu_ == "settings") settings_after_render();
|
||||
files_after_render();
|
||||
if(menu_=="widgets" && widget_restore_scroll_){if(auto *gallery=element("widget-gallery"))gallery->SetScrollTop(widget_gallery_scroll_);widget_restore_scroll_=false;}
|
||||
if (!report_option_to_scroll_.empty()) {
|
||||
if (auto *node = element(report_option_to_scroll_))
|
||||
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
@@ -1085,7 +1107,7 @@ class App final : public Rml::EventListener {
|
||||
renderer_.BeginFrame();
|
||||
context_->Render();
|
||||
renderer_.EndFrame();
|
||||
video_.present();
|
||||
if(!files_capturing_)video_.present();
|
||||
dirty_ = false;
|
||||
}
|
||||
void screenshot(const fs::path &file) {
|
||||
@@ -1320,12 +1342,15 @@ public:
|
||||
while (got) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
if (source_ && scene_ != "main") {
|
||||
quit_closes_app_=true;
|
||||
dispatch("context-quit", nullptr);
|
||||
} else
|
||||
closed_ = true;
|
||||
} else {
|
||||
if (event.type == SDL_WINDOWEVENT)
|
||||
if (event.type == SDL_WINDOWEVENT) {
|
||||
if(event.window.event==SDL_WINDOWEVENT_FOCUS_LOST)desktop_cancel_drag();
|
||||
resize();
|
||||
}
|
||||
int w, h, pw, ph;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
video_.drawable_size(pw, ph);
|
||||
@@ -1354,7 +1379,10 @@ public:
|
||||
}
|
||||
};
|
||||
#include "modern/ui/controls.inc"
|
||||
#include "modern/ui/desktop_screens.inc"
|
||||
#include "modern/ui/widgets_screens.inc"
|
||||
#include "modern/ui/widgets_controls.inc"
|
||||
#include "modern/ui/files_screens.inc"
|
||||
#include "modern/ui/files_controls.inc"
|
||||
#include "modern/ui/screens.inc"
|
||||
#include "modern/ui/sports_screens.inc"
|
||||
#include "modern/ui/calendar_screen.inc"
|
||||
|
||||
Reference in new issue
Block a user