From 97ef84da598aed61a6cb57a62796f302043181e8 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 29 Aug 2004 08:33:13 +0000 Subject: a few random fixes --- ChangeLog | 5 +++++ src/ButtonTool.cc | 7 ++++++- src/ButtonTool.hh | 3 ++- src/ClockTool.cc | 7 ++++++- src/ClockTool.hh | 3 ++- src/FbTk/Menu.cc | 11 ++++++++--- src/FbTk/MenuItem.cc | 5 +++-- src/FbTk/XftFontImp.cc | 7 +++++-- src/IconbarTool.cc | 17 ++++++++++++----- src/IconbarTool.hh | 4 +++- src/SystemTray.hh | 3 ++- src/TextTheme.cc | 5 +++-- src/Toolbar.cc | 17 +++++++++++------ src/ToolbarItem.hh | 5 ++++- src/WorkspaceNameTool.cc | 6 +++++- src/WorkspaceNameTool.hh | 3 ++- 16 files changed, 79 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9c402a..55826c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ (Format: Year/Month/Day) Changes for 0.9.10: +*04/08/29: + * More random render fixes (Simon) + (font alignment in menu, menu optimisation, toolbar font/render) + FbTk/Menu.cc FbTk/MenuItem.cc FbTk/XftFontImp.cc + TextTheme.cc Toolbar.cc ToolbarItem.hh .hh/cc *04/08/28: * Some more menu rendering fixes (Simon) Thanks Florian Pigorsch for nice bug reports + debugging diff --git a/src/ButtonTool.cc b/src/ButtonTool.cc index 78edbe7..0640048 100644 --- a/src/ButtonTool.cc +++ b/src/ButtonTool.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ButtonTool.cc,v 1.4 2004/08/26 15:09:33 rathnor Exp $ +// $Id: ButtonTool.cc,v 1.5 2004/08/29 08:33:12 rathnor Exp $ #include "ButtonTool.hh" @@ -48,6 +48,11 @@ ButtonTool::~ButtonTool() { } +void ButtonTool::updateSizing() { + FbTk::Button &btn = static_cast(window()); + btn.setBorderWidth(theme().border().width()); +} + void ButtonTool::renderTheme() { FbTk::Button &btn = static_cast(window()); diff --git a/src/ButtonTool.hh b/src/ButtonTool.hh index b40c5a7..73d9b76 100644 --- a/src/ButtonTool.hh +++ b/src/ButtonTool.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ButtonTool.hh,v 1.1 2003/10/13 23:38:17 fluxgen Exp $ +// $Id: ButtonTool.hh,v 1.2 2004/08/29 08:33:12 rathnor Exp $ #ifndef BUTTONTOOL_HH #define BUTTONTOOL_HH @@ -42,6 +42,7 @@ public: protected: void renderTheme(); + void updateSizing(); Pixmap m_cache_pm, m_cache_pressed_pm; FbTk::ImageControl &m_image_ctrl; }; diff --git a/src/ClockTool.cc b/src/ClockTool.cc index dca1d86..2364a5b 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ClockTool.cc,v 1.12 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ClockTool.cc,v 1.13 2004/08/29 08:33:12 rathnor Exp $ #include "ClockTool.hh" @@ -246,6 +246,11 @@ void ClockTool::updateTime() { m_button.clear(); } +// Just change things that affect the size +void ClockTool::updateSizing() { + m_button.setBorderWidth(m_theme.border().width()); +} + void ClockTool::renderTheme() { Pixmap old_pm = m_pixmap; if (!m_theme.texture().usePixmap()) { diff --git a/src/ClockTool.hh b/src/ClockTool.hh index 70f80cc..a8e9362 100644 --- a/src/ClockTool.hh +++ b/src/ClockTool.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ClockTool.hh,v 1.4 2003/12/04 23:02:23 fluxgen Exp $ +// $Id: ClockTool.hh,v 1.5 2004/08/29 08:33:12 rathnor Exp $ #ifndef CLOCKTOOL_HH #define CLOCKTOOL_HH @@ -66,6 +66,7 @@ private: void updateTime(); void update(FbTk::Subject *subj); void renderTheme(); + void updateSizing(); FbTk::TextButton m_button; diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 18c3b75..5fe8e36 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.74 2004/08/28 19:03:09 rathnor Exp $ +// $Id: Menu.cc,v 1.75 2004/08/29 08:33:13 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -777,12 +777,14 @@ void Menu::redrawTitle() { 0, 0, m_title_pm.width(), m_title_pm.height()); + // difference between height based on font, and style-set height + int height_offset = theme().titleHeight() - (font.height() + 2*theme().bevelWidth()); menu.title.updateTransparent(); font.drawText(m_real_title_pm.drawable(), // drawable screenNumber(), theme().titleTextGC().gc(), // graphic context - text, len, // text string with lenght - dx, theme().titleHeight()/2 + (font.ascent() - theme().bevelWidth())/2); // position + text, len, // text string with length + dx, font.ascent() + theme().bevelWidth() + height_offset/2); // position } @@ -1196,6 +1198,9 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { int sbl = (me.x / menu.item_w), i = (me.y / theme().itemHeight()), w = (sbl * menu.persub) + i; + + if (w == m_active_index) + return; if (validIndex(m_active_index) && w != m_active_index) { diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 898bf99..ee1db93 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuItem.cc,v 1.5 2004/08/03 21:31:31 fluxgen Exp $ +// $Id: MenuItem.cc,v 1.6 2004/08/29 08:33:13 rathnor Exp $ #include "MenuItem.hh" #include "Command.hh" @@ -91,7 +91,8 @@ void MenuItem::draw(FbDrawable &draw, int text_w = theme.frameFont().textWidth(label().c_str(), label().size()); - text_y = y - theme.bevelWidth()/2 + theme.frameFont().ascent()/2 + height/2; + int height_offset = theme.itemHeight() - (theme.frameFont().height() + 2*theme.bevelWidth()); + text_y = y + theme.bevelWidth() + theme.frameFont().ascent() + height_offset/2; ///2 + height/2; switch(theme.frameFontJustify()) { case FbTk::LEFT: diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc index c698238..c2f1dc8 100644 --- a/src/FbTk/XftFontImp.cc +++ b/src/FbTk/XftFontImp.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: XftFontImp.cc,v 1.3 2004/08/10 11:57:35 fluxgen Exp $ +//$Id: XftFontImp.cc,v 1.4 2004/08/29 08:33:13 rathnor Exp $ #include "XftFontImp.hh" #include "App.hh" @@ -157,7 +157,10 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co unsigned int XftFontImp::height() const { if (m_xftfont == 0) return 0; - return m_xftfont->height; + return m_xftfont->height; + //m_xftfont->ascent + m_xftfont->descent; + // curiously, fonts seem to have a smaller height, but the "height" + // is specified within the actual font, so it must be right, right? } }; // end namespace FbTk diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 5695639..100ad5b 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.cc,v 1.42 2004/08/25 17:16:40 rathnor Exp $ +// $Id: IconbarTool.cc,v 1.43 2004/08/29 08:33:12 rathnor Exp $ #include "IconbarTool.hh" @@ -543,10 +543,9 @@ void IconbarTool::renderWindow(FluxboxWindow &win) { renderButton(*button); } +void IconbarTool::updateSizing() { + m_icon_container.setBorderWidth(m_theme.border().width()); -void IconbarTool::renderTheme() { - - // update button sizes before we get max width per client! IconList::iterator icon_it = m_icon_list.begin(); const IconList::iterator icon_it_end = m_icon_list.end(); for (; icon_it != icon_it_end; ++icon_it) { @@ -555,6 +554,13 @@ void IconbarTool::renderTheme() { else // unfocused (*icon_it)->setBorderWidth(m_theme.unfocusedBorder().width()); } + +} + +void IconbarTool::renderTheme() { + + // update button sizes before we get max width per client! + updateSizing(); Pixmap tmp = m_focused_pm; Pixmap err_tmp = m_focused_err_pm; @@ -616,7 +622,8 @@ void IconbarTool::renderTheme() { m_icon_container.setAlpha(m_theme.alpha()); // update buttons - icon_it = m_icon_list.begin(); + IconList::iterator icon_it = m_icon_list.begin(); + const IconList::iterator icon_it_end = m_icon_list.end(); for (; icon_it != icon_it_end; ++icon_it) { renderButton(*(*icon_it)); } diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 600a862..96b51b5 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.hh,v 1.14 2004/06/16 15:38:19 rathnor Exp $ +// $Id: IconbarTool.hh,v 1.15 2004/08/29 08:33:12 rathnor Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH @@ -79,6 +79,8 @@ private: /// @return button associated with window IconButton *findButton(FluxboxWindow &win); + void updateSizing(); + /// render single button that holds win void renderWindow(FluxboxWindow &win); /// render single button, and probably apply changes (clear) diff --git a/src/SystemTray.hh b/src/SystemTray.hh index 324b544..2091241 100644 --- a/src/SystemTray.hh +++ b/src/SystemTray.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SystemTray.hh,v 1.5 2004/08/25 17:16:40 rathnor Exp $ +// $Id: SystemTray.hh,v 1.6 2004/08/29 08:33:12 rathnor Exp $ #ifndef SYSTEMTRAY_HH #define SYSTEMTRAY_HH @@ -66,6 +66,7 @@ public: const FbTk::FbWindow &window() const { return m_window; } inline void renderTheme() {} + inline void updateSizing() {} private: typedef std::list ClientList; diff --git a/src/TextTheme.cc b/src/TextTheme.cc index bebf010..f23e030 100644 --- a/src/TextTheme.cc +++ b/src/TextTheme.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextTheme.cc,v 1.6 2003/08/27 18:05:12 fluxgen Exp $ +// $Id: TextTheme.cc,v 1.7 2004/08/29 08:33:12 rathnor Exp $ #include "TextTheme.hh" @@ -28,7 +28,7 @@ #include -TextTheme::TextTheme(FbTk::Theme &theme, +TextTheme::TextTheme(FbTk::Theme &theme, const std::string &name, const std::string &altname): m_font(theme, name + ".font", altname + ".Font"), m_text_color(theme, name + ".textColor", altname + ".TextColor"), @@ -49,6 +49,7 @@ TextTheme::~TextTheme() { void TextTheme::update() { m_text_gc.setForeground(*m_text_color); } + void TextTheme::setAntialias(bool value) { font().setAntialias(value); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 082a7f2..1be10e2 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.148 2004/08/25 17:16:40 rathnor Exp $ +// $Id: Toolbar.cc,v 1.149 2004/08/29 08:33:12 rathnor Exp $ #include "Toolbar.hh" @@ -227,6 +227,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): m_theme.reconfigSig().attach(this); // listen to screen size changes screen().resizeSig().attach(this); + screen().reconfigureSig().attach(this); // get this on antialias change moveToLayer((*m_rc_layernum).getNum()); @@ -453,12 +454,16 @@ void Toolbar::reconfigure() { ItemList::iterator item_it = m_item_list.begin(); ItemList::iterator item_it_end = m_item_list.end(); - for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { - (*item_it)->renderTheme(); + for (; item_it != item_it_end; ++item_it) { + (*item_it)->updateSizing(); } rearrangeItems(); + for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { + (*item_it)->renderTheme(); + } + menu().reconfigure(); // we're done with all resizing and stuff now we can request a new // area to be reserved on screen @@ -568,11 +573,11 @@ void Toolbar::update(FbTk::Subject *subj) { // either screen reconfigured, theme was reloaded // or a tool resized itself - if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject)) { + if (typeid(*subj) == typeid(ToolbarItem::ToolbarItemSubject)) rearrangeItems(); - } else { + else reconfigure(); - } + } void Toolbar::setPlacement(Toolbar::Placement where) { diff --git a/src/ToolbarItem.hh b/src/ToolbarItem.hh index 20cfd0c..0e77766 100644 --- a/src/ToolbarItem.hh +++ b/src/ToolbarItem.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarItem.hh,v 1.5 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ToolbarItem.hh,v 1.6 2004/08/29 08:33:13 rathnor Exp $ #ifndef TOOLBARITEM_HH #define TOOLBARITEM_HH @@ -57,6 +57,9 @@ public: // the toolbar instead. Otherwise there are ordering problems. virtual void renderTheme() = 0; + // just update theme items that affect the size + virtual void updateSizing() = 0; + FbTk::Subject &resizeSig() { return m_resize_sig; } void setType(Type type) { m_type = type; } diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index d1fe945..245fce5 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTool.cc,v 1.9 2004/08/25 17:16:40 rathnor Exp $ +// $Id: WorkspaceNameTool.cc,v 1.10 2004/08/29 08:33:13 rathnor Exp $ #include "WorkspaceNameTool.hh" @@ -109,6 +109,10 @@ void WorkspaceNameTool::hide() { m_button.hide(); } +void WorkspaceNameTool::updateSizing() { + m_button.setBorderWidth(m_theme.border().width()); +} + void WorkspaceNameTool::renderTheme() { Pixmap tmp = m_pixmap; if (!m_theme.texture().usePixmap()) { diff --git a/src/WorkspaceNameTool.hh b/src/WorkspaceNameTool.hh index b51008e..bc6dd63 100644 --- a/src/WorkspaceNameTool.hh +++ b/src/WorkspaceNameTool.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTool.hh,v 1.4 2003/08/23 15:45:38 fluxgen Exp $ +// $Id: WorkspaceNameTool.hh,v 1.5 2004/08/29 08:33:13 rathnor Exp $ #ifndef WORKSPACENAMETOOL_HH #define WORKSPACENAMETOOL_HH @@ -54,6 +54,7 @@ public: const FbTk::Button &button() const { return m_button; } private: void renderTheme(); + void updateSizing(); FbTk::TextButton m_button; const ToolTheme &m_theme; BScreen &m_screen; -- cgit v0.11.2