Feature #3602124: 'LHalf' and 'RHalf' buttons to the titlebar
First draft of feature request of #3602124: Having 2 buttons in the titlebar which allow quick positioning of a Window into the left or right half of the current monitor.
This commit is contained in:
parent
94fddc09c0
commit
34343bb20b
6 changed files with 85 additions and 19 deletions
|
@ -108,6 +108,12 @@ getString() const {
|
||||||
case WinButton::MENUICON:
|
case WinButton::MENUICON:
|
||||||
retval.append("MenuIcon");
|
retval.append("MenuIcon");
|
||||||
break;
|
break;
|
||||||
|
case WinButton::LEFT_HALF:
|
||||||
|
retval.append("LHalf");
|
||||||
|
break;
|
||||||
|
case WinButton::RIGHT_HALF:
|
||||||
|
retval.append("RHalf");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +148,10 @@ setFromString(char const *strval) {
|
||||||
m_value.push_back(WinButton::MENUICON);
|
m_value.push_back(WinButton::MENUICON);
|
||||||
else if (v == "close")
|
else if (v == "close")
|
||||||
m_value.push_back(WinButton::CLOSE);
|
m_value.push_back(WinButton::CLOSE);
|
||||||
|
else if (v == "lhalf")
|
||||||
|
m_value.push_back(WinButton::LEFT_HALF);
|
||||||
|
else if (v == "rhalf")
|
||||||
|
m_value.push_back(WinButton::RIGHT_HALF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,10 @@ Pixmap WinButton::getPixmap(const FbTk::ThemeProxy<WinButtonTheme> &theme) const
|
||||||
return theme->titlePixmap().pixmap().drawable();
|
return theme->titlePixmap().pixmap().drawable();
|
||||||
else
|
else
|
||||||
return theme->menuiconPixmap().pixmap().drawable();
|
return theme->menuiconPixmap().pixmap().drawable();
|
||||||
|
case LEFT_HALF:
|
||||||
|
return theme->leftHalfPixmap().pixmap().drawable();
|
||||||
|
case RIGHT_HALF:
|
||||||
|
return theme->rightHalfPixmap().pixmap().drawable();
|
||||||
default:
|
default:
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -160,18 +164,14 @@ void WinButton::drawType() {
|
||||||
// otherwise draw old style imagery
|
// otherwise draw old style imagery
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case MAXIMIZE:
|
case MAXIMIZE:
|
||||||
// if no pixmap was used, use old style
|
drawRectangle(gc(), 2, 2, width() - 5, height() - 5);
|
||||||
if (gc() == 0) // must have valid graphic context
|
drawLine(gc(), 2, 3, width() - 3, 3);
|
||||||
return;
|
|
||||||
|
|
||||||
drawRectangle(gc(),
|
|
||||||
2, 2, width() - 5, height() - 5);
|
|
||||||
drawLine(gc(),
|
|
||||||
2, 3, width() - 3, 3);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MINIMIZE:
|
case MINIMIZE:
|
||||||
drawRectangle(gc(), 2, height() - 5, width() - 5, 2);
|
drawRectangle(gc(), 2, height() - 5, width() - 5, 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STICK:
|
case STICK:
|
||||||
// width/4 != width/2, so we use /4*2 so that it's properly centred
|
// width/4 != width/2, so we use /4*2 so that it's properly centred
|
||||||
if (m_listen_to.isStuck()) {
|
if (m_listen_to.isStuck()) {
|
||||||
|
@ -184,6 +184,7 @@ void WinButton::drawType() {
|
||||||
width()/10*2 + oddW, height()/10*2 + oddH);
|
width()/10*2 + oddW, height()/10*2 + oddH);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSE:
|
case CLOSE:
|
||||||
drawLine(gc(),
|
drawLine(gc(),
|
||||||
2, 2,
|
2, 2,
|
||||||
|
@ -199,15 +200,12 @@ void WinButton::drawType() {
|
||||||
// XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428170728)
|
// XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428170728)
|
||||||
// (X Protocol Version 11, Revision 0, Release 6.6)
|
// (X Protocol Version 11, Revision 0, Release 6.6)
|
||||||
|
|
||||||
drawLine(gc(),
|
drawLine(gc(), 2, height() - 3, width() - 3, 2);
|
||||||
2, height() - 3,
|
|
||||||
width() - 3, 2);
|
|
||||||
break;
|
break;
|
||||||
case SHADE:
|
|
||||||
|
|
||||||
|
case SHADE:
|
||||||
{
|
{
|
||||||
int size = width() - 5 - oddW;
|
int size = width() - 5 - oddW;
|
||||||
|
|
||||||
drawRectangle(gc(), 2, 2, size, 2);
|
drawRectangle(gc(), 2, 2, size, 2);
|
||||||
|
|
||||||
// draw a one-quarter triangle below the rectangle
|
// draw a one-quarter triangle below the rectangle
|
||||||
|
@ -220,6 +218,7 @@ void WinButton::drawType() {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MENUICON:
|
case MENUICON:
|
||||||
if (m_icon_pixmap.drawable()) {
|
if (m_icon_pixmap.drawable()) {
|
||||||
|
|
||||||
|
@ -242,10 +241,16 @@ void WinButton::drawType() {
|
||||||
for (unsigned int y = height()/3; y <= height() - height()/3; y+=3) {
|
for (unsigned int y = height()/3; y <= height() - height()/3; y+=3) {
|
||||||
drawLine(gc(), width()/4, y, width() - width()/4 - oddW - 1, y);
|
drawLine(gc(), width()/4, y, width() - width()/4 - oddW - 1, y);
|
||||||
}
|
}
|
||||||
drawRectangle(gc(),
|
drawRectangle(gc(), 2, 2, width() - 5, height() - 5);
|
||||||
2, 2, width() - 5, height() - 5);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LEFT_HALF:
|
||||||
|
fillRectangle(gc(), 2, 2, (width() / 2) - oddW, height() - 4);
|
||||||
|
break;
|
||||||
|
case RIGHT_HALF:
|
||||||
|
fillRectangle(gc(), width() / 2, 2, (width() / 2) - 2 + oddW, height() - 4);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,17 @@ template <class T> class ThemeProxy;
|
||||||
class WinButton:public FbTk::Button, public FbTk::SignalTracker {
|
class WinButton:public FbTk::Button, public FbTk::SignalTracker {
|
||||||
public:
|
public:
|
||||||
/// draw type for the button
|
/// draw type for the button
|
||||||
enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON};
|
enum Type {
|
||||||
|
MAXIMIZE,
|
||||||
|
MINIMIZE,
|
||||||
|
SHADE,
|
||||||
|
STICK,
|
||||||
|
CLOSE,
|
||||||
|
MENUICON,
|
||||||
|
LEFT_HALF,
|
||||||
|
RIGHT_HALF
|
||||||
|
};
|
||||||
|
|
||||||
WinButton(FluxboxWindow &listen_to,
|
WinButton(FluxboxWindow &listen_to,
|
||||||
FbTk::ThemeProxy<WinButtonTheme> &theme,
|
FbTk::ThemeProxy<WinButtonTheme> &theme,
|
||||||
FbTk::ThemeProxy<WinButtonTheme> &pressed,
|
FbTk::ThemeProxy<WinButtonTheme> &pressed,
|
||||||
|
@ -66,7 +76,7 @@ private:
|
||||||
|
|
||||||
FbTk::FbPixmap m_icon_pixmap;
|
FbTk::FbPixmap m_icon_pixmap;
|
||||||
FbTk::FbPixmap m_icon_mask;
|
FbTk::FbPixmap m_icon_mask;
|
||||||
|
|
||||||
bool overrode_bg, overrode_pressed;
|
bool overrode_bg, overrode_pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,10 @@ WinButtonTheme::WinButtonTheme(int screen_num,
|
||||||
"Window.Stick" + altextra + ".Pixmap"),
|
"Window.Stick" + altextra + ".Pixmap"),
|
||||||
m_stuck_pm(*this, "window.stuck" + extra + ".pixmap",
|
m_stuck_pm(*this, "window.stuck" + extra + ".pixmap",
|
||||||
"Window.Stuck" + altextra + ".Pixmap"),
|
"Window.Stuck" + altextra + ".Pixmap"),
|
||||||
|
m_lefthalf_pm(*this, "window.lhalf" + extra + ".pixmap",
|
||||||
|
"Window.LHalf" + altextra + ".Pixmap"),
|
||||||
|
m_righthalf_pm(*this, "window.rhalf" + extra + ".pixmap",
|
||||||
|
"Window.RHalf" + altextra + ".Pixmap"),
|
||||||
m_frame_theme(frame_theme) {
|
m_frame_theme(frame_theme) {
|
||||||
|
|
||||||
FbTk::ThemeManager::instance().loadTheme(*this);
|
FbTk::ThemeManager::instance().loadTheme(*this);
|
||||||
|
@ -82,5 +86,7 @@ void WinButtonTheme::reconfigTheme() {
|
||||||
m_title_pm->scale(size, size);
|
m_title_pm->scale(size, size);
|
||||||
m_stick_pm->scale(size, size);
|
m_stick_pm->scale(size, size);
|
||||||
m_stuck_pm->scale(size, size);
|
m_stuck_pm->scale(size, size);
|
||||||
|
m_lefthalf_pm->scale(size, size);
|
||||||
|
m_righthalf_pm->scale(size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,18 @@ public:
|
||||||
|
|
||||||
const FbTk::PixmapWithMask &menuiconPixmap() const { return *m_menuicon_pm; }
|
const FbTk::PixmapWithMask &menuiconPixmap() const { return *m_menuicon_pm; }
|
||||||
FbTk::PixmapWithMask &menuiconPixmap() { return *m_menuicon_pm; }
|
FbTk::PixmapWithMask &menuiconPixmap() { return *m_menuicon_pm; }
|
||||||
|
|
||||||
FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; }
|
FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; }
|
||||||
const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; }
|
const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; }
|
||||||
|
|
||||||
|
|
||||||
|
FbTk::PixmapWithMask &leftHalfPixmap() { return *m_lefthalf_pm; }
|
||||||
|
const FbTk::PixmapWithMask &leftHalfPixmap() const { return *m_lefthalf_pm; }
|
||||||
|
|
||||||
|
FbTk::PixmapWithMask &rightHalfPixmap() { return *m_righthalf_pm; }
|
||||||
|
const FbTk::PixmapWithMask &rightHalfPixmap() const { return *m_righthalf_pm; }
|
||||||
|
|
||||||
|
|
||||||
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
|
||||||
|
|
||||||
virtual WinButtonTheme &operator *() { return *this; }
|
virtual WinButtonTheme &operator *() { return *this; }
|
||||||
|
@ -75,7 +83,7 @@ private:
|
||||||
|
|
||||||
FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_maximize_pm,
|
FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_maximize_pm,
|
||||||
m_iconify_pm, m_shade_pm, m_unshade_pm, m_menuicon_pm, m_title_pm,
|
m_iconify_pm, m_shade_pm, m_unshade_pm, m_menuicon_pm, m_title_pm,
|
||||||
m_stick_pm, m_stuck_pm;
|
m_stick_pm, m_stuck_pm, m_lefthalf_pm, m_righthalf_pm;
|
||||||
|
|
||||||
FbTk::ThemeProxy<FbWinFrameTheme> &m_frame_theme;
|
FbTk::ThemeProxy<FbWinFrameTheme> &m_frame_theme;
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
#include "FbTk/StringUtil.hh"
|
#include "FbTk/StringUtil.hh"
|
||||||
#include "FbTk/Compose.hh"
|
#include "FbTk/Compose.hh"
|
||||||
|
#include "FbTk/CommandParser.hh"
|
||||||
#include "FbTk/EventManager.hh"
|
#include "FbTk/EventManager.hh"
|
||||||
#include "FbTk/KeyUtil.hh"
|
#include "FbTk/KeyUtil.hh"
|
||||||
#include "FbTk/SimpleCommand.hh"
|
#include "FbTk/SimpleCommand.hh"
|
||||||
|
@ -3600,6 +3601,32 @@ void FluxboxWindow::updateButtons() {
|
||||||
winbtn->setOnClick(show_menu_cmd);
|
winbtn->setOnClick(show_menu_cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WinButton::LEFT_HALF:
|
||||||
|
{
|
||||||
|
winbtn = new WinButton(*this, m_button_theme,
|
||||||
|
screen().pressedWinButtonTheme(),
|
||||||
|
dir[i],
|
||||||
|
frame().titlebar(),
|
||||||
|
0, 0, 10, 10);
|
||||||
|
|
||||||
|
CommandRef lhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 0 0} {ResizeTo 50% 100%}"));
|
||||||
|
winbtn->setOnClick(lhalf_cmd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WinButton::RIGHT_HALF:
|
||||||
|
{
|
||||||
|
winbtn = new WinButton(*this, m_button_theme,
|
||||||
|
screen().pressedWinButtonTheme(),
|
||||||
|
dir[i],
|
||||||
|
frame().titlebar(),
|
||||||
|
0, 0, 10, 10);
|
||||||
|
CommandRef rhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 50% 0} {ResizeTo 50% 100%}"));
|
||||||
|
winbtn->setOnClick(rhalf_cmd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue