int ColorWindow::handle_event()
{
- thread->handle_new_color(rgb888(), (int)(255*aph + 0.5));
+ thread->handle_new_color(rgb888(), alpha8());
return 1;
}
void ColorWindow::update_rgb_hex(const char *hex)
{
- int color;
+ unsigned color;
if( sscanf(hex,"%x",&color) == 1 ) {
+ if( thread->do_alpha ) {
+ aph = ((color>>24) & 0xff) / 255.;
+ aph_a->update(aph);
+ }
float r = ((color>>16) & 0xff) / 255.;
float g = ((color>>8) & 0xff) / 255.;
float b = ((color>>0) & 0xff) / 255.;
{
window->aph = get_value();
window->aph_a->update(window->aph);
+ window->hex_box->update();
window->handle_event();
return 1;
}
bclamp(r, 0, 255); bclamp(g, 0, 255); bclamp(b, 0, 255);
return (r<<16) | (g<<8) | (b<<0);
}
+int ColorWindow::alpha8()
+{
+ int a = 255*aph + 0.5;
+ bclamp(a, 0, 255);
+ return a;
+}
PaletteNum::PaletteNum(ColorWindow *window, int x, int y,
float &output, float min, float max)
}
void PaletteHex::update()
{
- char hex[BCSTRLEN]; sprintf(hex,"%06x",window->rgb888());
+ char hex[BCSTRLEN], *cp = hex;
+ if( window->thread->do_alpha )
+ cp += sprintf(cp,"%02x", window->alpha8());
+ sprintf(cp,"%06x",window->rgb888());
BC_TextBox::update(hex);
}
void update_yuv(float y, float u, float v);
void update_rgb_hex(const char *hex);
int rgb888();
+ int alpha8();
ColorPicker *thread;
PaletteWheel *wheel;
is_selected = 0;
hard_left = 0;
hard_right = 0;
- color = -1;
+ color = 0;
}
Indexable* Edit::get_source()
}
}
-int Edit::get_hash_color()
-{
- Indexable *idxbl = asset ? (Indexable*)asset : (Indexable*)nested_edl;
- if( !idxbl ) return -1;
- int v = 0;
- for( uint8_t *bp=(uint8_t*)idxbl->path; *bp; ++bp ) v += *bp;
- int color = 0x303030;
- if( v & 0x01 ) color ^= 0x000040;
- if( v & 0x02 ) color ^= 0x004000;
- if( v & 0x04 ) color ^= 0x400000;
- if( v & 0x08 ) color ^= 0x080000;
- if( v & 0x10 ) color ^= 0x000800;
- if( v & 0x20 ) color ^= 0x000008;
- if( v & 0x40 ) color ^= 0x202020;
- if( v & 0x80 ) color ^= 0x101010;
- return color;
-}
-
float zoom_units) { return 0; }
virtual int64_t get_source_end(int64_t default_);
void get_title(char *title);
-// edit title bar color
- int get_title_color();
-// default edit title bar color
- int get_hash_color();
int dump(FILE *fp=stdout);
virtual int dump_derived() { return 0; }
{
if( popup->edit ) {
int color = popup->mwindow->get_title_color(popup->edit);
- if( color < 0 ) color = popup->mwindow->theme->get_color_title_bg();
+ if( !color ) color = popup->mwindow->theme->get_color_title_bg();
delete color_picker;
- color_picker = new EditTitleColorPicker(popup);
- color_picker->start_window(color, -1, 1);
+ color_picker = new EditTitleColorPicker(popup, color);
+ int alpha = (~color>>24) & 0xff;
+ color_picker->start_window(color & 0xffffff, alpha, 1);
}
return 1;
}
int EditTitleColorDefault::handle_event()
{
- int color = color_picker->popup->mwindow->theme->get_color_title_bg();
- color_picker->update_gui(color, -1);
+ color_picker->color = 0;
+ color_picker->update_gui(0, 0);
return 1;
}
-EditTitleColorPicker::EditTitleColorPicker(EditPopup *popup)
- : ColorPicker(0, _("Bar Color"))
+EditTitleColorPicker::EditTitleColorPicker(EditPopup *popup, int color)
+ : ColorPicker(1, _("Bar Color"))
{
this->popup = popup;
- color = -1;
+ this->color = color;
}
EditTitleColorPicker::~EditTitleColorPicker()
{
}
void EditTitleColorPicker::create_objects(ColorWindow *gui)
{
- int y = gui->get_h() - BC_CancelButton::calculate_h() - 50;
- int x = gui->get_w() - BC_GenericButton::calculate_w(gui, _("default")) - 15;
+ int y = gui->get_h() - BC_CancelButton::calculate_h() + 10;
+ int x = gui->get_w() - BC_CancelButton::calculate_w() - 10;
+ x -= BC_GenericButton::calculate_w(gui, _("default")) + 15;
gui->add_subwindow(new EditTitleColorDefault(this, x, y));
}
int EditTitleColorPicker::handle_new_color(int color, int alpha)
{
- this->color = color;
+ this->color = color | (~alpha << 24);
return 1;
}
class EditTitleColorPicker : public ColorPicker
{
public:
- EditTitleColorPicker(EditPopup *popup);
+ EditTitleColorPicker(EditPopup *popup, int color);
~EditTitleColorPicker();
void create_objects(ColorWindow *gui);
int handle_new_color(int color, int alpha);
zwindow_fullscreen = 0;
selected_zwindow = -1;
actual_frame_rate = 0;
+ title_bar_alpha = 0;
window_config = 0;
a_x11_host[0] = 0;
b_x11_host[0] = 0;
current_tip = defaults->get("CURRENT_TIP", current_tip);
actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
+ title_bar_alpha = defaults->get("TITLE_BAR_ALPHA", (float)0);
boundaries();
return 0;
defaults->update("TRANSITIONDIALOG_H", transitiondialog_h);
defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
+ defaults->update("TITLE_BAR_ALPHA", title_bar_alpha);
defaults->update("CURRENT_TIP", current_tip);
// filename of the current project for window titling and saving
char filename[BCTEXTLEN];
+// title bar background blend
+ float title_bar_alpha;
+
int batchrender_x, batchrender_y, batchrender_w, batchrender_h;
// Window positions
keyframe_gui_lock->unlock();
}
+int MWindow::get_hash_color(Edit *edit)
+{
+ Indexable *idxbl = edit->asset ?
+ (Indexable*)edit->asset : (Indexable*)edit->nested_edl;
+ if( !idxbl ) return 0;
+ char path[BCTEXTLEN];
+ if( !edit->asset || edit->track->data_type != TRACK_VIDEO ||
+ edl->session->proxy_scale == 1 ||
+ ProxyRender::from_proxy_path(path, idxbl, edl->session->proxy_scale) )
+ strcpy(path, idxbl->path);
+ char *cp = strrchr(path, '/');
+ cp = !cp ? path : cp+1;
+ uint8_t *bp = (uint8_t*)cp;
+ int v = 0;
+ while( *bp ) v += *bp++;
+ int hash = 0x303030;
+ if( v & 0x01 ) hash ^= 0x000040;
+ if( v & 0x02 ) hash ^= 0x004000;
+ if( v & 0x04 ) hash ^= 0x400000;
+ if( v & 0x08 ) hash ^= 0x080000;
+ if( v & 0x10 ) hash ^= 0x000800;
+ if( v & 0x20 ) hash ^= 0x000008;
+ if( v & 0x40 ) hash ^= 0x404040;
+ if( v & 0x80 ) hash ^= 0x080808;
+ return hash;
+}
+
int MWindow::get_title_color(Edit *edit)
{
- int color = edit->color;
- if( color < 0 && preferences->autocolor_assets )
- color = edit->get_hash_color();
- return color;
+ unsigned color = edit->color;
+ if( !color ) {
+ if( !preferences->autocolor_assets ) return 0;
+ color = get_hash_color(edit);
+ }
+ unsigned alpha = (~edit->color>>24) & 0xff;
+ if( alpha == 0xff )
+ alpha = session->title_bar_alpha*255;
+ return color | (~alpha<<24);
}
void MWindow::update_keyframe_guis()
void hide_keyframe_guis();
void hide_keyframe_gui(Plugin *plugin);
void update_keyframe_guis();
+ int get_hash_color(Edit *edit);
int get_title_color(Edit *edit);
// ============================= editing commands ========================
SET_TRACE
add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
VScalingEquation *vscaling_equation =
- new VScalingEquation(x + title1->get_w() + 10, y,
+ new VScalingEquation(x + title1->get_w() + 65, y,
&pwindow->thread->edl->session->interpolation_type);
add_subwindow(vscaling_equation);
vscaling_equation->create_objects();
subtitle_number = new PlaybackSubtitleNumber(x1, y, pwindow, this);
subtitle_number->create_objects();
- x2 = x + title1->get_w() + 10 + subtitle_number->get_w() + 30;
+ x2 = x + title1->get_w() + 10 + subtitle_number->get_w() + 85;
PlaybackSubtitle *subtitle_toggle;
x1 += subtitle_number->get_w() + margin;
add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
x1 = x;
add_subwindow(new BC_Title(x1, y, _("Positioning:")));
- x1 += 100;
+ x1 += 120;
add_subwindow(textbox = new BC_TextBox(x1, y, 200, 1, ""));
RecordPositioning *positioning = new RecordPositioning(pwindow,textbox);
add_subwindow(positioning);
refresh_w = pixmap_w;
// Draw background image
- if( refresh_w > 0 )
- mwindow->theme->draw_resource_bg(canvas,
- this,
- edit_x,
- edit_w,
- pixmap_x,
- refresh_x,
- y,
- refresh_x + refresh_w,
- mwindow->edl->local_session->zoom_track + y);
+ if( refresh_w > 0 ) {
+ int x1 = refresh_x, x2 = x1 + refresh_w;
+ int y1 = y, y2 = y1 + mwindow->edl->local_session->zoom_track;
+ int color = mwindow->get_title_color(edit);
+ mwindow->theme->draw_resource_bg(canvas, this, color,
+ edit_x, edit_w, pixmap_x, x1,y1, x2,y2);
+ }
//printf("ResourcePixmap::draw_data 70\n");
{
case TRACK_AUDIO:
draw_audio_resource(canvas,
- edit,
- refresh_x,
- refresh_w);
+ edit, refresh_x, refresh_w);
break;
case TRACK_VIDEO:
- draw_video_resource(canvas,
- edit,
- edit_x,
- edit_w,
- pixmap_x,
- pixmap_w,
- refresh_x,
- refresh_w,
+ draw_video_resource(canvas, edit, edit_x, edit_w,
+ pixmap_x, pixmap_w, refresh_x, refresh_w,
mode);
break;
case TRACK_SUBTITLE:
- draw_subttl_resource(canvas,
- edit,
- refresh_x,
- refresh_w);
+ draw_subttl_resource(canvas, edit,
+ refresh_x, refresh_w);
break;
}
}
VFrame *ResourcePixmap::change_title_color(VFrame *title_bg, int color)
{
- if( color < 0 ) return title_bg;
int colormodel = title_bg->get_color_model();
int bpp = BC_CModels::calculate_pixelsize(colormodel);
- int tw = title_bg->get_w(), th = title_bg->get_h();
+ int tw = title_bg->get_w(), tw1 = tw-1, th = title_bg->get_h();
VFrame *title_bar = new VFrame(tw, th, colormodel);
uint8_t cr = (color>>16), cg = (color>>8), cb = (color>>0);
uint8_t **bar_rows = title_bar->get_rows();
- for( int y=0; y<th; ++y ) {
- uint8_t *cp = bar_rows[y];
+ if( th > 0 ) {
+ uint8_t *cp = bar_rows[0];
for( int x=0; x<tw; ++x ) {
+ cp[0] = cp[1] = cp[2] = 0;
+ if( bpp > 3 ) cp[3] = 0xff;
+ cp += bpp;
+ }
+ }
+ for( int y=1; y<th; ++y ) {
+ uint8_t *cp = bar_rows[y];
+ if( tw > 0 ) {
+ cp[0] = cp[1] = cp[2] = 0;
+ if( bpp > 3 ) cp[3] = 0xff;
+ cp += bpp;
+ }
+ for( int x=1; x<tw1; ++x ) {
cp[0] = cr; cp[1] = cg; cp[2] = cb;
if( bpp > 3 ) cp[3] = 0xff;
cp += bpp;
}
+ if( tw > 1 ) {
+ cp[0] = cp[1] = cp[2] = 0;
+ if( bpp > 3 ) cp[3] = 0xff;
+ }
}
return title_bar;
}
+VFrame *ResourcePixmap::change_picon_alpha(VFrame *picon_frame, int alpha)
+{
+ uint8_t **picon_rows = picon_frame->get_rows();
+ int w = picon_frame->get_w(), h = picon_frame->get_h();
+ VFrame *frame = new VFrame(w, h, BC_RGBA8888);
+ uint8_t **rows = frame->get_rows();
+ for( int y=0; y<h; ++y ) {
+ uint8_t *bp = picon_rows[y], *rp = rows[y];
+ for( int x=0; x<w; ++x ) {
+ rp[0] = bp[0]; rp[1] = bp[1];
+ rp[2] = bp[2]; bp += 3;
+ rp[3] = alpha; rp += 4;
+ }
+ }
+ return frame;
+}
+
void ResourcePixmap::draw_title(TrackCanvas *canvas,
Edit *edit, int64_t edit_x, int64_t edit_w,
int64_t pixmap_x, int64_t pixmap_w)
VFrame *title_bg = mwindow->theme->get_image("title_bg_data");
int color = mwindow->get_title_color(edit);
- VFrame *title_bar = color < 0 ? title_bg :
+ VFrame *title_bar = !color ? title_bg :
change_title_color(title_bg, color);
canvas->draw_3segmenth(x, 0, w, total_x, total_w, title_bar, this);
if( title_bar != title_bg ) delete title_bar;
mwindow->frame_cache->get_frame_ptr(speed_position, edit->channel,
mwindow->edl->session->frame_rate, BC_RGB888,
picon_w, picon_h, indexable->id);
+ int bg_color = gui->get_bg_color();
if( picon_frame ) {
- draw_vframe(picon_frame, x, y, picon_w, picon_h, 0, 0);
+ VFrame *frame = picon_frame;
+ int color = mwindow->get_title_color(edit);
+ if( color ) {
+ int alpha = (~color >> 24) & 0xff;
+ frame = change_picon_alpha(picon_frame, alpha);
+ gui->set_bg_color(color & 0xffffff);
+ }
+ draw_vframe(frame, x, y, picon_w, picon_h, 0, 0);
+ if( frame != picon_frame ) {
+ delete frame;
+ gui->set_bg_color(bg_color);
+ }
mwindow->frame_cache->unlock();
}
else if( mode != IGNORE_THREAD ) {
void draw_wave(TrackCanvas *canvas,
int x, double high, double low);
VFrame *change_title_color(VFrame *title_bg, int color);
+ VFrame *change_picon_alpha(VFrame *picon_frame, int alpha);
void draw_title(TrackCanvas *canvas,
Edit *edit, int64_t edit_x, int64_t edit_w,
int64_t pixmap_x, int64_t pixmap_w);
}
-void Theme::draw_resource_bg(TrackCanvas *canvas,
- ResourcePixmap *pixmap,
- int edit_x,
- int edit_w,
- int pixmap_x,
- int x1,
- int y1,
- int x2,
- int y2)
+void Theme::draw_resource_bg(TrackCanvas *canvas, ResourcePixmap *pixmap, int color,
+ int edit_x, int edit_w, int pixmap_x, int x1, int y1, int x2, int y2)
{
- VFrame *image;
+ VFrame *image = 0;
- switch(mwindow->edl->local_session->zoom_track)
- {
+ switch(mwindow->edl->local_session->zoom_track) {
case 1024: image = get_image("resource1024"); break;
case 512: image = get_image("resource512"); break;
case 256: image = get_image("resource256"); break;
case 128: image = get_image("resource128"); break;
case 64: image = get_image("resource64"); break;
- default:
- case 32: image = get_image("resource32"); break;
}
-
- canvas->draw_3segmenth(x1,
- y1,
- x2 - x1,
- edit_x - pixmap_x,
- edit_w,
- image,
- pixmap);
+ if( !image )
+ image = get_image("resource32");
+
+ VFrame *frame = image;
+ int bg_color = canvas->get_bg_color();
+ if( color ) {
+ int alpha = (~color >> 24) & 0xff;
+ frame = pixmap->change_picon_alpha(image, alpha);
+ canvas->set_bg_color(color & 0xffffff);
+ }
+ canvas->draw_3segmenth(x1, y1, x2 - x1,
+ edit_x - pixmap_x, edit_w, frame, pixmap);
+ if( frame != image ) {
+ delete frame;
+ canvas->set_bg_color(bg_color);
+ }
}
virtual void draw_lwindow_bg(LevelWindowGUI *gui);
virtual void draw_mwindow_bg(MWindowGUI *gui);
virtual void draw_vwindow_bg(VWindowGUI *gui);
- virtual void draw_resource_bg(TrackCanvas *canvas,
- ResourcePixmap *pixmap,
- int edit_x,
- int edit_w,
- int pixmap_x,
- int x1,
- int y1,
- int x2,
- int y2);
+ virtual void draw_resource_bg(TrackCanvas *canvas, ResourcePixmap *pixmap, int color,
+ int edit_x, int edit_w, int pixmap_x, int x1, int y1, int x2, int y2);
virtual void get_preferences_sizes();
virtual void draw_preferences_bg(PreferencesWindow *gui);
#include "zoombar.h"
-
-
ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
: BC_SubWindow(mwindow->theme->mzoom_x,
mwindow->theme->mzoom_y,
{
this->gui = gui;
this->mwindow = mwindow;
- old_position = 0;
}
ZoomBar::~ZoomBar()
x += length_value->get_w() + 5;
add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
x += to_value->get_w() + 5;
+ add_subwindow(title_alpha = new TitleBarAlpha(mwindow, this, x, y));
update_formatting(from_value);
update_formatting(length_value);
update_formatting(to_value);
- add_subwindow(playback_value = new BC_Title(x, 100, "--", MEDIUMFONT, RED));
-
- add_subwindow(zoom_value = new BC_Title(x, 100, "--", MEDIUMFONT, BLACK));
update();
}
return 0;
}
-int ZoomBar::update_playback(int64_t new_position)
+TitleBarAlpha::TitleBarAlpha(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : BC_FSlider(x, y, 0, 150, 200, 0, 1.0, mwindow->session->title_bar_alpha, 0)
{
- if(new_position != old_position)
- {
- Units::totext(string, new_position,
- mwindow->edl->session->sample_rate,
- mwindow->edl->session->time_format,
- mwindow->edl->session->frame_rate,
- mwindow->edl->session->frames_per_foot);
- playback_value->update(string);
- old_position = new_position;
- }
- return 0;
+ this->mwindow = mwindow;
+ this->zoombar = zoombar;
+ set_precision(0.01);
+ set_tooltip(_("TitleBar Alpha"));
+}
+
+int TitleBarAlpha::handle_event()
+{
+ mwindow->session->title_bar_alpha = get_value();
+ mwindow->gui->draw_trackmovement();
+ mwindow->gui->flush();
+ return 1;
}
int ZoomBar::resize_event(int w, int h)
#ifndef ZOOMBAR_H
#define ZOOMBAR_H
-class FromTextBox;
-class LengthTextBox;
-class ToTextBox;
-
-
-class SampleZoomPanel;
-class AmpZoomPanel;
-class TrackZoomPanel;
-class AutoZoom;
-class AutoTypeMenu;
-class ZoomTextBox;
-
#include "guicast.h"
#include "mwindow.inc"
#include "mwindowgui.inc"
+#include "zoombar.inc"
#include "zoompanel.h"
+
class ZoomBar : public BC_SubWindow
{
public:
AutoTypeMenu *auto_type;
ZoomTextBox *auto_zoom_text;
- BC_Title *zoom_value, *playback_value;
LengthTextBox *length_value;
FromTextBox *from_value;
ToTextBox *to_value;
+ TitleBarAlpha *title_alpha;
char string[256], string2[256];
- int64_t old_position;
};
class SampleZoomPanel : public ZoomPanel
};
-
-
-
-
-
-
class FromTextBox : public BC_TextBox
{
public:
ZoomBar *zoombar;
};
-
-
+class TitleBarAlpha : public BC_FSlider
+{
+public:
+ TitleBarAlpha(MWindow *mwindow, ZoomBar *zoombar, int x, int y);
+ int handle_event();
+ MWindow *mwindow;
+ ZoomBar *zoombar;
+};
#endif
#define ZOOMBAR_INC
class ZoomBar;
+class SampleZoomPanel;
+class AmpZoomPanel;
+class TrackZoomPanel;
+class AutoZoom;
+class AutoTypeMenu;
+class ZoomTextBox;
+class FromTextBox;
+class LengthTextBox;
+class ToTextBox;
+class TitleBarAlpha;
+
#define ZOOMBAR_PIXELS 24
#endif
this->use_shm = !use_shm ? 0 : need_shm();
this->shm_reply = this->use_shm && resources->shm_reply ? 1 : 0;
// dont use shm for less than one page
- this->bg_color = parent_window->bg_color;
if( !this->avail_lock )
this->avail_lock = new Mutex("BC_Bitmap::avail_lock");
else
parent_window->get_resources()->use_shm > 0 ? 1 : 0;
}
-int BC_Bitmap::set_bg_color(int color)
-{
- this->bg_color = color;
- return 0;
-}
-
int BC_Bitmap::invert()
{
for( int j=0; j<buffer_count; ++j ) {
// ============================ Decoding VFrames
int BC_Bitmap::read_frame(VFrame *frame, int x1, int y1, int x2, int y2)
+{
+ return read_frame(frame, x1, y1, x2, y2, parent_window->get_bg_color());
+}
+
+int BC_Bitmap::read_frame(VFrame *frame, int x1, int y1, int x2, int y2, int bg_color)
{
return read_frame(frame,
0, 0, frame->get_w(), frame->get_h(),
- x1, y1, x2 - x1, y2 - y1);
+ x1, y1, x2 - x1, y2 - y1, bg_color);
}
int BC_Bitmap::read_frame(VFrame *frame,
int in_x, int in_y, int in_w, int in_h,
- int out_x, int out_y, int out_w, int out_h)
+ int out_x, int out_y, int out_w, int out_h, int bg_color)
{
BC_BitmapImage *bfr = cur_bfr();
if( hardware_scaling() && frame->get_color_model() == color_model ) {
long best_buffer_size();
int need_shm();
-// Background color for using pngs
- int bg_color;
// Override top_level for small bitmaps
int use_shm;
BC_WindowBase *top_level;
// transfer VFrame
int read_frame(VFrame *frame,
int in_x, int in_y, int in_w, int in_h,
- int out_x, int out_y, int out_w, int out_h);
+ int out_x, int out_y, int out_w, int out_h,
+ int bg_color);
// x1, y1, x2, y2 dimensions of output area
int read_frame(VFrame *frame,
int x1, int y1, int x2, int y2);
+ int read_frame(VFrame *frame,
+ int x1, int y1, int x2, int y2, int bg_color);
// Reset bitmap to match the new parameters
int match_params(int w, int h, int color_model, int use_shm);
// Test if bitmap already matches parameters
int is_unshared() { return type==bmXvImage || type==bmXImage; }
int is_zombie() { return cur_bfr()->is_zombie(); }
- int set_bg_color(int color);
int invert();
};
if(use_opaque())
{
opaque_bitmap = new BC_Bitmap(parent_window,
- frame->get_w(),
- frame->get_h(),
- parent_window->get_color_model(),
- 0);
- opaque_bitmap->set_bg_color(parent_window->get_bg_color());
+ frame->get_w(), frame->get_h(),
+ parent_window->get_color_model(), 0);
opaque_bitmap->read_frame(frame,
- 0,
- 0,
- frame->get_w(),
- frame->get_h());
+ 0, 0, frame->get_w(), frame->get_h());
}
{
int new_w = get_text_width(current_font, text);
- if(new_w > w)
- {
+ if( new_w > w ) {
const char* separator = "...";
int separator_w = get_text_width(current_font, separator);
// can't fit
- if(separator_w >= w)
- {
+ if( separator_w >= w ) {
strcpy(result, separator);
return;
}
int text_len = strlen(text);
// widen middle gap until it fits
- for(int i = text_len / 2; i > 0; i--)
- {
+ for( int i=text_len/2; i>0; --i ) {
strncpy(result, text, i);
result[i] = 0;
strcat(result, separator);
strcpy(result, separator);
return;
}
- else
- {
- strcpy(result, text);
- }
+
+ strcpy(result, text);
}
void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length)
void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap)
{ BT
// Some X drivers can't draw 0 length lines
- if(x1 == x2 && y1 == y2)
- {
+ if( x1 == x2 && y1 == y2 ) {
draw_pixel(x1, y1, pixmap);
}
- else
- {
+ else {
XDrawLine(top_level->display,
pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- x1,
- y1,
- x2,
- y2);
+ top_level->gc, x1, y1, x2, y2);
}
}
int npoints = MIN(x->total, y->total);
XPoint *points = new XPoint[npoints];
- for(int i = 0; i < npoints; i++)
- {
+ for( int i=0; i<npoints; ++i ) {
points[i].x = x->values[i];
points[i].y = y->values[i];
}
XDrawLines(top_level->display,
- pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- points,
- npoints,
- CoordModeOrigin);
+ pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
+ top_level->gc, points, npoints, CoordModeOrigin);
delete [] points;
}
int npoints = MIN(x->total, y->total);
XPoint *points = new XPoint[npoints];
- for(int i = 0; i < npoints; i++)
- {
+ for( int i=0; i<npoints; ++i ) {
points[i].x = x->values[i];
points[i].y = y->values[i];
}
XFillPolygon(top_level->display,
- pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- points,
- npoints,
- Nonconvex,
- CoordModeOrigin);
+ pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
+ top_level->gc, points, npoints, Nonconvex, CoordModeOrigin);
delete [] points;
}
void BC_WindowBase::draw_rectangle(int x, int y, int w, int h)
{ BT
XDrawRectangle(top_level->display,
- pixmap->opaque_pixmap,
- top_level->gc,
- x,
- y,
- w - 1,
- h - 1);
+ pixmap->opaque_pixmap, top_level->gc,
+ x, y, w - 1, h - 1);
}
-void BC_WindowBase::draw_3d_border(int x,
- int y,
- int w,
- int h,
- int is_down)
+void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, int is_down)
{
- draw_3d_border(x,
- y,
- w,
- h,
+ draw_3d_border(x, y, w, h,
top_level->get_resources()->border_shadow2,
top_level->get_resources()->border_shadow1,
top_level->get_resources()->border_light1,
}
-void BC_WindowBase::draw_3d_border(int x,
- int y,
- int w,
- int h,
- int light1,
- int light2,
- int shadow1,
- int shadow2)
+void BC_WindowBase::draw_3d_border(int x, int y, int w, int h,
+ int light1, int light2, int shadow1, int shadow2)
{
int lx, ly, ux, uy;
draw_line(x, y + h, x + w, y + h);
}
-void BC_WindowBase::draw_3d_box(int x,
- int y,
- int w,
- int h,
- int light1,
- int light2,
- int middle,
- int shadow1,
- int shadow2,
+void BC_WindowBase::draw_3d_box(int x, int y, int w, int h,
+ int light1, int light2, int middle, int shadow1, int shadow2,
BC_Pixmap *pixmap)
{
int lx, ly, ux, uy;
void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h)
{ BT
- if(!tile)
- {
+ if( !tile ) {
set_color(bg_color);
draw_box(x, y, w, h);
}
- else
- {
+ else {
XSetFillStyle(top_level->display, top_level->gc, FillTiled);
// Don't know how slow this is
XSetTile(top_level->display, top_level->gc, tile->get_pixmap());
Window tempwin;
int origin_x, origin_y;
XTranslateCoordinates(top_level->display,
- parent_window->win,
- win,
- 0,
- 0,
- &origin_x,
- &origin_y,
- &tempwin);
-
+ parent_window->win, win,
+ 0, 0, &origin_x, &origin_y, &tempwin);
draw_tiles(parent_window->bg_pixmap,
- origin_x,
- origin_y,
- x,
- y,
- w,
- h);
+ origin_x, origin_y,
+ x, y, w, h);
}
void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window,
- int x,
- int y,
- int w,
- int h,
- BC_Pixmap *pixmap)
+ int x, int y, int w, int h, BC_Pixmap *pixmap)
{ BT
Window tempwin;
int top_x, top_y;
XLockDisplay(top_level->display);
XTranslateCoordinates(top_level->display,
- win,
- parent_window->win,
- x,
- y,
- &top_x,
- &top_y,
- &tempwin);
+ win, parent_window->win,
+ x, y, &top_x, &top_y, &tempwin);
XCopyArea(top_level->display,
parent_window->pixmap->opaque_pixmap,
pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- top_x,
- top_y,
- w,
- h,
- x,
- y);
+ top_level->gc, top_x, top_y, w, h, x, y);
XUnlockDisplay(top_level->display);
}
void BC_WindowBase::draw_background(int x, int y, int w, int h)
{
- if(bg_pixmap)
- {
+ if( bg_pixmap ) {
draw_tiles(bg_pixmap, 0, 0, x, y, w, h);
}
- else
- {
+ else {
clear_box(x, y, w, h);
}
}
-void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap,
- int dont_wait,
- int dest_x,
- int dest_y,
- int dest_w,
- int dest_h,
- int src_x,
- int src_y,
- int src_w,
- int src_h,
+void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, int dont_wait,
+ int dest_x, int dest_y, int dest_w, int dest_h,
+ int src_x, int src_y, int src_w, int src_h,
BC_Pixmap *pixmap)
{ BT
// Hide cursor if video enabled
update_video_cursor();
//printf("BC_WindowBase::draw_bitmap %d dest_y=%d\n", __LINE__, dest_y);
- if(dest_w <= 0 || dest_h <= 0)
- {
+ if( dest_w <= 0 || dest_h <= 0 ) {
// Use hardware scaling to canvas dimensions if proper color model.
- if(bitmap->get_color_model() == BC_YUV420P)
- {
+ if( bitmap->get_color_model() == BC_YUV420P ) {
dest_w = w;
dest_h = h;
}
- else
- {
+ else {
dest_w = bitmap->get_w();
dest_h = bitmap->get_h();
}
}
- if(src_w <= 0 || src_h <= 0)
- {
+ if( src_w <= 0 || src_h <= 0 ) {
src_w = bitmap->get_w();
src_h = bitmap->get_h();
}
- if(video_on)
- {
+ if( video_on ) {
bitmap->write_drawable(win,
- top_level->gc,
- src_x,
- src_y,
- src_w,
- src_h,
- dest_x,
- dest_y,
- dest_w,
- dest_h,
- dont_wait);
+ top_level->gc, src_x, src_y, src_w, src_h,
+ dest_x, dest_y, dest_w, dest_h, dont_wait);
top_level->flush();
}
- else
- {
+ else {
bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- dest_x,
- dest_y,
- src_x,
- src_y,
- dest_w,
- dest_h,
- dont_wait);
+ top_level->gc, dest_x, dest_y, src_x, src_y, dest_w, dest_h, dont_wait);
}
//printf("BC_WindowBase::draw_bitmap 2\n");
}
{ BT
XDrawPoint(top_level->display,
pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap,
- top_level->gc,
- x,
- y);
+ top_level->gc, x, y);
}
void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap,
- int dest_x,
- int dest_y,
- int dest_w,
- int dest_h,
- int src_x,
- int src_y,
- BC_Pixmap *dst)
+ int dest_x, int dest_y, int dest_w, int dest_h,
+ int src_x, int src_y, BC_Pixmap *dst)
{ BT
pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap,
- dest_x,
- dest_y,
- dest_w,
- dest_h,
- src_x,
- src_y);
+ dest_x, dest_y, dest_w, dest_h, src_x, src_y);
}
void BC_WindowBase::draw_vframe(VFrame *frame,
- int dest_x,
- int dest_y,
- int dest_w,
- int dest_h,
- int src_x,
- int src_y,
- int src_w,
- int src_h,
- BC_Pixmap *pixmap)
+ int dest_x, int dest_y, int dest_w, int dest_h,
+ int src_x, int src_y, int src_w, int src_h,
+ BC_Pixmap *pixmap)
{
if(dest_w <= 0) dest_w = frame->get_w() - src_x;
if(dest_h <= 0) dest_h = frame->get_h() - src_y;
if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x;
if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y;
- if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this,
- dest_w,
- dest_h,
- get_color_model(),
- 0);
-
- temp_bitmap->match_params(dest_w,
- dest_h,
- get_color_model(),
- 0);
+ if( !temp_bitmap )
+ temp_bitmap = new BC_Bitmap(this, dest_w, dest_h, get_color_model(), 0);
+ temp_bitmap->match_params(dest_w, dest_h, get_color_model(), 0);
temp_bitmap->read_frame(frame,
- src_x,
- src_y,
- src_w,
- src_h,
- 0,
- 0,
- dest_w,
- dest_h);
-
- draw_bitmap(temp_bitmap,
- 0,
- dest_x,
- dest_y,
- dest_w,
- dest_h,
- 0,
- 0,
- -1,
- -1,
- pixmap);
+ src_x, src_y, src_w, src_h,
+ 0, 0, dest_w, dest_h, bg_color);
+
+ draw_bitmap(temp_bitmap, 0,
+ dest_x, dest_y, dest_w, dest_h,
+ 0, 0, -1, -1, pixmap);
}
void BC_WindowBase::draw_tooltip(const char *text)
pixmap);
}
-void BC_WindowBase::draw_3segmenth(int x,
- int y,
- int w,
- int total_x,
- int total_w,
- VFrame *image,
+void BC_WindowBase::draw_3segmenth(int x, int y, int w,
+ int total_x, int total_w, VFrame *image,
BC_Pixmap *pixmap)
{
if(total_w <= 0 || w <= 0 || h <= 0) return;
}
if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level,
- image->get_w(),
- image->get_h(),
- get_color_model(),
- 0);
- temp_bitmap->match_params(image->get_w(),
- image->get_h(),
- get_color_model(),
- 0);
+ image->get_w(), image->get_h(),
+ get_color_model(), 0);
+ temp_bitmap->match_params(image->get_w(), image->get_h(),
+ get_color_model(), 0);
temp_bitmap->read_frame(image,
- 0,
- 0,
- image->get_w(),
- image->get_h());
-
-
+ 0, 0, image->get_w(), image->get_h(), bg_color);
+// src width and height are meaningless in video_off mode
//printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n",
// left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w);
- if(left_out_w > 0)
- {
- draw_bitmap(temp_bitmap,
- 0,
- left_out_x,
- y,
- left_out_w,
- image->get_h(),
- left_in_x,
- 0,
- -1, // src width and height are meaningless in video_off mode
- -1,
- pixmap);
+ if(left_out_w > 0) {
+ draw_bitmap(temp_bitmap, 0,
+ left_out_x, y, left_out_w, image->get_h(),
+ left_in_x, 0, -1, -1, pixmap);
}
- if(right_out_w > 0)
- {
- draw_bitmap(temp_bitmap,
- 0,
- right_out_x,
- y,
- right_out_w,
- image->get_h(),
- right_in_x,
- 0,
- -1, // src width and height are meaningless in video_off mode
- -1,
- pixmap);
+ if(right_out_w > 0) {
+ draw_bitmap(temp_bitmap, 0,
+ right_out_x, y, right_out_w, image->get_h(),
+ right_in_x, 0, -1, -1, pixmap);
}
- for(int pixel = center_out_x;
- pixel < center_out_x + center_out_w;
- pixel += half_image)
- {
+ for( int pixel = center_out_x;
+ pixel < center_out_x + center_out_w;
+ pixel += half_image ) {
int fragment_w = half_image;
if(fragment_w + pixel > center_out_x + center_out_w)
fragment_w = (center_out_x + center_out_w) - pixel;
//printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w);
- draw_bitmap(temp_bitmap,
- 0,
- pixel,
- y,
- fragment_w,
- image->get_h(),
- third_image,
- 0,
- -1, // src width and height are meaningless in video_off mode
- -1,
- pixmap);
+ draw_bitmap(temp_bitmap, 0,
+ pixel, y, fragment_w, image->get_h(),
+ third_image, 0, -1, -1, pixmap);
}
}
-
-
-
-
-
-
-void BC_WindowBase::draw_3segmenth(int x,
- int y,
- int w,
- int total_x,
- int total_w,
- BC_Pixmap *src,
- BC_Pixmap *dst)
+void BC_WindowBase::draw_3segmenth(int x, int y, int w, int total_x, int total_w,
+ BC_Pixmap *src, BC_Pixmap *dst)
{
if(w <= 0 || total_w <= 0) return;
if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n");
get_color_model(),
0);
temp_bitmap->read_frame(src,
- 0,
- 0,
- src->get_w(),
- src->get_h());
+ 0, 0, src->get_w(), src->get_h(), bg_color);
if(left_out_h > 0)
}
-void BC_WindowBase::draw_9segment(int x,
- int y,
- int w,
- int h,
- VFrame *src,
- BC_Pixmap *dst)
+void BC_WindowBase::draw_9segment(int x, int y, int w, int h,
+ VFrame *src, BC_Pixmap *dst)
{
if(w <= 0 || h <= 0) return;
get_color_model(),
0);
temp_bitmap->read_frame(src,
- 0,
- 0,
- src->get_w(),
- src->get_h());
+ 0, 0, src->get_w(), src->get_h(), bg_color);
// Segment 1
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x1,
- y + out_y1,
- out_x2 - out_x1,
- out_y2 - out_y1,
- in_x1,
- in_y1,
- in_x2 - in_x1,
- in_y2 - in_y1,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x1, y + out_y1, out_x2 - out_x1, out_y2 - out_y1,
+ in_x1, in_y1, in_x2 - in_x1, in_y2 - in_y1,
dst);
-
// Segment 2 * n
- for(int i = out_x2; i < out_x3; i += in_x3 - in_x2)
- {
- if(out_x3 - i > 0)
- {
+ for( int i = out_x2; i < out_x3; i += in_x3 - in_x2 ) {
+ if( out_x3 - i > 0 ) {
int w = MIN(in_x3 - in_x2, out_x3 - i);
- draw_bitmap(temp_bitmap,
- 0,
- x + i,
- y + out_y1,
- w,
- out_y2 - out_y1,
- in_x2,
- in_y1,
- w,
- in_y2 - in_y1,
+ draw_bitmap(temp_bitmap, 0,
+ x + i, y + out_y1, w, out_y2 - out_y1,
+ in_x2, in_y1, w, in_y2 - in_y1,
dst);
}
}
-
-
-
-
// Segment 3
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x3,
- y + out_y1,
- out_x4 - out_x3,
- out_y2 - out_y1,
- in_x3,
- in_y1,
- in_x4 - in_x3,
- in_y2 - in_y1,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x3, y + out_y1, out_x4 - out_x3, out_y2 - out_y1,
+ in_x3, in_y1, in_x4 - in_x3, in_y2 - in_y1,
dst);
-
-
// Segment 4 * n
- for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
- {
- if(out_y3 - i > 0)
- {
+ for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) {
+ if( out_y3 - i > 0 ) {
int h = MIN(in_y3 - in_y2, out_y3 - i);
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x1,
- y + i,
- out_x2 - out_x1,
- h,
- in_x1,
- in_y2,
- in_x2 - in_x1,
- h,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x1, y + i, out_x2 - out_x1, h,
+ in_x1, in_y2, in_x2 - in_x1, h,
dst);
}
}
-
// Segment 5 * n * n
- for(int i = out_y2; i < out_y3; i += in_y3 - in_y2)
- {
- if(out_y3 - i > 0)
- {
+ for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) {
+ if( out_y3 - i > 0 ) {
int h = MIN(in_y3 - in_y2, out_y3 - i);
-
- for(int j = out_x2; j < out_x3; j += in_x3 - in_x2)
- {
+ for( int j = out_x2; j < out_x3; j += in_x3 - in_x2 ) {
int w = MIN(in_x3 - in_x2, out_x3 - j);
if(out_x3 - j > 0)
- draw_bitmap(temp_bitmap,
- 0,
- x + j,
- y + i,
- w,
- h,
- in_x2,
- in_y2,
- w,
- h,
+ draw_bitmap(temp_bitmap, 0,
+ x + j, y + i, w, h,
+ in_x2, in_y2, w, h,
dst);
}
}
}
// Segment 6 * n
- for(int i = out_y2; i < out_y3; i += in_y_third)
- {
- if(out_y3 - i > 0)
- {
+ for( int i = out_y2; i < out_y3; i += in_y_third ) {
+ if( out_y3 - i > 0 ) {
int h = MIN(in_y_third, out_y3 - i);
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x3,
- y + i,
- out_x4 - out_x3,
- h,
- in_x3,
- in_y2,
- in_x4 - in_x3,
- h,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x3, y + i, out_x4 - out_x3, h,
+ in_x3, in_y2, in_x4 - in_x3, h,
dst);
}
}
-
-
-
// Segment 7
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x1,
- y + out_y3,
- out_x2 - out_x1,
- out_y4 - out_y3,
- in_x1,
- in_y3,
- in_x2 - in_x1,
- in_y4 - in_y3,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x1, y + out_y3, out_x2 - out_x1, out_y4 - out_y3,
+ in_x1, in_y3, in_x2 - in_x1, in_y4 - in_y3,
dst);
-
// Segment 8 * n
- for(int i = out_x2; i < out_x3; i += in_x_third)
- {
- if(out_x3 - i > 0)
- {
+ for( int i = out_x2; i < out_x3; i += in_x_third ) {
+ if( out_x3 - i > 0 ) {
int w = MIN(in_x_third, out_x3 - i);
- draw_bitmap(temp_bitmap,
- 0,
- x + i,
- y + out_y3,
- w,
- out_y4 - out_y3,
- in_x2,
- in_y3,
- w,
- in_y4 - in_y3,
+ draw_bitmap(temp_bitmap, 0,
+ x + i, y + out_y3, w, out_y4 - out_y3,
+ in_x2, in_y3, w, in_y4 - in_y3,
dst);
}
}
-
-
// Segment 9
- draw_bitmap(temp_bitmap,
- 0,
- x + out_x3,
- y + out_y3,
- out_x4 - out_x3,
- out_y4 - out_y3,
- in_x3,
- in_y3,
- in_x4 - in_x3,
- in_y4 - in_y3,
+ draw_bitmap(temp_bitmap, 0,
+ x + out_x3, y + out_y3, out_x4 - out_x3, out_y4 - out_y3,
+ in_x3, in_y3, in_x4 - in_x3, in_y4 - in_y3,
dst);
}
-
-
-
-
-
-
-
-
#!/bin/bash -e
# inst.sh <dir> <objs...>
-cr='
-'
dir="$1"; shift 1
mkdir -p "$dir"
if [ "$*" = "*" ]; then exit; fi
for f in "$@"; do
- if [ -f "$f" ]; then ( umask 755; cp "$f" "$dir" ); continue; fi
+ if [ -f "$f" ]; then cp "$f" "$dir"; continue; fi
if [ -d "$f" ]; then ( cd $f; $inst_sh "$dir/$f" * )
else echo "*** Error - inst.sh $f in $dir failed." 1>&2; exit 1; fi
done