code cleaning and optimization
This commit is contained in:
parent
ee0ff9d6e3
commit
cb0621a6b6
1 changed files with 55 additions and 67 deletions
|
@ -20,7 +20,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: IconbarTool.cc,v 1.4 2003/08/12 11:09:46 fluxgen Exp $
|
// $Id: IconbarTool.cc,v 1.5 2003/08/12 12:16:28 fluxgen Exp $
|
||||||
|
|
||||||
#include "IconbarTool.hh"
|
#include "IconbarTool.hh"
|
||||||
|
|
||||||
|
@ -31,14 +31,6 @@
|
||||||
#include "IconButton.hh"
|
#include "IconButton.hh"
|
||||||
#include "Workspace.hh"
|
#include "Workspace.hh"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
|
||||||
class ShowTextCmd: public FbTk::Command {
|
|
||||||
void execute() {
|
|
||||||
cerr<<"ShowTextCmd"<<endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen):
|
IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen):
|
||||||
ToolbarItem(ToolbarItem::RELATIVE),
|
ToolbarItem(ToolbarItem::RELATIVE),
|
||||||
m_screen(screen),
|
m_screen(screen),
|
||||||
|
@ -58,10 +50,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr
|
||||||
}
|
}
|
||||||
|
|
||||||
IconbarTool::~IconbarTool() {
|
IconbarTool::~IconbarTool() {
|
||||||
while (!m_icon_list.empty()) {
|
deleteIcons();
|
||||||
delete m_icon_list.back();
|
|
||||||
m_icon_list.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove cached images
|
// remove cached images
|
||||||
if (m_focused_pm)
|
if (m_focused_pm)
|
||||||
|
@ -106,26 +95,41 @@ unsigned int IconbarTool::height() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconbarTool::update(FbTk::Subject *subj) {
|
void IconbarTool::update(FbTk::Subject *subj) {
|
||||||
|
// ignore updates if we're shutting down
|
||||||
|
if (m_screen.isShuttingdown())
|
||||||
|
return;
|
||||||
|
|
||||||
// just focus signal?
|
// just focus signal?
|
||||||
if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) {
|
if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) {
|
||||||
// we handle everything except die signal here
|
// we handle everything except die signal here
|
||||||
FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj);
|
FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj);
|
||||||
if (subj != &(winsubj->win().dieSig())) {
|
if (subj != &(winsubj->win().dieSig())) {
|
||||||
renderButton(winsubj->win());
|
renderWindow(winsubj->win());
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
// got window die signal, lets find and remove the window
|
||||||
|
IconList::iterator it = m_icon_list.begin();
|
||||||
|
IconList::iterator it_end = m_icon_list.end();
|
||||||
|
for (; it != it_end; ++it) {
|
||||||
|
if (&(*it)->win() == &winsubj->win())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// did we find it?
|
||||||
|
if (it == m_icon_list.end())
|
||||||
|
return;
|
||||||
|
// remove from list and render theme again
|
||||||
|
delete *it;
|
||||||
|
m_icon_list.erase(it);
|
||||||
|
m_icon_container.removeItem(m_icon_container.find(*it));
|
||||||
|
renderTheme();
|
||||||
|
return; // we don't need to update the entire list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, we got some signal that we need to update our iconbar container
|
// ok, we got some signal that we need to update our iconbar container
|
||||||
|
|
||||||
// remove all clients and add them again...the only way to do it now
|
// remove all clients and add them again...the only way to do it now
|
||||||
m_icon_container.removeAll();
|
deleteIcons();
|
||||||
|
|
||||||
while (!m_icon_list.empty()) {
|
|
||||||
delete m_icon_list.back();
|
|
||||||
m_icon_list.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get current workspace and all it's clients
|
// get current workspace and all it's clients
|
||||||
Workspace &space = *m_screen.currentWorkspace();
|
Workspace &space = *m_screen.currentWorkspace();
|
||||||
|
@ -152,7 +156,7 @@ void IconbarTool::update(FbTk::Subject *subj) {
|
||||||
renderTheme();
|
renderTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconbarTool::renderButton(FluxboxWindow &win) {
|
void IconbarTool::renderWindow(FluxboxWindow &win) {
|
||||||
|
|
||||||
IconList::iterator icon_it = m_icon_list.begin();
|
IconList::iterator icon_it = m_icon_list.begin();
|
||||||
IconList::iterator icon_it_end = m_icon_list.end();
|
IconList::iterator icon_it_end = m_icon_list.end();
|
||||||
|
@ -160,33 +164,11 @@ void IconbarTool::renderButton(FluxboxWindow &win) {
|
||||||
if (&(*icon_it)->win() == &win)
|
if (&(*icon_it)->win() == &win)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon_it == m_icon_list.end())
|
if (icon_it == m_icon_list.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IconButton &button = *(*icon_it);
|
renderButton(*(*icon_it));
|
||||||
|
|
||||||
if (button.win().isFocused()) { // focused texture
|
|
||||||
button.setGC(m_theme.focusedText().textGC());
|
|
||||||
button.setFont(m_theme.focusedText().font());
|
|
||||||
button.setJustify(m_theme.focusedText().justify());
|
|
||||||
|
|
||||||
if (m_focused_pm != 0)
|
|
||||||
button.setBackgroundPixmap(m_focused_pm);
|
|
||||||
else
|
|
||||||
button.setBackgroundColor(m_theme.focusedTexture().color());
|
|
||||||
|
|
||||||
|
|
||||||
} else { // unfocused
|
|
||||||
button.setGC(m_theme.unfocusedText().textGC());
|
|
||||||
button.setFont(m_theme.unfocusedText().font());
|
|
||||||
button.setJustify(m_theme.unfocusedText().justify());
|
|
||||||
|
|
||||||
if (m_unfocused_pm != 0)
|
|
||||||
button.setBackgroundPixmap(m_unfocused_pm);
|
|
||||||
else
|
|
||||||
button.setBackgroundColor(m_theme.unfocusedTexture().color());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconbarTool::renderTheme() {
|
void IconbarTool::renderTheme() {
|
||||||
|
@ -230,32 +212,38 @@ void IconbarTool::renderTheme() {
|
||||||
// update buttons
|
// update buttons
|
||||||
IconList::iterator icon_it = m_icon_list.begin();
|
IconList::iterator icon_it = m_icon_list.begin();
|
||||||
IconList::iterator icon_it_end = m_icon_list.end();
|
IconList::iterator icon_it_end = m_icon_list.end();
|
||||||
for (; icon_it != icon_it_end; ++icon_it) {
|
for (; icon_it != icon_it_end; ++icon_it)
|
||||||
|
renderButton(*(*icon_it));
|
||||||
|
}
|
||||||
|
|
||||||
IconButton &button = *(*icon_it);
|
void IconbarTool::renderButton(IconButton &button) {
|
||||||
|
|
||||||
if (button.win().isFocused()) { // focused texture
|
if (button.win().isFocused()) { // focused texture
|
||||||
button.setGC(m_theme.focusedText().textGC());
|
button.setGC(m_theme.focusedText().textGC());
|
||||||
button.setFont(m_theme.focusedText().font());
|
button.setFont(m_theme.focusedText().font());
|
||||||
button.setJustify(m_theme.focusedText().justify());
|
button.setJustify(m_theme.focusedText().justify());
|
||||||
|
|
||||||
if (m_focused_pm != 0)
|
if (m_focused_pm != 0)
|
||||||
button.setBackgroundPixmap(m_focused_pm);
|
button.setBackgroundPixmap(m_focused_pm);
|
||||||
else
|
else
|
||||||
button.setBackgroundColor(m_theme.focusedTexture().color());
|
button.setBackgroundColor(m_theme.focusedTexture().color());
|
||||||
|
|
||||||
|
} else { // unfocused
|
||||||
|
button.setGC(m_theme.unfocusedText().textGC());
|
||||||
|
button.setFont(m_theme.unfocusedText().font());
|
||||||
|
button.setJustify(m_theme.unfocusedText().justify());
|
||||||
|
|
||||||
} else { // unfocused
|
if (m_unfocused_pm != 0)
|
||||||
button.setGC(m_theme.unfocusedText().textGC());
|
button.setBackgroundPixmap(m_unfocused_pm);
|
||||||
button.setFont(m_theme.unfocusedText().font());
|
else
|
||||||
button.setJustify(m_theme.unfocusedText().justify());
|
button.setBackgroundColor(m_theme.unfocusedTexture().color());
|
||||||
|
}
|
||||||
if (m_unfocused_pm != 0)
|
}
|
||||||
button.setBackgroundPixmap(m_unfocused_pm);
|
|
||||||
else
|
void IconbarTool::deleteIcons() {
|
||||||
button.setBackgroundColor(m_theme.unfocusedTexture().color());
|
m_icon_container.removeAll();
|
||||||
}
|
while (!m_icon_list.empty()) {
|
||||||
|
delete m_icon_list.back();
|
||||||
button.clear();
|
m_icon_list.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue