all repos — fluxbox @ f6e1f555f91059a0462db7d60b3a0923fed25652

custom fork of the fluxbox windowmanager

Add SpacerTool

This allows to add random spacers, fixed size or stretching, to the toolbar.

CCBUG: 1141
Thomas Lübking thomas.luebking@gmail.com
commit

f6e1f555f91059a0462db7d60b3a0923fed25652

parent

50b6102bbf998fc1d8393d4d48bf9507c359a9b9

4 files changed, 104 insertions(+), 0 deletions(-)

jump to
M src/Makemodule.amsrc/Makemodule.am

@@ -102,6 +102,8 @@ src/GenericTool.cc \

src/GenericTool.hh \ src/IconbarTool.cc \ src/IconbarTool.hh \ + src/SpacerTool.cc \ + src/SpacerTool.hh \ src/ToolFactory.cc \ src/ToolFactory.hh \ src/ToolTheme.cc \
A src/SpacerTool.cc

@@ -0,0 +1,39 @@

+// SpacerTool.cc for Fluxbox +// Copyright (c) 2016 Thomas Lübking <thomas.luebking@gmail.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#include "SpacerTool.hh" + +SpacerTool::SpacerTool(int size): + ToolbarItem(size < 0 ? RELATIVE : FIXED), m_size(size) { +} + +SpacerTool::~SpacerTool() { + +} + +unsigned int SpacerTool::width() const { + return ((orientation() & 1) || m_size < 0) ? 0 : m_size; +} + +unsigned int SpacerTool::height() const { + return ((orientation() & 1) && m_size > -1) ? m_size : 0; +} +
A src/SpacerTool.hh

@@ -0,0 +1,52 @@

+// SpacerTool.hh for Fluxbox +// Copyright (c) 2016 Thomas Lübking <thomas.luebking@gmail.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#ifndef SPACERTOOL_HH +#define SPACERTOOL_HH + +#include "ToolbarItem.hh" + + +class SpacerTool: public ToolbarItem { +public: + SpacerTool(int size = -1); + virtual ~SpacerTool(); + void move(int x, int y) {} + void resize(unsigned int x, unsigned int y) {} + void moveResize(int x, int y, + unsigned int width, unsigned int height) {} + void show() {} + void hide() {} + + unsigned int width() const; + unsigned int height() const; + unsigned int borderWidth() const {return 0;} + + void parentMoved() {} + void updateSizing() {} + + virtual void renderTheme(int alpha) {} + +private: + int m_size; +}; + +#endif // SPACERTOOL_HH
M src/ToolFactory.ccsrc/ToolFactory.cc

@@ -29,6 +29,7 @@ #include "SystemTray.hh"

#endif #include "IconbarTool.hh" #include "WorkspaceNameTool.hh" +#include "SpacerTool.hh" #include "ArrowButton.hh" // Themes

@@ -98,6 +99,16 @@ item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen());

#endif } else if (name == "clock") { item = new ClockTool(parent, m_clock_theme, screen(), tbar.menu()); + } else if (name.find("spacer") == 0) { + int size = -1; + if (name.size() > 6) { // spacer_20 creates a 20px spacer + if (name.at(6) != '_') + return 0; + size = atoi(name.substr(7, std::string::npos).c_str()); + if (size < 1) + return 0; + } + item = new SpacerTool(size); } else { std::string cmd_str = name;