more external tab work, tidying and tab width config option

This commit is contained in:
simonb 2006-03-22 13:06:00 +00:00
parent fe4a7db228
commit 5e22dcd9ff
7 changed files with 48 additions and 25 deletions

View file

@ -4,6 +4,7 @@ Changes for 0.9.16:
* More external tabs work (Simon)
- Can now be placed TopLeft/TopRight/BottomLeft/BottomRight
- New "Tab Options" config menu, with (efficient) runtime updating
- New tab.width config option to control external tab width
- edge snapping includes tabs
- decoration fixes where some missed the tab option
- label text color was not updated

View file

@ -260,7 +260,10 @@ void Container::setSelected(int pos) {
}
void Container::setMaxSizePerClient(unsigned int size) {
m_max_size_per_client = size;
if (size != m_max_size_per_client) {
m_max_size_per_client = size;
repositionItems();
}
}
void Container::setMaxTotalSize(unsigned int size) {

View file

@ -80,13 +80,12 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
EnterWindowMask | LeaveWindowMask),
m_bevel(1),
m_use_titlebar(true),
m_tabplacement(BOTTOMRIGHT),
m_use_tabs(true),
m_use_handle(true),
m_focused(false),
m_visible(false),
m_button_pm(0),
m_tabmode(NOTSET),
m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL),
m_need_render(true),
m_themelistener(*this),
m_shape(new Shape(m_window, theme.shapePlace())) {
@ -129,6 +128,8 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
m_tabmode = tabmode;
m_tab_container.setUpdateLock(true);
// reparent tab container
if (tabmode == EXTERNAL) {
m_label.show();
@ -145,7 +146,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window());
int tabx, taby;
switch (m_tabplacement) {
switch (m_screen.getTabPlacement()) {
case TOPLEFT:
m_tab_container.setAlignment(Container::LEFT);
tabx = x();
@ -173,9 +174,14 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
m_layeritem.addWindow(m_tab_container);
}
m_tab_container.setMaxSizePerClient(64); //!!TODO make this a setting
m_tab_container.setMaxSizePerClient(m_screen.getTabWidth());
m_tab_container.setUpdateLock(false);
m_tab_container.setMaxTotalSize(window().width());
renderTabContainer();
applyTabContainer();
m_tab_container.clear();
// TODO: tab position
if (m_use_tabs && m_visible)
m_tab_container.show();
@ -194,7 +200,13 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
}
m_tab_container.setBorderWidth(0);
m_tab_container.setMaxTotalSize(0);
m_tab_container.setUpdateLock(false);
m_tab_container.setMaxSizePerClient(0);
renderTabContainer();
applyTabContainer();
m_tab_container.clear();
if (!m_use_tabs)
m_tab_container.show();
else
@ -310,7 +322,7 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
m_window.resize(width, height);
}
if (move || resize && m_tabplacement != TOPLEFT)
if (move || resize && m_screen.getTabPlacement() != TOPLEFT)
alignTabs();
if (resize) {
@ -333,8 +345,10 @@ void FbWinFrame::alignTabs() {
if (m_tabmode != EXTERNAL)
return;
m_tab_container.setMaxSizePerClient(m_screen.getTabWidth());
int tabx = 0, taby = 0;
switch (m_tabplacement) {
switch (m_screen.getTabPlacement()) {
case TOPLEFT:
tabx = x();
taby = y() - yOffset();
@ -877,8 +891,10 @@ void FbWinFrame::reconfigure() {
} else
m_titlebar.lower();
if (m_tabmode == EXTERNAL)
if (m_tabmode == EXTERNAL) {
m_tab_container.resize(m_tab_container.width(), buttonHeight());
alignTabs();
}
// leave client+grips alone if we're shaded (it'll get fixed when we unshade)
if (!m_shaded) {
@ -1271,9 +1287,7 @@ void FbWinFrame::init() {
m_label.setBorderWidth(0);
m_shaded = false;
// TODO: configurable default (on compile, for backwards compat)
// setTabMode(EXTERNAL);
setTabMode(INTERNAL);
setTabMode(NOTSET);
m_label.setEventMask(ExposureMask | ButtonPressMask |
ButtonReleaseMask | ButtonMotionMask |
@ -1605,7 +1619,7 @@ int FbWinFrame::yOffset() const {
if (m_tabmode != EXTERNAL || !m_use_tabs)
return 0;
switch (m_tabplacement) {
switch (m_screen.getTabPlacement()) {
case TOPLEFT:
case TOPRIGHT:
return m_tab_container.height() + m_window.borderWidth();

View file

@ -125,7 +125,7 @@ public:
inline void setFocusTitle(const std::string &str) { m_label.setText(str); }
void setDoubleClickTime(unsigned int time);
bool setTabMode(TabMode tabmode);
inline void setTabPlacement(TabPlacement tabplacement) { m_tabplacement = tabplacement; alignTabs(); }
inline void updateTabProperties() { alignTabs(); }
/// add a button to the left of the label
void addLeftButton(FbTk::Button *btn);
@ -367,7 +367,6 @@ private:
//@}
TabMode m_tabmode;
TabPlacement m_tabplacement;
bool m_need_render;
int m_button_size; ///< size for all titlebar buttons

View file

@ -270,6 +270,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"),
menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"),
menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"),
tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"),
menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"),
gc_line_width(rm, 1, scrname+".overlay.lineWidth", altscrname+".Overlay.LineWidth"),
@ -287,7 +288,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
altscrname+".overlay.CapStyle"),
scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"),
scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"),
default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") {
default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") {
}
@ -900,7 +901,7 @@ void BScreen::reconfigureTabs() {
Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
for (; win_it != win_it_end; ++win_it) {
(*win_it)->frame().setTabPlacement(*resource.tab_placement);
(*win_it)->frame().updateTabProperties();
if (*resource.default_internal_tabs)
(*win_it)->frame().setTabMode(FbWinFrame::INTERNAL);
else
@ -1642,11 +1643,21 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
"Tabs in Titlebar", "Tabs in Titlebar",
*resource.default_internal_tabs, save_and_reconftabs);
FbTk::MenuItem *tab_width_item =
new IntResMenuItem(_FBTEXT(Configmenu, ExternalTabWidth,
"External Tab Width",
"Width of external-style tabs"),
resource.tab_width, 10, 3000, /* silly number */
*tab_menu);
tab_width_item->setCommand(save_and_reconftabs);
tab_menu->insert(tab_width_item);
typedef pair<const char*, FbWinFrame::TabPlacement> PlacementP;
typedef list<PlacementP> Placements;
Placements place_menu;
// menu is 3 wide, 5 down
// menu is 2 wide, 2 down
place_menu.push_back(PlacementP(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT));
place_menu.push_back(PlacementP(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT));
place_menu.push_back(PlacementP(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));

View file

@ -142,6 +142,8 @@ public:
inline const bool getScrollReverse() const { return *resource.scroll_reverse; }
inline const bool getDefaultInternalTabs() const { return *resource.default_internal_tabs; }
inline unsigned int getTabWidth() const { return *resource.tab_width; }
inline Slit *slit() { return m_slit.get(); }
inline const Slit *slit() const { return m_slit.get(); }
@ -445,7 +447,7 @@ private:
FbTk::Resource<FollowModel> follow_model;
bool ordered_dither;
FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha,
unfocused_alpha, menu_alpha, menu_delay, menu_delay_close;
unfocused_alpha, menu_alpha, menu_delay, menu_delay_close, tab_width;
FbTk::Resource<FbTk::MenuTheme::MenuMode> menu_mode;
FbTk::Resource<int> gc_line_width;

View file

@ -394,13 +394,6 @@ void FluxboxWindow::init() {
frame().setUseShape(!m_shaped);
frame().setTabPlacement(screen().getTabPlacement());
if (screen().getDefaultInternalTabs()) {
frame().setTabMode(FbWinFrame::INTERNAL);
} else {
frame().setTabMode(FbWinFrame::EXTERNAL);
}
//!! TODO init of client should be better
// we don't want to duplicate code here and in attachClient
m_clientlist.push_back(m_client);