Merged toolbar conflict.

This commit is contained in:
Ole Loots 2013-01-31 19:53:11 +01:00
parent 0703404654
commit 42054fabf0

View File

@ -269,73 +269,10 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
assert(init == true);
<<<<<<< HEAD
t = calloc(sizeof(struct s_toolbar), 1);
=======
static
void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
{
LGRECT work;
short pxy[4];
short mx, my, mb, kstat;
int old;
graf_mkstate( &mx, &my, &mb, &kstat );
struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
assert( gw != NULL );
CMP_TOOLBAR tb = gw->root->toolbar;
mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
mx = evnt.mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
my = evnt.my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
/* TODO: reset mouse state of browser window? */
/* select whole text when newly focused, otherwise set caret to end of text */
if( !window_url_widget_has_focus(gw) ) {
window_set_focus( gw, URL_WIDGET, (void*)&tb->url );
} else {
if( mb & 1 ) {
textarea_mouse_action( tb->url.textarea, BROWSER_MOUSE_DRAG_1,
mx, my );
short prev_x = mx;
short prev_y = my;
do{
if( abs(prev_x-mx) > 5 || abs(prev_y-my) > 5 ){
textarea_mouse_action( tb->url.textarea,
BROWSER_MOUSE_HOLDING_1, mx, my );
prev_x = mx;
prev_y = my;
if( tb->url.redraw ){
tb_url_redraw( gw );
}
}
graf_mkstate( &mx, &my, &mb, &kstat );
mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
}while( mb & 1 );
textarea_mouse_action( tb->url.textarea, BROWSER_MOUSE_HOVER, mx, my );
} else {
/* TODO: recognize click + shift key */
int mstate = BROWSER_MOUSE_PRESS_1;
if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 )
mstate = BROWSER_MOUSE_MOD_1;
if( evnt.nb_click == 2 ){
textarea_mouse_action( tb->url.textarea,
BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1,
mx, my );
} else {
textarea_mouse_action( tb->url.textarea,
BROWSER_MOUSE_PRESS_1, mx, my );
}
}
}
// TODO: do not send an complete redraw!
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
}
>>>>>>> master
assert(t);
<<<<<<< HEAD
/* initialize the toolbar values: */
t->owner = owner;
t->style = 1;
@ -345,183 +282,6 @@ void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
/* dublicate the form template: */
t->form = gemtk_obj_tree_copy(aes_toolbar);
=======
void tb_adjust_size( struct gui_window * gw )
{
LGRECT work;
CMP_TOOLBAR t = gw->root->toolbar;
mt_CompGetLGrect( &app, t->url.comp, WF_WORKXYWH, &work);
work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
/* do not overwrite the black border, because of that, add 1 */
work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
textarea_set_dimensions( t->url.textarea, work.g_w, work.g_h );
tb_txt_request_redraw( t, 0,0, work.g_w-1, work.g_h-1);
}
static void __CDECL evnt_toolbar_redraw( COMPONENT *c, long buff[8], void *data )
{
LGRECT work, clip;
short pxy[4];
const plot_style_t plot_style_background = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = toolbar_bg_color,
.stroke_type = PLOT_OP_TYPE_NONE
};
mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
clip = work;
if( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
if( work.g_y + work.g_h != clip.g_y + clip.g_h ) return;
vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
vsl_color(atari_plot_vdi_handle, BLACK );
vsl_type(atari_plot_vdi_handle, 1 );
vsl_width(atari_plot_vdi_handle, 1 );
pxy[0] = clip.g_x;
pxy[1] = pxy[3] = work.g_y + work.g_h-1 ;
pxy[2] = clip.g_x + clip.g_w;
v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
}
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
{
LGRECT work;
if( data == NULL )
return;
CMP_TOOLBAR t = data;
if( t->url.redraw == false ){
t->url.redraw = true;
//t->redraw = true;
t->url.rdw_area.g_x = x;
t->url.rdw_area.g_y = y;
t->url.rdw_area.g_w = w;
t->url.rdw_area.g_h = h;
} else {
/* merge the redraw area to the new area.: */
int newx1 = x+w;
int newy1 = y+h;
int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
}
}
static void tb_txt_callback(void *data, struct textarea_msg *msg)
{
switch (msg->type) {
case TEXTAREA_MSG_DRAG_REPORT:
break;
case TEXTAREA_MSG_REDRAW_REQUEST:
tb_txt_request_redraw(data,
msg->data.redraw.x0, msg->data.redraw.y0,
msg->data.redraw.x1 - msg->data.redraw.x0,
msg->data.redraw.y1 - msg->data.redraw.y0);
break;
default:
break;
}
}
void tb_url_redraw( struct gui_window * gw )
{
CMP_TOOLBAR t = gw->root->toolbar;
if (t != NULL) {
if( t->url.redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
const struct redraw_context ctx = {
.interactive = true,
.background_images = true,
.plot = &atari_plotters
};
short todo[4];
LGRECT work;
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
work.g_x += TOOLBAR_URL_MARGIN_RIGHT;
work.g_y += TOOLBAR_URL_MARGIN_LEFT;
work.g_w -= TOOLBAR_URL_MARGIN_RIGHT;
work.g_h -= TOOLBAR_URL_MARGIN_BOTTOM;
plot_set_dimensions( work.g_x, work.g_y, work.g_w, work.g_h );
if(plot_lock() == false)
return;
todo[0] = work.g_x;
todo[1] = work.g_y;
todo[2] = todo[0] + work.g_w-1;
todo[3] = todo[1] + work.g_h-1;
vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
/* convert screen to relative coords: */
todo[0] = todo[0] - work.g_x;
todo[1] = todo[1] - work.g_y;
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
}
if( todo[1] < 0 ){
todo[3] = todo[3] + todo[1];
todo[1] = 0;
}
if (rc_intersect(&t->url.rdw_area,(GRECT *)&todo)) {
struct rect clip = {
.x0 = todo[0],
.y0 = todo[1],
.x1 = todo[0]+todo[2],
.y1 = todo[1]+todo[3]
};
textarea_redraw( t->url.textarea, 0, 0, 0xffffff, &clip, &ctx );
}
if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
}
} else {
plot_unlock();
return;
}
plot_unlock();
vs_clip(atari_plot_vdi_handle, 0, (short*)&todo);
t->url.redraw = false;
t->url.rdw_area.g_x = 65000;
t->url.rdw_area.g_y = 65000;
t->url.rdw_area.g_w = -1;
t->url.rdw_area.g_h = -1;
} else {
/* just copy stuff from the offscreen buffer */
}
}
}
CMP_TOOLBAR tb_create( struct gui_window * gw )
{
int i;
CMP_TOOLBAR t = malloc( sizeof(struct s_toolbar) );
if( t == NULL )
return( NULL );
t->owner = gw;
t->style = 1;
>>>>>>> master
/* count buttons and add them as components: */
@ -540,41 +300,10 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
font_style_url.size =
toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
<<<<<<< HEAD
toolbar_get_grect(t, TOOLBAR_AREA_URL, &url_area);
url_area.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
t->url.textarea = textarea_create(300, url_area.g_h, 0, &font_style_url,
tb_txt_request_redraw, t);
=======
int ta_height = toolbar_styles[t->style].height;
ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
textarea_setup ta_setup;
ta_setup.flags = TEXTAREA_INTERNAL_CARET;
ta_setup.width = 300;
ta_setup.height = ta_height;
ta_setup.pad_top = 0;
ta_setup.pad_right = 4;
ta_setup.pad_bottom = 0;
ta_setup.pad_left = 4;
ta_setup.border_width = 1;
ta_setup.border_col = 0x000000;
ta_setup.selected_text = 0xffffff;
ta_setup.selected_bg = 0x000000;
ta_setup.text = font_style_url;
ta_setup.text.foreground = 0x000000;
ta_setup.text.background = 0xffffff;
t->url.textarea = textarea_create( &ta_setup, tb_txt_callback, t );
if( t->url.textarea != NULL ){
textarea_set_text(t->url.textarea, "http://");
}
t->url.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
toolbar_styles[t->style].height, 1);
mt_CompEvntDataAttach( &app, t->url.comp, WM_REDRAW, evnt_url_redraw, t);
mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
mt_CompAttach( &app, t->comp, t->url.comp );
>>>>>>> master
/* create the throbber widget: */
t->throbber.index = THROBBER_INACTIVE_INDEX;