From 771764f735ffe01cb170a10b24eb7dfc2a81b34d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 18 Aug 2023 23:54:47 +0300 Subject: [PATCH] Remove deprecated and unmaintained interfaces --- source/connector.cpp | 40 ------------ source/connector.h | 130 --------------------------------------- source/entry.cpp | 2 - source/entry.h | 3 - source/hslider.h | 2 - source/logic.cpp | 29 --------- source/logic.h | 52 ---------------- source/userinterface.cpp | 29 --------- source/userinterface.h | 58 ----------------- source/vslider.h | 2 - source/widget.cpp | 5 -- source/widget.h | 8 +-- 12 files changed, 1 insertion(+), 359 deletions(-) delete mode 100644 source/connector.cpp delete mode 100644 source/connector.h delete mode 100644 source/hslider.h delete mode 100644 source/logic.cpp delete mode 100644 source/logic.h delete mode 100644 source/userinterface.cpp delete mode 100644 source/userinterface.h delete mode 100644 source/vslider.h diff --git a/source/connector.cpp b/source/connector.cpp deleted file mode 100644 index 9915ecc..0000000 --- a/source/connector.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "connector.h" -#include "logic.h" - -using namespace std; - -namespace Msp { -namespace GLtk { - -Connector::~Connector() -{ - for(map::iterator i=actions.begin(); i!=actions.end(); ++i) - delete i->second; -} - -void Connector::connect(const Logic &logic) -{ - const list &logic_binds = logic.get_bindings(); - - for(list::const_iterator i=logic_binds.begin(); i!=logic_binds.end(); ++i) - { - ConnAction *action = get_item(actions, i->type); - action->connect(*this, *i->wdg, i->data); - } -} - -void Connector::add(const string &type, ConnAction *act) -{ - map::iterator i = actions.find(type); - if(i!=actions.end()) - { - delete i->second; - i->second = act; - } - else - actions[type] = act; -} - -} // namespace GLtk -} // namespace Msp diff --git a/source/connector.h b/source/connector.h deleted file mode 100644 index 739f67f..0000000 --- a/source/connector.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef MSP_GLTK_CONNECTOR_H_ -#define MSP_GLTK_CONNECTOR_H_ - -#include -#include -#include - -namespace Msp { -namespace GLtk { - -class Connector; -class Logic; -class Widget; - -class ConnAction -{ -public: - virtual void connect(Connector &conn, Widget &wdg, const std::string &data) const =0; - virtual ~ConnAction() { } -}; - -template -class ConnFunc0: public ConnAction -{ -public: - typedef void (C::*FuncType)(W &); - - ConnFunc0(FuncType f): func(f) { } - virtual void connect(Connector &conn, Widget &wdg, const std::string &) const - { - (dynamic_cast(conn).*func)(dynamic_cast(wdg)); - } - -private: - FuncType func; -}; - -template -class ConnFunc1: public ConnAction -{ -public: - typedef void (C::*FuncType)(W &, const std::string &); - - ConnFunc1(FuncType f): func(f) { } - virtual void connect(Connector &conn, Widget &wdg, const std::string &data) const - { - (dynamic_cast(conn).*func)(dynamic_cast(wdg), data); - } - -private: - FuncType func; -}; - -template -class ConnSignal: public ConnAction -{ -public: - ConnSignal(S W::*s, F f): signal(s), func(f) { } - virtual void connect(Connector &conn, Widget &wdg, const std::string &) const - { - (dynamic_cast(wdg).*signal).connect(sigc::mem_fun(&dynamic_cast(conn).get_object(), func)); - } - -private: - S W::*signal; - F func; -}; - -/** -Provides an interface for associating the bindings stored in a Logic object -with actual code. Derive a class from this and use the add functions to -specify handlers for each binding type. - -Bindings are normally handled by member functions of the Connector class. The -function must take a reference to a widget (of any type) as its first parameter. -If it takes a second parameter, the binding data is passed in as well. - -As a shortcut for simple connections, signals of widgets can be connected -directly to a handler object. For this to work, the Connector class must be a -public inner class of the handler class and it must have a get_object() member -function returning a reference to the handler object. - -TODO: lexical_cast the binding data (requires working around references) -*/ -class Connector -{ -private: - std::map actions; - -protected: - Connector() { } -public: - virtual ~Connector(); - - /** - Processes all bindings in the Logic object and calls appropriate handlers. - */ - void connect(const Logic &); - -protected: - /** - Adds a handler function for a binding. - */ - template - void add(const std::string &type, void (C::*func)(W &)) - { add(type, new ConnFunc0(func)); } - - /** - Adds a handler function for a binding. The binding data is passed in the - second parameter. - */ - template - void add(const std::string &type, void (C::*func)(W &, const std::string &)) - { add(type, new ConnFunc1(func)); } - - /** - Adds a signal connector for a binding. - */ - template - void add(const std::string &type, S W::*signal, F H::*func) - { add(type, new ConnSignal(signal, func)); } - -private: - void add(const std::string &, ConnAction *); -}; - -} // namespace GLtk -} // namespace Msp - -#endif diff --git a/source/entry.cpp b/source/entry.cpp index 53cb090..7ee7a32 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -332,8 +332,6 @@ bool Entry::navigate(Navigation nav) { if(nav==NAV_LEFT || nav==NAV_RIGHT || ((nav==NAV_DOWN || nav==NAV_UP) && multiline)) move_edit_position(nav, false); - else if(nav==NAV_ACCEPT && !signal_enter.empty()) - signal_enter.emit(); else return false; diff --git a/source/entry.h b/source/entry.h index 165b7c7..f7dd4ae 100644 --- a/source/entry.h +++ b/source/entry.h @@ -36,9 +36,6 @@ public: sigc::signal signal_selection_changed; sigc::signal signal_text_changed; - // Deprecated - sigc::signal signal_enter; - private: Text text; bool multiline; diff --git a/source/hslider.h b/source/hslider.h deleted file mode 100644 index 59222eb..0000000 --- a/source/hslider.h +++ /dev/null @@ -1,2 +0,0 @@ -// Deprecated, use slider.h instead -#include "slider.h" diff --git a/source/logic.cpp b/source/logic.cpp deleted file mode 100644 index e9542a6..0000000 --- a/source/logic.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "logic.h" - -using namespace std; - -namespace Msp { -namespace GLtk { - -Logic::Loader::Loader(Logic &l, const map &w): - DataFile::ObjectLoader(l), - widgets(w) -{ - add("bind", &Loader::bind); -} - -void Logic::Loader::bind(const string &wdg, const string &data) -{ - WidgetBinding act; - act.wdg = get_item(widgets, wdg); - - string::size_type colon = data.find(':'); - act.type = data.substr(0, colon); - if(colon!=string::npos) - act.data = data.substr(colon+1); - obj.bindings.push_back(act); -} - -} // namespace GLtk -} // namespace Msp diff --git a/source/logic.h b/source/logic.h deleted file mode 100644 index 1d25c6e..0000000 --- a/source/logic.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef MSP_GLTK_LOGIC_H_ -#define MSP_GLTK_LOGIC_H_ - -#include -#include -#include -#include -#include - -namespace Msp { -namespace GLtk { - -class Widget; - -/** -Stores use interface logic. This is represented as widget bindings. Each -binding has type and data. - -See also class Connector. -*/ -class Logic -{ -public: - class Loader: public DataFile::ObjectLoader - { - private: - const std::map &widgets; - - public: - Loader(Logic &, const std::map &); - private: - void bind(const std::string &, const std::string &); - }; - - struct WidgetBinding - { - Widget *wdg; - std::string type; - std::string data; - }; - -private: - std::list bindings; - -public: - const std::list &get_bindings() const { return bindings; } -}; - -} // namespace GLtk -} // namespace Msp - -#endif diff --git a/source/userinterface.cpp b/source/userinterface.cpp deleted file mode 100644 index 5bbe6ca..0000000 --- a/source/userinterface.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "userinterface.h" - -namespace Msp { -namespace GLtk { - -UserInterface::UserInterface(Resources &r, Graphics::Window &w): - root(r, w) -{ } - - -UserInterface::Loader::Loader(UserInterface &u): - ui(u) -{ - add("logic", &Loader::logic); - add("root", &Loader::root); -} - -void UserInterface::Loader::logic() -{ - load_sub(ui.logic, ui.widgets); -} - -void UserInterface::Loader::root() -{ - load_sub(ui.root, ui.widgets); -} - -} // namespace GLtk -} // namespace Msp diff --git a/source/userinterface.h b/source/userinterface.h deleted file mode 100644 index 04a9ccf..0000000 --- a/source/userinterface.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef MSP_GLTK_USERINTERFACE_H_ -#define MSP_GLTK_USERINTERFACE_H_ - -#include -#include "logic.h" -#include "root.h" - -namespace Msp { -namespace GLtk { - -/** -Encapsulates a Root widget and Logic associated with it. Allows looking up -widgets by name. -*/ -class UserInterface -{ -public: - class Loader: public DataFile::Loader - { - private: - UserInterface &ui; - - public: - Loader(UserInterface &); - private: - void logic(); - void root(); - }; - - typedef std::map WidgetMap; - -private: - WidgetMap widgets; - Root root; - Logic logic; - -public: - UserInterface(Resources &, Graphics::Window &); - Root &get_root() { return root; } - const Logic &get_logic() const { return logic; } - - template - W &get_widget(const std::string &n) const - { - return dynamic_cast(*get_item(widgets, n)); - } - - template - void get_widget(const std::string &n, W *&w) const - { - w = &get_widget(n); - } -}; - -} // namespace GLtk -} // namespace Msp - -#endif diff --git a/source/vslider.h b/source/vslider.h deleted file mode 100644 index 59222eb..0000000 --- a/source/vslider.h +++ /dev/null @@ -1,2 +0,0 @@ -// Deprecated, use slider.h instead -#include "slider.h" diff --git a/source/widget.cpp b/source/widget.cpp index 92cbaae..19949bb 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -169,11 +169,6 @@ void Widget::set_visible(bool v) signal_visibility_changed.emit(visible); } -void Widget::set_focusable(bool f) -{ - input_type = (f ? INPUT_TEXT : INPUT_NONE); -} - void Widget::set_focus() { if(!parent) diff --git a/source/widget.h b/source/widget.h index 555db7f..a941984 100644 --- a/source/widget.h +++ b/source/widget.h @@ -119,9 +119,6 @@ public: void set_enabled(bool); bool is_enabled() const { return !(state&DISABLED); } - // Deprecated - void set_focusable(bool); - protected: void set_state(State s) { set_state(s, s); } void clear_state(State s) { set_state(s, NORMAL); } @@ -164,12 +161,9 @@ public: virtual bool navigate(Navigation) { return false; } virtual void animate(const Time::TimeDelta &) { } protected: - virtual void on_size_change() { on_geometry_change(); } + virtual void on_size_change() { } virtual void on_style_change() { } virtual void on_reparent() { } - - // Deprecated - virtual void on_geometry_change() { } }; } // namespace GLtk -- 2.45.2