all repos — fluxbox @ 346a6598a62350c5d234e3177de9e6c6c1963475

custom fork of the fluxbox windowmanager

make arrow button's arrow size scalable by the user
rathnor rathnor
commit

346a6598a62350c5d234e3177de9e6c6c1963475

parent

13bf2a7fddff4242581eec62243222acd49a1537

M ChangeLogChangeLog

@@ -1,8 +1,16 @@

(Format: Year/Month/Day) Changes for 0.9.10: *04/08/26: - * Fixed 2 possible Memleaks (Mathias) - Ewmh.cc + * Make arrow in toolbar buttons scalable size (Simon) + - new theme item: toolbar.button.scale: <number> + The number is a scale factor, which is divided into 100 to give + the size relative to the button. 100 gives a arrow the same size + as button, 200 gives half the size, 300 a third, etc. + - default is now 300, not 200 + - also fix size balance with left/right arrows + ArrowButton.hh/cc ButtonTheme.hh/cc ButtonTool.cc FbTk/Button.hh + * Fixed 2 possible Memleaks (Mathias) + Ewmh.cc * Re-implement bevels in toolbar, plus numerous toolbar-related theme fixes => old styles now look like they used to! (Simon) Toolbar.cc ToolbarItem.h ToolTheme.cc ToolbarTheme.cc ToolFactory.cc
M src/ArrowButton.ccsrc/ArrowButton.cc

@@ -19,9 +19,10 @@ // 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. -// $Id: ArrowButton.cc,v 1.7 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ArrowButton.cc,v 1.8 2004/08/26 15:09:33 rathnor Exp $ #include "ArrowButton.hh" +#include "ButtonTheme.hh" ArrowButton::ArrowButton(ArrowButton::Type arrow_type, const FbTk::FbWindow &parent,

@@ -29,7 +30,8 @@ int x, int y,

unsigned int width, unsigned int height): FbTk::Button(parent, x, y, width, height), m_arrow_type(arrow_type), - m_mouse_handler(0) { + m_mouse_handler(0), + m_arrowscale(300) { setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask);

@@ -41,7 +43,8 @@ int x, int y,

unsigned int width, unsigned int height): FbTk::Button(screen_num, x, y, width, height), m_arrow_type(arrow_type), - m_mouse_handler(0) { + m_mouse_handler(0), + m_arrowscale(300) { setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask);

@@ -84,15 +87,20 @@ void ArrowButton::drawArrow() {

XPoint pts[3]; unsigned int w = width(); unsigned int h = height(); - // arrow size: half of the button - unsigned int ax = w / 2; - unsigned int ay = h / 2; + + int arrowscale_n = m_arrowscale; + int arrowscale_d = 100; + unsigned int ax = arrowscale_d * w / arrowscale_n; + unsigned int ay = arrowscale_d * h / arrowscale_n; + // if these aren't an even number, left and right arrows end up different + if (( ax % 2 ) == 1) ax++; + if (( ay % 2 ) == 1) ay++; switch (m_arrow_type) { case LEFT: // start at the tip pts[0].x = (w / 2) - (ax / 2); pts[0].y = h / 2; - pts[1].x = ax; pts[1].y = ay / 2; - pts[2].x = 0; pts[2].y = - ay; + pts[1].x = ax; pts[1].y = -ay / 2; + pts[2].x = 0; pts[2].y = ay; break; case RIGHT: pts[0].x = (w / 2) + (ax / 2); pts[0].y = h / 2;

@@ -118,3 +126,12 @@ Convex, CoordModePrevious);

} } +void ArrowButton::updateTheme(const FbTk::Theme &theme) { + // it must be a button theme + const ButtonTheme &btheme = static_cast<const ButtonTheme &>(theme); + + m_arrowscale = btheme.scale(); + if (m_arrowscale == 0) m_arrowscale = 300; // default is 0 => 300 + else if (m_arrowscale < 100) m_arrowscale = 100; // otherwise clamp + else if (m_arrowscale > 100000) m_arrowscale = 100000; // clamp below overflow when *100 +}
M src/ArrowButton.hhsrc/ArrowButton.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: ArrowButton.hh,v 1.4 2003/10/13 23:51:04 fluxgen Exp $ +// $Id: ArrowButton.hh,v 1.5 2004/08/26 15:09:33 rathnor Exp $ #ifndef ARROWBUTTON_HH #define ARROWBUTTON_HH

@@ -45,10 +45,13 @@ void enterNotifyEvent(XCrossingEvent &ce);

void leaveNotifyEvent(XCrossingEvent &ce); void setMouseMotionHandler(FbTk::EventHandler *eh) { m_mouse_handler = eh; } + + void updateTheme(const FbTk::Theme &theme); private: void drawArrow(); Type m_arrow_type; FbTk::EventHandler *m_mouse_handler; + int m_arrowscale; }; #endif // ARROWBUTTON_HH
M src/ButtonTheme.ccsrc/ButtonTheme.cc

@@ -8,7 +8,8 @@ const std::string &alt_name):

ToolTheme(screen_num, name, alt_name), m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"), m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"), - m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)) { + m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), + m_scale(*this, name + ".scale", alt_name + ".Scale") { }
M src/ButtonTheme.hhsrc/ButtonTheme.hh

@@ -16,10 +16,12 @@ void reconfigTheme();

inline const FbTk::Texture &pressed() const { return *m_pressed_texture; } inline GC gc() const { return m_gc.gc(); } + inline int scale() const { return *m_scale; } // scale factor for inside objects private: FbTk::ThemeItem<FbTk::Color> m_pic_color; FbTk::ThemeItem<FbTk::Texture> m_pressed_texture; FbTk::GContext m_gc; + FbTk::ThemeItem<int> m_scale; }; #endif // BUTTONTHEME_HH
M src/ButtonTool.ccsrc/ButtonTool.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: ButtonTool.cc,v 1.3 2004/01/13 14:41:32 rathnor Exp $ +// $Id: ButtonTool.cc,v 1.4 2004/08/26 15:09:33 rathnor Exp $ #include "ButtonTool.hh"

@@ -55,6 +55,7 @@ btn.setGC(static_cast<const ButtonTheme &>(theme()).gc());

btn.setBorderColor(theme().border().color()); btn.setBorderWidth(theme().border().width()); btn.setAlpha(theme().alpha()); + btn.updateTheme(static_cast<const FbTk::Theme &>(theme())); Pixmap old_pm = m_cache_pm; if (!theme().texture().usePixmap()) {
M src/FbTk/Button.hhsrc/FbTk/Button.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Button.hh,v 1.8 2003/12/16 17:06:49 fluxgen Exp $ +// $Id: Button.hh,v 1.9 2004/08/26 15:09:33 rathnor Exp $ #ifndef FBTK_BUTTON_HH #define FBTK_BUTTON_HH

@@ -35,6 +35,8 @@ #include <X11/Xlib.h>

#include <memory> namespace FbTk { + +class Theme; class Button:public FbTk::FbWindow, public EventHandler, private NotCopyable {

@@ -66,6 +68,9 @@ virtual void buttonPressEvent(XButtonEvent &event);

virtual void buttonReleaseEvent(XButtonEvent &event); virtual void exposeEvent(XExposeEvent &event); //@} + + // in case it cares about a theme + virtual void updateTheme(const FbTk::Theme &theme) {} /// @return true if the button is pressed, else false bool pressed() const { return m_pressed; }