From 7da3bb325f0d948396c827fe18957e561d06ae53 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 6 Sep 2013 23:42:21 -0700 Subject: [PATCH] Add fancy new focus frame. --- FL/focus_frame.C | 57 +++++++++++++++++++++++++++++++++++++++++ FL/focus_frame.H | 22 ++++++++++++++++ FL/wscript | 1 + mixer/src/Mixer_Strip.C | 15 ++++++----- mixer/src/Module.C | 7 +++-- 5 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 FL/focus_frame.C create mode 100644 FL/focus_frame.H diff --git a/FL/focus_frame.C b/FL/focus_frame.C new file mode 100644 index 0000000..44210d9 --- /dev/null +++ b/FL/focus_frame.C @@ -0,0 +1,57 @@ + +/*******************************************************************************/ +/* Copyright (C) 2012 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +#include +#include + +void +draw_focus_frame ( int x, int y, int w, int h, Fl_Color c ) +{ + fl_push_clip( x, y, w, h ); + +// fl_color( fl_color_average( FL_GRAY, c, 0.50 ) ); + + fl_color( fl_color_add_alpha( c, 100 ) ); + + fl_line_style( FL_DASH, 2 ); + + fl_rect( x, y, w, h ); + + fl_line_style( FL_SOLID, 2 ); + + fl_color( c ); + + int l = 15; + + fl_line( x, y, x + l, y ); + fl_line( x, y + l, x, y ); + + fl_line( x + w - 1, y, x + w - l - 1, y ); + fl_line( x + w - 1, y, x + w - 1, y + l - 1 ); + + fl_line( x, y + h - 1, x, y + h - l - 1); + fl_line( x, y + h - 1, x + l, y + h - 1 ); + + fl_line( x + w - 1, y + h - 1, x + w - 1, y + h - l - 1 ); + fl_line( x + w - 1, y + h - 1, x + w - l, y + h - 1 ); + + fl_line_style( FL_SOLID, 0 ); + + fl_pop_clip(); +} diff --git a/FL/focus_frame.H b/FL/focus_frame.H new file mode 100644 index 0000000..b464b93 --- /dev/null +++ b/FL/focus_frame.H @@ -0,0 +1,22 @@ + +/*******************************************************************************/ +/* Copyright (C) 2012 Jonathan Moore Liles */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but WITHOUT */ +/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ +/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ +/* more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with This program; see the file COPYING. If not,write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*******************************************************************************/ + +void +draw_focus_frame ( int x, int y, int w, int h, Fl_Color c ); + diff --git a/FL/wscript b/FL/wscript index fd8fbf6..a4056c9 100644 --- a/FL/wscript +++ b/FL/wscript @@ -21,6 +21,7 @@ New_Project_Dialog.fl event_name.C menu_popup.C test_press.C +focus_frame.C ''', includes = '.', export_incdirs = [ '.' 'FL' ], diff --git a/mixer/src/Mixer_Strip.C b/mixer/src/Mixer_Strip.C index 3068d1f..e98e095 100644 --- a/mixer/src/Mixer_Strip.C +++ b/mixer/src/Mixer_Strip.C @@ -52,13 +52,14 @@ #include "Controller_Module.H" #include "Meter_Indicator_Module.H" #include "debug.h" - +#include "FL/focus_frame.H" #include #include "FL/test_press.H" #include "FL/menu_popup.H" #include #include #include "Group.H" +#include "FL/focus_frame.H" extern Mixer *mixer; @@ -498,7 +499,7 @@ Mixer_Strip::update ( void ) void Mixer_Strip::init ( ) { - selection_color( FL_RED ); + selection_color( FL_MAGENTA ); _mute_controller_mode = 0; _gain_controller_mode = 0; @@ -718,11 +719,13 @@ void Mixer_Strip::draw ( void ) { /* don't bother drawing anything else, all we're doing is drawing the focus. */ - if ( damage() & ~FL_DAMAGE_USER1 ) +// if ( damage() & ~FL_DAMAGE_USER1 ) Fl_Group::draw(); - - fl_color( Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK ); - fl_rect( x(), y(), w(), h() ); + + if ( Fl::focus() == this ) + draw_focus_frame( x(),y(),w(),h(), Fl_Group::selection_color() ); + /* else */ + /* clear_focus_frame( x(),y(),w(),h(), FL_BACKGROUND_COLOR ); */ } /*****************/ diff --git a/mixer/src/Module.C b/mixer/src/Module.C index a15096e..602f119 100644 --- a/mixer/src/Module.C +++ b/mixer/src/Module.C @@ -36,6 +36,7 @@ #include "AUX_Module.H" #include "Spatializer_Module.H" +#include "FL/focus_frame.H" #include #include "FL/test_press.H" #include "FL/menu_popup.H" @@ -138,7 +139,7 @@ Module::init ( void ) labeltype( FL_NO_LABEL ); align( FL_ALIGN_CENTER | FL_ALIGN_INSIDE ); set_visible_focus(); - selection_color( FL_RED ); + selection_color( FL_MAGENTA ); labelsize(12); color( fl_color_average( FL_WHITE, FL_CYAN, 0.40 ) ); tooltip( "Left click to edit parameters; Ctrl + left click to select; right click or MENU key for menu." ); @@ -648,9 +649,7 @@ Module::draw_box ( int tx, int ty, int tw, int th ) fl_pop_clip(); if ( this == Fl::focus() ) - { - fl_draw_box( FL_UP_FRAME, tx, ty, tw, th, selection_color() ); - } + draw_focus_frame( tx,ty,tw,th, selection_color() ); fl_pop_clip(); }