Last round of simplification of Signal/Slot classes
- merged all the common stuff from 0,1,2,3 argument versions into one common base class - removed ReturnType template parameter as it was instantiated with "void" everywhere and the current ignores the return value of the callbacks anyway
This commit is contained in:
parent
bef2039d2c
commit
0775350fee
18 changed files with 106 additions and 142 deletions
|
@ -43,7 +43,7 @@ public:
|
||||||
int scale() const { return *m_scale; } // scale factor for inside objects
|
int scale() const { return *m_scale; } // scale factor for inside objects
|
||||||
const std::string &name() { return m_name; }
|
const std::string &name() { return m_name; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual ButtonTheme &operator *() { return *this; }
|
virtual ButtonTheme &operator *() { return *this; }
|
||||||
virtual const ButtonTheme &operator *() const { return *this; }
|
virtual const ButtonTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
m_hl_selected_pixmap->pixmap().dontFree();
|
m_hl_selected_pixmap->pixmap().dontFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Signal<void> &reconfigSig() { return Theme::reconfigSig(); }
|
virtual Signal<> &reconfigSig() { return Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual MenuTheme &operator *() { return *this; }
|
virtual MenuTheme &operator *() { return *this; }
|
||||||
virtual const MenuTheme &operator *() const { return *this; }
|
virtual const MenuTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#ifndef FBTK_SIGNAL_HH
|
#ifndef FBTK_SIGNAL_HH
|
||||||
#define FBTK_SIGNAL_HH
|
#define FBTK_SIGNAL_HH
|
||||||
|
|
||||||
#include "RefCount.hh"
|
|
||||||
#include "Slot.hh"
|
#include "Slot.hh"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -35,7 +34,7 @@ namespace FbTk {
|
||||||
namespace SigImpl {
|
namespace SigImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class for all \c Signal[0...*] classes.
|
* Parent class for all \c Signal template classes.
|
||||||
* It handles the disconnect and holds all the slots. The connect must be
|
* It handles the disconnect and holds all the slots. The connect must be
|
||||||
* handled by the child class so it can do the type checking.
|
* handled by the child class so it can do the type checking.
|
||||||
*/
|
*/
|
||||||
|
@ -121,93 +120,66 @@ private:
|
||||||
unsigned m_emitting;
|
unsigned m_emitting;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EmptyArg {};
|
template <typename Arg1, typename Arg2, typename Arg3>
|
||||||
|
class SignalTemplate: public SignalHolder {
|
||||||
|
public:
|
||||||
|
template<typename Functor>
|
||||||
|
SlotID connect(const Functor& functor) {
|
||||||
|
return SignalHolder::connect(SlotPtr( new Slot<Arg1, Arg2, Arg3, Functor>(functor) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void emit_(Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
||||||
|
begin_emitting();
|
||||||
|
for ( Iterator it = begin(); it != end(); ++it ) {
|
||||||
|
if(*it)
|
||||||
|
static_cast<SigImpl::SlotTemplate<Arg1, Arg2, Arg3> &>(**it)(arg1, arg2, arg3);
|
||||||
|
}
|
||||||
|
end_emitting();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace SigImpl
|
} // namespace SigImpl
|
||||||
|
|
||||||
|
|
||||||
/// Specialization for three arguments.
|
/// Base template for three arguments.
|
||||||
template <typename ReturnType,
|
template <typename Arg1 = SigImpl::EmptyArg, typename Arg2 = SigImpl::EmptyArg, typename Arg3 = SigImpl::EmptyArg >
|
||||||
typename Arg1 = SigImpl::EmptyArg, typename Arg2 = SigImpl::EmptyArg, typename Arg3 = SigImpl::EmptyArg >
|
class Signal: public SigImpl::SignalTemplate<Arg1, Arg2, Arg3> {
|
||||||
class Signal: public SigImpl::SignalHolder {
|
|
||||||
public:
|
public:
|
||||||
void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3)
|
||||||
begin_emitting();
|
{ SigImpl::SignalTemplate<Arg1, Arg2, Arg3>::emit_(arg1, arg2, arg3); }
|
||||||
for ( Iterator it = begin(); it != end(); ++it ) {
|
|
||||||
if(*it)
|
|
||||||
static_cast<SigImpl::SlotBase3<ReturnType, Arg1, Arg2, Arg3> &>(**it)(arg1, arg2, arg3);
|
|
||||||
}
|
|
||||||
end_emitting();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Functor>
|
|
||||||
SlotID connect(const Functor& functor) {
|
|
||||||
return SignalHolder::connect(SlotPtr(
|
|
||||||
new SigImpl::Slot3<ReturnType, Arg1, Arg2, Arg3, Functor>(functor)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialization for two arguments.
|
/// Specialization for two arguments.
|
||||||
template <typename ReturnType, typename Arg1, typename Arg2>
|
template <typename Arg1, typename Arg2>
|
||||||
class Signal<ReturnType, Arg1, Arg2, SigImpl::EmptyArg>: public SigImpl::SignalHolder {
|
class Signal<Arg1, Arg2, SigImpl::EmptyArg>:
|
||||||
|
public SigImpl::SignalTemplate<Arg1, Arg2, SigImpl::EmptyArg> {
|
||||||
public:
|
public:
|
||||||
void emit(Arg1 arg1, Arg2 arg2) {
|
void emit(Arg1 arg1, Arg2 arg2) {
|
||||||
begin_emitting();
|
SigImpl::SignalTemplate<Arg1, Arg2, SigImpl::EmptyArg>::
|
||||||
for ( Iterator it = begin(); it != end(); ++it ) {
|
emit_(arg1, arg2, SigImpl::EmptyArg());
|
||||||
if(*it)
|
|
||||||
static_cast<SigImpl::SlotBase2<ReturnType, Arg1, Arg2> &>(**it)(arg1, arg2);
|
|
||||||
}
|
|
||||||
end_emitting();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Functor>
|
|
||||||
SlotID connect(const Functor& functor) {
|
|
||||||
return SignalHolder::connect(SlotPtr(
|
|
||||||
new SigImpl::Slot2<ReturnType, Arg1, Arg2, Functor>(functor)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialization for one argument.
|
/// Specialization for one argument.
|
||||||
template <typename ReturnType, typename Arg1>
|
template <typename Arg1>
|
||||||
class Signal<ReturnType, Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>: public SigImpl::SignalHolder {
|
class Signal<Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>:
|
||||||
|
public SigImpl::SignalTemplate<Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg> {
|
||||||
public:
|
public:
|
||||||
void emit(Arg1 arg) {
|
void emit(Arg1 arg1) {
|
||||||
begin_emitting();
|
SigImpl::SignalTemplate<Arg1, SigImpl::EmptyArg, SigImpl::EmptyArg>
|
||||||
for ( Iterator it = begin(); it != end(); ++it ) {
|
::emit_(arg1, SigImpl::EmptyArg(), SigImpl::EmptyArg());
|
||||||
if(*it)
|
|
||||||
static_cast<SigImpl::SlotBase1<ReturnType, Arg1> &>(**it)(arg);
|
|
||||||
}
|
|
||||||
end_emitting();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Functor>
|
|
||||||
SlotID connect(const Functor& functor) {
|
|
||||||
return SignalHolder::connect(SlotPtr(
|
|
||||||
new SigImpl::Slot1<ReturnType, Arg1, Functor>(functor)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialization for no arguments.
|
/// Specialization for no arguments.
|
||||||
template <typename ReturnType>
|
template <>
|
||||||
class Signal<ReturnType, SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>: public SigImpl::SignalHolder {
|
class Signal<SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>:
|
||||||
|
public SigImpl::SignalTemplate<SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg> {
|
||||||
public:
|
public:
|
||||||
void emit() {
|
void emit() {
|
||||||
begin_emitting();
|
SigImpl::SignalTemplate<SigImpl::EmptyArg, SigImpl::EmptyArg, SigImpl::EmptyArg>
|
||||||
for ( Iterator it = begin(); it != end(); ++it ) {
|
::emit_(SigImpl::EmptyArg(), SigImpl::EmptyArg(), SigImpl::EmptyArg());
|
||||||
if(*it)
|
|
||||||
static_cast<SigImpl::SlotBase0<ReturnType> &>(**it)();
|
|
||||||
}
|
|
||||||
end_emitting();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Functor>
|
|
||||||
SlotID connect(const Functor& functor) {
|
|
||||||
return SignalHolder::connect(SlotPtr(
|
|
||||||
new SigImpl::Slot0<ReturnType, Functor>(functor)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,81 +22,72 @@
|
||||||
#ifndef FBTK_SLOT_HH
|
#ifndef FBTK_SLOT_HH
|
||||||
#define FBTK_SLOT_HH
|
#define FBTK_SLOT_HH
|
||||||
|
|
||||||
|
#include "RefCount.hh"
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
|
|
||||||
/// \namespace Implementation details for signals, do not use anything in this namespace
|
/// \namespace Implementation details for signals, do not use anything in this namespace
|
||||||
namespace SigImpl {
|
namespace SigImpl {
|
||||||
|
|
||||||
|
struct EmptyArg {};
|
||||||
|
|
||||||
class SlotBase {
|
class SlotBase {
|
||||||
public:
|
public:
|
||||||
virtual ~SlotBase() {}
|
virtual ~SlotBase() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ReturnType>
|
template<typename Arg1, typename Arg2, typename Arg3>
|
||||||
class SlotBase0: public SlotBase {
|
class SlotTemplate: public SlotBase {
|
||||||
public:
|
public:
|
||||||
virtual ReturnType operator()() = 0;
|
virtual void operator()(Arg1, Arg2, Arg3) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ReturnType, typename Functor>
|
template<typename Arg1, typename Arg2, typename Arg3, typename Functor>
|
||||||
class Slot0: public SlotBase0<ReturnType> {
|
class Slot: public SlotTemplate<Arg1, Arg2, Arg3> {
|
||||||
public:
|
public:
|
||||||
virtual ReturnType operator()() { return m_functor(); }
|
virtual void operator()(Arg1 arg1, Arg2 arg2, Arg3 arg3)
|
||||||
|
{ m_functor(arg1, arg2, arg3); }
|
||||||
|
|
||||||
Slot0(Functor functor) : m_functor(functor) {}
|
Slot(Functor functor) : m_functor(functor) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Functor m_functor;
|
Functor m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1>
|
// specialization for two arguments
|
||||||
class SlotBase1: public SlotBase {
|
template<typename Arg1, typename Arg2, typename Functor>
|
||||||
|
class Slot<Arg1, Arg2, EmptyArg, Functor>: public SlotTemplate<Arg1, Arg2, EmptyArg> {
|
||||||
public:
|
public:
|
||||||
virtual ReturnType operator()(Arg1) = 0;
|
virtual void operator()(Arg1 arg1, Arg2 arg2, EmptyArg)
|
||||||
};
|
{ m_functor(arg1, arg2); }
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1, typename Functor>
|
Slot(Functor functor) : m_functor(functor) {}
|
||||||
class Slot1: public SlotBase1<ReturnType, Arg1> {
|
|
||||||
public:
|
|
||||||
virtual ReturnType operator()(Arg1 arg1) { return m_functor(arg1); }
|
|
||||||
|
|
||||||
Slot1(Functor functor) : m_functor(functor) {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Functor m_functor;
|
Functor m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1, typename Arg2>
|
// specialization for one argument
|
||||||
class SlotBase2: public SlotBase {
|
template<typename Arg1, typename Functor>
|
||||||
|
class Slot<Arg1, EmptyArg, EmptyArg, Functor>: public SlotTemplate<Arg1, EmptyArg, EmptyArg> {
|
||||||
public:
|
public:
|
||||||
virtual ReturnType operator()(Arg1, Arg2) = 0;
|
virtual void operator()(Arg1 arg1, EmptyArg, EmptyArg)
|
||||||
};
|
{ m_functor(arg1); }
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1, typename Arg2, typename Functor>
|
Slot(Functor functor) : m_functor(functor) {}
|
||||||
class Slot2: public SlotBase2<ReturnType, Arg1, Arg2> {
|
|
||||||
public:
|
|
||||||
virtual ReturnType operator()(Arg1 arg1, Arg2 arg2) { return m_functor(arg1, arg2); }
|
|
||||||
|
|
||||||
Slot2(Functor functor) : m_functor(functor) {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Functor m_functor;
|
Functor m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1, typename Arg2, typename Arg3>
|
// specialization for no arguments
|
||||||
class SlotBase3: public SlotBase {
|
template<typename Functor>
|
||||||
|
class Slot<EmptyArg, EmptyArg, EmptyArg, Functor>: public SlotTemplate<EmptyArg, EmptyArg, EmptyArg> {
|
||||||
public:
|
public:
|
||||||
virtual ReturnType operator()(Arg1, Arg2, Arg3) = 0;
|
virtual void operator()(EmptyArg, EmptyArg, EmptyArg)
|
||||||
virtual ~SlotBase3() {}
|
{ m_functor(); }
|
||||||
};
|
|
||||||
|
|
||||||
template<typename ReturnType, typename Arg1, typename Arg2, typename Arg3, typename Functor>
|
Slot(Functor functor) : m_functor(functor) {}
|
||||||
class Slot3: public SlotBase3<ReturnType, Arg1, Arg2, Arg3> {
|
|
||||||
public:
|
|
||||||
virtual ReturnType operator()(Arg1 arg1, Arg2 arg2, Arg3 arg3)
|
|
||||||
{ return m_functor(arg1, arg2, arg3); }
|
|
||||||
|
|
||||||
Slot3(Functor functor) : m_functor(functor) {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Functor m_functor;
|
Functor m_functor;
|
||||||
|
@ -106,4 +97,5 @@ private:
|
||||||
|
|
||||||
} // namespace FbTk
|
} // namespace FbTk
|
||||||
|
|
||||||
|
|
||||||
#endif // FBTK_SLOT_H
|
#endif // FBTK_SLOT_H
|
||||||
|
|
|
@ -107,13 +107,13 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void remove(ThemeItem<T> &item);
|
void remove(ThemeItem<T> &item);
|
||||||
virtual bool fallback(ThemeItem_base &) { return false; }
|
virtual bool fallback(ThemeItem_base &) { return false; }
|
||||||
Signal<void> &reconfigSig() { return m_reconfig_sig; }
|
Signal<> &reconfigSig() { return m_reconfig_sig; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int m_screen_num;
|
const int m_screen_num;
|
||||||
|
|
||||||
ItemList m_themeitems;
|
ItemList m_themeitems;
|
||||||
Signal<void> m_reconfig_sig;
|
Signal<> m_reconfig_sig;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Proxy interface for themes, so they can be substituted dynamically
|
/// Proxy interface for themes, so they can be substituted dynamically
|
||||||
|
@ -122,7 +122,7 @@ class ThemeProxy {
|
||||||
public:
|
public:
|
||||||
virtual ~ThemeProxy() { }
|
virtual ~ThemeProxy() { }
|
||||||
|
|
||||||
virtual Signal<void> &reconfigSig() = 0;
|
virtual Signal<> &reconfigSig() = 0;
|
||||||
|
|
||||||
virtual BaseTheme &operator *() = 0;
|
virtual BaseTheme &operator *() = 0;
|
||||||
virtual const BaseTheme &operator *() const = 0;
|
virtual const BaseTheme &operator *() const = 0;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
IconbarTheme &iconbarTheme() { return m_iconbar_theme; }
|
IconbarTheme &iconbarTheme() { return m_iconbar_theme; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual FbWinFrameTheme &operator *() { return *this; }
|
virtual FbWinFrameTheme &operator *() { return *this; }
|
||||||
virtual const FbWinFrameTheme &operator *() const { return *this; }
|
virtual const FbWinFrameTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -119,13 +119,13 @@ public:
|
||||||
@name signals
|
@name signals
|
||||||
@{
|
@{
|
||||||
*/
|
*/
|
||||||
typedef FbTk::Signal<void, const std::string&, Focusable&> TitleSignal;
|
typedef FbTk::Signal<const std::string&, Focusable&> TitleSignal;
|
||||||
/// Used for both title and icon changes.
|
/// Used for both title and icon changes.
|
||||||
TitleSignal &titleSig() { return m_titlesig; }
|
TitleSignal &titleSig() { return m_titlesig; }
|
||||||
/// Used for both title and icon changes.
|
/// Used for both title and icon changes.
|
||||||
const TitleSignal &titleSig() const { return m_titlesig; }
|
const TitleSignal &titleSig() const { return m_titlesig; }
|
||||||
FbTk::Signal<void, Focusable&> &focusSig() { return m_focussig; }
|
FbTk::Signal<Focusable&> &focusSig() { return m_focussig; }
|
||||||
const FbTk::Signal<void, Focusable&> &focusSig() const { return m_focussig; }
|
const FbTk::Signal<Focusable&> &focusSig() const { return m_focussig; }
|
||||||
FbTk::Subject &dieSig() { return m_diesig; }
|
FbTk::Subject &dieSig() { return m_diesig; }
|
||||||
const FbTk::Subject &dieSig() const { return m_diesig; }
|
const FbTk::Subject &dieSig() const { return m_diesig; }
|
||||||
FbTk::Subject &attentionSig() { return m_attentionsig; }
|
FbTk::Subject &attentionSig() { return m_attentionsig; }
|
||||||
|
@ -153,7 +153,7 @@ protected:
|
||||||
FocusSubject m_diesig, m_attentionsig;
|
FocusSubject m_diesig, m_attentionsig;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FbTk::Signal<void, Focusable&> m_focussig;
|
FbTk::Signal<Focusable&> m_focussig;
|
||||||
TitleSignal m_titlesig;
|
TitleSignal m_titlesig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,13 @@ public:
|
||||||
m_win(win), m_focused_theme(focused), m_unfocused_theme(unfocused) {
|
m_win(win), m_focused_theme(focused), m_unfocused_theme(unfocused) {
|
||||||
|
|
||||||
m_signals.join(m_win.focusSig(),
|
m_signals.join(m_win.focusSig(),
|
||||||
FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<void>::emit));
|
FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
|
|
||||||
m_win.attentionSig().attach(this);
|
m_win.attentionSig().attach(this);
|
||||||
m_signals.join(m_focused_theme.reconfigSig(),
|
m_signals.join(m_focused_theme.reconfigSig(),
|
||||||
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<void>::emit));
|
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
m_signals.join(m_unfocused_theme.reconfigSig(),
|
m_signals.join(m_unfocused_theme.reconfigSig(),
|
||||||
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<void>::emit));
|
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
}
|
}
|
||||||
|
|
||||||
Focusable &win() { return m_win; }
|
Focusable &win() { return m_win; }
|
||||||
|
@ -54,7 +54,7 @@ public:
|
||||||
FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() { return m_unfocused_theme; }
|
FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() { return m_unfocused_theme; }
|
||||||
const FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() const { return m_unfocused_theme; }
|
const FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() const { return m_unfocused_theme; }
|
||||||
|
|
||||||
FbTk::Signal<void> &reconfigSig() { return m_reconfig_sig; }
|
FbTk::Signal<> &reconfigSig() { return m_reconfig_sig; }
|
||||||
|
|
||||||
virtual BaseTheme &operator *() {
|
virtual BaseTheme &operator *() {
|
||||||
return (m_win.isFocused() || m_win.getAttentionState()) ?
|
return (m_win.isFocused() || m_win.getAttentionState()) ?
|
||||||
|
@ -70,7 +70,7 @@ private:
|
||||||
|
|
||||||
Focusable &m_win;
|
Focusable &m_win;
|
||||||
FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme;
|
FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme;
|
||||||
FbTk::Signal<void> m_reconfig_sig;
|
FbTk::Signal<> m_reconfig_sig;
|
||||||
FbTk::SignalTracker m_signals;
|
FbTk::SignalTracker m_signals;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
const FbTk::Texture &texture() const { return *m_texture; }
|
const FbTk::Texture &texture() const { return *m_texture; }
|
||||||
const FbTk::Texture &emptyTexture() const { return *m_empty_texture; }
|
const FbTk::Texture &emptyTexture() const { return *m_empty_texture; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual IconbarTheme &operator *() { return *this; }
|
virtual IconbarTheme &operator *() { return *this; }
|
||||||
virtual const IconbarTheme &operator *() const { return *this; }
|
virtual const IconbarTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
GC opGC() const { return m_opgc.gc(); }
|
GC opGC() const { return m_opgc.gc(); }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual RootTheme &operator *() { return *this; }
|
virtual RootTheme &operator *() { return *this; }
|
||||||
virtual const RootTheme &operator *() const { return *this; }
|
virtual const RootTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -197,7 +197,7 @@ public:
|
||||||
@name Screen signals
|
@name Screen signals
|
||||||
*/
|
*/
|
||||||
//@{
|
//@{
|
||||||
typedef FbTk::Signal<void, BScreen&> ScreenSignal;
|
typedef FbTk::Signal<BScreen&> ScreenSignal;
|
||||||
/// client list signal
|
/// client list signal
|
||||||
ScreenSignal &clientListSig() { return m_clientlist_sig; }
|
ScreenSignal &clientListSig() { return m_clientlist_sig; }
|
||||||
/// icon list sig
|
/// icon list sig
|
||||||
|
@ -211,7 +211,7 @@ public:
|
||||||
/// current workspace signal
|
/// current workspace signal
|
||||||
ScreenSignal ¤tWorkspaceSig() { return m_currentworkspace_sig; }
|
ScreenSignal ¤tWorkspaceSig() { return m_currentworkspace_sig; }
|
||||||
/// focused window signal
|
/// focused window signal
|
||||||
FbTk::Signal<void, BScreen&, FluxboxWindow*, WinClient*> &focusedWindowSig() { return m_focusedwindow_sig; }
|
FbTk::Signal<BScreen&, FluxboxWindow*, WinClient*> &focusedWindowSig() { return m_focusedwindow_sig; }
|
||||||
/// reconfigure signal
|
/// reconfigure signal
|
||||||
FbTk::Subject &reconfigureSig() { return m_reconfigure_sig; }
|
FbTk::Subject &reconfigureSig() { return m_reconfigure_sig; }
|
||||||
ScreenSignal &resizeSig() { return m_resize_sig; }
|
ScreenSignal &resizeSig() { return m_resize_sig; }
|
||||||
|
@ -479,7 +479,7 @@ private:
|
||||||
ScreenSubject m_reconfigure_sig; ///< reconfigure signal
|
ScreenSubject m_reconfigure_sig; ///< reconfigure signal
|
||||||
|
|
||||||
|
|
||||||
FbTk::Signal<void, BScreen&, FluxboxWindow*, WinClient*> m_focusedwindow_sig; ///< focused window signal
|
FbTk::Signal<BScreen&, FluxboxWindow*, WinClient*> m_focusedwindow_sig; ///< focused window signal
|
||||||
ScreenSignal m_resize_sig; ///< resize signal
|
ScreenSignal m_resize_sig; ///< resize signal
|
||||||
ScreenSignal m_workspace_area_sig; ///< workspace area changed signal
|
ScreenSignal m_workspace_area_sig; ///< workspace area changed signal
|
||||||
ScreenSignal m_iconlist_sig; ///< notify if a window gets iconified/deiconified
|
ScreenSignal m_iconlist_sig; ///< notify if a window gets iconified/deiconified
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
int borderWidth() const { return *m_border_width; }
|
int borderWidth() const { return *m_border_width; }
|
||||||
int bevelWidth() const { return *m_bevel_width; }
|
int bevelWidth() const { return *m_bevel_width; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual SlitTheme &operator *() { return *this; }
|
virtual SlitTheme &operator *() { return *this; }
|
||||||
virtual const SlitTheme &operator *() const { return *this; }
|
virtual const SlitTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
int alpha() const { return m_alpha; }
|
int alpha() const { return m_alpha; }
|
||||||
void setAlpha(int alpha) { m_alpha = alpha; }
|
void setAlpha(int alpha) { m_alpha = alpha; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual ToolTheme &operator *() { return *this; }
|
virtual ToolTheme &operator *() { return *this; }
|
||||||
virtual const ToolTheme &operator *() const { return *this; }
|
virtual const ToolTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
int height() const { return *m_height; }
|
int height() const { return *m_height; }
|
||||||
int buttonSize() const { return *m_button_size; }
|
int buttonSize() const { return *m_button_size; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual ToolbarTheme &operator *() { return *this; }
|
virtual ToolbarTheme &operator *() { return *this; }
|
||||||
virtual const ToolbarTheme &operator *() const { return *this; }
|
virtual const ToolbarTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; }
|
FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; }
|
||||||
const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; }
|
const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; }
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual WinButtonTheme &operator *() { return *this; }
|
virtual WinButtonTheme &operator *() { return *this; }
|
||||||
virtual const WinButtonTheme &operator *() const { return *this; }
|
virtual const WinButtonTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
BScreen &m_screen;
|
BScreen &m_screen;
|
||||||
|
|
||||||
Windows m_windowlist;
|
Windows m_windowlist;
|
||||||
FbTk::Signal<void> m_clientlist_sig;
|
FbTk::Signal<> m_clientlist_sig;
|
||||||
ClientMenu m_clientmenu;
|
ClientMenu m_clientmenu;
|
||||||
|
|
||||||
FbTk::FbString m_name; ///< name of this workspace
|
FbTk::FbString m_name; ///< name of this workspace
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
return ToolTheme::fallback(item);
|
return ToolTheme::fallback(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual FbTk::Signal<void> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual WorkspaceNameTheme &operator *() { return *this; }
|
virtual WorkspaceNameTheme &operator *() { return *this; }
|
||||||
virtual const WorkspaceNameTheme &operator *() const { return *this; }
|
virtual const WorkspaceNameTheme &operator *() const { return *this; }
|
||||||
|
|
|
@ -80,16 +80,16 @@ int main() {
|
||||||
using FbTk::Signal;
|
using FbTk::Signal;
|
||||||
using FbTk::SignalTracker;
|
using FbTk::SignalTracker;
|
||||||
|
|
||||||
Signal<void> no_arg;
|
Signal<> no_arg;
|
||||||
no_arg.connect( NoArgument() );
|
no_arg.connect( NoArgument() );
|
||||||
|
|
||||||
Signal<void, int> one_arg;
|
Signal<int> one_arg;
|
||||||
one_arg.connect( OneArgument() );
|
one_arg.connect( OneArgument() );
|
||||||
|
|
||||||
Signal<void, int, const string&> two_args;
|
Signal<int, const string&> two_args;
|
||||||
two_args.connect( TwoArguments() );
|
two_args.connect( TwoArguments() );
|
||||||
|
|
||||||
Signal<void, int, const string&, double> three_args;
|
Signal<int, const string&, double> three_args;
|
||||||
three_args.connect( ThreeArguments() );
|
three_args.connect( ThreeArguments() );
|
||||||
|
|
||||||
// emit test
|
// emit test
|
||||||
|
@ -127,7 +127,7 @@ int main() {
|
||||||
no_arg.emit();
|
no_arg.emit();
|
||||||
|
|
||||||
string takeThis("Take this");
|
string takeThis("Take this");
|
||||||
Signal<void, string&> ref_arg;
|
Signal<string&> ref_arg;
|
||||||
ref_arg.connect(MemFun(obj, &FunctionClass::takeIt));
|
ref_arg.connect(MemFun(obj, &FunctionClass::takeIt));
|
||||||
ref_arg.emit( takeThis );
|
ref_arg.emit( takeThis );
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int main() {
|
||||||
using FbTk::MemFunIgnoreArgs;
|
using FbTk::MemFunIgnoreArgs;
|
||||||
// Create a signal that emits with three arguments, and connect
|
// Create a signal that emits with three arguments, and connect
|
||||||
// sinks that takes less than three arguments.
|
// sinks that takes less than three arguments.
|
||||||
Signal<void, string, string, float> more_args;
|
Signal<string, string, float> more_args;
|
||||||
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::print));
|
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::print));
|
||||||
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::takeIt));
|
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::takeIt));
|
||||||
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::showMessage2));
|
more_args.connect(MemFunIgnoreArgs(obj, &FunctionClass::showMessage2));
|
||||||
|
@ -168,7 +168,7 @@ int main() {
|
||||||
destination.attach(&obs);
|
destination.attach(&obs);
|
||||||
// create a new signal and relay it to the
|
// create a new signal and relay it to the
|
||||||
// old subject
|
// old subject
|
||||||
FbTk::Signal<void, string> source;
|
FbTk::Signal<string> source;
|
||||||
FbTk::relaySignal(source, destination);
|
FbTk::relaySignal(source, destination);
|
||||||
// the new signal should now make the old
|
// the new signal should now make the old
|
||||||
// subject notify its observers
|
// subject notify its observers
|
||||||
|
@ -178,7 +178,7 @@ int main() {
|
||||||
// Test argument selector
|
// Test argument selector
|
||||||
{
|
{
|
||||||
using namespace FbTk;
|
using namespace FbTk;
|
||||||
Signal<void, int, string, float> source;
|
Signal<int, string, float> source;
|
||||||
|
|
||||||
Printer printer;
|
Printer printer;
|
||||||
source.connect(MemFunSelectArg0(printer, &Printer::printInt));
|
source.connect(MemFunSelectArg0(printer, &Printer::printInt));
|
||||||
|
@ -187,7 +187,7 @@ int main() {
|
||||||
|
|
||||||
source.emit(10, "hello", 3.141592);
|
source.emit(10, "hello", 3.141592);
|
||||||
|
|
||||||
Signal<void, string, int> source2;
|
Signal<string, int> source2;
|
||||||
source2.connect(MemFunSelectArg0(printer, &Printer::printString));
|
source2.connect(MemFunSelectArg0(printer, &Printer::printString));
|
||||||
source2.connect(MemFunSelectArg1(printer, &Printer::printInt));
|
source2.connect(MemFunSelectArg1(printer, &Printer::printInt));
|
||||||
source2.emit("world", 37);
|
source2.emit("world", 37);
|
||||||
|
|
Loading…
Reference in a new issue