all repos — fluxbox @ 7d4f711204ab0b51d45eaff332708f529c11c9f5

custom fork of the fluxbox windowmanager

fix some menu drawing issues
simonb simonb
commit

7d4f711204ab0b51d45eaff332708f529c11c9f5

parent

575578d810733e0ca8d970f5923594a9d1930216

M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.13 *05/05/03: + * Fix drawing of no-title menus, plus updating of int menu items (Simon) + IntResMenuItem.hh/cc MenuItem.hh Menu.cc Screen.cc ToggleMenu.hh + Toolbar.cc Slit.cc * Code cleaning. (Henrik) Fluxbox::associateClient; creates tab and maps WinClient to label button.
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -475,7 +475,7 @@ width() + menu.title.borderWidth(), theme().titleHeight());

} menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + - menu.title.borderWidth()*2 : 1), + menu.title.borderWidth()*2 : 0), width(), menu.frame_h); if (m_title_vis && m_need_update) {

@@ -927,6 +927,8 @@ m_parent->clearItem(m_parent->m_which_sub); // clear

} m_moving = m_torn = true; + // clear current highlighted item + clearItem(m_active_index); if (m_which_sub >= 0) drawSubmenu(m_which_sub);

@@ -1238,7 +1240,8 @@ unsigned int item_w = menu.item_w, item_h = theme().itemHeight();

int item_x = (sbl * item_w), item_y = (i * item_h); bool highlight = (index == m_active_index); - if (highlight) { + // don't highlight if moving, doesn't work with alpha on + if (highlight && !m_moving) { highlightItem(index); return; } else if (clear)
M src/FbTk/MenuItem.hhsrc/FbTk/MenuItem.hh

@@ -42,6 +42,7 @@ class MenuItem {

public: MenuItem() : m_label(""), + m_menu(0), m_submenu(0), m_enabled(true), m_selected(false),

@@ -50,14 +51,25 @@ { }

explicit MenuItem( const char *label) : m_label(label ? label : ""), + m_menu(0), + m_submenu(0), + m_enabled(true), + m_selected(false), + m_toggle_item(false) + { } + + MenuItem(const char *label, Menu &host_menu) + : m_label(label ? label : ""), + m_menu(&host_menu), m_submenu(0), m_enabled(true), m_selected(false), m_toggle_item(false) { } /// create a menu item with a specific command to be executed on click - MenuItem(const char *label, RefCount<Command> &cmd): + MenuItem(const char *label, RefCount<Command> &cmd, Menu *menu = 0): m_label(label ? label : ""), + m_menu(menu), m_submenu(0), m_command(cmd), m_enabled(true),

@@ -66,8 +78,9 @@ m_toggle_item(false) {

} - MenuItem(const char *label, Menu *submenu) + MenuItem(const char *label, Menu *submenu, Menu *host_menu = 0) : m_label(label ? label : "") + , m_menu(host_menu) , m_submenu(submenu) , m_enabled(true) , m_selected(false),

@@ -110,9 +123,13 @@ virtual void click(int button, int time);

RefCount<Command> &command() { return m_command; } const RefCount<Command> &command() const { return m_command; } //@} + + void setMenu(Menu &menu) { m_menu = &menu; } + Menu *menu() { return m_menu; } private: std::string m_label; ///< label of this item + Menu *m_menu; ///< the menu we live in Menu *m_submenu; ///< a submenu, 0 if we don't have one RefCount<Command> m_command; ///< command to be executed bool m_enabled, m_selected;

@@ -123,6 +140,7 @@ std::auto_ptr<PixmapWithMask> pixmap;

std::string filename; }; std::auto_ptr<Icon> m_icon; + }; } // end namespace FbTk
M src/IntResMenuItem.ccsrc/IntResMenuItem.cc

@@ -21,8 +21,11 @@ // DEALINGS IN THE SOFTWARE.

// $Id$ +#include "FbTk/Menu.hh" + #include "IntResMenuItem.hh" #include "PixmapWithMask.hh" + #ifdef HAVE_CSTDIO #include <cstdio> #else

@@ -41,8 +44,8 @@ }

}; -IntResMenuItem::IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val): - FbTk::MenuItem(label), m_org_label(FbTk::MenuItem::label()), +IntResMenuItem::IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val, FbTk::Menu &host_menu): + FbTk::MenuItem(label, host_menu), m_org_label(FbTk::MenuItem::label()), m_max(max_val), m_min(min_val), m_res(res) { setLabel(appendIntValue(m_org_label, *m_res).c_str()); }

@@ -72,4 +75,11 @@ // update label

setLabel(appendIntValue(m_org_label, *m_res).c_str()); // call other commands FbTk::MenuItem::click(button, time); + + // show new value, which for us means forcing a full menu update + // since the text is drawn onto the background! + if (menu()) { + menu()->frameWindow().updateBackground(false); + menu()->clearWindow(); + } }
M src/IntResMenuItem.hhsrc/IntResMenuItem.hh

@@ -30,7 +30,7 @@

/// Changes an resource integer value between min and max class IntResMenuItem: public FbTk::MenuItem { public: - IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val); + IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val, FbTk::Menu &host_menu); void click(int button, int time);
M src/Screen.ccsrc/Screen.cc

@@ -1829,17 +1829,17 @@ Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure));

} FbTk::MenuItem *focused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, FocusedAlpha, "Focused Window Alpha", "Transparency level of the focused window"), - resource.focused_alpha, 0, 255); + resource.focused_alpha, 0, 255, *alpha_menu); focused_alpha_item->setCommand(saverc_cmd); alpha_menu->insert(focused_alpha_item); FbTk::MenuItem *unfocused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, UnfocusedAlpha, "Unfocused Window Alpha", "Transparency level of unfocused windows"), - resource.unfocused_alpha, 0, 255); + resource.unfocused_alpha, 0, 255, *alpha_menu); unfocused_alpha_item->setCommand(saverc_cmd); alpha_menu->insert(unfocused_alpha_item); FbTk::MenuItem *menu_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, MenuAlpha, "Menu Alpha", "Transparency level of menu"), - resource.menu_alpha, 0, 255); + resource.menu_alpha, 0, 255, *alpha_menu); menu_alpha_item->setCommand(saverc_cmd); alpha_menu->insert(menu_alpha_item);
M src/Slit.ccsrc/Slit.cc

@@ -1257,7 +1257,7 @@ // this saves resources and clears the slit window to update alpha value

FbTk::MenuItem *alpha_menuitem = new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), m_rc_alpha, - 0, 255); + 0, 255, m_slitmenu); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); RefCount<Command> alpha_cmd(new SimpleCommand<Slit>(*this, &Slit::updateAlpha));
M src/ToggleMenu.hhsrc/ToggleMenu.hh

@@ -48,11 +48,8 @@ // the items each time we get a button release event

// so that the last toggled item gets redrawn as // not toggled. if (ev.window == frameWindow()) { - // force full foreground update (by setting bg to same thing) - frameWindow().parentMoved(); -// for (size_t i = 0; i < numberOfItems(); ++i) { -// clearItem(i); -// } + // force full foreground update + frameWindow().updateBackground(false); } }
M src/Toolbar.ccsrc/Toolbar.cc

@@ -796,7 +796,7 @@ "Toolbar", "Title of Toolbar menu"));

MenuItem *toolbar_menuitem = new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, "Toolbar width percent", "Percentage of screen width taken by toolbar"), m_rc_width_percent, - 0, 100); // min/max value + 0, 100, menu()); // min/max value RefCommand reconfig_toolbar(new ToolbarCommand(*this, &Toolbar::reconfigure));

@@ -886,7 +886,7 @@ // this saves resources and clears the slit window to update alpha value

FbTk::MenuItem *alpha_menuitem = new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), m_rc_alpha, - 0, 255); + 0, 255, menu()); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); RefCount<Command> alpha_cmd(new SimpleCommand<Toolbar>(*this, &Toolbar::updateAlpha));