fix some menu drawing issues
This commit is contained in:
parent
575578d810
commit
7d4f711204
9 changed files with 49 additions and 18 deletions
|
@ -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.
|
||||
|
|
|
@ -475,7 +475,7 @@ void Menu::updateMenu(int active_index) {
|
|||
}
|
||||
|
||||
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 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
|
|||
}
|
||||
|
||||
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 @@ void Menu::clearItem(int index, bool clear) {
|
|||
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)
|
||||
|
|
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
|
||||
}
|
||||
|
||||
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 @@ public:
|
|||
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 @@ private:
|
|||
std::string filename;
|
||||
};
|
||||
std::auto_ptr<Icon> m_icon;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace FbTk
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
|
||||
// $Id$
|
||||
|
||||
#include "FbTk/Menu.hh"
|
||||
|
||||
#include "IntResMenuItem.hh"
|
||||
#include "PixmapWithMask.hh"
|
||||
|
||||
#ifdef HAVE_CSTDIO
|
||||
#include <cstdio>
|
||||
#else
|
||||
|
@ -41,8 +44,8 @@ std::string appendIntValue(const std::string &label, int value) {
|
|||
|
||||
};
|
||||
|
||||
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 @@ void IntResMenuItem::click(int button, int time) {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1829,17 +1829,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -1257,7 +1257,7 @@ void Slit::setupMenu() {
|
|||
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));
|
||||
|
|
|
@ -48,11 +48,8 @@ public:
|
|||
// 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -796,7 +796,7 @@ void Toolbar::setupMenus() {
|
|||
|
||||
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 @@ void Toolbar::setupMenus() {
|
|||
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));
|
||||
|
|
Loading…
Reference in a new issue