From: Mikko Rasa Date: Mon, 21 Aug 2023 08:23:42 +0000 (+0300) Subject: Minor refactoring X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=103ceeace366c6d80fce323438b31b9bbc167915;p=libs%2Fgltk.git Minor refactoring --- diff --git a/source/container.cpp b/source/container.cpp index 64e3a9a..a8c3133 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -103,8 +103,7 @@ Widget *Container::find_descendant_at(int x, int y) const if(Container *cont = dynamic_cast(wdg)) { const Geometry &cgeom = wdg->get_geometry(); - Widget *wdg2 = cont->find_descendant_at(x-cgeom.x, y-cgeom.y); - if(wdg2) + if(Widget *wdg2 = cont->find_descendant_at(x-cgeom.x, y-cgeom.y)) return wdg2; } return wdg; diff --git a/source/image.cpp b/source/image.cpp index 655ecc2..448da7b 100644 --- a/source/image.cpp +++ b/source/image.cpp @@ -55,22 +55,18 @@ void Image::set_keep_aspect(bool ka) void Image::update_icon() { - if(style) - { - Root *root = find_ancestor(); - if(root) - { - if(icon_name.empty()) - image = nullptr; - else - image = &root->get_resources().get(icon_name); - signal_autosize_changed.emit(); - mark_rebuild(); - return; - } - } - image = nullptr; + if(!style) + return; + + Root *root = find_ancestor(); + if(!root) + return; + + if(!icon_name.empty()) + image = &root->get_resources().get(icon_name); + signal_autosize_changed.emit(); + mark_rebuild(); } void Image::rebuild_special(const Part &part) diff --git a/source/layout.h b/source/layout.h index 2e58505..2d34b7a 100644 --- a/source/layout.h +++ b/source/layout.h @@ -1,7 +1,6 @@ #ifndef MSP_GLTK_LAYOUT_H_ #define MSP_GLTK_LAYOUT_H_ -#include #include #include #include diff --git a/source/panel.h b/source/panel.h index e9744fd..ab83de0 100644 --- a/source/panel.h +++ b/source/panel.h @@ -72,8 +72,6 @@ protected: static TypeRegistry widget_registry; static bool widget_registry_init_done; - Panel(const Panel &); - Panel &operator=(const Panel &); public: Panel(); virtual ~Panel(); diff --git a/source/part.cpp b/source/part.cpp index dbccc06..aacc52a 100644 --- a/source/part.cpp +++ b/source/part.cpp @@ -44,7 +44,7 @@ Part::Loader::Loader(Part &p, Resources &r): add("size", &Loader::size); } -Part::Loader::~Loader() +void Part::Loader::finish() { for(unsigned i=0; ipart==&part) - { - parts.erase(next, current); - break; - } + current = find_if(next, parts.end(), [&part](const CachedPart &p){ return p.part==∂ }); + if(current!=parts.end()) + parts.erase(next, current); if(current==parts.end()) current = parts.insert(next, CachedPart()); diff --git a/source/widget.cpp b/source/widget.cpp index 4d99000..b7dcfc5 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "container.h" #include "resources.h" #include "root.h" @@ -131,11 +132,7 @@ void Widget::update_style() else { string sname = get_class(); - if(!style_name.empty()) - { - sname += '-'; - sname += style_name; - } + append(sname, "-", style_name); style = &root->get_resources().get