most of the 2.X->3.0 commit (up to rev 4299) except for gtk2_ardour/editor_canvas.cc; builds and runs and does a few specific things but expect it to be buggy for a while yet

git-svn-id: svn://localhost/ardour2/branches/3.0@4313 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis
2008-12-12 14:43:24 +00:00
parent 30daaebaa2
commit bc89fe0147
252 changed files with 28174 additions and 14382 deletions

View File

@@ -43,6 +43,7 @@
#ifndef __CAAudioFile_h__
#define __CAAudioFile_h__
#include <iostream>
#include <AvailabilityMacros.h>
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
@@ -98,6 +99,7 @@ public:
// implementation-independent helpers
void Open(const char *filePath) {
FSRef fsref;
std::cerr << "Opening " << filePath << std::endl;
XThrowIfError(FSPathMakeRef((UInt8 *)filePath, &fsref, NULL), "locate audio file");
Open(fsref);
}
@@ -112,9 +114,10 @@ public:
// or the file's sample rate is 0 (unknown)
#if CAAF_USE_EXTAUDIOFILE
#warning HERE WE ARE
public:
CAAudioFile() : mExtAF(NULL) { }
virtual ~CAAudioFile() { if (mExtAF) Close(); }
CAAudioFile() : mExtAF(NULL) { std::cerr << "Constructing CAAudioFile\n"; }
virtual ~CAAudioFile() { std::cerr << "Destroying CAAudiofile @ " << this << std::endl; if (mExtAF) Close(); }
void Open(const FSRef &fsref) {
// open an existing file
@@ -131,6 +134,7 @@ public:
}
void Close() {
std::cerr << "\tdisposeo of ext audio file @ " << mExtAF << std::endl;
XThrowIfError(ExtAudioFileDispose(mExtAF), "ExtAudioFileClose failed");
mExtAF = NULL;
}

View File

@@ -4,7 +4,7 @@ import os
import os.path
import glob
appleutility_files = glob.glob('*.cpp')
appleutility_files = [ glob.glob('*.cpp') + glob.glob('*.c') + glob.glob('*.C') ]
Import('env install_prefix')
appleutility = env.Clone()

View File

@@ -75,7 +75,7 @@ Analyser::queue_source_for_analysis (boost::shared_ptr<Source> src, bool force)
void
Analyser::work ()
{
PBD::ThreadCreated (pthread_self(), string ("analyser-") + to_string (pthread_self(), std::dec));
PBD::notify_gui_about_thread_creation (pthread_self(), string ("analyser-") + to_string (pthread_self(), std::dec));
while (true) {
analysis_queue_lock.lock ();

View File

@@ -78,6 +78,19 @@ public:
_silent = ( (src.silent() && _silent) || (_silent && gain_coeff == 0) );
}
/** Accumulate (add) @a len frames FROM THE START OF @a src into self at @a offset
* scaling by @a gain_coeff */
void accumulate_with_gain_from(const Sample* src_raw, nframes_t len, nframes_t offset, gain_t gain_coeff) {
assert(_capacity > 0);
assert(offset + len <= _capacity);
Sample* const dst_raw = _data + offset;
mix_buffers_with_gain (dst_raw, src_raw, len, gain_coeff);
_silent = (_silent && gain_coeff == 0);
}
void apply_gain(gain_t gain, nframes_t len, nframes_t offset=0) {
apply_gain_to_buffer (_data + offset, len, gain);

View File

@@ -56,6 +56,10 @@ class AudioRegion : public Region
~AudioRegion();
void copy_settings (boost::shared_ptr<const AudioRegion>);
bool source_equivalent (boost::shared_ptr<const Region>) const;
bool speed_mismatch (float) const;
boost::shared_ptr<AudioSource> audio_source (uint32_t n=0) const;
@@ -78,8 +82,17 @@ class AudioRegion : public Region
uint32_t chan_n=0, double samples_per_unit= 1.0) const;
/* Readable interface */
enum ReadOps {
ReadOpsNone = 0x0,
ReadOpsOwnAutomation = 0x1,
ReadOpsOwnScaling = 0x2,
ReadOpsCount = 0x4,
ReadOpsFades = 0x8
};
virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const;
virtual nframes64_t read_with_ops (Sample*, nframes64_t pos, nframes64_t cnt, int channel, ReadOps rops) const;
virtual nframes64_t readable_length() const { return length(); }
virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf,
@@ -151,11 +164,14 @@ class AudioRegion : public Region
private:
friend class RegionFactory;
friend class Crossfade;
AudioRegion (boost::shared_ptr<AudioSource>, nframes_t start, nframes_t length);
AudioRegion (boost::shared_ptr<AudioSource>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (const SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (boost::shared_ptr<const AudioRegion>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (boost::shared_ptr<const AudioRegion>, const SourceList&, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (boost::shared_ptr<const AudioRegion>);
AudioRegion (boost::shared_ptr<AudioSource>, const XMLNode&);
AudioRegion (SourceList &, const XMLNode&);
@@ -174,7 +190,7 @@ class AudioRegion : public Region
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0,
bool raw = false) const;
ReadOps readops = ReadOps (~0)) const;
void recompute_at_start ();
void recompute_at_end ();
@@ -201,7 +217,6 @@ class AudioRegion : public Region
/* default constructor for derived (compound) types */
AudioRegion (Session& s, nframes_t, nframes_t, std::string name);
AudioRegion (boost::shared_ptr<const AudioRegion>);
int set_live_state (const XMLNode&, Change&, bool send);
};

View File

@@ -59,6 +59,10 @@ public:
return ((ARDOUR::AutomationList*)_list.get())->automation_state();
}
inline void set_automation_state(AutoState as) {
return ((ARDOUR::AutomationList*)_list.get())->set_automation_state(as);
}
inline void start_touch() {
return ((ARDOUR::AutomationList*)_list.get())->start_touch();
}

View File

@@ -42,12 +42,12 @@ class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlL
public:
AutomationList (Evoral::Parameter id);
AutomationList (const XMLNode&, Evoral::Parameter id);
AutomationList (const AutomationList&);
AutomationList (const AutomationList&, double start, double end);
~AutomationList();
virtual boost::shared_ptr<Evoral::ControlList> create(Evoral::Parameter id);
AutomationList (const AutomationList&);
AutomationList (const AutomationList&, double start, double end);
AutomationList& operator= (const AutomationList&);
bool operator== (const AutomationList&);

View File

@@ -95,6 +95,7 @@ CONFIG_VARIABLE (bool, solo_latched, "solo-latched", true)
CONFIG_VARIABLE (bool, latched_record_enable, "latched-record-enable", false)
CONFIG_VARIABLE (bool, all_safe, "all-safe", false)
CONFIG_VARIABLE (bool, show_solo_mutes, "show-solo-mutes", false)
CONFIG_VARIABLE (bool, solo_mute_override, "solo-mute-override", false)
CONFIG_VARIABLE (bool, tape_machine_mode, "tape-machine-mode", false)
/* click */
@@ -161,6 +162,7 @@ CONFIG_VARIABLE (uint32_t, periodic_safety_backup_interval, "periodic-safety-bac
CONFIG_VARIABLE (float, automation_interval, "automation-interval", 50)
CONFIG_VARIABLE (bool, sync_all_route_ordering, "sync-all-route-ordering", true)
CONFIG_VARIABLE (bool, only_copy_imported_files, "only-copy-imported-files", true)
CONFIG_VARIABLE (bool, new_plugins_active, "new-plugins-active", true)
CONFIG_VARIABLE (std::string, keyboard_layout, "keyboard-layout", "ansi")
CONFIG_VARIABLE (std::string, default_bindings, "default-bindings", "ardour")
CONFIG_VARIABLE (bool, default_narrow_ms, "default-narrow_ms", false)

View File

@@ -120,6 +120,29 @@ class OSC : public BasicUI, public sigc::trackable
PATH_CALLBACK1(set_transport_speed,f,);
PATH_CALLBACK1(access_action,s,&);
#define PATH_CALLBACK2(name,arg1type,arg2type) \
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
if (argc > 1) { \
name (argv[0]->arg1type, argv[1]->arg2type); \
} \
return 0; \
}
PATH_CALLBACK2(route_mute,i,i);
PATH_CALLBACK2(route_solo,i,i);
PATH_CALLBACK2(route_recenable,i,i);
PATH_CALLBACK2(route_set_gain_abs,i,f);
PATH_CALLBACK2(route_set_gain_dB,i,f);
int route_mute (int rid, int yn);
int route_solo (int rid, int yn);
int route_recenable (int rid, int yn);
int route_set_gain_abs (int rid, float level);
int route_set_gain_dB (int rid, float dB);
};
}

View File

@@ -131,8 +131,9 @@ class Region
nframes_t sync_offset(int& dir) const;
nframes_t sync_position() const;
nframes_t sync_point () const;
nframes_t adjust_to_sync (nframes_t);
nframes_t adjust_to_sync (nframes_t) const;
/* first_frame() is an alias; last_frame() just hides some math */
@@ -264,6 +265,7 @@ class Region
const string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags);
Region (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Flag flags = DefaultFlags);
Region (boost::shared_ptr<const Region>, nframes_t length, const string& name, layer_t = 0, Flag flags = DefaultFlags);
Region (boost::shared_ptr<const Region>);
Region (boost::shared_ptr<Source> src, const XMLNode&);
Region (const SourceList& srcs, const XMLNode&);
@@ -271,6 +273,8 @@ class Region
Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags);
protected:
void copy_stuff (boost::shared_ptr<const Region>, nframes_t start, nframes_t length, const string& name, layer_t, Flag flags);
XMLNode& get_short_state (); /* used only by Session */
void send_change (Change);

View File

@@ -48,11 +48,12 @@ class RegionFactory {
*/
static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, nframes_t start,
nframes_t length, std::string name,
nframes_t length, const std::string& name,
layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
static boost::shared_ptr<Region> create (boost::shared_ptr<AudioRegion>, nframes_t start,
nframes_t length, std::string name,
nframes_t length, const std::string& name,
layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, const SourceList&, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
static boost::shared_ptr<Region> create (const SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);

View File

@@ -107,6 +107,8 @@ class Route : public IO
/* end of vfunc-based API */
void shift (nframes64_t, nframes64_t);
/* override IO::set_gain() to provide group control */
void set_gain (gain_t val, void *src);
@@ -117,7 +119,7 @@ class Route : public IO
void set_solo_safe (bool yn, void *src);
bool solo_safe() const { return _solo_safe; }
void set_mute (bool yn, void *src);
bool muted() const { return _muted; }
bool solo_muted() const { return desired_solo_gain == 0.0; }
@@ -262,6 +264,7 @@ class Route : public IO
protected:
friend class Session;
void catch_up_on_solo_mute_override ();
void set_solo_mute (bool yn);
void set_block_size (nframes_t nframes);
bool has_external_redirects() const;

View File

@@ -413,6 +413,10 @@ class Session : public PBD::StatefulDestructible
double frames_per_smpte_frame() const { return _frames_per_smpte_frame; }
nframes_t smpte_frames_per_hour() const { return _smpte_frames_per_hour; }
MIDI::byte get_mtc_smpte_bits() const {
return mtc_smpte_bits; /* encoding of SMTPE type for MTC */
}
float smpte_frames_per_second() const;
bool smpte_drop_frames() const;
@@ -610,6 +614,7 @@ class Session : public PBD::StatefulDestructible
string doing_what;
/* control info */
uint32_t total;
SrcQuality quality;
volatile bool freeze;
std::vector<Glib::ustring> paths;
@@ -617,7 +622,6 @@ class Session : public PBD::StatefulDestructible
/* result */
SourceList sources;
};
void import_audiofiles (import_status&);
@@ -964,6 +968,10 @@ class Session : public PBD::StatefulDestructible
void add_controllable (boost::shared_ptr<PBD::Controllable>);
void remove_controllable (PBD::Controllable*);
/* metadata */
SessionMetadata & metadata () { return *_metadata; }
protected:
friend class AudioEngine;
void set_block_size (nframes_t nframes);
@@ -1457,6 +1465,7 @@ class Session : public PBD::StatefulDestructible
void route_mute_changed (void *src);
void route_solo_changed (void *src, boost::weak_ptr<Route>);
void catch_up_on_solo ();
void catch_up_on_solo_mute_override ();
void update_route_solo_state ();
void modify_solo_mute (bool, bool);
void strip_portname_for_solo (string& portname);
@@ -1701,6 +1710,12 @@ class Session : public PBD::StatefulDestructible
uint32_t n_physical_outputs;
uint32_t n_physical_inputs;
uint32_t n_physical_audio_outputs;
uint32_t n_physical_audio_inputs;
uint32_t n_physical_midi_outputs;
uint32_t n_physical_midi_inputs;
int find_all_sources (std::string path, std::set<std::string>& result);
int find_all_sources_across_snapshots (std::set<std::string>& result, bool exclude_this_snapshot);
@@ -1728,8 +1743,10 @@ class Session : public PBD::StatefulDestructible
/* Metadata */
SessionMetadata * _metadata;
public:
SessionMetadata & metadata () { return *_metadata; }
/* used in ::audible_frame() */
mutable bool have_looped;
};
} // namespace ARDOUR

View File

@@ -186,6 +186,7 @@ class MTC_Slave : public Slave, public sigc::trackable {
SafeTime current;
nframes_t mtc_frame; /* current time */
nframes_t last_inbound_frame; /* when we got it; audio clocked */
MIDI::byte last_mtc_fps_byte;
float mtc_speed;
nframes_t first_mtc_frame;

View File

@@ -1,6 +1,8 @@
#ifndef __ardour_svn_revision_h__
#define __ardour_svn_revision_h__
namespace ARDOUR {
extern const char* svn_revision;
extern const char* svn_revision;
}
#endif

View File

@@ -124,6 +124,9 @@ class Track : public Route
vector<FreezeRecordProcessorInfo*> processor_info;
bool have_mementos;
FreezeState state;
gain_t gain;
AutoState gain_automation_state;
AutoState pan_automation_state;
};
struct RecEnableControllable : public PBD::Controllable {

View File

@@ -586,19 +586,74 @@ AudioTrack::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame,
/* copy the diskstream data to all output buffers */
const size_t limit = n_process_buffers().n_audio();
BufferSet& bufs = _session.get_scratch_buffers (n_process_buffers());
size_t limit = n_process_buffers().n_audio();
BufferSet& bufs = _session.get_scratch_buffers ();
const size_t blimit = bufs.count().n_audio();
uint32_t n;
uint32_t i;
for (i = 0, n = 1; i < limit; ++i, ++n) {
memcpy (bufs.get_audio(i).data(), b, sizeof (Sample) * nframes);
if (n < diskstream->n_channels().n_audio()) {
tmpb = diskstream->playback_buffer(n);
if (tmpb!=0) {
b = tmpb;
if (limit > blimit) {
/* example case: auditioner configured for stereo output,
but loaded with an 8 channel file. there are only
2 passthrough buffers, but n_process_buffers() will
return 8.
arbitrary decision: map all channels in the diskstream
to the outputs available.
*/
float scaling = limit/blimit;
for (i = 0, n = 1; i < blimit; ++i, ++n) {
/* first time through just copy a channel into
the output buffer.
*/
Sample* bb = bufs.get_audio (i).data();
for (nframes_t xx = 0; xx < nframes; ++xx) {
bb[xx] = b[xx] * scaling;
}
if (n < diskstream->n_channels().n_audio()) {
tmpb = diskstream->playback_buffer(n);
if (tmpb!=0) {
b = tmpb;
}
}
}
for (;i < limit; ++i, ++n) {
/* for all remaining channels, sum with existing
data in the output buffers
*/
bufs.get_audio (i%blimit).accumulate_with_gain_from (b, nframes, 0, scaling);
if (n < diskstream->n_channels().n_audio()) {
tmpb = diskstream->playback_buffer(n);
if (tmpb!=0) {
b = tmpb;
}
}
}
limit = blimit;
} else {
for (i = 0, n = 1; i < limit; ++i, ++n) {
memcpy (bufs.get_audio (i).data(), b, sizeof (Sample) * nframes);
if (n < diskstream->n_channels().n_audio()) {
tmpb = diskstream->playback_buffer(n);
if (tmpb!=0) {
b = tmpb;
}
}
}
}
@@ -830,6 +885,11 @@ AudioTrack::freeze (InterThreadInfo& itt)
}
new_playlist = PlaylistFactory::create (DataType::AUDIO, _session, new_playlist_name, false);
_freeze_record.gain = _gain;
_freeze_record.gain_automation_state = _gain_control->automation_state();
_freeze_record.pan_automation_state = _panner->automation_state();
region_name = new_playlist_name;
/* create a new region from all filesources, keep it private */
@@ -847,6 +907,12 @@ AudioTrack::freeze (InterThreadInfo& itt)
diskstream->use_playlist (boost::dynamic_pointer_cast<AudioPlaylist>(new_playlist));
diskstream->set_record_enabled (false);
/* reset stuff that has already been accounted for in the freeze process */
set_gain (1.0, this);
_gain_control->set_automation_state (Off);
_panner->set_automation_state (Off);
_freeze_record.state = Frozen;
FreezeChange(); /* EMIT SIGNAL */
}
@@ -877,6 +943,9 @@ AudioTrack::unfreeze ()
}
_freeze_record.playlist.reset ();
set_gain (_freeze_record.gain, this);
_gain_control->set_automation_state (_freeze_record.gain_automation_state);
_panner->set_automation_state (_freeze_record.pan_automation_state);
}
_freeze_record.state = UnFrozen;

View File

@@ -103,7 +103,15 @@ AUPlugin::~AUPlugin ()
void
AUPlugin::init ()
{
OSErr err = CAAudioUnit::Open (*(comp.get()), *unit);
OSErr err;
try {
err = CAAudioUnit::Open (*(comp.get()), *unit);
} catch (...) {
error << _("Exception thrown during AudioUnit plugin loading - plugin ignored") << endmsg;
cerr << _("Exception thrown during AudioUnit plugin loading - plugin ignored") << endl;
throw failed_constructor();
}
if (err != noErr) {
error << _("AudioUnit: Could not convert CAComponent to CAAudioUnit") << endmsg;
@@ -1090,6 +1098,7 @@ AUPluginInfo::cached_io_configuration (const std::string& unique_id,
} catch (...) {
warning << string_compose (_("Could not load AU plugin %1 - ignored"), name) << endmsg;
cerr << string_compose (_("Could not load AU plugin %1 - ignored"), name) << endl;
return false;
}

View File

@@ -132,7 +132,7 @@ _thread_init_callback (void *arg)
knows about it.
*/
PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("Audioengine"), 4096);
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Audioengine"), 4096);
MIDI::JACK_MidiPort::set_process_thread (pthread_self());
}
@@ -922,8 +922,6 @@ AudioEngine::halted (void *arg)
ae->_buffer_size = 0;
ae->_frame_rate = 0;
cerr << "!!! HALTED !!!\n";
if (was_running) {
ae->Halted(); /* EMIT SIGNAL */
}
@@ -1318,7 +1316,7 @@ AudioEngine::reconnect_to_jack ()
if (Config->get_jack_time_master()) {
jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
}
}
if (jack_activate (_jack) == 0) {
_running = true;

View File

@@ -133,9 +133,9 @@ AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t len
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (other, offset, length, name, layer, flags)
, _automatable(other->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
, _fade_in (new AutomationList(*other->_fade_in, offset, offset + length))
, _fade_out (new AutomationList(*other->_fade_out, offset, offset + length))
, _envelope (new AutomationList(*other->_envelope, offset, offset + length))
{
set<boost::shared_ptr<Source> > unique_srcs;
@@ -185,17 +185,48 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
: Region (other)
, _automatable(other->session())
, _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation)))
, _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation)))
, _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation)))
, _automatable (other->session())
, _fade_in (new AutomationList (*other->_fade_in))
, _fade_out (new AutomationList (*other->_fade_out))
, _envelope (new AutomationList (*other->_envelope))
{
assert(_type == DataType::AUDIO);
_scale_amplitude = other->_scale_amplitude;
_envelope = other->_envelope;
set_default_fades ();
listen_to_my_curves ();
listen_to_my_sources ();
}
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const SourceList& srcs,
nframes_t length, const string& name, layer_t layer, Flag flags)
: Region (other, length, name, layer, flags)
, _automatable (other->session())
, _fade_in (new AutomationList (*other->_fade_in))
, _fade_out (new AutomationList (*other->_fade_out))
, _envelope (new AutomationList (*other->_envelope))
{
/* make-a-sort-of-copy-with-different-sources constructor (used by audio filter) */
set<boost::shared_ptr<AudioSource> > unique_srcs;
for (SourceList::const_iterator i=srcs.begin(); i != srcs.end(); ++i) {
_sources.push_back (*i);
_master_sources.push_back (*i);
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> ((*i));
if (afs) {
afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
}
}
_scale_amplitude = other->_scale_amplitude;
_fade_in_disabled = 0;
_fade_out_disabled = 0;
listen_to_my_curves ();
listen_to_my_sources ();
}
@@ -296,19 +327,25 @@ AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nfra
}
nframes64_t
AudioRegion::read (Sample* buf, nframes64_t position, nframes64_t cnt, int channel) const
AudioRegion::read (Sample* buf, nframes64_t timeline_position, nframes64_t cnt, int channel) const
{
/* raw read, no fades, no gain, nada */
return _read_at (_sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, true);
return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, 0, 0, ReadOps (0));
}
nframes64_t
AudioRegion::read_with_ops (Sample* buf, nframes64_t file_position, nframes64_t cnt, int channel, ReadOps rops) const
{
return _read_at (_sources, _length, buf, 0, 0, file_position, cnt, channel, 0, 0, rops);
}
nframes_t
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position,
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t file_position,
nframes_t cnt,
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
{
/* regular diskstream/butler read complete with fades etc */
return _read_at (_sources, _length, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames, false);
return _read_at (_sources, _length, buf, mixdown_buffer, gain_buffer, file_position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
}
nframes_t
@@ -325,11 +362,12 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
uint32_t chan_n,
nframes_t read_frames,
nframes_t skip_frames,
bool raw) const
ReadOps rops) const
{
nframes_t internal_offset;
nframes_t buf_offset;
nframes_t to_read;
bool raw = (rops == ReadOpsNone);
if (muted() && !raw) {
return 0; /* read nothing */
@@ -361,7 +399,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
mixdown_buffer += buf_offset;
}
if (!raw) {
if (rops & ReadOpsCount) {
_read_data_count = 0;
}
@@ -372,7 +410,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
return 0; /* "read nothing" */
}
if (!raw) {
if (rops & ReadOpsCount) {
_read_data_count += src->read_data_count();
}
@@ -383,18 +421,12 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
*/
memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
/* no fades required */
if (!raw) {
goto merge;
}
}
/* fade in */
if (!raw) {
if (rops & ReadOpsFades) {
/* fade in */
if ((_flags & FadeIn) && Config->get_use_region_fades()) {
nframes_t fade_in_length = (nframes_t) _fade_in->back()->when;
@@ -407,6 +439,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
fi_limit = min (to_read, fade_in_length - internal_offset);
_fade_in->curve().get_vector (internal_offset, internal_offset+fi_limit, gain_buffer, fi_limit);
for (nframes_t n = 0; n < fi_limit; ++n) {
@@ -422,12 +455,12 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
/* see if some part of this read is within the fade out */
/* ................. >| REGION
limit
limit
{ } FADE
fade_out_length
^
limit - fade_out_length
limit - fade_out_length
|--------------|
^internal_offset
^internal_offset + to_read
@@ -457,39 +490,43 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
}
}
/* Regular gain curves */
if (envelope_active()) {
_envelope->curve().get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
if (_scale_amplitude != 1.0f) {
for (nframes_t n = 0; n < to_read; ++n) {
mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
}
} else {
for (nframes_t n = 0; n < to_read; ++n) {
mixdown_buffer[n] *= gain_buffer[n];
}
}
} else if (_scale_amplitude != 1.0f) {
apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
}
merge:
if (!opaque()) {
/* gack. the things we do for users.
*/
buf += buf_offset;
for (nframes_t n = 0; n < to_read; ++n) {
buf[n] += mixdown_buffer[n];
}
}
}
/* Regular gain curves and scaling */
if ((rops & ReadOpsOwnAutomation) && envelope_active()) {
_envelope->curve().get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
for (nframes_t n = 0; n < to_read; ++n) {
mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
}
} else {
for (nframes_t n = 0; n < to_read; ++n) {
mixdown_buffer[n] *= gain_buffer[n];
}
}
} else if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
// XXX this should be using what in 2.0 would have been:
// Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
for (nframes_t n = 0; n < to_read; ++n) {
mixdown_buffer[n] *= _scale_amplitude;
}
}
if (!opaque()) {
/* gack. the things we do for users.
*/
buf += buf_offset;
for (nframes_t n = 0; n < to_read; ++n) {
buf[n] += mixdown_buffer[n];
}
}
return to_read;
}

View File

@@ -19,6 +19,8 @@
*/
#include <algorithm>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <pbd/error.h>
#include <ardour/coreaudiosource.h>
@@ -256,7 +258,103 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&
goto out;
}
_info.format_name = CFStringRefToStdString(name);
_info.format_name = "";
if (absd.mFormatID == kAudioFormatLinearPCM) {
if (absd.mFormatFlags & kAudioFormatFlagIsBigEndian) {
_info.format_name += "big-endian";
} else {
_info.format_name += "little-endian";
}
char buf[32];
snprintf (buf, sizeof (buf), " %" PRIu32 " bit", absd.mBitsPerChannel);
_info.format_name += buf;
_info.format_name += '\n';
if (absd.mFormatFlags & kAudioFormatFlagIsFloat) {
_info.format_name += "float";
} else {
if (absd.mFormatFlags & kAudioFormatFlagIsSignedInteger) {
_info.format_name += "signed";
} else {
_info.format_name += "unsigned";
}
/* integer is typical, do not show it */
}
if (_info.channels > 1) {
if (absd.mFormatFlags & kAudioFormatFlagIsNonInterleaved) {
_info.format_name += " noninterleaved";
}
/* interleaved is the normal case, do not show it */
}
_info.format_name += ' ';
}
switch (absd.mFormatID) {
case kAudioFormatLinearPCM:
_info.format_name += "PCM";
break;
case kAudioFormatAC3:
_info.format_name += "AC3";
break;
case kAudioFormat60958AC3:
_info.format_name += "60958 AC3";
break;
case kAudioFormatMPEGLayer1:
_info.format_name += "MPEG-1";
break;
case kAudioFormatMPEGLayer2:
_info.format_name += "MPEG-2";
break;
case kAudioFormatMPEGLayer3:
_info.format_name += "MPEG-3";
break;
case kAudioFormatAppleIMA4:
_info.format_name += "IMA-4";
break;
case kAudioFormatMPEG4AAC:
_info.format_name += "AAC";
break;
case kAudioFormatMPEG4CELP:
_info.format_name += "CELP";
break;
case kAudioFormatMPEG4HVXC:
_info.format_name += "HVXC";
break;
case kAudioFormatMPEG4TwinVQ:
_info.format_name += "TwinVQ";
break;
/* these really shouldn't show up, but we should do something
somewhere else to make sure that doesn't happen. until
that is guaranteed, print something anyway.
*/
case kAudioFormatTimeCode:
_info.format_name += "timecode";
break;
case kAudioFormatMIDIStream:
_info.format_name += "MIDI";
break;
case kAudioFormatParameterValueStream:
_info.format_name += "parameter values";
break;
}
// XXX it would be nice to find a way to get this information if it exists

View File

@@ -217,22 +217,57 @@ Crossfade::initialize ()
_fade_out.freeze ();
_fade_out.clear ();
_fade_out.add (0.0, 1.0);
_fade_out.add ((_length * 0.1), 0.99);
_fade_out.add ((_length * 0.2), 0.97);
_fade_out.add ((_length * 0.8), 0.03);
_fade_out.add ((_length * 0.9), 0.01);
_fade_out.add (_length, 0.0);
#define EQUAL_POWER_MINUS_3DB
#ifdef EQUAL_POWER_MINUS_3DB
_fade_out.add ((_length * 0.000000), 1.000000);
_fade_out.add ((_length * 0.166667), 0.948859);
_fade_out.add ((_length * 0.333333), 0.851507);
_fade_out.add ((_length * 0.500000), 0.707946);
_fade_out.add ((_length * 0.666667), 0.518174);
_fade_out.add ((_length * 0.833333), 0.282192);
_fade_out.add ((_length * 1.000000), 0.000000);
#else // EQUAL_POWER_MINUS_6DB
_fade_out.add ((_length * 0.000000), 1.000000);
_fade_out.add ((_length * 0.166667), 0.833033);
_fade_out.add ((_length * 0.333333), 0.666186);
_fade_out.add ((_length * 0.500000), 0.499459);
_fade_out.add ((_length * 0.666667), 0.332853);
_fade_out.add ((_length * 0.833333), 0.166366);
_fade_out.add ((_length * 1.000000), 0.000000);
#endif
_fade_out.thaw ();
_fade_in.freeze ();
_fade_in.clear ();
_fade_in.add (0.0, 0.0);
_fade_in.add ((_length * 0.1), 0.01);
_fade_in.add ((_length * 0.2), 0.03);
_fade_in.add ((_length * 0.8), 0.97);
_fade_in.add ((_length * 0.9), 0.99);
_fade_in.add (_length, 1.0);
#define EQUAL_POWER_MINUS_3DB
#ifdef EQUAL_POWER_MINUS_3DB
_fade_in.add ((_length * 0.000000), 0.000000);
_fade_in.add ((_length * 0.166667), 0.282192);
_fade_in.add ((_length * 0.333333), 0.518174);
_fade_in.add ((_length * 0.500000), 0.707946);
_fade_in.add ((_length * 0.666667), 0.851507);
_fade_in.add ((_length * 0.833333), 0.948859);
_fade_in.add ((_length * 1.000000), 1.000000);
#else // EQUAL_POWER_MINUS_SIX_DB
_fade_in.add ((_length * 0.000000), 0.000000);
_fade_in.add ((_length * 0.166667), 0.166366);
_fade_in.add ((_length * 0.333333), 0.332853);
_fade_in.add ((_length * 0.500000), 0.499459);
_fade_in.add ((_length * 0.666667), 0.666186);
_fade_in.add ((_length * 0.833333), 0.833033);
_fade_in.add ((_length * 1.000000), 1.000000);
#endif
_fade_in.thaw ();
overlap_type = _in->coverage (_out->position(), _out->last_frame());

View File

@@ -174,8 +174,7 @@ ExportChannelConfiguration::write_file ()
void *
ExportChannelConfiguration::_write_files (void *arg)
{
PBD::ThreadCreated (pthread_self(), "Export post-processing");
notify_gui_about_thread_creation (pthread_self(), "Export post-processing");
// cc can be trated like 'this'
WriterThread & cc (*((WriterThread *) arg));

View File

@@ -128,6 +128,7 @@ setup_osc ()
return 0;
}
}
#endif
int
@@ -204,16 +205,17 @@ ARDOUR::setup_midi ()
<< endmsg;
return 0;
}
if (default_mtc_port == 0) {
warning << string_compose (_("No MTC support (MIDI port \"%1\" not available)"), Config->get_mtc_port_name())
<< endmsg;
}
}
if (default_midi_port == 0) {
warning << string_compose (_("No MIDI parameter support (MIDI port \"%1\" not available)"), Config->get_midi_port_name())
<< endmsg;
}
}
if (default_midi_clock_port == 0) {
warning << string_compose (_("No MIDI Clock support (MIDI port \"%1\" not available)"), Config->get_midi_clock_port_name())

View File

@@ -56,8 +56,10 @@
#include <ardour/tempo.h>
#ifdef HAVE_COREAUDIO
#ifdef USE_COREAUDIO_FOR_FILE_IO
#include <ardour/caimportable.h>
#endif
#endif
#include "i18n.h"
@@ -69,11 +71,13 @@ static boost::shared_ptr<ImportableSource>
open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQuality quality)
{
#ifdef HAVE_COREAUDIO
#ifdef USE_COREAUDIO_FOR_FILE_IO
/* see if we can use CoreAudio to handle the IO */
try {
boost::shared_ptr<CAImportableSource> source(new CAImportableSource(path));
CAImportableSource* src = new CAImportableSource(path);
boost::shared_ptr<CAImportableSource> source (src);
if (source->samplerate() == samplerate) {
return source;
@@ -87,8 +91,8 @@ open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQua
catch (...) {
/* fall back to SndFile */
#endif
#endif
try {
boost::shared_ptr<SndFileImportableSource> source(new SndFileImportableSource(path));
@@ -96,7 +100,7 @@ open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQua
if (source->samplerate() == samplerate) {
return source;
}
/* rewrap as a resampled source */
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
@@ -107,8 +111,10 @@ open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQua
}
#ifdef HAVE_COREAUDIO
#ifdef USE_COREAUDIO_FOR_FILE_IO
}
#endif
#endif
}
static std::string
@@ -437,7 +443,7 @@ Session::import_audiofiles (import_status& status)
if (source) { // audio
status.doing_what = compose_status_message (*p, source->samplerate(),
frame_rate(), cnt, status.paths.size());
frame_rate(), cnt, status.total);
write_audio_data_to_new_files (source.get(), status, newfiles);
} else if (smf_reader.get()) { // midi
status.doing_what = string_compose(_("loading MIDI file %1"), *p);
@@ -479,8 +485,7 @@ Session::import_audiofiles (import_status& status)
save_state (_name);
std::copy (all_new_sources.begin(), all_new_sources.end(),
std::back_inserter(status.sources));
std::copy (all_new_sources.begin(), all_new_sources.end(), std::back_inserter(status.sources));
} else {
// this can throw...but it seems very unlikely
std::for_each (all_new_sources.begin(), all_new_sources.end(), remove_file_source);

View File

@@ -2331,8 +2331,9 @@ void
IO::set_gain (gain_t val, void *src)
{
// max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
if (val > 1.99526231f)
if (val > 1.99526231f) {
val = 1.99526231f;
}
if (src != _gain_control.get()) {
_gain_control->set_value(val);
@@ -2347,7 +2348,7 @@ IO::set_gain (gain_t val, void *src)
}
if (_session.transport_stopped()) {
_gain = val;
// _gain = val;
}
/*
@@ -2541,7 +2542,6 @@ IO::set_active (bool yn)
active_changed(); /* EMIT SIGNAL */
}
AudioPort*
IO::audio_input(uint32_t n) const
{

View File

@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include <errno.h>
#include <poll.h>
#include <sys/types.h>
@@ -43,6 +43,8 @@ MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p)
{
can_notify_on_unknown_rate = true;
last_mtc_fps_byte = session.get_mtc_smpte_bits ();
rebind (p);
reset ();
}
@@ -96,6 +98,8 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
smpte.seconds = msg[1];
smpte.frames = msg[0];
last_mtc_fps_byte = msg[4];
switch (msg[4]) {
case MTC_24_FPS:
smpte.rate = 24;
@@ -120,7 +124,9 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
default:
/* throttle error messages about unknown MTC rates */
if (can_notify_on_unknown_rate) {
error << _("Unknown rate/drop value in incoming MTC stream, session values used instead") << endmsg;
error << string_compose (_("Unknown rate/drop value %1 in incoming MTC stream, session values used instead"),
(int) msg[4])
<< endmsg;
can_notify_on_unknown_rate = false;
}
smpte.rate = session.smpte_frames_per_second();
@@ -170,8 +176,9 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
void
MTC_Slave::handle_locate (const MIDI::byte* mmc_tc)
{
MIDI::byte mtc[4];
MIDI::byte mtc[5];
mtc[4] = last_mtc_fps_byte;
mtc[3] = mmc_tc[0] & 0xf; /* hrs only */
mtc[2] = mmc_tc[1];
mtc[1] = mmc_tc[2];

View File

@@ -32,11 +32,13 @@
#include <pbd/pthread_utils.h>
#include <pbd/file_utils.h>
#include <pbd/filesystem.h>
#include <ardour/osc.h>
#include <ardour/session.h>
#include <ardour/route.h>
#include <ardour/audio_track.h>
#include <ardour/dB.h>
#include <ardour/filesystem_paths.h>
#include "i18n.h"
@@ -107,10 +109,10 @@ OSC::start ()
cerr << "OSC @ " << get_server_url () << endl;
sys::path url_file;
PBD::sys::path url_file;
if (find_file_in_search_path (ardour_search_path() + system_config_search_path(),
"osc_url", url_file)) {
"osc_url", url_file)) {
_osc_url_file = url_file.to_string();
ofstream urlfile;
urlfile.open(_osc_url_file.c_str(), ios::trunc);
@@ -154,9 +156,9 @@ OSC::stop ()
unlink(_osc_unix_socket_path.c_str());
}
if (! _osc_url_file.empty() ) {
unlink(_osc_url_file.c_str() );
}
if (! _osc_url_file.empty() ) {
unlink(_osc_url_file.c_str() );
}
return 0;
}
@@ -204,6 +206,12 @@ OSC::register_callbacks()
REGISTER_CALLBACK (serv, "/ardour/rec_enable_toggle", "", rec_enable_toggle);
REGISTER_CALLBACK (serv, "/ardour/toggle_all_rec_enables", "", toggle_all_rec_enables);
REGISTER_CALLBACK (serv, "/ardour/routes/mute", "ii", route_mute);
REGISTER_CALLBACK (serv, "/ardour/routes/solo", "ii", route_solo);
REGISTER_CALLBACK (serv, "/ardour/routes/recenable", "ii", route_recenable);
REGISTER_CALLBACK (serv, "/ardour/routes/gainabs", "if", route_set_gain_abs);
REGISTER_CALLBACK (serv, "/ardour/routes/gaindB", "if", route_set_gain_dB);
#if 0
REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value);
REGISTER_CALLBACK (serv, "/ardour/set", "", set);
@@ -310,7 +318,7 @@ OSC::get_unix_server_url()
void *
OSC::_osc_receiver(void * arg)
{
PBD::ThreadCreated (pthread_self(), X_("OSC"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("OSC"));
static_cast<OSC*> (arg)->osc_receiver();
return 0;
@@ -378,7 +386,7 @@ OSC::osc_receiver()
if (pfd[i].revents & POLLIN)
{
// this invokes callbacks
//cerr << "invoking recv on " << pfd[i].fd << endl;
// cerr << "invoking recv on " << pfd[i].fd << endl;
lo_server_recv(srvs[i]);
}
}
@@ -390,7 +398,7 @@ OSC::osc_receiver()
if (_osc_server) {
int fd = lo_server_get_socket_fd(_osc_server);
if (fd >=0) {
// hack around
// hack around
close(fd);
}
lo_server_free (_osc_server);
@@ -500,3 +508,70 @@ OSC::current_value (const char *path, const char *types, lo_arg **argv, int argc
#endif
return 0;
}
int
OSC::route_mute (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_mute (yn, this);
}
return 0;
}
int
OSC::route_solo (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_solo (yn, this);
}
return 0;
}
int
OSC::route_recenable (int rid, int yn)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_record_enable (yn, this);
}
return 0;
}
int
OSC::route_set_gain_abs (int rid, float level)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_gain (level, this);
}
return 0;
}
int
OSC::route_set_gain_dB (int rid, float dB)
{
if (!session) return -1;
boost::shared_ptr<Route> r = session->route_by_remote_id (rid);
if (r) {
r->set_gain (dB_to_coefficient (dB), this);
}
return 0;
}

View File

@@ -749,10 +749,14 @@ Panner::reset (uint32_t nouts, uint32_t npans)
{
uint32_t n;
bool changed = false;
bool do_not_and_did_not_need_panning = ((nouts < 2) && (outputs.size() < 2));
//configure_io( ChanCount( DataType::AUDIO, nout ), ChanCount( DataType::AUDIO, nin ) )
if (nouts < 2 || (nouts == outputs.size() && npans == _streampanners.size())) {
/* if new and old config don't need panning, or if
the config hasn't changed, we're done.
*/
if (do_not_and_did_not_need_panning ||
((nouts == outputs.size()) && (npans == _streampanners.size()))) {
return;
}
@@ -770,6 +774,10 @@ Panner::reset (uint32_t nouts, uint32_t npans)
changed = true;
}
if (nouts < 2) {
goto send_changed;
}
switch (nouts) {
case 0:
break;
@@ -871,6 +879,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
}
}
send_changed:
if (changed) {
Changed (); /* EMIT SIGNAL */
}

View File

@@ -130,6 +130,8 @@ PluginManager::PluginManager ()
_lv2_world = new LV2World();
#endif
BootMessage (_("Discovering Plugins"));
refresh ();
}
@@ -632,7 +634,7 @@ PluginManager::add_favorite (PluginType t, string id)
{
FavoritePlugin fp (t, id);
pair<FavoritePluginList::iterator,bool> res = favorites.insert (fp);
cerr << "Added " << t << " " << id << " success ? " << res.second << endl;
//cerr << "Added " << t << " " << id << " success ? " << res.second << endl;
}
void

View File

@@ -206,7 +206,7 @@ RBEffect::run (boost::shared_ptr<Region> r)
while (pos < read_duration && !tsr.cancel) {
nframes_t this_read = 0;
for (uint32_t i = 0; i < channels; ++i) {
this_read = 0;
@@ -229,7 +229,7 @@ RBEffect::run (boost::shared_ptr<Region> r)
if (this_read != this_time) {
error << string_compose
(_("tempoize: error reading data from %1 at %2 (wanted %3, got %4)"),
region->name(), pos + region->position(), this_time, this_read) << endmsg;
region->name(), this_position, this_time, this_read) << endmsg;
goto out;
}
}

View File

@@ -38,6 +38,7 @@
#include <ardour/tempo.h>
#include <ardour/region_factory.h>
#include <ardour/filter.h>
#include <ardour/profile.h>
#include "i18n.h"
@@ -153,50 +154,90 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
/** Create a new Region from part of an existing one */
Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
: SessionObject(other->session(), name)
, _type(other->data_type())
, _flags(Flag(flags & ~(Locked|PositionLocked|WholeFile|Hidden)))
, _start(other->_start + offset)
, _length(length)
, _position(0)
, _last_position(0)
, _positional_lock_style(other->_positional_lock_style)
, _sync_position(_start)
, _layer(layer)
, _first_edit(EditChangesNothing)
, _frozen(0)
, _ancestral_start (other->_ancestral_start + offset)
, _ancestral_length (length)
, _stretch (other->_stretch)
, _shift (other->_shift)
, _valid_transients(false)
, _read_data_count(0)
, _pending_changed(Change (0))
, _last_layer_op(0)
, _type (other->data_type())
{
if (other->_sync_position < offset)
_sync_position = other->_sync_position;
_start = other->_start + offset;
copy_stuff (other, offset, length, name, layer, flags);
set<boost::shared_ptr<Source> > unique_srcs;
/* if the other region had a distinct sync point
set, then continue to use it as best we can.
otherwise, reset sync point back to start.
*/
for (SourceList::const_iterator i= other->_sources.begin(); i != other->_sources.end(); ++i) {
_sources.push_back (*i);
(*i)->GoingAway.connect (bind (mem_fun (*this, &Region::source_deleted), (*i)));
unique_srcs.insert (*i);
}
if (other->_sync_position < offset) {
_sync_position = other->_sync_position;
}
for (SourceList::const_iterator i = other->_master_sources.begin(); i != other->_master_sources.end(); ++i) {
if (unique_srcs.find (*i) == unique_srcs.end()) {
(*i)->GoingAway.connect (bind (mem_fun (*this, &Region::source_deleted), (*i)));
if (other->flags() & SyncMarked) {
if (other->_sync_position < _start) {
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
} else {
_sync_position = other->_sync_position;
}
_master_sources.push_back (*i);
} else {
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
}
if (Profile->get_sae()) {
/* reset sync point to start if its ended up
outside region bounds.
*/
if (_sync_position < _start || _sync_position >= _start + _length) {
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
}
}
}
Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
: SessionObject(other->session(), name)
, _type (other->data_type())
{
/* create a new Region exactly like another but starting at 0 in its sources */
_start = 0;
copy_stuff (other, 0, length, name, layer, flags);
/* sync pos is relative to start of file. our start-in-file is now zero,
so set our sync position to whatever the the difference between
_start and _sync_pos was in the other region.
result is that our new sync pos points to the same point in our source(s)
as the sync in the other region did in its source(s).
since we start at zero in our source(s), it is not possible to use a sync point that
is before the start. reset it to _start if that was true in the other region.
*/
assert(_sources.size() > 0);
if (other->flags() & SyncMarked) {
if (other->_start < other->_sync_position) {
/* sync pos was after the start point of the other region */
_sync_position = other->_sync_position - other->_start;
} else {
/* sync pos was before the start point of the other region. not possible here. */
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
}
} else {
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
}
if (Profile->get_sae()) {
/* reset sync point to start if its ended up
outside region bounds.
*/
if (_sync_position < _start || _sync_position >= _start + _length) {
_flags = Flag (_flags & ~SyncMarked);
_sync_position = _start;
}
}
/* reset a couple of things that copy_stuff() gets wrong in this particular case */
_positional_lock_style = other->_positional_lock_style;
_first_edit = other->_first_edit;
}
/** Pure copy constructor */
@@ -336,6 +377,31 @@ Region::~Region ()
GoingAway (); /* EMIT SIGNAL */
}
void
Region::copy_stuff (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
{
_frozen = 0;
_pending_changed = Change (0);
_read_data_count = 0;
_valid_transients = false;
_length = length;
_last_length = length;
_sync_position = other->_sync_position;
_ancestral_start = other->_ancestral_start;
_ancestral_length = other->_ancestral_length;
_stretch = other->_stretch;
_shift = other->_shift;
_name = name;
_last_position = 0;
_position = 0;
_layer = layer;
_flags = Flag (flags & ~(Locked|WholeFile|Hidden));
_first_edit = EditChangesNothing;
_last_layer_op = 0;
_positional_lock_style = AudioTime;
}
void
Region::set_playlist (boost::weak_ptr<Playlist> wpl)
{
@@ -982,7 +1048,7 @@ Region::sync_offset (int& dir) const
}
nframes_t
Region::adjust_to_sync (nframes_t pos)
Region::adjust_to_sync (nframes_t pos) const
{
int sync_dir;
nframes_t offset = sync_offset (sync_dir);
@@ -1245,16 +1311,26 @@ Region::set_live_state (const XMLNode& node, Change& what_changed, bool send)
if ((prop = node.property ("stretch")) != 0) {
_stretch = atof (prop->value());
if( _stretch == 0.0 )
/* fix problem with old sessions corrupted by an impossible
value for _stretch
*/
if (_stretch == 0.0) {
_stretch = 1.0;
}
} else {
_stretch = 1.0;
}
if ((prop = node.property ("shift")) != 0) {
_shift = atof (prop->value());
if( _shift == 0.0 )
/* fix problem with old sessions corrupted by an impossible
value for _shift
*/
if (_shift == 0.0) {
_shift = 1.0;
}
} else {
_shift = 1.0;
}

View File

@@ -37,7 +37,7 @@ sigc::signal<void,boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, nframes_t start,
nframes_t length, std::string name,
nframes_t length, const std::string& name,
layer_t layer, Region::Flag flags, bool announce)
{
boost::shared_ptr<const AudioRegion> other_a;
@@ -91,12 +91,39 @@ RegionFactory::create (boost::shared_ptr<const Region> region)
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<AudioRegion> region, nframes_t start,
nframes_t length, std::string name,
nframes_t length, const std::string& name,
layer_t layer, Region::Flag flags, bool announce)
{
return create (boost::static_pointer_cast<Region> (region), start, length, name, layer, flags, announce);
}
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
const std::string& name, layer_t layer, Region::Flag flags, bool announce)
{
boost::shared_ptr<const AudioRegion> other;
/* used by AudioFilter when constructing a new region that is intended to have nearly
identical settings to an original, but using different sources.
*/
if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
AudioRegion* ar = new AudioRegion (other, srcs, srcs.front()->length(), name, layer, flags);
boost::shared_ptr<AudioRegion> arp (ar);
boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
if (announce) {
CheckNewRegion (ret);
}
return ret;
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
/*NOTREACHED*/
return boost::shared_ptr<Region>();
}
}
boost::shared_ptr<Region>
RegionFactory::create (Session& session, XMLNode& node, bool yn)
{

View File

@@ -70,6 +70,7 @@ Reverse::run (boost::shared_ptr<Region> r)
}
fpos = max (fstart, (fstart + region->length() - blocksize));
buf = new Sample[blocksize];
to_read = blocksize;
@@ -81,7 +82,7 @@ Reverse::run (boost::shared_ptr<Region> r)
for (n = 0, si = nsrcs.begin(); n < region->n_channels(); ++n, ++si) {
/* read it in */
/* read it in directly from the source */
if (region->audio_source (n)->read (buf, fpos, to_read) != to_read) {
goto out;
@@ -92,7 +93,7 @@ Reverse::run (boost::shared_ptr<Region> r)
for (nframes_t i = 0; i < to_read/2; ++i) {
swap (buf[i],buf[to_read-1-i]);
}
/* write it out */
boost::shared_ptr<AudioSource> asrc(boost::dynamic_pointer_cast<AudioSource>(*si));

View File

@@ -25,6 +25,7 @@
#include <pbd/xml++.h>
#include <pbd/enumwriter.h>
#include <pbd/stacktrace.h>
#include <pbd/memento_command.h>
#include <ardour/timestamps.h>
#include <ardour/audioengine.h>
@@ -1087,6 +1088,31 @@ Route::set_solo (bool yn, void *src)
_soloed = yn;
solo_changed (src); /* EMIT SIGNAL */
_solo_control->Changed (); /* EMIT SIGNAL */
}
catch_up_on_solo_mute_override ();
}
void
Route::catch_up_on_solo_mute_override ()
{
if (Config->get_solo_model() != InverseMute) {
return;
}
{
Glib::Mutex::Lock lm (declick_lock);
if (_muted) {
if (Config->get_solo_mute_override()) {
desired_mute_gain = (_soloed?1.0:0.0);
} else {
desired_mute_gain = 0.0;
}
} else {
desired_mute_gain = 1.0;
}
}
}
@@ -1126,7 +1152,12 @@ Route::set_mute (bool yn, void *src)
_mute_control->Changed (); /* EMIT SIGNAL */
Glib::Mutex::Lock lm (declick_lock);
desired_mute_gain = (yn?0.0f:1.0f);
if (_soloed && Config->get_solo_mute_override()){
desired_mute_gain = 1.0f;
} else {
desired_mute_gain = (yn?0.0f:1.0f);
}
}
}
@@ -1234,7 +1265,6 @@ Route::add_processors (const ProcessorList& others, ProcessorStreams* err)
return -1;
}
(*i)->activate ();
(*i)->ActiveChanged.connect (bind (mem_fun (_session, &Session::update_latency_compensation), false, false));
}
@@ -3089,3 +3119,50 @@ Route::set_pending_declick (int declick)
}
/** Shift automation forwards from a particular place, thereby inserting time.
* Adds undo commands for any shifts that are performed.
*
* @param pos Position to start shifting from.
* @param frames Amount to shift forwards by.
*/
void
Route::shift (nframes64_t pos, nframes64_t frames)
{
#ifdef THIS_NEEDS_FIXING_FOR_V3
/* gain automation */
XMLNode &before = _gain_control->get_state ();
_gain_control->shift (pos, frames);
XMLNode &after = _gain_control->get_state ();
_session.add_command (new MementoCommand<AutomationList> (_gain_automation_curve, &before, &after));
/* pan automation */
for (std::vector<StreamPanner*>::iterator i = _panner->begin (); i != _panner->end (); ++i) {
Curve & c = (*i)->automation ();
XMLNode &before = c.get_state ();
c.shift (pos, frames);
XMLNode &after = c.get_state ();
_session.add_command (new MementoCommand<AutomationList> (c, &before, &after));
}
/* redirect automation */
{
Glib::RWLock::ReaderLock lm (redirect_lock);
for (RedirectList::iterator i = _redirects.begin (); i != _redirects.end (); ++i) {
set<uint32_t> a;
(*i)->what_has_automation (a);
for (set<uint32_t>::const_iterator j = a.begin (); j != a.end (); ++j) {
AutomationList & al = (*i)->automation_list (*j);
XMLNode &before = al.get_state ();
al.shift (pos, frames);
XMLNode &after = al.get_state ();
_session.add_command (new MementoCommand<AutomationList> (al, &before, &after));
}
}
}
#endif
}

View File

@@ -27,6 +27,8 @@
#include <ardour/audio_port.h>
#include <ardour/buffer_set.h>
#include <ardour/meter.h>
#include <ardour/panner.h>
#include "i18n.h"
using namespace ARDOUR;
@@ -55,6 +57,41 @@ Send::Send (const Send& other)
: IOProcessor (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement())
{
_metering = false;
expected_inputs.set (DataType::AUDIO, 0);
#ifdef THIS_NEEDS_FIXING_FOR_V3
/* set up the same outputs, and connect them to the same places */
_io->no_panner_reset = true;
for (uint32_t i = 0; i < other.n_outputs (); ++i) {
add_output_port ("", 0);
Port* p = other.output (i);
if (p) {
/* this is what the other send's output is connected to */
const char **connections = p->get_connections ();
if (connections) {
for (uint32_t c = 0; connections[c]; ++c) {
connect_output (output (i), connections [c], 0);
}
}
}
}
/* setup panner */
_io->no_panner_reset = false;
/* copy state */
XMLNode& other_state (const_cast<Send*>(&other)->_panner->get_state());
_panner->set_state (other_state);
delete &other_state;
#endif
ProcessorCreated (this); /* EMIT SIGNAL */
}

View File

@@ -123,23 +123,31 @@ Session::Session (AudioEngine &eng,
_scratch_buffers(new BufferSet()),
_silent_buffers(new BufferSet()),
_mix_buffers(new BufferSet()),
mmc (0),
_mmc_port (default_mmc_port),
_mtc_port (default_mtc_port),
_midi_port (default_midi_port),
_midi_clock_port (default_midi_clock_port),
_session_dir (new SessionDirectory(fullpath)),
pending_events (2048),
state_tree (0),
butler_mixdown_buffer (0),
butler_gain_buffer (0),
post_transport_work((PostTransportWork)0),
_send_smpte_update (false),
midi_requests (128),
midi_thread (pthread_t (0)),
midi_requests (128), // the size of this should match the midi request pool size
diskstreams (new DiskstreamList),
routes (new RouteList),
auditioner ((Auditioner*) 0),
_total_free_4k_blocks (0),
_bundle_xml_node (0),
_click_io ((IO*) 0),
click_data (0),
click_emphasis_data (0),
main_outs (0),
_metadata (new SessionMetadata())
{
bool new_session;
@@ -196,21 +204,30 @@ Session::Session (AudioEngine &eng,
_scratch_buffers(new BufferSet()),
_silent_buffers(new BufferSet()),
_mix_buffers(new BufferSet()),
mmc (0),
_mmc_port (default_mmc_port),
_mtc_port (default_mtc_port),
_midi_port (default_midi_port),
_midi_clock_port (default_midi_clock_port),
_session_dir ( new SessionDirectory(fullpath)),
pending_events (2048),
state_tree (0),
butler_mixdown_buffer (0),
butler_gain_buffer (0),
post_transport_work((PostTransportWork)0),
_send_smpte_update (false),
midi_thread (pthread_t (0)),
midi_requests (16),
diskstreams (new DiskstreamList),
routes (new RouteList),
auditioner ((Auditioner *) 0),
_total_free_4k_blocks (0),
_bundle_xml_node (0),
main_outs (0)
_click_io ((IO *) 0),
click_data (0),
click_emphasis_data (0),
main_outs (0),
_metadata (new SessionMetadata())
{
bool new_session;
@@ -316,18 +333,16 @@ Session::destroy ()
/* clear state tree so that no references to objects are held any more */
if (state_tree) {
delete state_tree;
}
delete state_tree;
terminate_butler_thread ();
//terminate_midi_thread ();
if (click_data && click_data != default_click) {
if (click_data != default_click) {
delete [] click_data;
}
if (click_emphasis_data && click_emphasis_data != default_click_emphasis) {
if (click_emphasis_data != default_click_emphasis) {
delete [] click_emphasis_data;
}
@@ -471,19 +486,12 @@ Session::destroy ()
i = tmp;
}
if (butler_mixdown_buffer) {
delete [] butler_mixdown_buffer;
}
if (butler_gain_buffer) {
delete [] butler_gain_buffer;
}
delete [] butler_mixdown_buffer;
delete [] butler_gain_buffer;
Crossfade::set_buffer_size (0);
if (mmc) {
delete mmc;
}
delete mmc;
}
void
@@ -1213,6 +1221,10 @@ Session::audible_frame () const
nframes_t offset;
nframes_t tf;
if (_transport_speed == 0.0f && non_realtime_work_pending()) {
return last_stop_frame;
}
/* the first of these two possible settings for "offset"
mean that the audible frame is stationary until
audio emerges from the latency compensation
@@ -1241,24 +1253,43 @@ Session::audible_frame () const
} else {
tf = _transport_frame;
}
if (_transport_speed == 0) {
return tf;
}
if (tf < offset) {
return 0;
}
ret = tf;
if (!non_realtime_work_pending()) {
/* MOVING */
/* take latency into account */
/* check to see if we have passed the first guaranteed
audible frame past our last stopping position. if not,
the return that last stopping point because in terms
of audible frames, we have not moved yet.
*/
ret -= offset;
if (_transport_speed > 0.0f) {
if (!play_loop || !have_looped) {
if (tf < last_stop_frame + offset) {
return last_stop_frame;
}
}
/* forwards */
ret -= offset;
} else if (_transport_speed < 0.0f) {
/* XXX wot? no backward looping? */
if (tf > last_stop_frame - offset) {
return last_stop_frame;
} else {
/* backwards */
ret += offset;
}
}
}
return ret;
@@ -1875,6 +1906,10 @@ Session::new_audio_route (int input_channels, int output_channels, uint32_t how_
_engine.get_physical_outputs (DataType::AUDIO, physoutputs);
_engine.get_physical_inputs (DataType::AUDIO, physinputs);
n_physical_audio_outputs = physoutputs.size();
n_physical_audio_inputs = physinputs.size();
control_id = ntracks() + nbusses() + 1;
while (how_many) {
@@ -1900,21 +1935,24 @@ Session::new_audio_route (int input_channels, int output_channels, uint32_t how_
goto failure;
}
for (uint32_t x = 0; n_physical_inputs && x < bus->n_inputs().n_audio(); ++x) {
/*
for (uint32_t x = 0; n_physical_audio_inputs && x < bus->n_inputs(); ++x) {
port = "";
if (Config->get_input_auto_connect() & AutoConnectPhysical) {
port = physinputs[((n+x)%n_physical_inputs)];
}
port = physinputs[((n+x)%n_physical_audio_inputs)];
}
if (port.length() && bus->connect_input (bus->input (x), port, this)) {
break;
}
}
*/
for (uint32_t x = 0; x < bus->n_outputs().n_audio(); ++x) {
for (uint32_t x = 0; n_physical_audio_outputs && x < bus->n_outputs().n_audio(); ++x) {
port = "";
if (Config->get_output_auto_connect() & AutoConnectPhysical) {
@@ -2240,8 +2278,6 @@ Session::update_route_solo_state ()
bool is_track = false;
bool signal = false;
/* caller must hold RouteLock */
/* this is where we actually implement solo by changing
the solo mute setting of each track.
*/
@@ -2341,7 +2377,24 @@ Session::catch_up_on_solo ()
has.
*/
update_route_solo_state();
}
}
void
Session::catch_up_on_solo_mute_override ()
{
if (Config->get_solo_model() != InverseMute) {
return;
}
/* this is called whenever the param solo-mute-override is
changed.
*/
shared_ptr<RouteList> r = routes.reader ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
(*i)->catch_up_on_solo_mute_override ();
}
}
shared_ptr<Route>
Session::route_by_name (string name)
@@ -4220,8 +4273,13 @@ Session::get_silent_buffers (ChanCount count)
BufferSet&
Session::get_scratch_buffers (ChanCount count)
{
assert(_scratch_buffers->available() >= count);
_scratch_buffers->set_count(count);
if (count != ChanCount::ZERO) {
assert(_scratch_buffers->available() >= count);
_scratch_buffers->set_count(count);
} else {
_scratch_buffers->set_count (_scratch_buffers->available());
}
return *_scratch_buffers;
}

View File

@@ -162,7 +162,7 @@ Session::wait_till_butler_finished ()
void *
Session::_butler_thread_work (void* arg)
{
PBD::ThreadCreated (pthread_self(), X_("Butler"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Butler"));
return ((Session *) arg)->butler_thread_work ();
return 0;
}

View File

@@ -60,6 +60,7 @@ Session::get_export_status ()
return export_status;
}
int
Session::pre_export ()
{

View File

@@ -1120,7 +1120,7 @@ Session::midi_thread_work ()
bool restart;
vector<MIDI::Port*> ports;
PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("MIDI"), 2048);
PBD::notify_gui_about_thread_creation (pthread_self(), X_("MIDI"), 2048);
memset (&rtparam, 0, sizeof (rtparam));
rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */
@@ -1145,6 +1145,7 @@ Session::midi_thread_work ()
pfd[nfds].fd = _mmc_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _mmc_port;
//cerr << "MIDI port " << nfds << " = MMC @ " << _mmc_port << endl;
nfds++;
}
@@ -1157,6 +1158,7 @@ Session::midi_thread_work ()
pfd[nfds].fd = _mtc_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _mtc_port;
//cerr << "MIDI port " << nfds << " = MTC @ " << _mtc_port << endl;
nfds++;
}
@@ -1175,6 +1177,7 @@ Session::midi_thread_work ()
pfd[nfds].fd = _midi_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _midi_port;
// cerr << "MIDI port " << nfds << " = MIDI @ " << _midi_port << endl;
nfds++;
}

View File

@@ -677,12 +677,13 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
#if 0
cerr << "adjust using " << delta
<< " towards " << adjusted_speed
<< " ratio = " << adjusted_speed / slave_speed
<< " current = " << _transport_speed
<< " slave @ " << slave_speed
<< endl;
#endif
<< " towards " << adjusted_speed
<< " ratio = " << adjusted_speed / slave_speed
<< " current = " << _transport_speed
<< " slave @ " << slave_speed
<< endl;
#endif
request_transport_speed (adjusted_speed);
#if 1

View File

@@ -165,6 +165,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
g_atomic_int_set (&_record_status, Disabled);
loop_changing = false;
play_loop = false;
have_looped = false;
_last_roll_location = 0;
_last_record_location = 0;
pending_locate_frame = 0;
@@ -172,7 +173,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
pending_locate_flush = false;
audio_dstream_buffer_size = 0;
midi_dstream_buffer_size = 0;
state_tree = 0;
state_was_pending = false;
set_next_event ();
outbound_mtc_smpte_frame = 0;
@@ -187,9 +187,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
_state_of_the_state = StateOfTheState(CannotSave|InitialConnecting|Loading);
_slave = 0;
butler_mixdown_buffer = 0;
butler_gain_buffer = 0;
mmc = 0;
session_send_mmc = false;
session_send_mtc = false;
post_transport_work = PostTransportWork (0);
@@ -227,8 +224,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
waveforms for clicks.
*/
click_data = 0;
click_emphasis_data = 0;
click_length = 0;
click_emphasis_length = 0;
_clicking = false;
@@ -362,6 +357,8 @@ Session::second_stage_init (bool new_session)
MidiClockTicker::instance().set_session(*this);
MIDI::Name::MidiPatchManager::instance().set_session(*this);
/* initial program change will be delivered later; see ::config_changed() */
BootMessage (_("Reset Control Protocols"));
ControlProtocolManager::instance().set_session (*this);
@@ -3272,6 +3269,17 @@ Session::config_changed (const char* parameter_name)
_mmc_port->midimsg (buf, sizeof (buf), 0);
}
} else if (PARAM_IS ("initial-program-change")) {
if (_mmc_port && Config->get_initial_program_change() >= 0) {
MIDI::byte* buf = new MIDI::byte[2];
buf[0] = MIDI::program; // channel zero by default
buf[1] = (Config->get_initial_program_change() & 0x7f);
// deliver_midi (_mmc_port, buf, 2);
}
} else if (PARAM_IS ("solo-mute-override")) {
catch_up_on_solo_mute_override ();
}
set_dirty ();

View File

@@ -212,8 +212,7 @@ Session::butler_transport_work ()
}
if (post_transport_work & PostTransportReverse) {
clear_clicks();
cumulative_rf_motion = 0;
reset_rf_scale (0);
@@ -449,6 +448,12 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
_requested_return_frame = -1;
}
have_looped = false;
send_full_time_code (0);
deliver_mmc (MIDI::MachineControl::cmdStop, 0);
deliver_mmc (MIDI::MachineControl::cmdLocate, _transport_frame);
if (did_record) {
/* XXX its a little odd that we're doing this here
@@ -779,7 +784,7 @@ Session::locate (nframes_t target_frame, bool with_roll, bool with_flush, bool w
}
}
}
have_looped = true;
TransportLooped(); // EMIT SIGNAL
}
}
@@ -886,6 +891,7 @@ Session::set_transport_speed (float speed, bool abort)
if ((_transport_speed && speed * _transport_speed < 0.0f) || (_last_transport_speed * speed < 0.0f) || (_last_transport_speed == 0.0f && speed < 0.0f)) {
post_transport_work = PostTransportWork (post_transport_work | PostTransportReverse);
last_stop_frame = _transport_frame;
}
_last_transport_speed = _transport_speed;
@@ -951,6 +957,7 @@ void
Session::start_transport ()
{
_last_roll_location = _transport_frame;
have_looped = false;
/* if record status is Enabled, move it to Recording. if its
already Recording, move it to Disabled.

View File

@@ -1,5 +1,6 @@
#include <ardour/sndfileimportable.h>
#include <sndfile.h>
#include <iostream>
using namespace ARDOUR;
using namespace std;

View File

@@ -317,7 +317,12 @@ SndFileSource::read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const
if (_info.channels == 1) {
nframes_t ret = sf_read_float (sf, dst, file_cnt);
_read_data_count = cnt * sizeof(float);
_read_data_count = ret * sizeof(float);
if (ret != file_cnt) {
char errbuf[256];
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
cerr << string_compose(_("SndFileSource: @ %1 could not read %2 within %3 (%4) (len = %5)"), start, file_cnt, _name.substr (1), errbuf, _length) << endl;
}
return ret;
}
}
@@ -381,7 +386,7 @@ SndFileSource::nondestructive_write_unlocked (Sample *data, nframes_t cnt)
}
_write_data_count = cnt;
return cnt;
}

View File

@@ -52,7 +52,7 @@ std::list<boost::weak_ptr<AudioSource> > SourceFactory::files_with_peaks;
static void
peak_thread_work ()
{
PBD::ThreadCreated (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
PBD::notify_gui_about_thread_creation (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
while (true) {

View File

@@ -282,7 +282,7 @@ compute_equal_power_fades (nframes_t nframes, float* in, float* out)
{
double step;
step = 1.0/nframes;
step = 1.0/(nframes-1);
in[0] = 0.0f;

View File

@@ -6,7 +6,7 @@ import glob
libclearlooks_files = [
'animation.c',
'cairo-support.c',
'clearlooks_draw.c',
'clearlooks_draw.c',
'clearlooks_draw_glossy.c',
'clearlooks_draw_gummy.c',
'clearlooks_draw_inverted.c',
@@ -28,16 +28,23 @@ if env['GTKOSX']:
clearlooks.Append (CCFLAGS = '-DGTKOSX')
libclearlooks = clearlooks.SharedLibrary('clearlooks', libclearlooks_files)
usable_libclearlooks = clearlooks.Install ('engines', libclearlooks)
Default (usable_libclearlooks)
env.Alias('install',
env.Install(os.path.join(install_prefix,env['LIBDIR'], 'ardour3', 'engines'),
libclearlooks))
if env['GTKOSX']:
# GTK looks only for foo.so, not foo.dylib
print ("GTKOSX part");
really_usable_module = clearlooks.Command ('engines/libclearlooks.so', usable_libclearlooks, 'ln -s libclearlooks.dylib libclearlooks.so', chdir=1)
Default (really_usable_module)
else:
print ("non-GTKOSX part");
Default (usable_libclearlooks)
env.Alias('install', env.Install (
os.path.join(install_prefix,env['LIBDIR'], 'ardour2', 'engines'),
libclearlooks))
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript' ] +
[ 'SConscript', 'bits.c'] +
libclearlooks_files +
glob.glob('*.h')
))

View File

@@ -16,7 +16,7 @@
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "config.h"
#ifdef HAVE_ANIMATION
#include <gtk/gtk.h>

View File

@@ -0,0 +1,121 @@
static unsigned char dot_intensity[] = {
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x98,0xb9,0xc6,0xb9,0x91,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xb9,0xbd,0xac,0x9e,0x65,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xc6,0xac,0x9e,0x96,0x5c,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xb9,0x9e,0x96,0x62,0x55,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x91,0x65,0x5c,0x55,0x68,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
};
static unsigned char dot_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x66,0xc4,0xff,0xc4,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0xdf,0xff,0xff,0xff,0xdf,0x66,0x00,0x00,0x00,
0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0xff,0xff,0xc4,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0xff,0xff,0xc4,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0xdf,0xff,0xff,0xff,0xdf,0x66,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x66,0xc4,0xff,0xc4,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char circle_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x23,0x62,0x92,0xb3,0xb2,0x95,0x2b,0x00,0x00,0x00,
0x00,0x00,0x3e,0xab,0xc9,0xeb,0xf9,0xf5,0xfd,0xff,0x57,0x00,0x00,
0x00,0x1f,0xb5,0xd8,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x2b,0x00,
0x00,0x67,0xb9,0xf2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x00,
0x00,0x9a,0xe2,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0x00,
0x00,0xba,0xeb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xc0,0xfa,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0x00,
0x00,0x9b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x00,
0x00,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2b,0x00,
0x00,0x00,0x57,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x57,0x00,0x00,
0x00,0x00,0x00,0x2b,0x9c,0xe5,0xff,0xe5,0x9c,0x2b,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char outline_alpha[] = {
0x00,0x00,0x00,0x4a,0xac,0xe9,0xff,0xe9,0xac,0x4a,0x00,0x00,0x00,
0x00,0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,0x00,
0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,
0x4a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4a,
0xac,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xac,
0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe9,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe9,
0xac,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xac,
0x4a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4a,
0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,
0x00,0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,0x00,
0x00,0x00,0x00,0x4a,0xac,0xe9,0xff,0xe9,0xac,0x4a,0x00,0x00,0x00,
};
static unsigned char inconsistent_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_base_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, 137, 151,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, 183, 172, 7,0x00,0x00,
0x00,0x00, 12, 18,0x00,0x00, 3, 161, 233, 27,0x00,0x00,0x00,
0x00,0x00, 199, 239, 101,0x00, 85, 253, 108,0x00,0x00,0x00,0x00,
0x00,0x00, 83, 245, 250, 75, 206, 230, 8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, 104, 252, 243, 253, 124,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, 2, 162, 255, 241, 28,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 18, 228, 163,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00, 78, 62,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_inconsistent_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

View File

@@ -81,31 +81,31 @@ ge_color_from_hsb (gdouble hue,
gdouble m1, m2, m3;
if (!color) return;
if (brightness <= 0.5)
m2 = brightness * (1 + saturation);
else
m2 = brightness + saturation - brightness * saturation;
m1 = 2 * brightness - m2;
hue_shift[0] = hue + 120;
hue_shift[1] = hue;
hue_shift[2] = hue - 120;
color_shift[0] = color_shift[1] = color_shift[2] = brightness;
i = (saturation == 0)?3:0;
for (; i < 3; i++)
{
m3 = hue_shift[i];
if (m3 > 360)
m3 = MODULA(m3, 360);
else if (m3 < 0)
m3 = 360 - MODULA(ABS(m3), 360);
if (m3 < 60)
color_shift[i] = m1 + (m2 - m1) * m3 / 60;
else if (m3 < 180)
@@ -114,8 +114,8 @@ ge_color_from_hsb (gdouble hue,
color_shift[i] = m1 + (m2 - m1) * (240 - m3) / 60;
else
color_shift[i] = m1;
}
}
color->r = color_shift[0];
color->g = color_shift[1];
color->b = color_shift[2];
@@ -163,7 +163,7 @@ ge_gtk_style_to_cairo_color_cube (GtkStyle * style, CairoColorCube *cube)
g_return_if_fail (style && cube);
for (i = 0; i < 5; i++)
{
{
ge_gdk_color_to_cairo (&style->bg[i], &cube->bg[i]);
ge_gdk_color_to_cairo (&style->fg[i], &cube->fg[i]);
@@ -174,7 +174,7 @@ ge_gtk_style_to_cairo_color_cube (GtkStyle * style, CairoColorCube *cube)
ge_gdk_color_to_cairo (&style->base[i], &cube->base[i]);
ge_gdk_color_to_cairo (&style->text[i], &cube->text[i]);
ge_gdk_color_to_cairo (&style->text_aa[i], &cube->text_aa[i]);
}
}
cube->black.r = cube->black.g = cube->black.b = 0;
cube->black.a = 1;
@@ -189,27 +189,17 @@ ge_shade_color(const CairoColor *base, gdouble shade_ratio, CairoColor *composit
gdouble hue = 0;
gdouble saturation = 0;
gdouble brightness = 0;
g_return_if_fail (base && composite);
if (shade_ratio == 1.0)
{
composite->r = base->r;
composite->g = base->g;
composite->b = base->b;
composite->a = base->a;
return;
}
ge_hsb_from_color (base, &hue, &saturation, &brightness);
brightness = MIN(brightness*shade_ratio, 1.0);
brightness = MAX(brightness, 0.0);
saturation = MIN(saturation*shade_ratio, 1.0);
saturation = MAX(saturation, 0.0);
ge_color_from_hsb (hue, saturation, brightness, composite);
composite->a = base->a;
}
@@ -220,7 +210,7 @@ ge_saturate_color (const CairoColor *base, gdouble saturate_level, CairoColor *c
gdouble hue = 0;
gdouble saturation = 0;
gdouble brightness = 0;
g_return_if_fail (base && composite);
ge_hsb_from_color (base, &hue, &saturation, &brightness);
@@ -233,7 +223,7 @@ ge_saturate_color (const CairoColor *base, gdouble saturate_level, CairoColor *c
}
void
ge_mix_color (const CairoColor *color1, const CairoColor *color2,
ge_mix_color (const CairoColor *color1, const CairoColor *color2,
gdouble mix_factor, CairoColor *composite)
{
g_return_if_fail (color1 && color2 && composite);
@@ -256,7 +246,7 @@ ge_gdk_drawable_to_cairo (GdkDrawable *window, GdkRectangle *area)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
if (area)
if (area)
{
cairo_rectangle (cr, area->x, area->y, area->width, area->height);
cairo_clip_preserve (cr);
@@ -287,8 +277,8 @@ ge_cairo_set_gdk_color_with_alpha (cairo_t *cr, const GdkColor *color, gdouble a
void
ge_cairo_pattern_add_color_stop_color (cairo_pattern_t *pattern,
gfloat offset,
const CairoColor *color)
gfloat offset,
const CairoColor *color)
{
g_return_if_fail (pattern && color);
@@ -296,10 +286,10 @@ ge_cairo_pattern_add_color_stop_color (cairo_pattern_t *pattern,
}
void
ge_cairo_pattern_add_color_stop_shade (cairo_pattern_t *pattern,
gdouble offset,
const CairoColor *color,
gdouble shade)
ge_cairo_pattern_add_color_stop_shade(cairo_pattern_t *pattern,
gdouble offset,
const CairoColor *color,
gdouble shade)
{
CairoColor shaded;
@@ -312,14 +302,12 @@ ge_cairo_pattern_add_color_stop_shade (cairo_pattern_t *pattern,
ge_shade_color(color, shade, &shaded);
}
ge_cairo_pattern_add_color_stop_color(pattern, offset, &shaded);
ge_cairo_pattern_add_color_stop_color(pattern, offset, &shaded);
}
/*
* This function will draw a rounded corner at position x,y. If the radius
/* This function will draw a rounded corner at position x,y. If the radius
* is very small (or negative) it will instead just do a line_to.
* ge_cairo_rounded_corner assumes clockwise drawing.
*/
* ge_cairo_rounded_corner assumes clockwise drawing. */
void
ge_cairo_rounded_corner (cairo_t *cr,
double x,
@@ -333,29 +321,28 @@ ge_cairo_rounded_corner (cairo_t *cr,
}
else
{
switch (corner)
{
case CR_CORNER_NONE:
cairo_line_to (cr, x, y);
break;
case CR_CORNER_TOPLEFT:
cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 3/2);
break;
case CR_CORNER_TOPRIGHT:
cairo_arc (cr, x - radius, y + radius, radius, G_PI * 3/2, G_PI * 2);
break;
case CR_CORNER_BOTTOMRIGHT:
cairo_arc (cr, x - radius, y - radius, radius, 0, G_PI * 1/2);
break;
case CR_CORNER_BOTTOMLEFT:
cairo_arc (cr, x + radius, y - radius, radius, G_PI * 1/2, G_PI);
break;
switch (corner) {
case CR_CORNER_NONE:
cairo_line_to (cr, x, y);
break;
case CR_CORNER_TOPLEFT:
cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 3/2);
break;
case CR_CORNER_TOPRIGHT:
cairo_arc (cr, x - radius, y + radius, radius, G_PI * 3/2, G_PI * 2);
break;
case CR_CORNER_BOTTOMRIGHT:
cairo_arc (cr, x - radius, y - radius, radius, 0, G_PI * 1/2);
break;
case CR_CORNER_BOTTOMLEFT:
cairo_arc (cr, x + radius, y - radius, radius, G_PI * 1/2, G_PI);
break;
default:
/* A bitfield and not a sane value ... */
g_assert_not_reached ();
cairo_line_to (cr, x, y);
return;
default:
/* A bitfield and not a sane value ... */
g_assert_not_reached ();
cairo_line_to (cr, x, y);
return;
}
}
}
@@ -408,9 +395,9 @@ ge_cairo_rounded_rectangle (cairo_t *cr,
/* ge_cairo_stroke_rectangle.
*
* A simple function to stroke the rectangle { x, y, w, h}.
* (This function only exists because of a cairo performance bug that
* has been fixed and it may be a good idea to get rid of it again.)
* A simple function to stroke the rectangle { x, y, w, h}.
* (This function only exists because of a cairo performance bug that
* has been fixed and it may be a good idea to get rid of it again.)
*/
void
ge_cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h)
@@ -419,48 +406,19 @@ ge_cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h)
cairo_stroke (cr);
}
void
ge_cairo_inner_rectangle (cairo_t *cr,
double x, double y,
double width, double height)
{
double line_width = cairo_get_line_width (cr);
cairo_rectangle (cr, x + line_width / 2.0,
y + line_width / 2.0,
width - line_width,
height - line_width);
}
void
ge_cairo_inner_rounded_rectangle (cairo_t *cr,
double x, double y,
double width, double height,
double radius, CairoCorners corners)
{
double line_width = cairo_get_line_width (cr);
ge_cairo_rounded_rectangle (cr,
x + line_width / 2.0,
y + line_width / 2.0,
width - line_width,
height - line_width,
radius, corners);
}
/***********************************************
* ge_cairo_simple_border -
*
* A simple routine to draw thin squared
* borders with a topleft and bottomright color.
*
*
* It originated in Smooth-Engine.
***********************************************/
void
ge_cairo_simple_border (cairo_t *cr,
const CairoColor * tl, const CairoColor * br,
gint x, gint y, gint width, gint height,
gboolean topleft_overlap)
const CairoColor * tl, const CairoColor * br,
gint x, gint y, gint width, gint height,
gboolean topleft_overlap)
{
gboolean solid_color;
@@ -487,7 +445,7 @@ ge_cairo_simple_border (cairo_t *cr,
cairo_stroke (cr);
}
ge_cairo_set_color(cr, tl);
cairo_move_to(cr, x + 0.5, y + height - 0.5);
@@ -513,9 +471,9 @@ ge_cairo_simple_border (cairo_t *cr,
}
void ge_cairo_polygon (cairo_t *cr,
const CairoColor *color,
GdkPoint *points,
gint npoints)
const CairoColor *color,
GdkPoint *points,
gint npoints)
{
int i = 0;
@@ -545,12 +503,12 @@ void ge_cairo_polygon (cairo_t *cr,
}
void ge_cairo_line (cairo_t *cr,
const CairoColor *color,
gint x1,
gint y1,
gint x2,
gint y2)
{
const CairoColor *color,
gint x1,
gint y1,
gint x2,
gint y2)
{
cairo_save(cr);
ge_cairo_set_color(cr, color);
@@ -626,19 +584,18 @@ ge_cairo_exchange_axis (cairo_t *cr,
***********************************************/
void
ge_cairo_pattern_fill(cairo_t *canvas,
CairoPattern *pattern,
gint x,
gint y,
gint width,
gint height)
CairoPattern *pattern,
gint x,
gint y,
gint width,
gint height)
{
cairo_matrix_t original_matrix, current_matrix;
if (pattern->operator == CAIRO_OPERATOR_DEST)
{
return;
if (width <= 0 || height <= 0)
return;
}
cairo_pattern_get_matrix(pattern->handle, &original_matrix);
current_matrix = original_matrix;
@@ -684,7 +641,7 @@ ge_cairo_pattern_fill(cairo_t *canvas,
cairo_save(canvas);
cairo_set_source(canvas, pattern->handle);
cairo_set_operator(canvas, pattern->operator);
cairo_set_operator(canvas, pattern->operator);
cairo_rectangle(canvas, x, y, width, height);
cairo_fill (canvas);
@@ -701,7 +658,7 @@ ge_cairo_pattern_fill(cairo_t *canvas,
***********************************************/
CairoPattern*
ge_cairo_color_pattern(CairoColor *base)
{
{
CairoPattern * result = g_new0(CairoPattern, 1);
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
@@ -711,10 +668,10 @@ ge_cairo_color_pattern(CairoColor *base)
result->scale = GE_DIRECTION_NONE;
result->translate = GE_DIRECTION_NONE;
result->handle = cairo_pattern_create_rgba(base->r,
base->g,
base->b,
base->a);
result->handle = cairo_pattern_create_rgba(base->r,
base->g,
base->b,
base->a);
result->operator = CAIRO_OPERATOR_SOURCE;
@@ -728,14 +685,14 @@ ge_cairo_color_pattern(CairoColor *base)
***********************************************/
CairoPattern*
ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf)
{
{
CairoPattern * result = g_new0(CairoPattern, 1);
cairo_t *canvas;
cairo_surface_t * surface;
gint width, height;
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
result->type = CAIRO_PATTERN_TYPE_SURFACE;
#endif
@@ -780,8 +737,8 @@ ge_cairo_pixmap_pattern(GdkPixmap *pixmap)
gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (pixmap),
gdk_drawable_get_colormap(GDK_DRAWABLE (pixmap)),
0, 0, 0, 0, width, height);
gdk_drawable_get_colormap(GDK_DRAWABLE (pixmap)),
0, 0, 0, 0, width, height);
result = ge_cairo_pixbuf_pattern(pixbuf);
@@ -800,9 +757,9 @@ ge_cairo_pixmap_pattern(GdkPixmap *pixmap)
***********************************************/
CairoPattern *
ge_cairo_linear_shade_gradient_pattern(CairoColor *base,
gdouble shade1,
gdouble shade2,
gboolean vertical)
gdouble shade1,
gdouble shade2,
gboolean vertical)
{
CairoPattern * result = g_new0(CairoPattern, 1);
@@ -839,13 +796,12 @@ ge_cairo_pattern_destroy(CairoPattern *pattern)
{
if (pattern->handle)
cairo_pattern_destroy(pattern->handle);
g_free(pattern);
}
}
/*
* The following function will be called by GTK+ when the module
/* The following function will be called by GTK+ when the module
* is loaded and checks to see if we are compatible with the
* version of GTK+ that loads us.
*/
@@ -853,7 +809,7 @@ GE_EXPORT const gchar* g_module_check_init (GModule *module);
const gchar*
g_module_check_init (GModule *module)
{
return gtk_check_version (GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
return gtk_check_version (GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
}

View File

@@ -101,8 +101,6 @@ GE_INTERNAL void ge_cairo_rounded_corner (cairo_t *cr, double x, double y, doubl
GE_INTERNAL void ge_cairo_rounded_rectangle (cairo_t *cr, double x, double y, double w, double h, double radius, CairoCorners corners);
GE_INTERNAL void ge_cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h);
GE_INTERNAL void ge_cairo_inner_rectangle (cairo_t *cr, double x, double y, double width, double height);
GE_INTERNAL void ge_cairo_inner_rounded_rectangle (cairo_t *cr, double x, double y, double width, double height, double radius, CairoCorners corners);
GE_INTERNAL void ge_cairo_simple_border (cairo_t *cr, const CairoColor * tl, const CairoColor * br, gint x, gint y, gint width, gint height, gboolean topleft_overlap);
GE_INTERNAL void ge_cairo_line (cairo_t *cr, const CairoColor *color, gint x1, gint y1, gint x2, gint y2);

View File

@@ -0,0 +1,17 @@
#ifndef CLEARLOOKS_DRAW_H
#define CLEARLOOKS_DRAW_H
#include "clearlooks_types.h"
#include "clearlooks_style.h"
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <cairo.h>
GE_INTERNAL void clearlooks_register_style_classic (ClearlooksStyleFunctions *functions);
GE_INTERNAL void clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions);
GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions);
GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions);
#endif /* CLEARLOOKS_DRAW_H */

View File

@@ -36,9 +36,9 @@
static void
clearlooks_draw_glossy_gradient (cairo_t *cr,
double x, double y, int width, int height,
const CairoColor *color,
gboolean disabled, gboolean radius, CairoCorners corners)
double x, double y, int width, int height,
const CairoColor *color,
gboolean disabled, gboolean radius, CairoCorners corners)
{
CairoColor a, b, c, d;
cairo_pattern_t *pt;
@@ -49,10 +49,10 @@ clearlooks_draw_glossy_gradient (cairo_t *cr,
ge_shade_color (color, disabled? 1.02 : 1.08, &d);
pt = cairo_pattern_create_linear (x, y, x, y+height);
cairo_pattern_add_color_stop_rgb (pt, 0.0, a.r, a.g, a.b);
cairo_pattern_add_color_stop_rgb (pt, 0.5, b.r, b.g, b.b);
cairo_pattern_add_color_stop_rgb (pt, 0.5, c.r, c.g, c.b);
cairo_pattern_add_color_stop_rgb (pt, 1.0, d.r, d.g, d.b);
cairo_pattern_add_color_stop_rgb (pt, 0.0, a.r, a.g, a.b);
cairo_pattern_add_color_stop_rgb (pt, 0.5, b.r, b.g, b.b);
cairo_pattern_add_color_stop_rgb (pt, 0.5, c.r, c.g, c.b);
cairo_pattern_add_color_stop_rgb (pt, 1.0, d.r, d.g, d.b);
cairo_set_source (cr, pt);
ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, corners);
@@ -73,66 +73,60 @@ clearlooks_set_mixed_color (cairo_t *cr,
ge_cairo_set_color (cr, &composite);
}
/* This draw_inset implementation only differes in the shades values from the
* default one. */
static void
clearlooks_glossy_draw_inset (cairo_t *cr,
const CairoColor *bg_color,
double x, double y, double width, double height,
double x, double y, double w, double h,
double radius, uint8 corners)
{
CairoColor shadow;
CairoColor highlight;
double line_width;
double min = MIN (width, height);
line_width = cairo_get_line_width (cr);
/* not really sure of shading ratios... we will think */
ge_shade_color (bg_color, 0.93, &shadow);
ge_shade_color (bg_color, 1.07, &highlight);
/* highlight */
cairo_save (cr);
cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
cairo_move_to (cr, x, y + height);
cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
cairo_line_to (cr, x + width, y);
cairo_line_to (cr, x, y);
cairo_close_path (cr);
cairo_clip (cr);
if (corners & CR_CORNER_TOPRIGHT)
cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.75, G_PI * 2);
else
cairo_line_to (cr, x + w, y);
ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
width - line_width, height - line_width,
radius, corners);
if (corners & CR_CORNER_BOTTOMRIGHT)
cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
else
cairo_line_to (cr, x + w, y + h);
ge_cairo_set_color (cr, &shadow);
cairo_stroke (cr);
cairo_restore (cr);
/* shadow */
cairo_save (cr);
cairo_move_to (cr, x, y + height);
cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
cairo_line_to (cr, x + width, y);
cairo_line_to (cr, x + width, y + height);
cairo_close_path (cr);
cairo_clip (cr);
ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
width - line_width, height - line_width,
radius, corners);
if (corners & CR_CORNER_BOTTOMLEFT)
cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI * 0.75);
else
cairo_line_to (cr, x, y + h);
ge_cairo_set_color (cr, &highlight);
cairo_stroke (cr);
cairo_restore (cr);
/* shadow */
cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
if (corners & CR_CORNER_BOTTOMLEFT)
cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.75, M_PI);
else
cairo_line_to (cr, x, y + h);
if (corners & CR_CORNER_TOPLEFT)
cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
else
cairo_line_to (cr, x, y);
if (corners & CR_CORNER_TOPRIGHT)
cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, M_PI * 1.75);
else
cairo_line_to (cr, x + w, y);
ge_cairo_set_color (cr, &shadow);
cairo_stroke (cr);
}
static void
@@ -173,17 +167,17 @@ clearlooks_glossy_draw_light_inset (cairo_t *cr,
cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
if (corners & CR_CORNER_BOTTOMLEFT)
cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.75, G_PI);
cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.75, M_PI);
else
cairo_line_to (cr, x, y + h);
if (corners & CR_CORNER_TOPLEFT)
cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 1.5);
cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
else
cairo_line_to (cr, x, y);
if (corners & CR_CORNER_TOPRIGHT)
cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.5, G_PI * 1.75);
cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, M_PI * 1.75);
else
cairo_line_to (cr, x + w, y);
@@ -191,7 +185,6 @@ clearlooks_glossy_draw_light_inset (cairo_t *cr,
cairo_stroke (cr);
}
/* This function currently assumes that the input is translated by 0.5px! */
static void
clearlooks_glossy_draw_highlight_and_shade (cairo_t *cr,
const CairoColor *bg_color,
@@ -248,9 +241,9 @@ clearlooks_glossy_draw_highlight_and_shade (cairo_t *cr,
static void
clearlooks_glossy_draw_button (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
int x, int y, int width, int height)
const ClearlooksColors *colors,
const WidgetParameters *params,
int x, int y, int width, int height)
{
double xoffset = 0, yoffset = 0;
CairoColor fill = colors->bg[params->state_type];
@@ -264,7 +257,7 @@ clearlooks_glossy_draw_button (cairo_t *cr,
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 1.0);
/* Shadows and shadow */
/* Shadows and Glow */
if (params->xthickness == 3 || params->ythickness == 3)
{
if (params->xthickness == 3)
@@ -277,32 +270,35 @@ clearlooks_glossy_draw_button (cairo_t *cr,
if (params->xthickness == 3 || params->ythickness == 3)
{
/* if (params->enable_shadow && !params->active && !params->disabled) */
if (!params->active && (params->prelight || params->enable_shadow))
cairo_translate (cr, 0.5, 0.5);
/* if (params->enable_glow && !params->active && !params->disabled) */
if (params->prelight && params->enable_glow && !params->active)
{
/* shadow becomes a shadow to have 3d prelight buttons :) */
CairoColor shadow;
/* Glow becomes a shadow to have 3d prelight buttons :) */
CairoColor glow;
radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius+1, params->corners);
ge_shade_color (&params->parentbg, 0.96, &shadow);
ge_cairo_set_color (cr, &shadow);
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius+1, params->corners);
ge_shade_color (&params->parentbg, 0.96, &glow);
ge_cairo_set_color (cr, &glow);
cairo_stroke (cr);
ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-2, height-2, radius+1, params->corners);
ge_shade_color (&params->parentbg, 0.92, &shadow);
ge_cairo_set_color (cr, &shadow);
ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius+1, params->corners);
ge_shade_color (&params->parentbg, 0.92, &glow);
ge_cairo_set_color (cr, &glow);
cairo_stroke (cr);
}
else
{
/* if (!(params->enable_glow && !params->active && !params->disabled)) */
if (!(params->prelight && params->enable_glow && !params->active))
if (!(params->disabled))
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, params->radius+1, params->corners);
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width-1, height-1, params->radius+1, params->corners);
else
/*Draw a lighter inset */
clearlooks_glossy_draw_light_inset (cr, &params->parentbg, 0, 0, width, height, params->radius+1, params->corners);
}
clearlooks_glossy_draw_light_inset (cr, &params->parentbg, 0, 0, width-1, height-1, params->radius+1, params->corners);
cairo_translate (cr, -0.5, -0.5);
}
clearlooks_draw_glossy_gradient (cr, xoffset+1, yoffset+1,
@@ -343,30 +339,30 @@ clearlooks_glossy_draw_button (cairo_t *cr,
/* Default button highlight */
if (params->is_default && !params->active && !params->disabled)
{
const CairoColor *shadow = &colors->spot[0];
const CairoColor *glow = &colors->spot[0];
double hh = (height-5)/2.0 + 1;
cairo_rectangle (cr, 3.5, 3.5, width-7, height-7);
ge_cairo_set_color (cr, shadow);
ge_cairo_set_color (cr, glow);
cairo_stroke (cr);
shadow = &colors->spot[0];
glow = &colors->spot[0];
cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, -hh);
cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, hh);
ge_cairo_set_color (cr, shadow);
ge_cairo_set_color (cr, glow);
cairo_stroke (cr);
hh--;
shadow = &colors->spot[1];
glow = &colors->spot[1];
cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, hh);
cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, -hh);
ge_cairo_set_color (cr, shadow);
ge_cairo_set_color (cr, glow);
cairo_stroke (cr);
}
/* Border */
if (params->is_default || (params->prelight && params->enable_shadow))
if (params->is_default || (params->prelight && params->enable_glow))
border_normal = colors->spot[2];
/* ge_mix_color (&border_normal, &colors->spot[2], 0.5, &border_normal); */
if (params->disabled)
@@ -395,6 +391,12 @@ clearlooks_glossy_draw_progressbar_trough (cairo_t *cr,
cairo_set_line_width (cr, 1.0);
/* Fill with bg color */
ge_cairo_set_color (cr, &colors->bg[params->state_type]);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
/* Create trough box */
ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
ge_cairo_set_color (cr, &colors->shade[2]);
@@ -602,21 +604,20 @@ clearlooks_glossy_scale_draw_gradient (cairo_t *cr,
{
cairo_pattern_t *pattern;
pattern = cairo_pattern_create_linear (0.5, 0.5, horizontal ? 0.5 : width + 1, horizontal ? height + 1 : 0.5);
pattern = cairo_pattern_create_linear (0, 0, horizontal ? 0 : width, horizontal ? height : 0);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, c1->r, c1->g, c1->b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, c2->r, c2->g, c2->b);
cairo_rectangle (cr, x, y, width, height);
cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
clearlooks_set_mixed_color (cr, c3, c1, 0.3);
ge_cairo_inner_rectangle (cr, x, y, width, height);
cairo_stroke (cr);
ge_cairo_stroke_rectangle (cr, x, y, width, height);
}
#define TROUGH_SIZE 7
#define TROUGH_SIZE 6
static void
clearlooks_glossy_draw_scale_trough (cairo_t *cr,
const ClearlooksColors *colors,
@@ -627,44 +628,43 @@ clearlooks_glossy_draw_scale_trough (cairo_t *cr,
int trough_width, trough_height;
double translate_x, translate_y;
cairo_save (cr);
if (slider->horizontal)
{
trough_width = width;
trough_height = TROUGH_SIZE;
trough_width = width-3;
trough_height = TROUGH_SIZE-2;
translate_x = x;
translate_y = y + (height/2) - (TROUGH_SIZE/2);
translate_x = x + 0.5;
translate_y = y + 0.5 + (height/2) - (TROUGH_SIZE/2);
}
else
{
trough_width = TROUGH_SIZE;
trough_height = height;
trough_width = TROUGH_SIZE-2;
trough_height = height-3;
translate_x = x + (width/2) - (TROUGH_SIZE/2);
translate_y = y;
translate_x = x + 0.5 + (width/2) - (TROUGH_SIZE/2);
translate_y = y + 0.5;
}
cairo_set_line_width (cr, 1.0);
cairo_translate (cr, translate_x, translate_y);
if (!slider->fill_level)
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width, trough_height, 0, 0);
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width+2, trough_height+2, 0, 0);
cairo_translate (cr, 1, 1);
if (!slider->lower && !slider->fill_level)
clearlooks_glossy_scale_draw_gradient (cr, &colors->shade[3], /* top */
&colors->shade[2], /* bottom */
&colors->shade[6], /* border */
1.0, 1.0, trough_width - 2, trough_height - 2,
0, 0, trough_width, trough_height,
slider->horizontal);
else
clearlooks_glossy_scale_draw_gradient (cr, &colors->spot[1], /* top */
&colors->spot[0], /* bottom */
&colors->spot[2], /* border */
1.0, 1.0, trough_width - 2, trough_height - 2,
0, 0, trough_width, trough_height,
slider->horizontal);
cairo_restore (cr);
}
static void
@@ -685,7 +685,6 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
double radius;
double strip_size;
double length;
radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
@@ -704,7 +703,6 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
{
height += 3.0;
length = height;
strip_size = 2.0/height; /* 2 pixel high strip */
if (tab->gap_side == CL_GAP_TOP)
@@ -713,7 +711,6 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
else
{
width += 3.0;
length = width;
strip_size = 2.0/width;
if (tab->gap_side == CL_GAP_LEFT)
@@ -741,8 +738,6 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
shadow.shadow = CL_SHADOW_OUT;
shadow.corners = params->corners;
/* This is the only usage of clearlooks_glossy_draw_highlight_and_shade,
* the function assumes currently that the input is translated by 0.5 px. */
clearlooks_glossy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow,
width,
height, radius);
@@ -752,23 +747,10 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
{
CairoColor shadow, hilight, f1, f2;
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (0, 1, 0, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 0, 1, 0);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (1, 0, width-2, 0);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-1 : 0,
tab->gap_side == CL_GAP_TOP ? height-2 : 1,
tab->gap_side == CL_GAP_RIGHT ? width : 0,
tab->gap_side == CL_GAP_BOTTOM ? height : 0);
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
@@ -778,8 +760,8 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
ge_shade_color (fill, 1.06, &f2);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, hilight.r, hilight.g, hilight.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, hilight.r, hilight.g, hilight.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, f1.r, f1.g, f1.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, hilight.r, hilight.g, hilight.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, f1.r, f1.g, f1.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.45, f2.r, f2.g, f2.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.45, fill->r, fill->g, fill->b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r, shadow.g, shadow.b);
@@ -790,23 +772,10 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
else
{
/* Draw shade */
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (0, 0, 0, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 0, 0, 0);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (0, 0, width, 0);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-2 : 0,
tab->gap_side == CL_GAP_TOP ? height-2 : 0,
tab->gap_side == CL_GAP_RIGHT ? width : 0,
tab->gap_side == CL_GAP_BOTTOM ? height : 0);
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
@@ -827,23 +796,10 @@ clearlooks_glossy_draw_tab (cairo_t *cr,
}
else
{
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (2, height-2, 2, 2);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (2, 2, 2, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 2, 2, 2);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (2, 2, width, 2);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-2 : 2,
tab->gap_side == CL_GAP_TOP ? height-2 : 2,
tab->gap_side == CL_GAP_RIGHT ? width : 2,
tab->gap_side == CL_GAP_BOTTOM ? height : 2);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r, border->g, border->b);
@@ -868,6 +824,8 @@ clearlooks_glossy_draw_slider (cairo_t *cr,
cairo_set_line_width (cr, 1.0);
cairo_translate (cr, x, y);
cairo_translate (cr, -0.5, -0.5);
ge_shade_color (&colors->bg[params->state_type], 1.0, &fill);
if (params->prelight)
ge_shade_color (&fill, 1.1, &fill);
@@ -913,8 +871,9 @@ clearlooks_glossy_draw_slider_button (cairo_t *cr,
if (!slider->horizontal)
ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
cairo_translate (cr, x, y);
params->style_functions->draw_shadow (cr, colors, radius, width, height);
cairo_translate (cr, x+0.5, y+0.5);
params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
}
@@ -971,12 +930,16 @@ clearlooks_glossy_draw_scrollbar_stepper (cairo_t *cr,
cairo_fill (cr);
cairo_pattern_destroy (pattern);
ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
cairo_translate (cr, 0.5, 0.5);
cairo_translate (cr, -0.5, -0.5);
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
clearlooks_set_mixed_color (cr, border, &fill, 0.2);
if (widget->prelight)
ge_cairo_set_color (cr, &colors->spot[2]);
cairo_stroke (cr);
cairo_translate (cr, 0.5, 0.5);
shadow.shadow = CL_SHADOW_OUT;
shadow.corners = corners;
}
@@ -1091,7 +1054,7 @@ clearlooks_glossy_draw_list_view_header (cairo_t *cr,
cairo_pattern_destroy (pattern);
/* Draw highlight */
if (header->order & CL_ORDER_FIRST)
if (header->order == CL_ORDER_FIRST)
{
cairo_move_to (cr, 0.5, height-1);
cairo_line_to (cr, 0.5, 0.5);
@@ -1105,8 +1068,8 @@ clearlooks_glossy_draw_list_view_header (cairo_t *cr,
cairo_stroke (cr);
/* Draw resize grip */
if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
(!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
if ((params->ltr && header->order != CL_ORDER_LAST) ||
(!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
{
SeparatorParameters separator;
separator.horizontal = FALSE;
@@ -1274,13 +1237,6 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr,
cairo_pattern_t *pt;
gboolean inconsistent;
gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
gdouble w, h, cx, cy, radius;
w = (gdouble) width;
h = (gdouble) height;
cx = width / 2.0;
cy = height / 2.0;
radius = MIN (width, height) / 2.0;
inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
draw_bullet |= inconsistent;
@@ -1302,7 +1258,7 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr,
ge_shade_color (&widget->parentbg, 0.9, &shadow);
ge_shade_color (&widget->parentbg, 1.1, &highlight);
pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
pt = cairo_pattern_create_linear (0, 0, 13, 13);
cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
@@ -1310,15 +1266,15 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr,
cairo_translate (cr, x, y);
cairo_set_line_width (cr, MAX (1.0, floor (radius/3)));
cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2);
cairo_set_line_width (cr, 2);
cairo_arc (cr, 7, 7, 6, 0, G_PI*2);
cairo_set_source (cr, pt);
cairo_stroke (cr);
cairo_pattern_destroy (pt);
cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
cairo_set_line_width (cr, 1);
cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
cairo_arc (cr, 7, 7, 5.5, 0, G_PI*2);
if (!widget->disabled)
{
@@ -1337,21 +1293,21 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr,
if (inconsistent)
{
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width (cr, ceil (radius * 2 / 3));
cairo_set_line_width (cr, 4);
cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy));
cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy));
cairo_move_to(cr, 5, 7);
cairo_line_to(cr, 9, 7);
ge_cairo_set_color (cr, dot);
cairo_stroke (cr);
}
else
{
cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
cairo_arc (cr, 7, 7, 3, 0, G_PI*2);
ge_cairo_set_color (cr, dot);
cairo_fill (cr);
cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
cairo_arc (cr, 6, 6, 1, 0, G_PI*2);
cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
cairo_fill (cr);
}
@@ -1392,8 +1348,8 @@ clearlooks_glossy_draw_checkbox (cairo_t *cr,
if (widget->xthickness > 2 && widget->ythickness > 2)
{
widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0,
width, height, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
widget->style_functions->draw_inset (cr, &widget->parentbg, 0.5, 0.5,
width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
/* Draw the rectangle for the checkbox itself */
ge_cairo_rounded_rectangle (cr, 1.5, 1.5,
@@ -1444,7 +1400,7 @@ clearlooks_glossy_draw_checkbox (cairo_t *cr,
}
void
clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions)
{
functions->draw_inset = clearlooks_glossy_draw_inset;
functions->draw_button = clearlooks_glossy_draw_button;

View File

@@ -29,6 +29,29 @@
#include <cairo.h>
static void
clearlooks_draw_top_left_highlight (cairo_t *cr,
const CairoColor *color,
const WidgetParameters *params,
int width, int height, gdouble radius)
{
CairoColor hilight;
double light_top = params->ythickness-1,
light_bottom = height - params->ythickness - 1,
light_left = params->xthickness-1,
light_right = width - params->xthickness - 1;
ge_shade_color (color, 1.3, &hilight);
cairo_move_to (cr, light_left, light_bottom - (int)radius/2);
ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
cairo_line_to (cr, light_right - (int)radius/2, light_top);
cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.7);
cairo_stroke (cr);
}
static void
clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
{
@@ -78,7 +101,9 @@ clearlooks_inverted_draw_button (cairo_t *cr,
if (params->xthickness == 3 || params->ythickness == 3)
{
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
cairo_translate (cr, 0.5, 0.5);
params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
cairo_translate (cr, -0.5, -0.5);
}
ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
@@ -160,17 +185,15 @@ clearlooks_inverted_draw_button (cairo_t *cr,
/* Draw the "shadow" */
if (!params->active)
{
cairo_translate (cr, 0.5, 0.5);
/* Draw right shadow */
cairo_move_to (cr, width-xoffset-1.5, yoffset + radius);
cairo_line_to (cr, width-xoffset-1.5, height - yoffset - radius);
cairo_move_to (cr, width-params->xthickness, params->ythickness - 1);
cairo_line_to (cr, width-params->xthickness, height - params->ythickness - 1);
cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
cairo_stroke (cr);
/* Draw topleft shadow */
params->style_functions->draw_top_left_highlight (cr, fill, params,
xoffset+1, yoffset+1,
width-2*(xoffset+1), height-2*(yoffset+1),
radius, params->corners);
clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
}
cairo_restore (cr);
}
@@ -413,7 +436,6 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
double radius;
double strip_size;
double length;
radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
@@ -432,7 +454,6 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
{
height += 3.0;
length = height;
strip_size = 2.0/height; /* 2 pixel high strip */
if (tab->gap_side == CL_GAP_TOP)
@@ -441,7 +462,6 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
else
{
width += 3.0;
length = width;
strip_size = 2.0/width;
if (tab->gap_side == CL_GAP_LEFT)
@@ -476,23 +496,10 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
if (params->active)
{
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (0, 1, 0, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 0, 1, 0);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (1, 0, width-2, 0);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-1 : 0,
tab->gap_side == CL_GAP_TOP ? height-2 : 1,
tab->gap_side == CL_GAP_RIGHT ? width : 0,
tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
@@ -509,23 +516,10 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
else
{
/* Draw shade */
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (0, 0, 0, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 0, 0, 0);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (0, 0, width, 0);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 0,
tab->gap_side == CL_GAP_TOP ? height-2 : 0,
tab->gap_side == CL_GAP_RIGHT ? width : 0,
tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
@@ -548,23 +542,10 @@ clearlooks_inverted_draw_tab (cairo_t *cr,
}
else
{
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (2, height-2, 2, 2);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (2, 2, 2, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 2, 2, 2);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (2, 2, width, 2);
break;
default:
pattern = NULL;
}
pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 2,
tab->gap_side == CL_GAP_TOP ? height-2 : 2,
tab->gap_side == CL_GAP_RIGHT ? width : 2,
tab->gap_side == CL_GAP_BOTTOM ? height : 2 );
cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_border->r, stripe_border->g, stripe_border->b);
@@ -600,7 +581,7 @@ clearlooks_inverted_draw_slider (cairo_t *cr,
border = &colors->shade[6];
/* fill the widget */
cairo_rectangle (cr, 1.0, 1.0, width-2, height-2);
cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
/* Fake light */
if (!params->disabled)
@@ -618,20 +599,20 @@ clearlooks_inverted_draw_slider (cairo_t *cr,
else
{
ge_cairo_set_color (cr, fill);
cairo_rectangle (cr, 1.0, 1.0, width-2, height-2);
cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
cairo_fill (cr);
}
/* Set the clip */
cairo_save (cr);
cairo_rectangle (cr, 1.0, 1.0, 6, height-2);
cairo_rectangle (cr, width-7.0, 1.0, 6, height-2);
cairo_rectangle (cr, 0.5, 0.5, 6, height-2);
cairo_rectangle (cr, width-7.5, 0.5, 6 , height-2);
cairo_clip_preserve (cr);
cairo_new_path (cr);
/* Draw the handles */
ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners);
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, 0.5+height);
if (params->prelight)
@@ -654,7 +635,7 @@ clearlooks_inverted_draw_slider (cairo_t *cr,
cairo_restore (cr);
/* Draw the border */
ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
if (params->prelight || params->disabled)
ge_cairo_set_color (cr, border);
else
@@ -664,11 +645,11 @@ clearlooks_inverted_draw_slider (cairo_t *cr,
/* Draw handle lines */
if (width > 14)
{
cairo_move_to (cr, 6.5, 1.0);
cairo_line_to (cr, 6.5, height-1);
cairo_move_to (cr, 6, 0.5);
cairo_line_to (cr, 6, height-1);
cairo_move_to (cr, width-6.5, 1.0);
cairo_line_to (cr, width-6.5, height-1);
cairo_move_to (cr, width-7, 0.5);
cairo_line_to (cr, width-7, height-1);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, border->r,
@@ -679,6 +660,27 @@ clearlooks_inverted_draw_slider (cairo_t *cr,
}
}
static void
clearlooks_inverted_draw_slider_button (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
const SliderParameters *slider,
int x, int y, int width, int height)
{
double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
cairo_set_line_width (cr, 1.0);
if (!slider->horizontal)
ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
cairo_translate (cr, x+0.5, y+0.5);
params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
if (width > 24)
params->style_functions->draw_gripdots (cr, colors, 0, 0, width-2, height-2, 3, 3, 0);
}
static void
clearlooks_inverted_draw_list_view_header (cairo_t *cr,
const ClearlooksColors *colors,
@@ -701,7 +703,7 @@ clearlooks_inverted_draw_list_view_header (cairo_t *cr,
cairo_set_line_width (cr, 1.0);
/* Draw highlight */
if (header->order & CL_ORDER_FIRST)
if (header->order == CL_ORDER_FIRST)
{
cairo_move_to (cr, 0.5, height-1);
cairo_line_to (cr, 0.5, 0.5);
@@ -731,8 +733,8 @@ clearlooks_inverted_draw_list_view_header (cairo_t *cr,
cairo_pattern_destroy (pattern);
/* Draw resize grip */
if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
(!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
if ((params->ltr && header->order != CL_ORDER_LAST) ||
(!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
{
SeparatorParameters separator;
separator.horizontal = FALSE;
@@ -759,6 +761,7 @@ clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
CairoColor border;
CairoColor s1, s2, s3;
cairo_pattern_t *pattern;
ShadowParameters shadow;
double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
ge_shade_color(&colors->shade[6], 1.05, &border);
@@ -798,11 +801,19 @@ clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
cairo_fill (cr);
cairo_pattern_destroy (pattern);
widget->style_functions->draw_top_left_highlight (cr, &s1, widget, 1, 1, width-2, height-2, radius, corners);
clearlooks_draw_top_left_highlight (cr, &s1, widget, width, height, radius);
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
cairo_stroke (cr);
cairo_translate (cr, 0.5, 0.5);
shadow.shadow = CL_SHADOW_OUT;
shadow.corners = corners;
/*
clearlooks_draw_highlight_and_shade (cr, &shadow,
width,
height, params->radius);*/
}
static void
@@ -898,7 +909,7 @@ clearlooks_inverted_draw_scrollbar_slider (cairo_t *cr,
cairo_fill(cr);
cairo_pattern_destroy(pattern);
widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width-2, height-2, 0, widget->corners);
clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, 0);
clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
@@ -974,10 +985,11 @@ clearlooks_inverted_draw_selected_cell (cairo_t *cr,
}
void
clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions)
{
functions->draw_button = clearlooks_inverted_draw_button;
functions->draw_slider = clearlooks_inverted_draw_slider;
functions->draw_slider_button = clearlooks_inverted_draw_slider_button;
functions->draw_progressbar_fill = clearlooks_inverted_draw_progressbar_fill;
functions->draw_menuitem = clearlooks_inverted_draw_menuitem;
functions->draw_menubaritem = clearlooks_inverted_draw_menubaritem;
@@ -986,8 +998,5 @@ clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, Clearlo
functions->draw_scrollbar_stepper = clearlooks_inverted_draw_scrollbar_stepper;
functions->draw_scrollbar_slider = clearlooks_inverted_draw_scrollbar_slider;
functions->draw_selected_cell = clearlooks_inverted_draw_selected_cell;
constants->topleft_highlight_shade = 1.3;
constants->topleft_highlight_alpha = 0.7;
}

View File

@@ -1,7 +1,5 @@
/* Clearlooks theme engine
* Copyright (C) 2005 Richard Stellingwerff
* Copyright (C) 2007 Benjamin Berg
* Copyright (C) 2007 Andrea Cimitan
* Copyright (C) 2005 Richard Stellingwerff.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -24,32 +22,35 @@
* Modified by Kulyk Nazar <schamane@myeburg.net>
*/
#include <string.h>
#include <widget-information.h>
#include "clearlooks_style.h"
#include "clearlooks_rc_style.h"
#include "animation.h"
static void clearlooks_rc_style_init (ClearlooksRcStyle *style);
#ifdef HAVE_ANIMATION
static void clearlooks_rc_style_finalize (GObject *object);
#endif
static void clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass);
static GtkStyle *clearlooks_rc_style_create_style (GtkRcStyle *rc_style);
static guint clearlooks_rc_style_parse (GtkRcStyle *rc_style,
GtkSettings *settings,
GScanner *scanner);
GtkSettings *settings,
GScanner *scanner);
static void clearlooks_rc_style_merge (GtkRcStyle *dest,
GtkRcStyle *src);
GtkRcStyle *src);
static GtkRcStyleClass *clearlooks_parent_rc_class;
GType clearlooks_type_rc_style = 0;
enum
{
TOKEN_FOCUSCOLOR = G_TOKEN_LAST + 1,
TOKEN_SCROLLBARCOLOR,
TOKEN_SCROLLBARCOLOR = G_TOKEN_LAST + 1,
TOKEN_COLORIZESCROLLBAR,
TOKEN_CONTRAST,
TOKEN_SUNKENMENU,
TOKEN_PROGRESSBARSTYLE,
TOKEN_RELIEFSTYLE,
TOKEN_MENUBARSTYLE,
TOKEN_TOOLBARSTYLE,
TOKEN_MENUITEMSTYLE,
@@ -57,7 +58,6 @@ enum
TOKEN_ANIMATION,
TOKEN_STYLE,
TOKEN_RADIUS,
TOKEN_HINT,
TOKEN_CLASSIC,
TOKEN_GLOSSY,
@@ -65,42 +65,60 @@ enum
TOKEN_GUMMY,
TOKEN_TRUE,
TOKEN_FALSE,
TOKEN_LAST
TOKEN_FALSE
};
static gchar* clearlooks_rc_symbols =
"focus_color\0"
"scrollbar_color\0"
"colorize_scrollbar\0"
"contrast\0"
"sunkenmenubar\0"
"progressbarstyle\0"
"reliefstyle\0"
"menubarstyle\0"
"toolbarstyle\0"
"menuitemstyle\0"
"listviewitemstyle\0"
"animation\0"
"style\0"
"radius\0"
"hint\0"
static struct
{
const gchar *name;
guint token;
}
clearlooks_gtk2_rc_symbols[] =
{
{ "scrollbar_color", TOKEN_SCROLLBARCOLOR },
{ "colorize_scrollbar", TOKEN_COLORIZESCROLLBAR },
{ "contrast", TOKEN_CONTRAST },
{ "sunkenmenubar", TOKEN_SUNKENMENU },
{ "progressbarstyle", TOKEN_PROGRESSBARSTYLE },
{ "menubarstyle", TOKEN_MENUBARSTYLE },
{ "toolbarstyle", TOKEN_TOOLBARSTYLE },
{ "menuitemstyle", TOKEN_MENUITEMSTYLE },
{ "listviewitemstyle", TOKEN_LISTVIEWITEMSTYLE },
{ "animation", TOKEN_ANIMATION },
{ "style", TOKEN_STYLE },
{ "radius", TOKEN_RADIUS },
"CLASSIC\0"
"GLOSSY\0"
"INVERTED\0"
"GUMMY\0"
{ "CLASSIC", TOKEN_CLASSIC },
{ "GLOSSY", TOKEN_GLOSSY },
{ "INVERTED", TOKEN_INVERTED },
{ "GUMMY", TOKEN_GUMMY },
"TRUE\0"
"FALSE\0";
{ "TRUE", TOKEN_TRUE },
{ "FALSE", TOKEN_FALSE }
};
G_DEFINE_DYNAMIC_TYPE (ClearlooksRcStyle, clearlooks_rc_style, GTK_TYPE_RC_STYLE)
void
clearlooks_rc_style_register_types (GTypeModule *module)
clearlooks_rc_style_register_type (GTypeModule *module)
{
clearlooks_rc_style_register_type (module);
static const GTypeInfo object_info =
{
sizeof (ClearlooksRcStyleClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) clearlooks_rc_style_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (ClearlooksRcStyle),
0, /* n_preallocs */
(GInstanceInitFunc) clearlooks_rc_style_init,
NULL
};
clearlooks_type_rc_style = g_type_module_register_type (module,
GTK_TYPE_RC_STYLE,
"ClearlooksRcStyle",
&object_info, 0);
}
static void
@@ -111,13 +129,11 @@ clearlooks_rc_style_init (ClearlooksRcStyle *clearlooks_rc)
clearlooks_rc->flags = 0;
clearlooks_rc->contrast = 1.0;
clearlooks_rc->reliefstyle = 0;
clearlooks_rc->menubarstyle = 0;
clearlooks_rc->toolbarstyle = 0;
clearlooks_rc->animation = FALSE;
clearlooks_rc->colorize_scrollbar = FALSE;
clearlooks_rc->radius = 3.0;
clearlooks_rc->hint = 0;
}
#ifdef HAVE_ANIMATION
@@ -127,8 +143,8 @@ clearlooks_rc_style_finalize (GObject *object)
/* cleanup all the animation stuff */
clearlooks_animation_cleanup ();
if (G_OBJECT_CLASS (clearlooks_rc_style_parent_class)->finalize != NULL)
G_OBJECT_CLASS (clearlooks_rc_style_parent_class)->finalize (object);
if (G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize != NULL)
G_OBJECT_CLASS (clearlooks_parent_rc_class)->finalize(object);
}
#endif
@@ -141,6 +157,8 @@ clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass)
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
#endif
clearlooks_parent_rc_class = g_type_class_peek_parent (klass);
rc_style_class->parse = clearlooks_rc_style_parse;
rc_style_class->create_style = clearlooks_rc_style_create_style;
rc_style_class->merge = clearlooks_rc_style_merge;
@@ -150,15 +168,10 @@ clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass)
#endif
}
static void
clearlooks_rc_style_class_finalize (ClearlooksRcStyleClass *klass)
{
}
static guint
clearlooks_gtk2_rc_parse_boolean (GtkSettings *settings,
GScanner *scanner,
gboolean *retval)
GScanner *scanner,
gboolean *retval)
{
guint token;
token = g_scanner_get_next_token(scanner);
@@ -180,9 +193,8 @@ clearlooks_gtk2_rc_parse_boolean (GtkSettings *settings,
static guint
clearlooks_gtk2_rc_parse_color(GtkSettings *settings,
GScanner *scanner,
GtkRcStyle *style,
GdkColor *color)
GScanner *scanner,
GdkColor *color)
{
guint token;
@@ -193,7 +205,7 @@ clearlooks_gtk2_rc_parse_color(GtkSettings *settings,
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
return gtk_rc_parse_color_full (scanner, style, color);
return gtk_rc_parse_color (scanner, color);
}
static guint
@@ -221,12 +233,12 @@ clearlooks_gtk2_rc_parse_double (GtkSettings *settings,
static guint
clearlooks_gtk2_rc_parse_int (GtkSettings *settings,
GScanner *scanner,
guint8 *progressbarstyle)
GScanner *scanner,
guint8 *progressbarstyle)
{
guint token;
/* Skip option name */
/* Skip 'sunkenmenubar' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
@@ -259,7 +271,7 @@ clearlooks_gtk2_rc_parse_style (GtkSettings *settings,
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case TOKEN_CLASSIC:
@@ -307,14 +319,16 @@ clearlooks_gtk2_rc_parse_dummy (GtkSettings *settings,
static guint
clearlooks_rc_style_parse (GtkRcStyle *rc_style,
GtkSettings *settings,
GScanner *scanner)
GtkSettings *settings,
GScanner *scanner)
{
static GQuark scope_id = 0;
ClearlooksRcStyle *clearlooks_style = CLEARLOOKS_RC_STYLE (rc_style);
guint old_scope;
guint token;
guint i;
/* Set up a new scope in this scanner. */
@@ -330,18 +344,13 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
* (in some previous call to clearlooks_rc_style_parse for the
* same scanner.
*/
if (!g_scanner_lookup_symbol(scanner, clearlooks_rc_symbols)) {
gchar *current_symbol = clearlooks_rc_symbols;
gint i = G_TOKEN_LAST + 1;
/* Add our symbols */
while ((current_symbol[0] != '\0') && (i < TOKEN_LAST)) {
g_scanner_scope_add_symbol(scanner, scope_id, current_symbol, GINT_TO_POINTER (i));
current_symbol += strlen(current_symbol) + 1;
i++;
}
g_assert (i == TOKEN_LAST && current_symbol[0] == '\0');
if (!g_scanner_lookup_symbol(scanner, clearlooks_gtk2_rc_symbols[0].name))
{
for (i = 0; i < G_N_ELEMENTS (clearlooks_gtk2_rc_symbols); i++)
g_scanner_scope_add_symbol(scanner, scope_id,
clearlooks_gtk2_rc_symbols[i].name,
GINT_TO_POINTER(clearlooks_gtk2_rc_symbols[i].token));
}
/* We're ready to go, now parse the top level */
@@ -351,12 +360,8 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
{
switch (token)
{
case TOKEN_FOCUSCOLOR:
token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->focus_color);
clearlooks_style->flags |= CL_FLAG_FOCUS_COLOR;
break;
case TOKEN_SCROLLBARCOLOR:
token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->scrollbar_color);
token = clearlooks_gtk2_rc_parse_color (settings, scanner, &clearlooks_style->scrollbar_color);
clearlooks_style->flags |= CL_FLAG_SCROLLBAR_COLOR;
break;
case TOKEN_COLORIZESCROLLBAR:
@@ -367,10 +372,6 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->contrast);
clearlooks_style->flags |= CL_FLAG_CONTRAST;
break;
case TOKEN_RELIEFSTYLE:
token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->reliefstyle);
clearlooks_style->flags |= CL_FLAG_RELIEFSTYLE;
break;
case TOKEN_MENUBARSTYLE:
token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->menubarstyle);
clearlooks_style->flags |= CL_FLAG_MENUBARSTYLE;
@@ -391,10 +392,6 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->radius);
clearlooks_style->flags |= CL_FLAG_RADIUS;
break;
case TOKEN_HINT:
token = ge_rc_parse_hint (scanner, &clearlooks_style->hint);
clearlooks_style->flags |= CL_FLAG_HINT;
break;
/* stuff to ignore */
case TOKEN_SUNKENMENU:
@@ -431,12 +428,12 @@ clearlooks_rc_style_parse (GtkRcStyle *rc_style,
static void
clearlooks_rc_style_merge (GtkRcStyle *dest,
GtkRcStyle *src)
GtkRcStyle *src)
{
ClearlooksRcStyle *dest_w, *src_w;
ClearlooksRcFlags flags;
GTK_RC_STYLE_CLASS (clearlooks_rc_style_parent_class)->merge (dest, src);
clearlooks_parent_rc_class->merge (dest, src);
if (!CLEARLOOKS_IS_RC_STYLE (src))
return;
@@ -450,14 +447,10 @@ clearlooks_rc_style_merge (GtkRcStyle *dest,
dest_w->style = src_w->style;
if (flags & CL_FLAG_CONTRAST)
dest_w->contrast = src_w->contrast;
if (flags & CL_FLAG_RELIEFSTYLE)
dest_w->reliefstyle = src_w->reliefstyle;
if (flags & CL_FLAG_MENUBARSTYLE)
dest_w->menubarstyle = src_w->menubarstyle;
if (flags & CL_FLAG_TOOLBARSTYLE)
dest_w->toolbarstyle = src_w->toolbarstyle;
if (flags & CL_FLAG_FOCUS_COLOR)
dest_w->focus_color = src_w->focus_color;
if (flags & CL_FLAG_SCROLLBAR_COLOR)
dest_w->scrollbar_color = src_w->scrollbar_color;
if (flags & CL_FLAG_COLORIZE_SCROLLBAR)
@@ -466,8 +459,6 @@ clearlooks_rc_style_merge (GtkRcStyle *dest,
dest_w->animation = src_w->animation;
if (flags & CL_FLAG_RADIUS)
dest_w->radius = src_w->radius;
if (flags & CL_FLAG_HINT)
dest_w->hint = src_w->hint;
dest_w->flags |= src_w->flags;
}

View File

@@ -1,7 +1,5 @@
/* Clearlooks theme engine
* Copyright (C) 2005 Richard Stellingwerff
* Copyright (C) 2007 Benjamin Berg
* Copyright (C) 2007 Andrea Cimitan
/* Clearlooks Theme Engine
* Copyright (C) 2005 Richard Stellingwerff.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,13 +25,12 @@
#include <gtk/gtkrc.h>
#include "clearlooks_types.h"
#ifndef CLEARLOOKS_RC_STYLE_H
#define CLEARLOOKS_RC_STYLE_H
typedef struct _ClearlooksRcStyle ClearlooksRcStyle;
typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
#define CLEARLOOKS_TYPE_RC_STYLE (clearlooks_rc_style_get_type ())
GE_INTERNAL extern GType clearlooks_type_rc_style;
#define CLEARLOOKS_TYPE_RC_STYLE clearlooks_type_rc_style
#define CLEARLOOKS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyle))
#define CLEARLOOKS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
#define CLEARLOOKS_IS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_RC_STYLE))
@@ -43,19 +40,15 @@ typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
/* XXX: needs fixing! */
typedef enum {
CL_FLAG_STYLE = 1 << 0,
CL_FLAG_FOCUS_COLOR = 1 << 1,
CL_FLAG_SCROLLBAR_COLOR = 1 << 2,
CL_FLAG_COLORIZE_SCROLLBAR = 1 << 3,
CL_FLAG_CONTRAST = 1 << 4,
CL_FLAG_RELIEFSTYLE = 1 << 5,
CL_FLAG_MENUBARSTYLE = 1 << 6,
CL_FLAG_TOOLBARSTYLE = 1 << 7,
CL_FLAG_ANIMATION = 1 << 8,
CL_FLAG_RADIUS = 1 << 9,
CL_FLAG_HINT = 1 << 10
CL_FLAG_SCROLLBAR_COLOR = 1 << 1,
CL_FLAG_COLORIZE_SCROLLBAR = 1 << 2,
CL_FLAG_CONTRAST = 1 << 3,
CL_FLAG_MENUBARSTYLE = 1 << 4,
CL_FLAG_TOOLBARSTYLE = 1 << 5,
CL_FLAG_ANIMATION = 1 << 6,
CL_FLAG_RADIUS = 1 << 7
} ClearlooksRcFlags;
struct _ClearlooksRcStyle
{
GtkRcStyle parent_instance;
@@ -64,24 +57,18 @@ struct _ClearlooksRcStyle
ClearlooksStyles style;
GdkColor focus_color;
GdkColor scrollbar_color;
gboolean colorize_scrollbar;
double contrast;
guint8 reliefstyle;
guint8 menubarstyle;
guint8 toolbarstyle;
gboolean animation;
double radius;
GQuark hint;
};
struct _ClearlooksRcStyleClass
{
GtkRcStyleClass parent_class;
GtkRcStyleClass parent_class;
};
GE_INTERNAL void clearlooks_rc_style_register_types (GTypeModule *module);
GE_INTERNAL GType clearlooks_rc_style_get_type (void);
#endif /* CLEARLOOKS_RC_STYLE_H */
GE_INTERNAL void clearlooks_rc_style_register_type (GTypeModule *module);

View File

@@ -1,7 +1,6 @@
/* Clearlooks theme engine
/* Clearlooks Engine
* Copyright (C) 2005 Richard Stellingwerff.
* Copyright (C) 2007 Benjamin Berg
* Copyright (C) 2007 Andrea Cimitan
* Copyright (C) 2006 Benjamin Berg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,7 +21,6 @@
* and by Alexander Larsson <alexl@redhat.com>
* Modified by Richard Stellingwerff <remenic@gmail.com>
*/
#include <gtk/gtkstyle.h>
#ifndef CLEARLOOKS_STYLE_H
@@ -34,7 +32,9 @@
typedef struct _ClearlooksStyle ClearlooksStyle;
typedef struct _ClearlooksStyleClass ClearlooksStyleClass;
#define CLEARLOOKS_TYPE_STYLE (clearlooks_style_get_type ())
GE_INTERNAL extern GType clearlooks_type_style;
#define CLEARLOOKS_TYPE_STYLE clearlooks_type_style
#define CLEARLOOKS_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_STYLE, ClearlooksStyle))
#define CLEARLOOKS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
#define CLEARLOOKS_IS_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_STYLE))
@@ -48,12 +48,9 @@ struct _ClearlooksStyle
ClearlooksColors colors;
ClearlooksStyles style;
guint8 reliefstyle;
guint8 menubarstyle;
guint8 toolbarstyle;
GdkColor focus_color;
gboolean has_focus_color;
GdkColor scrollbar_color;
gboolean colorize_scrollbar;
gboolean has_scrollbar_color;
@@ -66,10 +63,8 @@ struct _ClearlooksStyleClass
GtkStyleClass parent_class;
ClearlooksStyleFunctions style_functions[CL_NUM_STYLES];
ClearlooksStyleConstants style_constants[CL_NUM_STYLES];
};
GE_INTERNAL void clearlooks_style_register_types (GTypeModule *module);
GE_INTERNAL GType clearlooks_style_get_type (void);
GE_INTERNAL void clearlooks_style_register_type (GTypeModule *module);
#endif /* CLEARLOOKS_STYLE_H */

View File

@@ -7,8 +7,8 @@
GE_EXPORT void
theme_init (GTypeModule *module)
{
clearlooks_rc_style_register_types (module);
clearlooks_style_register_types (module);
clearlooks_rc_style_register_type (module);
clearlooks_style_register_type (module);
}
GE_EXPORT void

View File

@@ -0,0 +1,455 @@
#ifndef CLEARLOOKS_TYPES_H
#define CLEARLOOKS_TYPES_H
#include <ge-support.h>
typedef unsigned char boolean;
typedef unsigned char uint8;
typedef struct _ClearlooksStyleFunctions ClearlooksStyleFunctions;
typedef enum
{
CL_STYLE_CLASSIC = 0,
CL_STYLE_GLOSSY = 1,
CL_STYLE_INVERTED = 2,
CL_STYLE_GUMMY = 3,
CL_NUM_STYLES = 4
} ClearlooksStyles;
typedef enum
{
CL_STATE_NORMAL,
CL_STATE_ACTIVE,
CL_STATE_SELECTED,
CL_STATE_INSENSITIVE
} ClearlooksStateType;
typedef enum
{
CL_JUNCTION_NONE = 0,
CL_JUNCTION_BEGIN = 1,
CL_JUNCTION_END = 2
} ClearlooksJunction;
typedef enum
{
CL_STEPPER_UNKNOWN = 0,
CL_STEPPER_A = 1,
CL_STEPPER_B = 2,
CL_STEPPER_C = 4,
CL_STEPPER_D = 8
} ClearlooksStepper;
typedef enum
{
CL_ORDER_FIRST,
CL_ORDER_MIDDLE,
CL_ORDER_LAST
} ClearlooksOrder;
typedef enum
{
CL_ORIENTATION_LEFT_TO_RIGHT,
CL_ORIENTATION_RIGHT_TO_LEFT,
CL_ORIENTATION_BOTTOM_TO_TOP,
CL_ORIENTATION_TOP_TO_BOTTOM
} ClearlooksOrientation;
typedef enum
{
CL_GAP_LEFT,
CL_GAP_RIGHT,
CL_GAP_TOP,
CL_GAP_BOTTOM
} ClearlooksGapSide;
typedef enum
{
CL_SHADOW_NONE,
CL_SHADOW_IN,
CL_SHADOW_OUT,
CL_SHADOW_ETCHED_IN,
CL_SHADOW_ETCHED_OUT
} ClearlooksShadowType;
typedef enum
{
CL_HANDLE_TOOLBAR,
CL_HANDLE_SPLITTER
} ClearlooksHandleType;
typedef enum
{
CL_ARROW_NORMAL,
CL_ARROW_COMBO
} ClearlooksArrowType;
typedef enum
{
CL_DIRECTION_UP,
CL_DIRECTION_DOWN,
CL_DIRECTION_LEFT,
CL_DIRECTION_RIGHT
} ClearlooksDirection;
typedef enum
{
CL_PROGRESSBAR_CONTINUOUS,
CL_PROGRESSBAR_DISCRETE
} ClearlooksProgressBarStyle;
typedef enum
{
CL_WINDOW_EDGE_NORTH_WEST,
CL_WINDOW_EDGE_NORTH,
CL_WINDOW_EDGE_NORTH_EAST,
CL_WINDOW_EDGE_WEST,
CL_WINDOW_EDGE_EAST,
CL_WINDOW_EDGE_SOUTH_WEST,
CL_WINDOW_EDGE_SOUTH,
CL_WINDOW_EDGE_SOUTH_EAST
} ClearlooksWindowEdge;
typedef struct
{
double x;
double y;
double width;
double height;
} ClearlooksRectangle;
typedef struct
{
CairoColor fg[5];
CairoColor bg[5];
CairoColor base[5];
CairoColor text[5];
CairoColor shade[9];
CairoColor spot[3];
} ClearlooksColors;
typedef struct
{
boolean active;
boolean prelight;
boolean disabled;
boolean focus;
boolean is_default;
boolean ltr;
boolean enable_glow;
gfloat radius;
ClearlooksStateType state_type;
uint8 corners;
uint8 xthickness;
uint8 ythickness;
CairoColor parentbg;
ClearlooksStyleFunctions *style_functions;
} WidgetParameters;
typedef struct
{
boolean lower;
boolean horizontal;
boolean fill_level;
} SliderParameters;
typedef struct
{
ClearlooksOrientation orientation;
boolean pulsing;
float value;
} ProgressBarParameters;
typedef struct
{
int linepos;
} OptionMenuParameters;
typedef struct
{
ClearlooksShadowType shadow;
ClearlooksGapSide gap_side;
int gap_x;
int gap_width;
const CairoColor *border; /* maybe changes this to some other hint ... */
} FrameParameters;
typedef struct
{
ClearlooksGapSide gap_side;
} TabParameters;
typedef struct
{
CairoCorners corners;
ClearlooksShadowType shadow;
} ShadowParameters;
typedef struct
{
boolean horizontal;
} SeparatorParameters;
typedef struct
{
ClearlooksOrder order; /* XXX: rename to position */
boolean resizable;
} ListViewHeaderParameters;
typedef struct
{
CairoColor color;
ClearlooksJunction junction; /* On which sides the slider junctions */
boolean horizontal;
boolean has_color;
} ScrollBarParameters;
typedef struct
{
ClearlooksHandleType type;
boolean horizontal;
} HandleParameters;
typedef struct
{
ClearlooksStepper stepper; /* Which stepper to draw */
} ScrollBarStepperParameters;
typedef struct
{
ClearlooksWindowEdge edge;
} ResizeGripParameters;
typedef struct
{
int style;
} MenuBarParameters;
typedef struct
{
ClearlooksShadowType shadow_type;
boolean in_cell;
boolean in_menu;
} CheckboxParameters;
typedef struct
{
ClearlooksArrowType type;
ClearlooksDirection direction;
} ArrowParameters;
typedef struct
{
int style;
boolean topmost;
} ToolbarParameters;
struct _ClearlooksStyleFunctions
{
void (*draw_button) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_scale_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SliderParameters *slider,
int x, int y, int width, int height);
void (*draw_progressbar_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_progressbar_fill) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ProgressBarParameters *progressbar,
int x, int y, int width, int height, gint offset);
void (*draw_slider_button) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SliderParameters *slider,
int x, int y, int width, int height);
void (*draw_entry) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_spinbutton) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_spinbutton_down) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_optionmenu) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const OptionMenuParameters *optionmenu,
int x, int y, int width, int height);
void (*draw_inset) (cairo_t *cr,
const CairoColor *bg_color,
double x, double y, double w, double h,
double radius, uint8 corners);
void (*draw_menubar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const MenuBarParameters *menubar,
int x, int y, int width, int height);
void (*draw_tab) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const TabParameters *tab,
int x, int y, int width, int height);
void (*draw_frame) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const FrameParameters *frame,
int x, int y, int width, int height);
void (*draw_separator) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SeparatorParameters *separator,
int x, int y, int width, int height);
void (*draw_menu_item_separator) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SeparatorParameters *separator,
int x, int y, int width, int height);
void (*draw_list_view_header) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ListViewHeaderParameters *header,
int x, int y, int width, int height);
void (*draw_toolbar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ToolbarParameters *toolbar,
int x, int y, int width, int height);
void (*draw_menuitem) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_menubaritem) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_selected_cell) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_scrollbar_stepper) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
const ScrollBarStepperParameters *stepper,
int x, int y, int width, int height);
void (*draw_scrollbar_slider) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height);
void (*draw_scrollbar_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height);
void (*draw_statusbar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_menu_frame) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_tooltip) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_handle) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const HandleParameters *handle,
int x, int y, int width, int height);
void (*draw_resize_grip) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ResizeGripParameters *grip,
int x, int y, int width, int height);
void (*draw_arrow) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ArrowParameters *arrow,
int x, int y, int width, int height);
void (*draw_checkbox) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const CheckboxParameters *checkbox,
int x, int y, int width, int height);
void (*draw_radiobutton) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const CheckboxParameters *checkbox,
int x, int y, int width, int height);
/* Style internal functions */
/* XXX: Only used by slider_button, inline it? */
void (*draw_shadow) (cairo_t *cr,
const ClearlooksColors *colors,
gfloat radius,
int width, int height);
void (*draw_slider) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_gripdots) (cairo_t *cr,
const ClearlooksColors *colors, int x, int y,
int width, int height, int xr, int yr,
float contrast);
};
#define CLEARLOOKS_RECTANGLE_SET(rect, _x, _y, _w, _h) rect.x = _x; \
rect.y = _y; \
rect.width = _w; \
rect.height = _h;
#endif /* CLEARLOOKS_TYPES_H */

View File

@@ -1,13 +1,9 @@
/* engines/support/config.h. Generated from config.h.in by configure. */
/* engines/support/config.h.in. Generated from configure.ac by autoheader. */
/* engines/clearlooks/src/config.h. Generated from config.h.in by configure. */
/* engines/clearlooks/src/config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Defines whether to enable runtime widget checks as a fallback to hints from
the theme. */
#define ENABLE_WIDGET_CHECKS 1
/* Gettext package */
#define GETTEXT_PACKAGE "gtk-engines"
@@ -59,9 +55,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Name of package */
#define PACKAGE "gtk-engines"
@@ -72,16 +65,16 @@
#define PACKAGE_NAME "gtk-engines"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "gtk-engines 2.16.0"
#define PACKAGE_STRING "gtk-engines 2.12.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "gtk-engines"
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.16.0"
#define PACKAGE_VERSION "2.12.2"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "2.16.0"
#define VERSION "2.12.2"

View File

@@ -5,4 +5,5 @@
#include "cairo-support.h"
#include "widget-information.h"
#endif /* GE_SUPPORT_H */

View File

@@ -1,5 +1,3 @@
#ifndef __GENERAL_SUPPORT_H
#define __GENERAL_SUPPORT_H
#include <gmodule.h>
#include <glib.h>
@@ -39,5 +37,3 @@
# define GE_EXPORT __global
# define GE_INTERNAL __hidden
#endif
#endif /* __GENERAL_SUPPORT_H */

View File

@@ -66,34 +66,14 @@ clearlooks_get_parent_bg (const GtkWidget *widget, CairoColor *color)
GtkStateType state_type;
const GtkWidget *parent;
GdkColor *gcolor;
gboolean stop;
if (widget == NULL)
return;
parent = widget->parent;
stop = FALSE;
while (parent && !stop)
{
stop = FALSE;
stop |= !GTK_WIDGET_NO_WINDOW (parent);
stop |= GTK_IS_NOTEBOOK (parent) &&
gtk_notebook_get_show_tabs (GTK_NOTEBOOK (parent)) &&
gtk_notebook_get_show_border (GTK_NOTEBOOK (parent));
if (GTK_IS_TOOLBAR (parent))
{
GtkShadowType shadow = GTK_SHADOW_OUT;
gtk_widget_style_get (GTK_WIDGET (parent), "shadow-type", &shadow, NULL);
stop |= (shadow != GTK_SHADOW_NONE);
}
if (!stop)
parent = parent->parent;
}
while (parent && GTK_WIDGET_NO_WINDOW (parent) && !((GTK_IS_NOTEBOOK (parent)) || (GTK_IS_TOOLBAR (parent))))
parent = parent->parent;
if (parent == NULL)
return;
@@ -171,10 +151,8 @@ clearlooks_scrollbar_visible_steppers (GtkWidget *widget)
{
ClearlooksStepper steppers = 0;
/* If this is not a range widget, assume that the primary steppers
* are present. */
if (!GE_IS_RANGE (widget))
return CL_STEPPER_A | CL_STEPPER_D;
return 0;
if (GTK_RANGE (widget)->has_stepper_a)
steppers |= CL_STEPPER_A;
@@ -205,29 +183,20 @@ clearlooks_scrollbar_get_junction (GtkWidget *widget)
if (adj->value <= adj->lower &&
(GTK_RANGE (widget)->has_stepper_a || GTK_RANGE (widget)->has_stepper_b))
{
if (!gtk_range_get_inverted (GTK_RANGE (widget)))
junction |= CL_JUNCTION_BEGIN;
else
junction |= CL_JUNCTION_END;
junction |= CL_JUNCTION_BEGIN;
}
if (adj->value >= adj->upper - adj->page_size &&
(GTK_RANGE (widget)->has_stepper_c || GTK_RANGE (widget)->has_stepper_d))
{
if (!gtk_range_get_inverted (GTK_RANGE (widget)))
junction |= CL_JUNCTION_END;
else
junction |= CL_JUNCTION_BEGIN;
junction |= CL_JUNCTION_END;
}
return junction;
}
void
clearlooks_set_toolbar_parameters (ToolbarParameters *toolbar,
GtkWidget *widget,
GdkWindow *window,
gint x, gint y)
clearlooks_set_toolbar_parameters (ToolbarParameters *toolbar, GtkWidget *widget, GdkWindow *window, gint x, gint y)
{
toolbar->topmost = FALSE;

View File

@@ -0,0 +1,110 @@
#include <gtk/gtk.h>
#include <math.h>
#include <string.h>
/* GTK 2.2 compatibility */
#ifndef GTK_IS_COMBO_BOX_ENTRY
#define GTK_IS_COMBO_BOX_ENTRY(x) 0
#endif
#ifndef GTK_IS_COMBO_BOX
#define GTK_IS_COMBO_BOX(x) 0
#endif
#define RADIO_SIZE 13
#define CHECK_SIZE 13
GtkTextDirection
get_direction (GtkWidget *widget);
GdkPixbuf *
generate_bit (unsigned char alpha[],
GdkColor *color,
double mult);
GdkPixbuf *
colorize_bit (unsigned char *bit,
unsigned char *alpha,
GdkColor *new_color);
GdkPixmap *
pixbuf_to_pixmap (GtkStyle *style,
GdkPixbuf *pixbuf,
GdkScreen *screen);
gboolean
sanitize_size (GdkWindow *window,
gint *width,
gint *height);
void
rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b);
void
hls_to_rgb (gdouble *h,
gdouble *l,
gdouble *s);
void
shade (GdkColor * a, GdkColor * b, float k);
void
draw_hgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *top_color, GdkColor *bottom_color);
void
draw_vgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *left_color, GdkColor *right_color);
void
arrow_draw_hline (GdkWindow *window,
GdkGC *gc,
int x1,
int x2,
int y,
gboolean last);
void
arrow_draw_vline (GdkWindow *window,
GdkGC *gc,
int y1,
int y2,
int x,
gboolean last);
void
draw_arrow (GdkWindow *window,
GdkGC *gc,
GdkRectangle *area,
GtkArrowType arrow_type,
gint x,
gint y,
gint width,
gint height);
void
calculate_arrow_geometry (GtkArrowType arrow_type,
gint *x,
gint *y,
gint *width,
gint *height);
GtkWidget *special_get_ancestor(GtkWidget * widget,
GType widget_type);
void blend (GdkColormap *colormap,
GdkColor *a, GdkColor *b, GdkColor *c, int alpha);
GtkWidget *get_parent_window (GtkWidget *widget);
GdkColor *get_parent_bgcolor (GtkWidget *widget);
gboolean is_combo_box (GtkWidget * widget);
GtkWidget *find_combo_box_widget (GtkWidget * widget);
void gtk_clist_get_header_index (GtkCList *clist, GtkWidget *button,
gint *column_index, gint *columns);

View File

@@ -2,169 +2,9 @@
#include "general-support.h"
#include "widget-information.h"
#include "config.h"
#include <math.h>
#include <string.h>
static gchar ge_widget_hints[] =
"treeview\0"
"treeview-header\0"
"statusbar\0"
"comboboxentry\0"
"spinbutton\0"
"scale\0"
"vscale\0"
"hscale\0"
"scrollbar\0"
"vscrollbar\0"
"hscrollbar\0"
"progressbar\0"
"menubar\0";
gboolean
ge_check_hint (GEHint hint,
GQuark style_hint,
GtkWidget *widget)
{
static GEHint quark_hint_lookup[GE_HINT_COUNT] = {0};
g_assert ((hint >= 0) && (hint < GE_HINT_COUNT));
/* Initilize lookup table */
if (G_UNLIKELY (quark_hint_lookup[0] == 0))
{
guint i = 0;
gchar *cur_hint_str = ge_widget_hints;
while ((i < GE_HINT_COUNT) && cur_hint_str[0])
{
/* Can't use _from_static_string as the engine may be unloaded. */
quark_hint_lookup[i] = g_quark_from_string (cur_hint_str);
cur_hint_str += strlen(cur_hint_str) + 1;
i++;
}
g_assert (i == GE_HINT_COUNT && cur_hint_str[0] == '\0');
}
if (quark_hint_lookup[hint] == style_hint)
return TRUE;
/* Try to decide based on other hints, eg. hscale is also a scale. */
if (hint == GE_HINT_SCALE)
if (ge_check_hint (GE_HINT_VSCALE, style_hint, widget) ||
ge_check_hint (GE_HINT_HSCALE, style_hint, widget))
return TRUE;
if (hint == GE_HINT_SCROLLBAR)
if (ge_check_hint (GE_HINT_VSCROLLBAR, style_hint, widget) ||
ge_check_hint (GE_HINT_HSCROLLBAR, style_hint, widget))
return TRUE;
if (hint == GE_HINT_TREEVIEW)
if (ge_check_hint (GE_HINT_TREEVIEW_HEADER, style_hint, widget))
return TRUE;
/* These may be caused by applications so we never want to disable them.
* TODO: This does not catch the case where the theme uses appears-as-list
* and the application turns it off again. Though this case
* is even less likely. */
switch (hint) {
case GE_HINT_COMBOBOX_ENTRY:
if (widget && ge_object_is_a (G_OBJECT (widget), "GtkComboBox"))
{
gboolean appears_as_list = FALSE;
gtk_widget_style_get (widget, "appears-as-list", &appears_as_list, NULL);
if (appears_as_list)
return TRUE;
}
break;
default:
break;
}
#ifdef ENABLE_WIDGET_CHECKS
/* If a style_hint *was* set, and nothing matched, just give up right away.
* A theme shall either support it fully, or not at all. */
if (style_hint != 0)
return FALSE;
/* No widget? Just give up. Nothing we can do. */
if (widget == NULL)
return FALSE;
/* Try to do something based on the passed in widget pointer. */
switch (hint) {
case GE_HINT_TREEVIEW:
if (widget->parent && (ge_object_is_a (G_OBJECT (widget->parent), "GtkTreeView")))
return TRUE;
break;
case GE_HINT_TREEVIEW_HEADER:
if (ge_object_is_a (G_OBJECT (widget), "GtkButton") && widget->parent &&
(ge_object_is_a (G_OBJECT (widget->parent), "GtkTreeView") || ge_object_is_a (G_OBJECT (widget->parent), "GtkCList") ||
ge_object_is_a (G_OBJECT (widget->parent), "GtkCTree")))
return TRUE;
if (widget->parent && ge_object_is_a (G_OBJECT (widget->parent), "ETreeView"))
return TRUE;
break;
case GE_HINT_COMBOBOX_ENTRY:
if (ge_is_in_combo_box (widget))
return TRUE;
break;
case GE_HINT_SPINBUTTON:
if (ge_object_is_a (G_OBJECT (widget), "GtkSpinButton"))
return TRUE;
break;
case GE_HINT_STATUSBAR:
if (widget->parent && ge_object_is_a (G_OBJECT (widget), "GtkStatusbar"))
return TRUE;
break;
case GE_HINT_SCALE:
if (ge_object_is_a (G_OBJECT (widget), "GtkScale"))
return TRUE;
break;
case GE_HINT_HSCALE:
if (ge_object_is_a (G_OBJECT (widget), "GtkHScale"))
return TRUE;
break;
case GE_HINT_VSCALE:
if (ge_object_is_a (G_OBJECT (widget), "GtkVScale"))
return TRUE;
break;
case GE_HINT_SCROLLBAR:
if (ge_object_is_a (G_OBJECT (widget), "GtkScrollbar"))
return TRUE;
break;
case GE_HINT_HSCROLLBAR:
if (ge_object_is_a (G_OBJECT (widget), "GtkHScrollbar"))
return TRUE;
break;
case GE_HINT_VSCROLLBAR:
if (ge_object_is_a (G_OBJECT (widget), "GtkVScrollbar"))
return TRUE;
break;
case GE_HINT_PROGRESSBAR:
if (ge_object_is_a (G_OBJECT (widget), "GtkProgressBar"))
return TRUE;
break;
case GE_HINT_MENUBAR:
if (ge_object_is_a (G_OBJECT (widget), "GtkMenuBar") ||
ge_object_is_a (G_OBJECT (widget->parent), "GtkMenuBar"))
return TRUE;
break;
default:
break;
}
#endif
return FALSE;
}
/* Widget Type Lookups/Macros
Based on/modified from functions in
@@ -200,14 +40,21 @@ ge_is_combo_box_entry (GtkWidget * widget)
}
return result;
}
static gboolean
ge_combo_box_is_using_list (GtkWidget * widget)
{
gboolean result = FALSE;
if (GE_IS_COMBO_BOX (widget))
gtk_widget_style_get (widget, "appears-as-list", &result, NULL);
{
gboolean *tmp = NULL;
gtk_widget_style_get (widget, "appears-as-list", &result, NULL);
if (tmp)
result = *tmp;
}
return result;
}
@@ -395,8 +242,8 @@ ge_find_combo_box_widget_parent (GtkWidget * widget)
***********************************************/
void
ge_option_menu_get_props (GtkWidget * widget,
GtkRequisition * indicator_size,
GtkBorder * indicator_spacing)
GtkRequisition * indicator_size,
GtkBorder * indicator_spacing)
{
GtkRequisition default_size = { 9, 5 };
GtkBorder default_spacing = { 7, 5, 2, 2 };
@@ -446,6 +293,7 @@ ge_button_get_default_border (GtkWidget *widget,
}
}
gboolean
ge_widget_is_ltr (GtkWidget *widget)
{
@@ -462,26 +310,3 @@ ge_widget_is_ltr (GtkWidget *widget)
else
return TRUE;
}
guint
ge_rc_parse_hint (GScanner *scanner,
GQuark *quark)
{
guint token;
/* Skip 'hint' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
*quark = g_quark_from_string (scanner->value.v_string);
return G_TOKEN_NONE;
}

View File

@@ -1,45 +1,18 @@
#ifndef WIDGET_INFORMATION_H
#define WIDGET_INFORMATION_H
#include "general-support.h"
#include <glib.h>
#include <gtk/gtkwidget.h>
typedef enum {
GE_HINT_TREEVIEW,
GE_HINT_TREEVIEW_HEADER,
GE_HINT_STATUSBAR,
GE_HINT_COMBOBOX_ENTRY,
GE_HINT_SPINBUTTON,
GE_HINT_SCALE,
GE_HINT_VSCALE,
GE_HINT_HSCALE,
GE_HINT_SCROLLBAR,
GE_HINT_VSCROLLBAR,
GE_HINT_HSCROLLBAR,
GE_HINT_PROGRESSBAR,
GE_HINT_MENUBAR,
GE_HINT_COUNT
} GEHint;
/* ALL OF THE FOLLOWING SHOULD DIE ...
* instead the hint system will be used, and a huge switch ;-) */
/* Object Type Lookups/Macros
Based on/modified from functions in
Smooth-Engine.
*/
#define GE_IS_WIDGET(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkWidget"))
#define GE_IS_CONTAINER(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkContainer"))
#define GE_IS_BIN(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkBin"))
#define GE_IS_WIDGET(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkWidget"))
#define GE_IS_CONTAINER(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkContainer"))
#define GE_IS_BIN(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkBin"))
#define GE_IS_ARROW(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkArrow"))
#define GE_IS_ARROW(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkArrow"))
#define GE_IS_SEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkSeparator"))
#define GE_IS_VSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVSeparator"))
#define GE_IS_HSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHSeparator"))
#define GE_IS_SEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkSeparator"))
#define GE_IS_VSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkVSeparator"))
#define GE_IS_HSEPARATOR(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHSeparator"))
#define GE_IS_HANDLE_BOX(object) ((object) && ge_object_is_a ((GObject*)(object), "GtkHandleBox"))
#define GE_IS_HANDLE_BOX_ITEM(object) ((object) && GE_IS_HANDLE_BOX(object->parent))
@@ -100,9 +73,6 @@ typedef enum {
#define GE_WIDGET_HAS_DEFAULT(object) ((object) && GE_IS_WIDGET(object) && GTK_WIDGET_HAS_DEFAULT(object))
GE_INTERNAL gboolean ge_check_hint (GEHint hint, GQuark style_hint, GtkWidget *widget);
GE_INTERNAL gboolean ge_object_is_a (const GObject * object, const gchar * type_name);
GE_INTERNAL gboolean ge_is_combo_box_entry (GtkWidget * widget);
@@ -127,6 +97,3 @@ GE_INTERNAL void ge_button_get_default_border (GtkWidget *widget,
GE_INTERNAL gboolean ge_widget_is_ltr (GtkWidget *widget);
GE_INTERNAL guint ge_rc_parse_hint (GScanner *scanner, GQuark *quark);
#endif /* WIDGET_INFORMATION_H */

View File

@@ -0,0 +1,36 @@
# -*- python -*-
import os.path
import glob
libclearlooks_files = [
'clearlooks_draw.c',
'clearlooks_rc_style.c',
'clearlooks_style.c',
'clearlooks_theme_main.c',
'support.c' ]
Import ('env install_prefix')
clearlooks = env.Clone()
clearlooks.Replace(CCFLAGS = ' `pkg-config --cflags gtk+-2.0` ',
LINKFLAGS = ' `pkg-config --libs gtk+-2.0` ')
if env['GTKOSX']:
clearlooks.Append (CCFLAGS = '-DGTKOSX')
libclearlooks = clearlooks.SharedLibrary('clearlooks', libclearlooks_files)
usable_libclearlooks = clearlooks.Install ('engines', libclearlooks)
Default (usable_libclearlooks)
env.Alias('install',
env.Install(os.path.join(install_prefix,env['LIBDIR'], 'ardour2', 'engines'),
libclearlooks))
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript', 'bits.c'] +
libclearlooks_files +
glob.glob('*.h')
))

View File

@@ -0,0 +1,121 @@
static unsigned char dot_intensity[] = {
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x98,0xb9,0xc6,0xb9,0x91,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xb9,0xbd,0xac,0x9e,0x65,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xc6,0xac,0x9e,0x96,0x5c,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0xb9,0x9e,0x96,0x62,0x55,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x91,0x65,0x5c,0x55,0x68,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,0x6e,
};
static unsigned char dot_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x66,0xc4,0xff,0xc4,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0xdf,0xff,0xff,0xff,0xdf,0x66,0x00,0x00,0x00,
0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0xff,0xff,0xc4,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0xff,0xff,0xc4,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0xdf,0xff,0xff,0xff,0xdf,0x66,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x66,0xc4,0xff,0xc4,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char circle_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x23,0x62,0x92,0xb3,0xb2,0x95,0x2b,0x00,0x00,0x00,
0x00,0x00,0x3e,0xab,0xc9,0xeb,0xf9,0xf5,0xfd,0xff,0x57,0x00,0x00,
0x00,0x1f,0xb5,0xd8,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x2b,0x00,
0x00,0x67,0xb9,0xf2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x00,
0x00,0x9a,0xe2,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0x00,
0x00,0xba,0xeb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xc0,0xfa,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0x00,
0x00,0x9b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x00,
0x00,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2b,0x00,
0x00,0x00,0x57,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x57,0x00,0x00,
0x00,0x00,0x00,0x2b,0x9c,0xe5,0xff,0xe5,0x9c,0x2b,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char outline_alpha[] = {
0x00,0x00,0x00,0x4a,0xac,0xe9,0xff,0xe9,0xac,0x4a,0x00,0x00,0x00,
0x00,0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,0x00,
0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,
0x4a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4a,
0xac,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xac,
0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe9,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe9,
0xac,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xac,
0x4a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4a,
0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,
0x00,0x00,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x00,0x00,
0x00,0x00,0x00,0x4a,0xac,0xe9,0xff,0xe9,0xac,0x4a,0x00,0x00,0x00,
};
static unsigned char inconsistent_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_base_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, 137, 151,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, 183, 172, 7,0x00,0x00,
0x00,0x00, 12, 18,0x00,0x00, 3, 161, 233, 27,0x00,0x00,0x00,
0x00,0x00, 199, 239, 101,0x00, 85, 253, 108,0x00,0x00,0x00,0x00,
0x00,0x00, 83, 245, 250, 75, 206, 230, 8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, 104, 252, 243, 253, 124,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00, 2, 162, 255, 241, 28,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 18, 228, 163,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00, 78, 62,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static unsigned char check_inconsistent_alpha[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,159 @@
#ifndef CLEARLOOKS_DRAW_H
#define CLEARLOOKS_DRAW_H
#include <gtk/gtk.h>
#include <gdk/gdk.h>
typedef struct
{
GdkColor *from;
GdkColor *to;
} CLGradient;
typedef enum
{
CL_GRADIENT_NONE,
CL_GRADIENT_HORIZONTAL,
CL_GRADIENT_VERTICAL
} CLGradientType;
typedef struct
{
CLGradient fill_gradient;
CLGradient border_gradient;
CLGradientType gradient_type;
GdkGC *bordergc;
GdkGC *fillgc;
guint8 corners[4];
GdkGC *topleft; /* top + left shadow */
GdkGC *bottomright; /* bottom + right shadow */
GdkColor tmp_color; /* used for gradient */
} CLRectangle;
typedef enum /* DON'T CHANGE THE ORDER! */
{
CL_CORNER_TOPRIGHT,
CL_CORNER_BOTTOMRIGHT,
CL_CORNER_BOTTOMLEFT,
CL_CORNER_TOPLEFT
} CLCornerSide;
typedef enum /* DON'T CHANGE THE ORDER! */
{
CL_BORDER_TOP,
CL_BORDER_RIGHT,
CL_BORDER_BOTTOM,
CL_BORDER_LEFT
} CLBorderType;
typedef enum
{
CL_CORNER_NONE = 0,
CL_CORNER_NARROW = 1,
CL_CORNER_ROUND = 2
} CLCornerSharpness;
CLRectangle *cl_rectangle_new(GdkGC *fillgc, GdkGC *bordergc,
int tl, int tr, int bl, int br);
void cl_draw_rectangle (GdkWindow *window, GtkWidget *widget, GtkStyle *style,
int x, int y, int width, int height, CLRectangle *r);
void cl_rectangle_set_color (CLGradient *g, GdkColor *color);
void cl_rectangle_set_gradient (CLGradient *g, GdkColor *from, GdkColor *to);
void cl_rectangle_set_button (CLRectangle *r, GtkStyle *style,
GtkStateType state_type, gboolean hasdefault, gboolean has_focus,
CLBorderType tl, CLBorderType tr,
CLBorderType bl, CLBorderType br);
void cl_rectangle_set_entry (CLRectangle *r, GtkStyle *style,
GtkStateType state_type,
CLBorderType tl, CLBorderType tr,
CLBorderType bl, CLBorderType br,
gboolean has_focus);
void cl_draw_shadow(GdkWindow *window, GtkWidget *widget, GtkStyle *style,
int x, int y, int width, int height, CLRectangle *r);
void cl_rectangle_set_clip_rectangle (CLRectangle *r, GdkRectangle *area);
void cl_rectangle_reset_clip_rectangle (CLRectangle *r);
void cl_set_corner_sharpness (const gchar *detail, GtkWidget *widget, CLRectangle *r);
void cl_rectangle_set_corners (CLRectangle *r, int tl, int tr, int bl, int br);
void cl_rectangle_init (CLRectangle *r, GdkGC *fillgc, GdkGC *bordergc,
int tl, int tr, int bl, int br);
void cl_rectangle_reset (CLRectangle *r, GtkStyle *style);
GdkPixmap* cl_progressbar_tile_new (GdkDrawable *drawable, GtkWidget *widget,
GtkStyle *style, gint height, gint offset);
void cl_progressbar_fill (GdkDrawable *drawable, GtkWidget *widget,
GtkStyle *style, GdkGC *gc,
gint x, gint y, gint width, gint height,
guint8 offset, GdkRectangle *area);
GdkColor cl_gc_set_fg_color_shade (GdkGC *gc, GdkColormap *colormap,
GdkColor *from, gfloat s);
void cl_draw_spinbutton(GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
void cl_draw_button(GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
void cl_draw_entry (GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
void cl_draw_combobox_entry (GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
void cl_draw_combobox_button (GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
void cl_draw_menuitem_button (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
GdkRectangle *area, GtkStateType state_type,
int x, int y, int wiidth, int height, CLRectangle *r);
void cl_draw_menuitem_flat (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
GdkRectangle *area, GtkStateType state_type,
int x, int y, int wiidth, int height, CLRectangle *r);
void cl_draw_menuitem_gradient (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
GdkRectangle *area, GtkStateType state_type,
int x, int y, int wiidth, int height, CLRectangle *r);
void cl_draw_treeview_header (GtkStyle *style, GdkWindow *window,
GtkStateType state_type, GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height);
#endif /* CLEARLOOKS_DRAW_H */

View File

@@ -0,0 +1,392 @@
/* Clearlooks theme engine
* Copyright (C) 2005 Richard Stellingwerff.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Written by Owen Taylor <otaylor@redhat.com>
* and by Alexander Larsson <alexl@redhat.com>
* Modified by Richard Stellingwerff <remenic@gmail.com>
*/
#include "clearlooks_style.h"
#include "clearlooks_rc_style.h"
static void clearlooks_rc_style_init (ClearlooksRcStyle *style);
static void clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass);
static GtkStyle *clearlooks_rc_style_create_style (GtkRcStyle *rc_style);
static guint clearlooks_rc_style_parse (GtkRcStyle *rc_style,
GtkSettings *settings,
GScanner *scanner);
static void clearlooks_rc_style_merge (GtkRcStyle *dest,
GtkRcStyle *src);
static GtkRcStyleClass *parent_class;
GType clearlooks_type_rc_style = 0;
enum
{
TOKEN_SPOTCOLOR = G_TOKEN_LAST + 1,
TOKEN_CONTRAST,
TOKEN_SUNKENMENU,
TOKEN_PROGRESSBARSTYLE,
TOKEN_MENUBARSTYLE,
TOKEN_MENUITEMSTYLE,
TOKEN_LISTVIEWITEMSTYLE
};
static struct
{
const gchar *name;
guint token;
}
theme_symbols[] =
{
{ "spotcolor", TOKEN_SPOTCOLOR },
{ "contrast", TOKEN_CONTRAST },
{ "sunkenmenubar", TOKEN_SUNKENMENU },
{ "progressbarstyle", TOKEN_PROGRESSBARSTYLE },
{ "menubarstyle", TOKEN_MENUBARSTYLE },
{ "menuitemstyle", TOKEN_MENUITEMSTYLE },
{ "listviewitemstyle", TOKEN_LISTVIEWITEMSTYLE }
};
void
clearlooks_rc_style_register_type (GTypeModule *module)
{
static const GTypeInfo object_info =
{
sizeof (ClearlooksRcStyleClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) clearlooks_rc_style_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (ClearlooksRcStyle),
0, /* n_preallocs */
(GInstanceInitFunc) clearlooks_rc_style_init,
NULL
};
clearlooks_type_rc_style = g_type_module_register_type (module,
GTK_TYPE_RC_STYLE,
"ClearlooksRcStyle",
&object_info, 0);
}
static void
clearlooks_rc_style_init (ClearlooksRcStyle *clearlooks_rc)
{
clearlooks_rc->has_spot_color = FALSE;
clearlooks_rc->contrast = 1.0;
clearlooks_rc->sunkenmenubar = 1;
clearlooks_rc->progressbarstyle = 0;
clearlooks_rc->menubarstyle = 0;
clearlooks_rc->menuitemstyle = 1;
clearlooks_rc->listviewitemstyle = 1;
}
static void
clearlooks_rc_style_class_init (ClearlooksRcStyleClass *klass)
{
GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
rc_style_class->parse = clearlooks_rc_style_parse;
rc_style_class->create_style = clearlooks_rc_style_create_style;
rc_style_class->merge = clearlooks_rc_style_merge;
}
static guint
theme_parse_color(GtkSettings *settings,
GScanner *scanner,
GdkColor *color)
{
guint token;
/* Skip 'blah_color' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
return gtk_rc_parse_color (scanner, color);
}
static guint
theme_parse_contrast(GtkSettings *settings,
GScanner *scanner,
double *contrast)
{
guint token;
/* Skip 'contrast' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_FLOAT)
return G_TOKEN_FLOAT;
*contrast = scanner->value.v_float;
return G_TOKEN_NONE;
}
static guint
theme_parse_sunkenmenubar(GtkSettings *settings,
GScanner *scanner,
guint8 *sunken)
{
guint token;
/* Skip 'sunkenmenubar' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_INT)
return G_TOKEN_INT;
*sunken = scanner->value.v_int;
return G_TOKEN_NONE;
}
static guint
theme_parse_progressbarstyle(GtkSettings *settings,
GScanner *scanner,
guint8 *progressbarstyle)
{
guint token;
/* Skip 'sunkenmenubar' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_INT)
return G_TOKEN_INT;
*progressbarstyle = scanner->value.v_int;
return G_TOKEN_NONE;
}
static guint
theme_parse_menubarstyle(GtkSettings *settings,
GScanner *scanner,
guint8 *menubarstyle)
{
guint token;
/* Skip 'menubarstyle' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_INT)
return G_TOKEN_INT;
*menubarstyle = scanner->value.v_int;
return G_TOKEN_NONE;
}
static guint
theme_parse_menuitemstyle(GtkSettings *settings,
GScanner *scanner,
guint8 *menuitemstyle)
{
guint token;
/* Skip 'sunkenmenubar' */
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_INT)
return G_TOKEN_INT;
*menuitemstyle = scanner->value.v_int;
return G_TOKEN_NONE;
}
static guint
theme_parse_listviewitemstyle(GtkSettings *settings,
GScanner *scanner,
guint8 *listviewitemstyle)
{
guint token;
token = g_scanner_get_next_token(scanner);
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_EQUAL_SIGN)
return G_TOKEN_EQUAL_SIGN;
token = g_scanner_get_next_token(scanner);
if (token != G_TOKEN_INT)
return G_TOKEN_INT;
*listviewitemstyle = scanner->value.v_int;
return G_TOKEN_NONE;
}
static guint
clearlooks_rc_style_parse (GtkRcStyle *rc_style,
GtkSettings *settings,
GScanner *scanner)
{
static GQuark scope_id = 0;
ClearlooksRcStyle *clearlooks_style = CLEARLOOKS_RC_STYLE (rc_style);
guint old_scope;
guint token;
guint i;
/* Set up a new scope in this scanner. */
if (!scope_id)
scope_id = g_quark_from_string("clearlooks_theme_engine");
/* If we bail out due to errors, we *don't* reset the scope, so the
* error messaging code can make sense of our tokens.
*/
old_scope = g_scanner_set_scope(scanner, scope_id);
/* Now check if we already added our symbols to this scope
* (in some previous call to clearlooks_rc_style_parse for the
* same scanner.
*/
if (!g_scanner_lookup_symbol(scanner, theme_symbols[0].name))
{
g_scanner_freeze_symbol_table(scanner);
for (i = 0; i < G_N_ELEMENTS (theme_symbols); i++)
g_scanner_scope_add_symbol(scanner, scope_id,
theme_symbols[i].name,
GINT_TO_POINTER(theme_symbols[i].token));
g_scanner_thaw_symbol_table(scanner);
}
/* We're ready to go, now parse the top level */
token = g_scanner_peek_next_token(scanner);
while (token != G_TOKEN_RIGHT_CURLY)
{
switch (token)
{
case TOKEN_SPOTCOLOR:
token = theme_parse_color(settings, scanner, &clearlooks_style->spot_color);
clearlooks_style->has_spot_color = TRUE;
break;
case TOKEN_CONTRAST:
token = theme_parse_contrast(settings, scanner, &clearlooks_style->contrast);
break;
case TOKEN_SUNKENMENU:
token = theme_parse_sunkenmenubar(settings, scanner, &clearlooks_style->sunkenmenubar);
break;
case TOKEN_PROGRESSBARSTYLE:
token = theme_parse_progressbarstyle(settings, scanner, &clearlooks_style->progressbarstyle);
break;
case TOKEN_MENUBARSTYLE:
token = theme_parse_menubarstyle(settings, scanner, &clearlooks_style->menubarstyle);
break;
case TOKEN_MENUITEMSTYLE:
token = theme_parse_menuitemstyle(settings, scanner, &clearlooks_style->menuitemstyle);
break;
case TOKEN_LISTVIEWITEMSTYLE:
token = theme_parse_listviewitemstyle(settings, scanner, &clearlooks_style->listviewitemstyle);
break;
default:
g_scanner_get_next_token(scanner);
token = G_TOKEN_RIGHT_CURLY;
break;
}
if (token != G_TOKEN_NONE)
return token;
token = g_scanner_peek_next_token(scanner);
}
g_scanner_get_next_token(scanner);
g_scanner_set_scope(scanner, old_scope);
return G_TOKEN_NONE;
}
static void
clearlooks_rc_style_merge (GtkRcStyle *dest,
GtkRcStyle *src)
{
ClearlooksRcStyle *dest_w, *src_w;
parent_class->merge (dest, src);
if (!CLEARLOOKS_IS_RC_STYLE (src))
return;
src_w = CLEARLOOKS_RC_STYLE (src);
dest_w = CLEARLOOKS_RC_STYLE (dest);
dest_w->contrast = src_w->contrast;
dest_w->sunkenmenubar = src_w->sunkenmenubar;
dest_w->progressbarstyle = src_w->progressbarstyle;
dest_w->menubarstyle = src_w->menubarstyle;
dest_w->menuitemstyle = src_w->menuitemstyle;
dest_w->listviewitemstyle = src_w->listviewitemstyle;
if (src_w->has_spot_color)
{
dest_w->has_spot_color = TRUE;
dest_w->spot_color = src_w->spot_color;
}
}
/* Create an empty style suitable to this RC style
*/
static GtkStyle *
clearlooks_rc_style_create_style (GtkRcStyle *rc_style)
{
return GTK_STYLE (g_object_new (CLEARLOOKS_TYPE_STYLE, NULL));
}

View File

@@ -0,0 +1,57 @@
/* Clearlooks Theme Engine
* Copyright (C) 2005 Richard Stellingwerff.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Written by Owen Taylor <otaylor@redhat.com>
* and by Alexander Larsson <alexl@redhat.com>
* Modified by Richard Stellingwerff <remenic@gmail.com>
*/
#include <gtk/gtkrc.h>
typedef struct _ClearlooksRcStyle ClearlooksRcStyle;
typedef struct _ClearlooksRcStyleClass ClearlooksRcStyleClass;
extern GType clearlooks_type_rc_style;
#define CLEARLOOKS_TYPE_RC_STYLE clearlooks_type_rc_style
#define CLEARLOOKS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyle))
#define CLEARLOOKS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
#define CLEARLOOKS_IS_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_RC_STYLE))
#define CLEARLOOKS_IS_RC_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_RC_STYLE))
#define CLEARLOOKS_RC_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_RC_STYLE, ClearlooksRcStyleClass))
struct _ClearlooksRcStyle
{
GtkRcStyle parent_instance;
GdkColor spot_color;
gboolean has_spot_color;
double contrast;
guint8 sunkenmenubar;
guint8 progressbarstyle;
guint8 menubarstyle;
guint8 menuitemstyle;
guint8 listviewitemstyle;
};
struct _ClearlooksRcStyleClass
{
GtkRcStyleClass parent_class;
};
void clearlooks_rc_style_register_type (GTypeModule *module);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
/* Clearlooks Engine
* Copyright (C) 2005 Richard Stellingwerff.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Written by Owen Taylor <otaylor@redhat.com>
* and by Alexander Larsson <alexl@redhat.com>
* Modified by Richard Stellingwerff <remenic@gmail.com>
*/
#include <gtk/gtkstyle.h>
#include "clearlooks_draw.h"
typedef struct _ClearlooksStyle ClearlooksStyle;
typedef struct _ClearlooksStyleClass ClearlooksStyleClass;
extern GType clearlooks_type_style;
#define CLEARLOOKS_TYPE_STYLE clearlooks_type_style
#define CLEARLOOKS_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CLEARLOOKS_TYPE_STYLE, ClearlooksStyle))
#define CLEARLOOKS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
#define CLEARLOOKS_IS_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CLEARLOOKS_TYPE_STYLE))
#define CLEARLOOKS_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLEARLOOKS_TYPE_STYLE))
#define CLEARLOOKS_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLEARLOOKS_TYPE_STYLE, ClearlooksStyleClass))
typedef enum
{
CL_BORDER_UPPER = 0,
CL_BORDER_LOWER,
CL_BORDER_UPPER_ACTIVE,
CL_BORDER_LOWER_ACTIVE,
CL_BORDER_COUNT
} ClBorderColorType;
typedef enum
{
CL_SCROLLBUTTON_BEGIN = 0,
CL_SCROLLBUTTON_END,
CL_SCROLLBUTTON_OTHER
} ClScrollButtonType;
struct _ClearlooksStyle
{
GtkStyle parent_instance;
GdkColor shade[9];
GdkColor spot_color;
GdkColor spot1;
GdkColor spot2;
GdkColor spot3;
GdkColor border[CL_BORDER_COUNT];
/* from light to dark */
GdkGC *shade_gc[9];
GdkGC *border_gc[CL_BORDER_COUNT];
GdkGC *spot1_gc;
GdkGC *spot2_gc;
GdkGC *spot3_gc;
GdkColor inset_light[5];
GdkColor inset_dark[5];
GdkColor button_g1[5];
GdkColor button_g2[5];
GdkColor button_g3[5];
GdkColor button_g4[5];
GdkColor listview_bg[5];
GdkPixmap *radio_pixmap_nonactive[5];
GdkPixmap *radio_pixmap_active[5];
GdkPixmap *radio_pixmap_inconsistent[5];
GdkBitmap *radio_pixmap_mask; /* All masks are the same */
GdkPixmap *check_pixmap_nonactive[5];
GdkPixmap *check_pixmap_active[5];
GdkPixmap *check_pixmap_inconsistent[5];
gboolean sunkenmenubar:1;
guint8 progressbarstyle;
guint8 menubarstyle;
guint8 menuitemstyle;
guint8 listviewitemstyle;
};
struct _ClearlooksStyleClass
{
GtkStyleClass parent_class;
};
void clearlooks_style_register_type (GTypeModule *module);

View File

@@ -0,0 +1,37 @@
#include <gmodule.h>
#include <gtk/gtk.h>
#include "clearlooks_style.h"
#include "clearlooks_rc_style.h"
G_MODULE_EXPORT void
theme_init (GTypeModule *module)
{
clearlooks_rc_style_register_type (module);
clearlooks_style_register_type (module);
printf("theme_init() called from internal clearlooks engine\n");
}
G_MODULE_EXPORT void
theme_exit (void)
{
}
G_MODULE_EXPORT GtkRcStyle *
theme_create_rc_style (void)
{
return GTK_RC_STYLE (g_object_new (CLEARLOOKS_TYPE_RC_STYLE, NULL));
}
/* The following function will be called by GTK+ when the module
* is loaded and checks to see if we are compatible with the
* version of GTK+ that loads us.
*/
G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module);
const gchar*
g_module_check_init (GModule *module)
{
return gtk_check_version (GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
}

2
libs/clearlooks-older/cpdll.sh Executable file
View File

@@ -0,0 +1,2 @@
mkdir engines
cp libclearlooks.so engines

View File

@@ -0,0 +1,981 @@
#include "support.h"
/* #define ALWAYS_DITHER_GRADIENTS */
GtkTextDirection
get_direction (GtkWidget *widget)
{
GtkTextDirection dir;
if (widget)
dir = gtk_widget_get_direction (widget);
else
dir = GTK_TEXT_DIR_LTR;
return dir;
}
GdkPixbuf *
generate_bit (unsigned char alpha[], GdkColor *color, double mult)
{
guint r, g, b;
GdkPixbuf *pixbuf;
unsigned char *pixels;
int w, h, rs;
int x, y;
r = (color->red >> 8) * mult;
r = MIN(r, 255);
g = (color->green >> 8) * mult;
g = MIN(g, 255);
b = (color->blue >> 8) * mult;
b = MIN(b, 255);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, RADIO_SIZE, RADIO_SIZE);
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
rs = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
for (y=0; y < h; y++)
{
for (x=0; x < w; x++)
{
pixels[y*rs + x*4 + 0] = r;
pixels[y*rs + x*4 + 1] = g;
pixels[y*rs + x*4 + 2] = b;
if (alpha)
pixels[y*rs + x*4 + 3] = alpha[y*w + x];
else
pixels[y*rs + x*4 + 3] = 255;
}
}
return pixbuf;
}
#define CLAMP_UCHAR(v) ((guchar) (CLAMP (((int)v), (int)0, (int)255)))
GdkPixbuf *
colorize_bit (unsigned char *bit,
unsigned char *alpha,
GdkColor *new_color)
{
GdkPixbuf *pixbuf;
double intensity;
int x, y;
const guchar *src, *asrc;
guchar *dest;
int dest_rowstride;
int width, height;
guchar *dest_pixels;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, RADIO_SIZE, RADIO_SIZE);
if (pixbuf == NULL)
return NULL;
dest_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
dest_pixels = gdk_pixbuf_get_pixels (pixbuf);
for (y = 0; y < RADIO_SIZE; y++)
{
src = bit + y * RADIO_SIZE;
asrc = alpha + y * RADIO_SIZE;
dest = dest_pixels + y * dest_rowstride;
for (x = 0; x < RADIO_SIZE; x++)
{
double dr, dg, db;
intensity = (src[x] + 0 )/ 255.0;
if (intensity <= 0.5)
{
/* Go from black at intensity = 0.0 to new_color at intensity = 0.5 */
dr = (new_color->red * intensity * 2.0) / 65535.0;
dg = (new_color->green * intensity * 2.0) / 65535.0;
db = (new_color->blue * intensity * 2.0) / 65535.0;
}
else
{
/* Go from new_color at intensity = 0.5 to white at intensity = 1.0 */
dr = (new_color->red + (65535 - new_color->red) * (intensity - 0.5) * 2.0) / 65535.0;
dg = (new_color->green + (65535 - new_color->green) * (intensity - 0.5) * 2.0) / 65535.0;
db = (new_color->blue + (65535 - new_color->blue) * (intensity - 0.5) * 2.0) / 65535.0;
}
dest[0] = CLAMP_UCHAR (255 * dr);
dest[1] = CLAMP_UCHAR (255 * dg);
dest[2] = CLAMP_UCHAR (255 * db);
dest[3] = asrc[x];
dest += 4;
}
}
return pixbuf;
}
GdkPixmap *
pixbuf_to_pixmap (GtkStyle *style,
GdkPixbuf *pixbuf,
GdkScreen *screen)
{
GdkGC *tmp_gc;
GdkPixmap *pixmap;
pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
style->depth);
gdk_drawable_set_colormap (pixmap, style->colormap);
tmp_gc = gdk_gc_new (pixmap);
gdk_pixbuf_render_to_drawable (pixbuf, pixmap, tmp_gc, 0, 0, 0, 0,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
GDK_RGB_DITHER_NORMAL, 0, 0);
gdk_gc_unref (tmp_gc);
return pixmap;
}
void
rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b)
{
gdouble min;
gdouble max;
gdouble red;
gdouble green;
gdouble blue;
gdouble h, l, s;
gdouble delta;
red = *r;
green = *g;
blue = *b;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
l = (max + min) / 2;
s = 0;
h = 0;
if (max != min)
{
if (l <= 0.5)
s = (max - min) / (max + min);
else
s = (max - min) / (2 - max - min);
delta = max -min;
if (red == max)
h = (green - blue) / delta;
else if (green == max)
h = 2 + (blue - red) / delta;
else if (blue == max)
h = 4 + (red - green) / delta;
h *= 60;
if (h < 0.0)
h += 360;
}
*r = h;
*g = l;
*b = s;
}
void
hls_to_rgb (gdouble *h,
gdouble *l,
gdouble *s)
{
gdouble hue;
gdouble lightness;
gdouble saturation;
gdouble m1, m2;
gdouble r, g, b;
lightness = *l;
saturation = *s;
if (lightness <= 0.5)
m2 = lightness * (1 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2 * lightness - m2;
if (saturation == 0)
{
*h = lightness;
*l = lightness;
*s = lightness;
}
else
{
hue = *h + 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
r = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
r = m2;
else if (hue < 240)
r = m1 + (m2 - m1) * (240 - hue) / 60;
else
r = m1;
hue = *h;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
g = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
g = m2;
else if (hue < 240)
g = m1 + (m2 - m1) * (240 - hue) / 60;
else
g = m1;
hue = *h - 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
b = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
b = m2;
else if (hue < 240)
b = m1 + (m2 - m1) * (240 - hue) / 60;
else
b = m1;
*h = r;
*l = g;
*s = b;
}
}
void
shade (GdkColor * a, GdkColor * b, float k)
{
gdouble red;
gdouble green;
gdouble blue;
red = (gdouble) a->red / 65535.0;
green = (gdouble) a->green / 65535.0;
blue = (gdouble) a->blue / 65535.0;
rgb_to_hls (&red, &green, &blue);
green *= k;
if (green > 1.0)
green = 1.0;
else if (green < 0.0)
green = 0.0;
blue *= k;
if (blue > 1.0)
blue = 1.0;
else if (blue < 0.0)
blue = 0.0;
hls_to_rgb (&red, &green, &blue);
b->red = red * 65535.0;
b->green = green * 65535.0;
b->blue = blue * 65535.0;
}
/**************************************************************************/
void
arrow_draw_hline (GdkWindow *window,
GdkGC *gc,
int x1,
int x2,
int y,
gboolean last)
{
if (x2 - x1 < 7 && !last) /* 7 to get garretts pixels, otherwise 6 */
{
gdk_draw_line (window, gc, x1, y, x2, y);
}
else if (last)
{
/* we don't draw "spikes" for very small arrows */
if (x2 - x1 <= 9)
{
/*gdk_draw_line (window, gc, x1+1, y, x1+1, y);
gdk_draw_line (window, gc, x2-1, y, x2-1, y);*/
}
else
{
gdk_draw_line (window, gc, x1+2, y, x1+2, y);
gdk_draw_line (window, gc, x2-2, y, x2-2, y);
}
}
else
{
gdk_draw_line (window, gc, x1, y, x1+2, y);
gdk_draw_line (window, gc, x2-2, y, x2, y);
}
}
void
arrow_draw_vline (GdkWindow *window,
GdkGC *gc,
int y1,
int y2,
int x,
gboolean last)
{
if (y2 - y1 < 7 && !last) /* 7 to get garretts pixels */
gdk_draw_line (window, gc, x, y1, x, y2);
else if (last)
{
/* we don't draw "spikes" for very small arrows */
if (y2 - y1 > 9) {
gdk_draw_line (window, gc, x, y1+2, x, y1+2);
gdk_draw_line (window, gc, x, y2-2, x, y2-2);
}
}
else
{
gdk_draw_line (window, gc, x, y1, x, y1+2);
gdk_draw_line (window, gc, x, y2-2, x, y2);
}
}
void
draw_arrow (GdkWindow *window,
GdkGC *gc,
GdkRectangle *area,
GtkArrowType arrow_type,
gint x,
gint y,
gint width,
gint height)
{
gint i, j;
if (area)
gdk_gc_set_clip_rectangle (gc, area);
if (arrow_type == GTK_ARROW_DOWN)
{
for (i = 0, j = -1; i < height; i++, j++)
arrow_draw_hline (window, gc, x + j, x + width - j - 1, y + i, i == 0);
}
else if (arrow_type == GTK_ARROW_UP)
{
for (i = height - 1, j = -1; i >= 0; i--, j++)
arrow_draw_hline (window, gc, x + j, x + width - j - 1, y + i, i == height - 1);
}
else if (arrow_type == GTK_ARROW_LEFT)
{
for (i = width - 1, j = -1; i >= 0; i--, j++)
arrow_draw_vline (window, gc, y + j, y + height - j - 1, x + i, i == width - 1);
}
else if (arrow_type == GTK_ARROW_RIGHT)
{
for (i = 0, j = -1; i < width; i++, j++)
arrow_draw_vline (window, gc, y + j, y + height - j - 1, x + i, i == 0);
}
if (area)
gdk_gc_set_clip_rectangle (gc, NULL);
}
void
calculate_arrow_geometry (GtkArrowType arrow_type,
gint *x,
gint *y,
gint *width,
gint *height)
{
gint w = *width;
gint h = *height;
switch (arrow_type)
{
case GTK_ARROW_UP:
case GTK_ARROW_DOWN:
w += (w % 2) - 1;
h = (w / 2 + 1) + 1;
if (h > *height)
{
h = *height;
w = 2 * (h - 1) - 1;
}
if (arrow_type == GTK_ARROW_DOWN)
{
if (*height % 2 == 1 || h % 2 == 0)
*height += 1;
}
else
{
if (*height % 2 == 0 || h % 2 == 0)
*height -= 1;
}
break;
case GTK_ARROW_RIGHT:
case GTK_ARROW_LEFT:
h += (h % 2) - 1;
w = (h / 2 + 1) + 1;
if (w > *width)
{
w = *width;
h = 2 * (w - 1) - 1;
}
if (arrow_type == GTK_ARROW_RIGHT)
{
if (*width % 2 == 1 || w % 2 == 0)
*width += 1;
}
else
{
if (*width % 2 == 0 || w % 2 == 0)
*width -= 1;
}
break;
default:
/* should not be reached */
break;
}
*x += (*width - w) / 2;
*y += (*height - h) / 2;
*height = h;
*width = w;
}
void gtk_treeview_get_header_index (GtkTreeView *tv, GtkWidget *header,
gint *column_index, gint *columns,
gboolean *resizable)
{
GList *list;
*column_index = *columns = 0;
list = gtk_tree_view_get_columns (tv);
do
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(list->data);
if ( column->button == header )
{
*column_index = *columns;
*resizable = column->resizable;
}
if ( column->visible )
(*columns)++;
} while ((list = g_list_next(list)));
}
void gtk_clist_get_header_index (GtkCList *clist, GtkWidget *button,
gint *column_index, gint *columns)
{
*columns = clist->columns;
int i;
for (i=0; i<*columns; i++)
{
if (clist->column[i].button == button)
{
*column_index = i;
break;
}
}
}
gboolean
sanitize_size (GdkWindow *window,
gint *width,
gint *height)
{
gboolean set_bg = FALSE;
if ((*width == -1) && (*height == -1))
{
set_bg = GDK_IS_WINDOW (window);
gdk_window_get_size (window, width, height);
}
else if (*width == -1)
gdk_window_get_size (window, width, NULL);
else if (*height == -1)
gdk_window_get_size (window, NULL, height);
return set_bg;
}
static GtkRequisition default_option_indicator_size = { 7, 13 };
static GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
void
option_menu_get_props (GtkWidget *widget,
GtkRequisition *indicator_size,
GtkBorder *indicator_spacing)
{
GtkRequisition *tmp_size = NULL;
GtkBorder *tmp_spacing = NULL;
if (widget)
gtk_widget_style_get (widget, "indicator_size", &tmp_size,
"indicator_spacing", &tmp_spacing, NULL);
if (tmp_size)
{
*indicator_size = *tmp_size;
g_free (tmp_size);
}
else
*indicator_size = default_option_indicator_size;
if (tmp_spacing)
{
*indicator_spacing = *tmp_spacing;
g_free (tmp_spacing);
}
else
*indicator_spacing = default_option_indicator_spacing;
}
GtkWidget *special_get_ancestor(GtkWidget * widget,
GType widget_type)
{
g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
while (widget && widget->parent
&& !g_type_is_a(GTK_WIDGET_TYPE(widget->parent),
widget_type))
widget = widget->parent;
if (!
(widget && widget->parent
&& g_type_is_a(GTK_WIDGET_TYPE(widget->parent), widget_type)))
return NULL;
return widget;
}
/* Dithered Gradient Buffers */
static void
internel_image_buffer_free_pixels (guchar *pixels, gpointer data)
{
g_free (pixels);
}
static GdkPixbuf*
internal_image_buffer_new (gint width, gint height)
{
guchar *buf;
int rowstride;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
rowstride = width * 3;
buf = g_try_malloc (height * rowstride);
if (!buf)
return NULL;
return gdk_pixbuf_new_from_data(buf, GDK_COLORSPACE_RGB,
FALSE, 8,
width, height, rowstride,
internel_image_buffer_free_pixels, NULL);
}
static void
internal_color_get_as_uchars(GdkColor *color,
guchar *red,
guchar *green,
guchar *blue)
{
*red = (guchar) (color->red / 256.0);
*green = (guchar) (color->green / 256.0);
*blue = (guchar) (color->blue / 256.0);
}
static GdkPixbuf*
internal_create_horizontal_gradient_image_buffer (gint width, gint height,
GdkColor *from,
GdkColor *to)
{
int i;
long r, g, b, dr, dg, db;
GdkPixbuf* buffer;
guchar *ptr;
guchar *pixels;
guchar r0, g0, b0;
guchar rf, gf, bf;
int rowstride;
buffer = internal_image_buffer_new (width, height);
if (buffer == NULL)
return NULL;
pixels = gdk_pixbuf_get_pixels (buffer);
ptr = pixels;
rowstride = gdk_pixbuf_get_rowstride (buffer);
internal_color_get_as_uchars(from, &r0, &g0, &b0);
internal_color_get_as_uchars(to, &rf, &gf, &bf);
r = r0 << 16;
g = g0 << 16;
b = b0 << 16;
dr = ((rf-r0)<<16)/width;
dg = ((gf-g0)<<16)/width;
db = ((bf-b0)<<16)/width;
/* render the first line */
for (i=0; i<width; i++)
{
*(ptr++) = (guchar)(r>>16);
*(ptr++) = (guchar)(g>>16);
*(ptr++) = (guchar)(b>>16);
r += dr;
g += dg;
b += db;
}
/* copy the first line to the other lines */
for (i=1; i<height; i++)
{
memcpy (&(pixels[i*rowstride]), pixels, rowstride);
}
return buffer;
}
static GdkPixbuf*
internal_create_vertical_gradient_image_buffer (gint width, gint height,
GdkColor *from,
GdkColor *to)
{
gint i, j, max_block, last_block;
long r, g, b, dr, dg, db;
GdkPixbuf *buffer;
guchar *ptr;
guchar point[4];
guchar r0, g0, b0;
guchar rf, gf, bf;
gint rowstride;
guchar *pixels;
buffer = internal_image_buffer_new (width, height);
if (buffer == NULL)
return NULL;
pixels = gdk_pixbuf_get_pixels (buffer);
rowstride = gdk_pixbuf_get_rowstride (buffer);
internal_color_get_as_uchars(from, &r0, &g0, &b0);
internal_color_get_as_uchars(to, &rf, &gf, &bf);
r = r0<<16;
g = g0<<16;
b = b0<<16;
dr = ((rf-r0)<<16)/height;
dg = ((gf-g0)<<16)/height;
db = ((bf-b0)<<16)/height;
max_block = width/2;
for (i=0; i < height; i++)
{
ptr = pixels + i * rowstride;
ptr[0] = r>>16;
ptr[1] = g>>16;
ptr[2] = b>>16;
if (width > 1)
{
last_block = 0;
for (j=1; j <= max_block; j *= 2)
{
memcpy (&(ptr[j*3]), ptr, j*3);
if ((j*2) >= max_block)
{
last_block = j*2;
}
}
if ((last_block < width) && (last_block > 0))
{
memcpy (&(ptr[last_block*3]), ptr, (width - last_block)*3);
}
}
r += dr;
g += dg;
b += db;
}
return buffer;
}
void
draw_vgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *left_color, GdkColor *right_color)
{
#ifndef ALWAYS_DITHER_GRADIENTS
gboolean dither = ((style->depth > 0) && (style->depth <= 16));
#endif
if ((width <= 0) || (height <= 0))
return;
if ( left_color == NULL || right_color == NULL )
{
gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
return;
}
#ifndef ALWAYS_DITHER_GRADIENTS
if (dither)
#endif
{
GdkPixbuf *image_buffer = NULL;
image_buffer = internal_create_horizontal_gradient_image_buffer (width, height, left_color, right_color);
if (image_buffer)
{
gdk_draw_pixbuf(drawable, gc, image_buffer, 0, 0, x, y, width, height, GDK_RGB_DITHER_MAX, 0, 0);
g_object_unref(image_buffer);
}
}
#ifndef ALWAYS_DITHER_GRADIENTS
else
{
int i;
GdkColor col;
int dr, dg, db;
GdkGCValues old_values;
gdk_gc_get_values (gc, &old_values);
if (left_color == right_color )
{
col = *left_color;
gdk_rgb_find_color (style->colormap, &col);
gdk_gc_set_foreground (gc, &col);
gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
gdk_gc_set_foreground (gc, &old_values.foreground);
return;
}
col = *left_color;
dr = (right_color->red - left_color->red) / width;
dg = (right_color->green - left_color->green) / width;
db = (right_color->blue - left_color->blue) / width;
for (i = 0; i < width; i++)
{
gdk_rgb_find_color (style->colormap, &col);
gdk_gc_set_foreground (gc, &col);
gdk_draw_line (drawable, gc, x + i, y, x + i, y + height - 1);
col.red += dr;
col.green += dg;
col.blue += db;
}
gdk_gc_set_foreground (gc, &old_values.foreground);
}
#endif
}
void
draw_hgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *top_color, GdkColor *bottom_color)
{
#ifndef ALWAYS_DITHER_GRADIENTS
gboolean dither = ((style->depth > 0) && (style->depth <= 16));
#endif
if ((width <= 0) || (height <= 0))
return;
#ifndef ALWAYS_DITHER_GRADIENTS
if (dither)
#endif
{
GdkPixbuf *image_buffer = NULL;
image_buffer = internal_create_vertical_gradient_image_buffer (width, height, top_color, bottom_color);
if (image_buffer)
{
gdk_draw_pixbuf(drawable, gc, image_buffer, 0, 0, x, y, width, height, GDK_RGB_DITHER_MAX, 0, 0);
g_object_unref(image_buffer);
}
}
#ifndef ALWAYS_DITHER_GRADIENTS
else
{
int i;
GdkColor col;
int dr, dg, db;
GdkGCValues old_values;
gdk_gc_get_values (gc, &old_values);
if (top_color == bottom_color )
{
col = *top_color;
gdk_rgb_find_color (style->colormap, &col);
gdk_gc_set_foreground (gc, &col);
gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
gdk_gc_set_foreground (gc, &old_values.foreground);
return;
}
col = *top_color;
dr = (bottom_color->red - top_color->red) / height;
dg = (bottom_color->green - top_color->green) / height;
db = (bottom_color->blue - top_color->blue) / height;
for (i = 0; i < height; i++)
{
gdk_rgb_find_color (style->colormap, &col);
gdk_gc_set_foreground (gc, &col);
gdk_draw_line (drawable, gc, x, y + i, x + width - 1, y + i);
col.red += dr;
col.green += dg;
col.blue += db;
}
gdk_gc_set_foreground (gc, &old_values.foreground);
}
#endif
}
void blend (GdkColormap *colormap,
GdkColor *a, GdkColor *b, GdkColor *c, int alpha)
{
int inAlpha = 100-alpha;
c->red = (a->red * alpha + b->red * inAlpha) / 100;
c->green = (a->green * alpha + b->green * inAlpha) / 100;
c->blue = (a->blue * alpha + b->blue * inAlpha) / 100;
gdk_rgb_find_color (colormap, c);
}
GtkWidget *get_parent_window (GtkWidget *widget)
{
GtkWidget *parent = widget->parent;
while (parent && GTK_WIDGET_NO_WINDOW (parent))
parent = parent->parent;
return parent;
}
GdkColor *get_parent_bgcolor (GtkWidget *widget)
{
GtkWidget *parent = get_parent_window (widget);
if (parent && parent->style)
return &parent->style->bg[GTK_STATE_NORMAL];
return NULL;
}
GtkWidget *
find_combo_box_widget (GtkWidget * widget)
{
GtkWidget *result = NULL;
if (widget && !GTK_IS_COMBO_BOX_ENTRY (widget))
{
if (GTK_IS_COMBO_BOX (widget))
result = widget;
else
result = find_combo_box_widget(widget->parent);
}
return result;
}
gboolean
is_combo_box (GtkWidget * widget)
{
return (find_combo_box_widget(widget) != NULL);
}

View File

@@ -0,0 +1,110 @@
#include <gtk/gtk.h>
#include <math.h>
#include <string.h>
/* GTK 2.2 compatibility */
#ifndef GTK_IS_COMBO_BOX_ENTRY
#define GTK_IS_COMBO_BOX_ENTRY(x) 0
#endif
#ifndef GTK_IS_COMBO_BOX
#define GTK_IS_COMBO_BOX(x) 0
#endif
#define RADIO_SIZE 13
#define CHECK_SIZE 13
GtkTextDirection
get_direction (GtkWidget *widget);
GdkPixbuf *
generate_bit (unsigned char alpha[],
GdkColor *color,
double mult);
GdkPixbuf *
colorize_bit (unsigned char *bit,
unsigned char *alpha,
GdkColor *new_color);
GdkPixmap *
pixbuf_to_pixmap (GtkStyle *style,
GdkPixbuf *pixbuf,
GdkScreen *screen);
gboolean
sanitize_size (GdkWindow *window,
gint *width,
gint *height);
void
rgb_to_hls (gdouble *r,
gdouble *g,
gdouble *b);
void
hls_to_rgb (gdouble *h,
gdouble *l,
gdouble *s);
void
shade (GdkColor * a, GdkColor * b, float k);
void
draw_hgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *top_color, GdkColor *bottom_color);
void
draw_vgradient (GdkDrawable *drawable, GdkGC *gc, GtkStyle *style,
int x, int y, int width, int height,
GdkColor *left_color, GdkColor *right_color);
void
arrow_draw_hline (GdkWindow *window,
GdkGC *gc,
int x1,
int x2,
int y,
gboolean last);
void
arrow_draw_vline (GdkWindow *window,
GdkGC *gc,
int y1,
int y2,
int x,
gboolean last);
void
draw_arrow (GdkWindow *window,
GdkGC *gc,
GdkRectangle *area,
GtkArrowType arrow_type,
gint x,
gint y,
gint width,
gint height);
void
calculate_arrow_geometry (GtkArrowType arrow_type,
gint *x,
gint *y,
gint *width,
gint *height);
GtkWidget *special_get_ancestor(GtkWidget * widget,
GType widget_type);
void blend (GdkColormap *colormap,
GdkColor *a, GdkColor *b, GdkColor *c, int alpha);
GtkWidget *get_parent_window (GtkWidget *widget);
GdkColor *get_parent_bgcolor (GtkWidget *widget);
gboolean is_combo_box (GtkWidget * widget);
GtkWidget *find_combo_box_widget (GtkWidget * widget);
void gtk_clist_get_header_index (GtkCList *clist, GtkWidget *button,
gint *column_index, gint *columns);

View File

@@ -1,24 +0,0 @@
#ifndef CLEARLOOKS_DRAW_H
#define CLEARLOOKS_DRAW_H
#include "clearlooks_types.h"
#include "clearlooks_style.h"
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <cairo.h>
GE_INTERNAL void clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
GE_INTERNAL void clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
/* Fallback focus function */
GE_INTERNAL void clearlooks_draw_focus (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const FocusParameters *focus,
int x, int y, int width, int height);
#endif /* CLEARLOOKS_DRAW_H */

View File

@@ -1,510 +0,0 @@
#ifndef CLEARLOOKS_TYPES_H
#define CLEARLOOKS_TYPES_H
#include <ge-support.h>
typedef unsigned char boolean;
typedef unsigned char uint8;
typedef struct _ClearlooksStyleFunctions ClearlooksStyleFunctions;
typedef struct _ClearlooksStyleConstants ClearlooksStyleConstants;
typedef enum
{
CL_STYLE_CLASSIC = 0,
CL_STYLE_GLOSSY = 1,
CL_STYLE_INVERTED = 2,
CL_STYLE_GUMMY = 3,
CL_NUM_STYLES = 4
} ClearlooksStyles;
typedef enum
{
CL_STATE_NORMAL,
CL_STATE_ACTIVE,
CL_STATE_SELECTED,
CL_STATE_INSENSITIVE
} ClearlooksStateType;
typedef enum
{
CL_JUNCTION_NONE = 0,
CL_JUNCTION_BEGIN = 1,
CL_JUNCTION_END = 2
} ClearlooksJunction;
typedef enum
{
CL_STEPPER_UNKNOWN = 0,
CL_STEPPER_A = 1,
CL_STEPPER_B = 2,
CL_STEPPER_C = 4,
CL_STEPPER_D = 8
} ClearlooksStepper;
typedef enum
{
CL_ORDER_FIRST = 1 << 0,
CL_ORDER_LAST = 1 << 1,
} ClearlooksOrder;
typedef enum
{
CL_CONT_NONE = 0,
CL_CONT_LEFT = 1 << 0,
CL_CONT_RIGHT = 1 << 1
} ClearlooksContinue;
typedef enum
{
CL_ORIENTATION_LEFT_TO_RIGHT,
CL_ORIENTATION_RIGHT_TO_LEFT,
CL_ORIENTATION_BOTTOM_TO_TOP,
CL_ORIENTATION_TOP_TO_BOTTOM
} ClearlooksOrientation;
typedef enum
{
CL_GAP_LEFT,
CL_GAP_RIGHT,
CL_GAP_TOP,
CL_GAP_BOTTOM
} ClearlooksGapSide;
typedef enum
{
CL_SHADOW_NONE,
CL_SHADOW_IN,
CL_SHADOW_OUT,
CL_SHADOW_ETCHED_IN,
CL_SHADOW_ETCHED_OUT
} ClearlooksShadowType;
typedef enum
{
CL_HANDLE_TOOLBAR,
CL_HANDLE_SPLITTER
} ClearlooksHandleType;
typedef enum
{
CL_ARROW_NORMAL,
CL_ARROW_COMBO
} ClearlooksArrowType;
typedef enum
{
CL_FOCUS_BUTTON,
CL_FOCUS_BUTTON_FLAT,
CL_FOCUS_LABEL,
CL_FOCUS_TREEVIEW,
CL_FOCUS_TREEVIEW_HEADER,
CL_FOCUS_TREEVIEW_ROW,
CL_FOCUS_TREEVIEW_DND,
CL_FOCUS_SCALE,
CL_FOCUS_TAB,
CL_FOCUS_COLOR_WHEEL_DARK,
CL_FOCUS_COLOR_WHEEL_LIGHT,
CL_FOCUS_UNKNOWN
} ClearlooksFocusType;
typedef enum
{
CL_DIRECTION_UP,
CL_DIRECTION_DOWN,
CL_DIRECTION_LEFT,
CL_DIRECTION_RIGHT
} ClearlooksDirection;
typedef enum
{
CL_PROGRESSBAR_CONTINUOUS,
CL_PROGRESSBAR_DISCRETE
} ClearlooksProgressBarStyle;
typedef enum
{
CL_WINDOW_EDGE_NORTH_WEST,
CL_WINDOW_EDGE_NORTH,
CL_WINDOW_EDGE_NORTH_EAST,
CL_WINDOW_EDGE_WEST,
CL_WINDOW_EDGE_EAST,
CL_WINDOW_EDGE_SOUTH_WEST,
CL_WINDOW_EDGE_SOUTH,
CL_WINDOW_EDGE_SOUTH_EAST
} ClearlooksWindowEdge;
typedef struct
{
double x;
double y;
double width;
double height;
} ClearlooksRectangle;
typedef struct
{
CairoColor fg[5];
CairoColor bg[5];
CairoColor base[5];
CairoColor text[5];
CairoColor shade[9];
CairoColor spot[3];
} ClearlooksColors;
typedef struct
{
boolean active;
boolean prelight;
boolean disabled;
boolean focus;
boolean is_default;
boolean ltr;
boolean enable_shadow;
gfloat radius;
ClearlooksStateType state_type;
uint8 corners;
uint8 xthickness;
uint8 ythickness;
CairoColor parentbg;
ClearlooksStyleFunctions *style_functions;
ClearlooksStyleConstants *style_constants;
} WidgetParameters;
typedef struct
{
ClearlooksFocusType type;
ClearlooksContinue continue_side;
CairoColor color;
boolean has_color;
gint line_width;
gint padding;
guint8* dash_list;
boolean interior;
} FocusParameters;
typedef struct
{
boolean lower;
boolean horizontal;
boolean fill_level;
} SliderParameters;
typedef struct
{
ClearlooksOrientation orientation;
boolean pulsing;
float value;
} ProgressBarParameters;
typedef struct
{
int linepos;
} OptionMenuParameters;
typedef struct
{
ClearlooksShadowType shadow;
ClearlooksGapSide gap_side;
int gap_x;
int gap_width;
const CairoColor *border; /* maybe changes this to some other hint ... */
} FrameParameters;
typedef struct
{
ClearlooksGapSide gap_side;
FocusParameters focus;
} TabParameters;
typedef struct
{
CairoCorners corners;
ClearlooksShadowType shadow;
} ShadowParameters;
typedef struct
{
boolean horizontal;
} SeparatorParameters;
typedef struct
{
ClearlooksOrder order; /* XXX: rename to position */
boolean resizable;
} ListViewHeaderParameters;
typedef struct
{
CairoColor color;
ClearlooksJunction junction; /* On which sides the slider junctions */
boolean horizontal;
boolean has_color;
} ScrollBarParameters;
typedef struct
{
ClearlooksHandleType type;
boolean horizontal;
} HandleParameters;
typedef struct
{
ClearlooksStepper stepper; /* Which stepper to draw */
} ScrollBarStepperParameters;
typedef struct
{
ClearlooksWindowEdge edge;
} ResizeGripParameters;
typedef struct
{
int style;
} MenuBarParameters;
typedef struct
{
ClearlooksShadowType shadow_type;
boolean in_cell;
boolean in_menu;
} CheckboxParameters;
typedef struct
{
ClearlooksArrowType type;
ClearlooksDirection direction;
} ArrowParameters;
typedef struct
{
int style;
boolean topmost;
} ToolbarParameters;
struct _ClearlooksStyleConstants
{
gdouble topleft_highlight_shade;
gdouble topleft_highlight_alpha;
};
struct _ClearlooksStyleFunctions
{
void (*draw_top_left_highlight) (cairo_t *cr,
const CairoColor *color,
const WidgetParameters *params,
int x, int y, int width, int height,
gdouble radius,
CairoCorners corners);
void (*draw_button) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_scale_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SliderParameters *slider,
int x, int y, int width, int height);
void (*draw_progressbar_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_progressbar_fill) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ProgressBarParameters *progressbar,
int x, int y, int width, int height, gint offset);
void (*draw_slider_button) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SliderParameters *slider,
int x, int y, int width, int height);
void (*draw_entry) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_spinbutton) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_spinbutton_down) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_optionmenu) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const OptionMenuParameters *optionmenu,
int x, int y, int width, int height);
void (*draw_inset) (cairo_t *cr,
const CairoColor *bg_color,
double x, double y, double w, double h,
double radius, uint8 corners);
void (*draw_menubar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const MenuBarParameters *menubar,
int x, int y, int width, int height);
void (*draw_tab) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const TabParameters *tab,
int x, int y, int width, int height);
void (*draw_frame) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const FrameParameters *frame,
int x, int y, int width, int height);
void (*draw_separator) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SeparatorParameters *separator,
int x, int y, int width, int height);
void (*draw_menu_item_separator) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const SeparatorParameters *separator,
int x, int y, int width, int height);
void (*draw_list_view_header) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ListViewHeaderParameters *header,
int x, int y, int width, int height);
void (*draw_toolbar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ToolbarParameters *toolbar,
int x, int y, int width, int height);
void (*draw_menuitem) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_menubaritem) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_selected_cell) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_scrollbar_stepper) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
const ScrollBarStepperParameters *stepper,
int x, int y, int width, int height);
void (*draw_scrollbar_slider) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height);
void (*draw_scrollbar_trough) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height);
void (*draw_statusbar) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_menu_frame) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_tooltip) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_handle) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const HandleParameters *handle,
int x, int y, int width, int height);
void (*draw_resize_grip) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ResizeGripParameters *grip,
int x, int y, int width, int height);
void (*draw_arrow) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ArrowParameters *arrow,
int x, int y, int width, int height);
void (*draw_focus) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const FocusParameters *focus,
int x, int y, int width, int height);
void (*draw_checkbox) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const CheckboxParameters *checkbox,
int x, int y, int width, int height);
void (*draw_radiobutton) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const CheckboxParameters *checkbox,
int x, int y, int width, int height);
/* Style internal functions */
/* XXX: Only used by slider_button, inline it? */
void (*draw_shadow) (cairo_t *cr,
const ClearlooksColors *colors,
gfloat radius, int width, int height);
void (*draw_slider) (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
int x, int y, int width, int height);
void (*draw_gripdots) (cairo_t *cr,
const ClearlooksColors *colors, int x, int y,
int width, int height, int xr, int yr,
float contrast);
};
#define CLEARLOOKS_RECTANGLE_SET(rect, _x, _y, _w, _h) (rect).x = (_x); \
(rect).y = (_y); \
(rect).width = (_w); \
(rect).height = (_h);
#endif /* CLEARLOOKS_TYPES_H */

View File

@@ -29,6 +29,8 @@ using namespace Gtk;
using namespace Glib;
using namespace Gtkmm2ext;
DnDTreeViewBase::DragData DnDTreeViewBase::drag_data;
DnDTreeViewBase::DnDTreeViewBase ()
: TreeView ()
{
@@ -47,6 +49,7 @@ DnDTreeViewBase::add_drop_targets (list<TargetEntry>& targets)
for (list<TargetEntry>::iterator i = targets.begin(); i != targets.end(); ++i) {
draggable.push_back (*i);
}
enable_model_drag_source (draggable);
enable_model_drag_dest (draggable);
}
@@ -56,6 +59,7 @@ DnDTreeViewBase::add_object_drag (int column, string type_name)
{
draggable.push_back (TargetEntry (type_name, TargetFlags(0)));
data_column = column;
object_type = type_name;
enable_model_drag_source (draggable);
enable_model_drag_dest (draggable);

View File

@@ -65,6 +65,9 @@ UI::UI (string namestr, int *argc, char ***argv)
: AbstractUI<UIRequest> (namestr, true)
{
theMain = new Main (argc, argv);
#ifndef GTK_NEW_TOOLTIP_API
tips = new Tooltips;
#endif
_active = false;
@@ -95,6 +98,7 @@ UI::UI (string namestr, int *argc, char ***argv)
errors->dismiss_button().set_name ("ErrorLogCloseButton");
errors->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), (Window *) errors));
errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
register_thread (pthread_self(), X_("GUI"));
@@ -372,7 +376,16 @@ UI::do_request (UIRequest* req)
} else if (req->type == SetTip) {
/* XXX need to figure out how this works */
#ifdef GTK_NEW_TOOLTIP_API
/* even if the installed GTK is up to date,
at present (November 2008) our included
version of gtkmm is not. so use the GTK
API that we've verified has the right function.
*/
gtk_widget_set_tooltip_text (req->widget->gobj(), req->msg);
#else
tips->set_tip (*req->widget, req->msg, "");
#endif
} else {

View File

@@ -62,6 +62,21 @@ class DnDTreeViewBase : public Gtk::TreeView
std::list<Gtk::TargetEntry> draggable;
Gdk::DragAction suggested_action;
int data_column;
std::string object_type;
struct DragData {
Gtk::TreeView* source;
int data_column;
std::string object_type;
};
static DragData drag_data;
void start_object_drag () {
drag_data.source = this;
drag_data.data_column = data_column;
drag_data.object_type = object_type;
}
};
template<class DataType>
@@ -71,21 +86,26 @@ class DnDTreeView : public DnDTreeViewBase
DnDTreeView() {}
~DnDTreeView() {}
sigc::signal<void,std::string,uint32_t,const DataType*> signal_object_drop;
sigc::signal<void,const std::list<DataType>& > signal_drop;
void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time) {
if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") {
TreeView::on_drag_data_get (context, selection_data, info, time);
} else if (data_column >= 0) {
Gtk::TreeSelection::ListHandle_Path selection = get_selection()->get_selected_rows ();
SerializedObjectPointers<DataType>* sr = serialize_pointers (get_model(), &selection, selection_data.get_target());
selection_data.set (8, (guchar*)sr, sr->size);
} else if (selection_data.get_target() == object_type) {
start_object_drag ();
/* we don't care about the data passed around by DnD, but
we have to provide something otherwise it will stop.
*/
guchar c;
selection_data.set (8, (guchar*)&c, 1);
}
}
void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time) {
if (suggested_action) {
/* this is a drag motion callback. just update the status to
@@ -100,64 +120,39 @@ class DnDTreeView : public DnDTreeViewBase
TreeView::on_drag_data_received (context, x, y, selection_data, info, time);
} else if (data_column >= 0) {
/* object D-n-D */
const void* data = selection_data.get_data();
const SerializedObjectPointers<DataType>* sr = reinterpret_cast<const SerializedObjectPointers<DataType> *>(data);
if (sr) {
signal_object_drop (sr->type, sr->cnt, sr->data);
}
} else if (selection_data.get_target() == object_type) {
end_object_drag ();
} else {
/* some kind of target type added by the app, which will be handled by a signal handler */
}
}
private:
/**
* this can be called by the Treeview itself or by some other
* object that wants to get the list of dragged items.
*/
SerializedObjectPointers<DataType>* serialize_pointers (Glib::RefPtr<Gtk::TreeModel> model,
Gtk::TreeSelection::ListHandle_Path* selection,
Glib::ustring type) {
/* this nasty chunk of code is here because X's DnD protocol (probably other graphics UI's too)
requires that we package up the entire data collection for DnD in a single contiguous region
(so that it can be trivially copied between address spaces). We don't know the type of DataType so
we have to mix-and-match C and C++ programming techniques here to get the right result.
The C trick is to use the "someType foo[0];" declaration trick to create a zero-sized array at the
end of a SerializedObjectPointers<DataType object. Then we allocate a raw memory buffer that extends
past that array and thus provides space for however many DataType items we actually want to pass
around.
The C++ trick is to use the placement operator new() syntax to initialize that extra
memory properly.
*/
void get_object_drag_data (std::list<DataType>& l) {
Glib::RefPtr<Gtk::TreeModel> model = drag_data.source->get_model();
DataType v;
Gtk::TreeSelection::ListHandle_Path selection = drag_data.source->get_selection()->get_selected_rows ();
uint32_t cnt = selection->size();
uint32_t sz = (sizeof (DataType) * cnt) + sizeof (SerializedObjectPointers<DataType>);
char* buf = new char[sz];
SerializedObjectPointers<DataType>* sr = (SerializedObjectPointers<DataType>*) buf;
for (uint32_t i = 0; i < cnt; ++i) {
new ((void *) &sr->data[i]) DataType ();
for (Gtk::TreeSelection::ListHandle_Path::iterator x = selection.begin(); x != selection.end(); ++x) {
model->get_iter (*x)->get_value (drag_data.data_column, v);
l.push_back (v);
}
sr->cnt = cnt;
sr->size = sz;
snprintf (sr->type, sizeof (sr->type), "%s", type.c_str());
cnt = 0;
for (Gtk::TreeSelection::ListHandle_Path::iterator x = selection->begin(); x != selection->end(); ++x, ++cnt) {
model->get_iter (*x)->get_value (data_column, sr->data[cnt]);
}
return sr;
}
private:
void end_object_drag () {
std::list<DataType> l;
get_object_drag_data (l);
signal_drop (l);
}
};
} // namespace

View File

@@ -29,6 +29,9 @@
#include <pthread.h>
#include <gtkmm/widget.h>
#include <gtkmm/style.h>
#ifndef GTK_NEW_TOOLTIP_API
#include <gtkmm/tooltips.h>
#endif
#include <gtkmm/textbuffer.h>
#include <gtkmm/main.h>
#include <gdkmm/color.h>
@@ -149,6 +152,9 @@ class UI : public Receiver, public AbstractUI<UIRequest>
static pthread_t gui_thread;
bool _active;
Gtk::Main *theMain;
#ifndef GTK_NEW_TOOLTIP_API
Gtk::Tooltips *tips;
#endif
TextViewer *errors;
Glib::RefPtr<Gtk::TextBuffer::Tag> error_ptag;
Glib::RefPtr<Gtk::TextBuffer::Tag> error_mtag;

View File

@@ -34,6 +34,8 @@ class TearOff : public Gtk::HBox
virtual ~TearOff ();
void set_visible (bool yn);
void set_can_be_torn_off (bool);
bool can_be_torn_off () const { return _can_be_torn_off; }
sigc::signal<void> Detach;
sigc::signal<void> Attach;
@@ -55,6 +57,7 @@ class TearOff : public Gtk::HBox
double drag_y;
bool dragging;
bool _visible;
bool _can_be_torn_off;
gint tearoff_click (GdkEventButton*);
gint close_click (GdkEventButton*);

View File

@@ -22,6 +22,7 @@
#include <gtkmm2ext/popup.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/gtk_ui.h>
using namespace std;
using namespace Gtk;
@@ -83,9 +84,17 @@ PopUp::remove ()
}
}
#define ENSURE_GUI_THREAD(slot) \
if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {\
Gtkmm2ext::UI::instance()->call_slot ((slot));\
return;\
}
void
PopUp::touch ()
{
ENSURE_GUI_THREAD (mem_fun (*this, &PopUp::touch));
if (is_visible ()) {
remove ();
} else {

View File

@@ -36,6 +36,7 @@ TearOff::TearOff (Widget& c, bool allow_resize)
{
dragging = false;
_visible = true;
_can_be_torn_off = true;
tearoff_event_box.add (tearoff_arrow);
tearoff_event_box.set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
@@ -78,6 +79,21 @@ TearOff::~TearOff ()
{
}
void
TearOff::set_can_be_torn_off (bool yn)
{
if (yn != _can_be_torn_off) {
if (yn) {
tearoff_arrow.set_no_show_all (false);
tearoff_arrow.show ();
} else {
tearoff_arrow.set_no_show_all (true);
tearoff_arrow.hide ();
}
_can_be_torn_off = yn;
}
}
void
TearOff::set_visible (bool yn)
{
@@ -102,13 +118,16 @@ TearOff::set_visible (bool yn)
gint
TearOff::tearoff_click (GdkEventButton* ev)
{
remove (contents);
window_box.pack_start (contents);
own_window.set_name (get_name());
close_event_box.set_name (get_name());
own_window.show_all ();
hide ();
Detach ();
if (_can_be_torn_off) {
remove (contents);
window_box.pack_start (contents);
own_window.set_name (get_name());
close_event_box.set_name (get_name());
own_window.show_all ();
hide ();
Detach ();
}
return true;
}

View File

@@ -171,7 +171,7 @@ ALSA_SequencerMidiPort::create_ports (const Port::Descriptor& desc)
caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
if (desc.mode == O_RDONLY || desc.mode == O_RDWR)
caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
if (0 <= (err = snd_seq_create_simple_port (seq, desc.tag.c_str(), caps,
(SND_SEQ_PORT_TYPE_MIDI_GENERIC|
SND_SEQ_PORT_TYPE_SOFTWARE|
@@ -308,13 +308,17 @@ ALSA_SequencerMidiPort::get_connections (vector<SequencerPortAddress>& connectio
seq_addr.client = snd_seq_client_id (seq);
seq_addr.port = port_id;
snd_seq_query_subscribe_set_root(subs, &seq_addr);
while (snd_seq_query_port_subscribers(seq, subs) >= 0) {
seq_addr = *snd_seq_query_subscribe_get_addr (subs);
connections.push_back (SequencerPortAddress (seq_addr.client,
seq_addr.port));
if (snd_seq_query_subscribe_get_time_real (subs)) {
/* interesting connection */
seq_addr = *snd_seq_query_subscribe_get_addr (subs);
connections.push_back (SequencerPortAddress (seq_addr.client,
seq_addr.port));
}
snd_seq_query_subscribe_set_index(subs, snd_seq_query_subscribe_get_index(subs) + 1);
}

View File

@@ -122,7 +122,7 @@ void CoreMidi_MidiPort::read_proc (const MIDIPacketList *pktlist, void *refCon,
if (driver->firstrecv) {
driver->firstrecv = false;
PBD::ThreadCreated (pthread_self(), "COREMIDI");
PBD::notify_gui_about_thread_creation (pthread_self(), "COREMIDI");
}
for (unsigned int i = 0; i < pktlist->numPackets; ++i) {

View File

@@ -18,8 +18,6 @@
$Id$
*/
#include <cstring>
#include <string>
#include <cstring>
#include <cstdlib>
#include <midi++/types.h>

View File

@@ -70,6 +70,47 @@ Manager::add_port (const XMLNode& node)
PortMap::iterator existing;
pair<string, Port *> newpair;
/* do not allow multiple ports with the same tag. if attempted, just return the existing
port with the same tag. XXX this is really caused by the mess of setup_midi() being
called twice in Ardour, once in the global init() function and once after the user RC file
has been loaded (there may be extra ports in it).
*/
if ((existing = ports_by_tag.find (desc.tag)) != ports_by_tag.end()) {
port = (*existing).second;
if (port->mode() == desc.mode) {
/* Same mode - reuse the port, and just
create a new tag entry.
*/
newpair.first = desc.tag;
newpair.second = port;
ports_by_tag.insert (newpair);
return port;
}
/* If the existing is duplex, and this request
is not, then fail, because most drivers won't
allow opening twice with duplex and non-duplex
operation.
*/
if ((desc.mode == O_RDWR && port->mode() != O_RDWR) ||
(desc.mode != O_RDWR && port->mode() == O_RDWR)) {
error << "MIDIManager: port tagged \""
<< desc.tag
<< "\" cannot be opened duplex and non-duplex"
<< endmsg;
return 0;
}
/* modes must be different or complementary */
}
if (!PortFactory::ignore_duplicate_devices (desc.type)) {
if ((existing = ports_by_device.find (desc.device)) != ports_by_device.end()) {

View File

@@ -24,7 +24,7 @@
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <string>
#include <cstring>
#include <iostream>
#include <iterator>

View File

@@ -18,10 +18,9 @@
$Id$
*/
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <string>
#include <cstring>
#include <iostream>
#include <midi++/types.h>
@@ -51,7 +50,6 @@ Parser::possible_mtc (byte *sysex_buf, size_t msglen)
fake_mtc_time[3] = (sysex_buf[5] & 0x1f); // hours
_mtc_fps = MTC_FPS ((sysex_buf[5] & 0x60) >> 5); // fps
fake_mtc_time[4] = (byte) _mtc_fps;
/* wait for first quarter frame, which could indicate forwards
@@ -293,6 +291,7 @@ Parser::process_mtc_quarter_frame (byte *msg)
if (!_mtc_locked) {
_mtc_locked = true;
}
mtc_time (_mtc_time, false);
}
expected_mtc_quarter_frame_code = 0;

Some files were not shown because too many files have changed in this diff Show More