Add new Fl_Scalepack class.

This commit is contained in:
Jonathan Moore Liles 2008-03-12 12:59:59 -05:00
parent 62f5e9006c
commit 56c04b6e30
5 changed files with 167 additions and 7 deletions

2
DPM.C
View File

@ -30,7 +30,7 @@
DPM::DPM ( int X, int Y, int W, int H, const char *L ) : DPM::DPM ( int X, int Y, int W, int H, const char *L ) :
Meter( X, Y, W, H, L ) Meter( X, Y, W, H, L )
{ {
divisions( 32 ); divisions( 64 );
type( FL_VERTICAL ); type( FL_VERTICAL );
dim( 0.80f ); dim( 0.80f );

95
Fl_Scalepack.C Normal file
View File

@ -0,0 +1,95 @@
/*******************************************************************************/
/* Copyright (C) 2008 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. */
/*******************************************************************************/
/* Fl_Scalepack
This is similar to an Fl_Pack, but instead of the pack resizing
itself to enclose its children, this pack resizes its children to
fit itself. Of course, this only works well with highly flexible
widgets, but the task comes up often enough to warrent this class.
If any child happens to be the resizable() widget, it is given half
of the available area, with the other widgets packed around it in
the remaining space.
*/
#include "Fl_Scalepack.H"
#include <FL/Fl.H>
#include <stdio.h>
Fl_Scalepack::Fl_Scalepack ( int X, int Y, int W, int H, const char *L ) :
Fl_Group( X, Y, W, H, L )
{
resizable( 0 );
_spacing = 0;
}
void
Fl_Scalepack::draw ( void )
{
int tx = x() + Fl::box_dx( box() );
int ty = y() + Fl::box_dy( box() );
int tw = w() - Fl::box_dw( box() );
int th = h() - Fl::box_dh( box() );
if ( damage() & FL_DAMAGE_ALL )
{
draw_box();
draw_label();
}
int v = 0;
for ( int i = children(); i--; )
if ( child( i )->visible() )
++v;
int sz, pos;
if ( type() == HORIZONTAL )
{
sz = tw / v;
pos = tw - ( tw % sz );
}
else
{
sz = th / v;
pos = th - ( th % sz );
}
for ( int i = children(); i--; )
if ( child( i )->visible() )
{
pos -= sz;
if ( type() == HORIZONTAL )
child( i )->resize( tx + pos, ty, sz, th );
else
child( i )->resize( tx, ty + pos, tw, sz );
if ( damage() & FL_DAMAGE_CHILD )
update_child( *child( i ) );
else
draw_child( *child( i ) );
}
}

41
Fl_Scalepack.H Normal file
View File

@ -0,0 +1,41 @@
/*******************************************************************************/
/* Copyright (C) 2008 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. */
/*******************************************************************************/
#pragma once
#include <FL/Fl_Group.H>
class Fl_Scalepack : public Fl_Group
{
int _spacing;
public:
enum { VERTICAL, HORIZONTAL };
Fl_Scalepack ( int X, int Y, int W, int H, const char *L = 0 );
virtual ~Fl_Scalepack ( ) { }
int spacing ( void ) const { return _spacing; }
void spacing ( int v ) { _spacing = v; redraw(); }
virtual void draw ( void );
};

View File

@ -26,8 +26,8 @@ $(OBJS): Makefile
test: $(OBJS) test: $(OBJS)
$(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@ $(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@
mixer: Mixer_Strip.o Mixer.o DPM.o mixer: Mixer_Strip.o Mixer.o DPM.o Fl_Scalepack.o
$(CXX) $(CXXFLAGS) $(LIBS) Mixer_Strip.o Mixer.o DPM.o -o $@ $(CXX) $(CXXFLAGS) $(LIBS) Mixer_Strip.o Mixer.o DPM.o Fl_Scalepack.o -o $@
ESRCS=Audio_File.C Audio_File_SF.C Loggable.C ESRCS=Audio_File.C Audio_File_SF.C Loggable.C

View File

@ -5,6 +5,9 @@ code_name {.C}
decl {\#include "DPM.H"} {public global decl {\#include "DPM.H"} {public global
} }
decl {\#include "Fl_Scalepack.H"} {public global
}
widget_class Mixer_Strip {open widget_class Mixer_Strip {open
xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable xywh {1051 42 124 816} type Double box UP_FRAME color 32 selection_color 63 resizable
code0 {size( 120, h() );} visible code0 {size( 120, h() );} visible
@ -41,11 +44,32 @@ widget_class Mixer_Strip {open
callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );} callback {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );}
xywh {14 195 33 471} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14 xywh {14 195 33 471} type {Vert Knob} color 32 selection_color 1 minimum 1.5 maximum 0 step 0.01 value 1 textsize 14
} }
Fl_Pack meters_pack {
label meters open selected
xywh {57 189 59 490} type HORIZONTAL
class Fl_Scalepack
} {
Fl_Box meter { Fl_Box meter {
label DPM selected label DPM
xywh {57 193 55 484} box ROUNDED_BOX selection_color 88 xywh {57 193 28 484} box ROUNDED_BOX selection_color 88
class DPM class DPM
} }
Fl_Box {} {
label DPM
xywh {86 193 30 484} box ROUNDED_BOX selection_color 88
class DPM
}
Fl_Box {} {
label DPM
xywh {96 203 20 476} box ROUNDED_BOX selection_color 88
class DPM
}
Fl_Box {} {
label DPM
xywh {106 213 20 476} box ROUNDED_BOX selection_color 88
class DPM
}
}
} }
Fl_Box {} { Fl_Box {} {
label {<Panner>} label {<Panner>}