Convert Focusable::attentionSig to FbTk::Signal
This commit is contained in:
parent
2073ae12a4
commit
e1b0decf55
4 changed files with 10 additions and 47 deletions
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "FbTk/PixmapWithMask.hh"
|
#include "FbTk/PixmapWithMask.hh"
|
||||||
#include "FbTk/ITypeAheadable.hh"
|
#include "FbTk/ITypeAheadable.hh"
|
||||||
#include "FbTk/Subject.hh"
|
|
||||||
#include "FbTk/Signal.hh"
|
#include "FbTk/Signal.hh"
|
||||||
#include "FbTk/FbString.hh"
|
#include "FbTk/FbString.hh"
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ public:
|
||||||
m_screen(scr), m_fbwin(fbwin),
|
m_screen(scr), m_fbwin(fbwin),
|
||||||
m_instance_name("fluxbox"), m_class_name("fluxbox"),
|
m_instance_name("fluxbox"), m_class_name("fluxbox"),
|
||||||
m_focused(false), m_attention_state(false),
|
m_focused(false), m_attention_state(false),
|
||||||
m_attentionsig(*this),
|
m_attentionsig(),
|
||||||
m_focussig(),
|
m_focussig(),
|
||||||
m_diesig(),
|
m_diesig(),
|
||||||
m_titlesig() { }
|
m_titlesig() { }
|
||||||
|
@ -62,7 +61,7 @@ public:
|
||||||
bool getAttentionState() const { return m_attention_state; }
|
bool getAttentionState() const { return m_attention_state; }
|
||||||
/// @set the attention state
|
/// @set the attention state
|
||||||
virtual void setAttentionState(bool value) {
|
virtual void setAttentionState(bool value) {
|
||||||
m_attention_state = value; attentionSig().notify();
|
m_attention_state = value; attentionSig().emit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the screen in which this object resides
|
/// @return the screen in which this object resides
|
||||||
|
@ -101,19 +100,6 @@ public:
|
||||||
virtual const FbTk::BiDiString &title() const { return m_title; }
|
virtual const FbTk::BiDiString &title() const { return m_title; }
|
||||||
/// @return type ahead string
|
/// @return type ahead string
|
||||||
const std::string &iTypeString() const { return title().logical(); }
|
const std::string &iTypeString() const { return title().logical(); }
|
||||||
/**
|
|
||||||
* Signaling object to attatch observers to.
|
|
||||||
*/
|
|
||||||
class FocusSubject: public FbTk::Subject {
|
|
||||||
public:
|
|
||||||
explicit FocusSubject(Focusable &w):m_win(w) { }
|
|
||||||
/// @return context focusable for this signal
|
|
||||||
Focusable &win() { return m_win; }
|
|
||||||
/// @return context focusable for this signal
|
|
||||||
const Focusable &win() const { return m_win; }
|
|
||||||
private:
|
|
||||||
Focusable &m_win; //< the context
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@name signals
|
@name signals
|
||||||
|
@ -126,8 +112,7 @@ public:
|
||||||
const TitleSignal &titleSig() const { return m_titlesig; }
|
const TitleSignal &titleSig() const { return m_titlesig; }
|
||||||
FbTk::Signal<Focusable&> &focusSig() { return m_focussig; }
|
FbTk::Signal<Focusable&> &focusSig() { return m_focussig; }
|
||||||
FbTk::Signal<Focusable&> &dieSig() { return m_diesig; }
|
FbTk::Signal<Focusable&> &dieSig() { return m_diesig; }
|
||||||
FbTk::Subject &attentionSig() { return m_attentionsig; }
|
FbTk::Signal<Focusable&> &attentionSig() { return m_attentionsig; }
|
||||||
const FbTk::Subject &attentionSig() const { return m_attentionsig; }
|
|
||||||
/** @} */ // end group signals
|
/** @} */ // end group signals
|
||||||
|
|
||||||
/// Notify any listeners that the focus changed for this window.
|
/// Notify any listeners that the focus changed for this window.
|
||||||
|
@ -147,10 +132,9 @@ protected:
|
||||||
bool m_attention_state; //< state of icon button while demanding attention
|
bool m_attention_state; //< state of icon button while demanding attention
|
||||||
FbTk::PixmapWithMask m_icon; //< icon pixmap with mask
|
FbTk::PixmapWithMask m_icon; //< icon pixmap with mask
|
||||||
|
|
||||||
// state and hint signals
|
|
||||||
FocusSubject m_attentionsig;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FbTk::Signal<Focusable&> m_attentionsig;
|
||||||
FbTk::Signal<Focusable&> m_focussig;
|
FbTk::Signal<Focusable&> m_focussig;
|
||||||
FbTk::Signal<Focusable&> m_diesig;
|
FbTk::Signal<Focusable&> m_diesig;
|
||||||
TitleSignal m_titlesig;
|
TitleSignal m_titlesig;
|
||||||
|
|
|
@ -23,13 +23,11 @@
|
||||||
#define FOCUSABLETHEME_HH
|
#define FOCUSABLETHEME_HH
|
||||||
|
|
||||||
#include "Focusable.hh"
|
#include "Focusable.hh"
|
||||||
#include "FbTk/Observer.hh"
|
|
||||||
#include "FbTk/Theme.hh"
|
#include "FbTk/Theme.hh"
|
||||||
#include "FbTk/RelaySignal.hh"
|
#include "FbTk/RelaySignal.hh"
|
||||||
|
|
||||||
template <typename BaseTheme>
|
template <typename BaseTheme>
|
||||||
class FocusableTheme: public FbTk::ThemeProxy<BaseTheme>,
|
class FocusableTheme: public FbTk::ThemeProxy<BaseTheme> {
|
||||||
private FbTk::Observer {
|
|
||||||
public:
|
public:
|
||||||
FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused,
|
FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused,
|
||||||
FbTk::ThemeProxy<BaseTheme> &unfocused):
|
FbTk::ThemeProxy<BaseTheme> &unfocused):
|
||||||
|
@ -37,8 +35,8 @@ public:
|
||||||
|
|
||||||
m_signals.join(m_win.focusSig(),
|
m_signals.join(m_win.focusSig(),
|
||||||
FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
|
FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
|
m_signals.join(m_win.attentionSig(),
|
||||||
m_win.attentionSig().attach(this);
|
FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
m_signals.join(m_focused_theme.reconfigSig(),
|
m_signals.join(m_focused_theme.reconfigSig(),
|
||||||
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit));
|
FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit));
|
||||||
m_signals.join(m_unfocused_theme.reconfigSig(),
|
m_signals.join(m_unfocused_theme.reconfigSig(),
|
||||||
|
@ -66,8 +64,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update(FbTk::Subject *subj) { m_reconfig_sig.emit(); }
|
|
||||||
|
|
||||||
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<> m_reconfig_sig;
|
FbTk::Signal<> m_reconfig_sig;
|
||||||
|
|
|
@ -61,7 +61,8 @@ IconButton::IconButton(const FbTk::FbWindow &parent,
|
||||||
m_signals.join(m_win.focusSig(),
|
m_signals.join(m_win.focusSig(),
|
||||||
MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));
|
MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));
|
||||||
|
|
||||||
m_win.attentionSig().attach(this);
|
m_signals.join(m_win.attentionSig(),
|
||||||
|
MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));
|
||||||
|
|
||||||
FbTk::EventManager::instance()->add(*this, m_icon_window);
|
FbTk::EventManager::instance()->add(*this, m_icon_window);
|
||||||
|
|
||||||
|
@ -250,22 +251,6 @@ void IconButton::clientTitleChanged() {
|
||||||
showTooltip();
|
showTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconButton::update(FbTk::Subject *subj) {
|
|
||||||
// if the window's focus state changed, we need to update the background
|
|
||||||
if (subj == &m_win.attentionSig()) {
|
|
||||||
reconfigAndClear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we got signal that either title or
|
|
||||||
// icon pixmap was updated,
|
|
||||||
// so we refresh everything
|
|
||||||
// if the title was changed AND the mouse is over *this,
|
|
||||||
// update the tooltip
|
|
||||||
|
|
||||||
refreshEverything(subj != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconButton::setupWindow() {
|
void IconButton::setupWindow() {
|
||||||
m_icon_window.clear();
|
m_icon_window.clear();
|
||||||
setText(m_win.title());
|
setText(m_win.title());
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
#include "FbTk/CachedPixmap.hh"
|
#include "FbTk/CachedPixmap.hh"
|
||||||
#include "FbTk/FbPixmap.hh"
|
#include "FbTk/FbPixmap.hh"
|
||||||
#include "FbTk/Observer.hh"
|
|
||||||
#include "FbTk/TextButton.hh"
|
#include "FbTk/TextButton.hh"
|
||||||
#include "FbTk/Signal.hh"
|
#include "FbTk/Signal.hh"
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ namespace FbTk {
|
||||||
template <class T> class ThemeProxy;
|
template <class T> class ThemeProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
class IconButton: public FbTk::TextButton, public FbTk::Observer {
|
class IconButton: public FbTk::TextButton {
|
||||||
public:
|
public:
|
||||||
IconButton(const FbTk::FbWindow &parent,
|
IconButton(const FbTk::FbWindow &parent,
|
||||||
FbTk::ThemeProxy<IconbarTheme> &focused_theme,
|
FbTk::ThemeProxy<IconbarTheme> &focused_theme,
|
||||||
|
@ -58,7 +57,6 @@ public:
|
||||||
|
|
||||||
void reconfigTheme();
|
void reconfigTheme();
|
||||||
|
|
||||||
void update(FbTk::Subject *subj);
|
|
||||||
void setPixmap(bool use);
|
void setPixmap(bool use);
|
||||||
|
|
||||||
Focusable &win() { return m_win; }
|
Focusable &win() { return m_win; }
|
||||||
|
|
Loading…
Reference in a new issue