/*
* ion/ioncore/frame-draw.c
*
- * Copyright (c) Tuomo Valkonen 1999-2006.
+ * Copyright (c) Tuomo Valkonen 1999-2007.
*
* Ion is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
#include "framep.h"
#include "frame-draw.h"
#include "strings.h"
+#include "activity.h"
#include "names.h"
#include "gr.h"
+#include "gr-util.h"
#define BAR_INSIDE_BORDER(FRAME) \
#define BAR_H(FRAME) (FRAME)->bar_h
+/*{{{ Attributes */
+
+
+GR_DEFATTR(active);
+GR_DEFATTR(inactive);
+GR_DEFATTR(selected);
+GR_DEFATTR(unselected);
+GR_DEFATTR(tagged);
+GR_DEFATTR(not_tagged);
+GR_DEFATTR(dragged);
+GR_DEFATTR(not_dragged);
+GR_DEFATTR(activity);
+GR_DEFATTR(no_activity);
+GR_DEFATTR(quasiactive);
+GR_DEFATTR(not_quasiactive);
+
+
+static void ensure_create_attrs()
+{
+ GR_ALLOCATTR_BEGIN;
+ GR_ALLOCATTR(active);
+ GR_ALLOCATTR(inactive);
+ GR_ALLOCATTR(selected);
+ GR_ALLOCATTR(unselected);
+ GR_ALLOCATTR(tagged);
+ GR_ALLOCATTR(not_tagged);
+ GR_ALLOCATTR(dragged);
+ GR_ALLOCATTR(not_dragged);
+ GR_ALLOCATTR(no_activity);
+ GR_ALLOCATTR(activity);
+ GR_ALLOCATTR(quasiactive);
+ GR_ALLOCATTR(not_quasiactive);
+ GR_ALLOCATTR_END;
+}
+
+
+void frame_update_attr(WFrame *frame, int i, WRegion *reg)
+{
+ GrStyleSpec *spec;
+ bool selected, tagged, dragged, activity;
+
+ if(i>=frame->titles_n){
+ /* Might happen when deinitialising */
+ return;
+ }
+
+ ensure_create_attrs();
+
+ spec=&frame->titles[i].attr;
+
+ selected=(reg==FRAME_CURRENT(frame));
+ tagged=(reg!=NULL && reg->flags®ION_TAGGED);
+ dragged=(i==frame->tab_dragged_idx);
+ activity=(reg!=NULL && region_is_activity_r(reg));
+
+ gr_stylespec_unalloc(spec);
+ gr_stylespec_set(spec, selected ? GR_ATTR(selected) : GR_ATTR(unselected));
+ gr_stylespec_set(spec, tagged ? GR_ATTR(tagged) : GR_ATTR(not_tagged));
+ gr_stylespec_set(spec, dragged ? GR_ATTR(dragged) : GR_ATTR(not_dragged));
+ gr_stylespec_set(spec, activity ? GR_ATTR(activity) : GR_ATTR(no_activity));
+}
+
+
+/*}}}*/
+
+
/*{{{ (WFrame) dynfun default implementations */
uint off;
if(BAR_INSIDE_BORDER(frame)){
- off=get_spacing(frame);
+ off=0; /*get_spacing(frame);*/
frame_border_inner_geom(frame, geom);
}else{
off=0;
frame_border_inner_geom(frame, geom);
+ /*
geom->x+=spacing;
geom->y+=spacing;
geom->w-=2*spacing;
geom->h-=2*spacing;
+ */
if(BAR_INSIDE_BORDER(frame) && BAR_EXISTS(frame)){
geom->y+=frame->bar_h+spacing;
if(FRAME_MCOUNT(frame)==0){
textw=init_title(frame, i);
if(textw>0){
- title=grbrush_make_label(frame->bar_brush, CF_STR_EMPTY, textw);
+ title=grbrush_make_label(frame->bar_brush, TR("<empty frame>"),
+ textw);
frame->titles[i].text=title;
}
return;
}
+static void set_common_attrs(const WFrame *frame, GrBrush *brush)
+{
+ ensure_create_attrs();
+
+ grbrush_set_attr(brush, REGION_IS_ACTIVE(frame)
+ ? GR_ATTR(active)
+ : GR_ATTR(inactive));
+ grbrush_set_attr(brush, frame->quasiactive_count>0
+ ? GR_ATTR(quasiactive)
+ : GR_ATTR(not_quasiactive));
+}
+
+
void frame_draw_bar(const WFrame *frame, bool complete)
{
WRectangle geom;
- const char *cattr=(REGION_IS_ACTIVE(frame)
- ? "active" : "inactive");
if(frame->bar_brush==NULL
|| !BAR_EXISTS(frame)
grbrush_begin(frame->bar_brush, &geom, GRBRUSH_AMEND);
+ set_common_attrs(frame, frame->bar_brush);
+
grbrush_draw_textboxes(frame->bar_brush, &geom, frame->titles_n,
- frame->titles, complete, cattr);
+ frame->titles, complete);
grbrush_end(frame->bar_brush);
}
-
void frame_draw(const WFrame *frame, bool complete)
{
WRectangle geom;
- const char *attr=(REGION_IS_ACTIVE(frame)
- ? "active" : "inactive");
if(frame->brush==NULL)
return;
-
+
frame_border_geom(frame, &geom);
grbrush_begin(frame->brush, &geom, (complete ? 0 : GRBRUSH_NO_CLEAR_OK));
- grbrush_draw_border(frame->brush, &geom, attr);
+ set_common_attrs(frame, frame->brush);
+
+ grbrush_draw_border(frame->brush, &geom);
+
frame_draw_bar(frame, TRUE);
grbrush_end(frame->brush);
}
+void frame_setup_dragwin_style(WFrame *frame, GrStyleSpec *spec, int tab)
+{
+ gr_stylespec_append(spec, &frame->titles[tab].attr);
+
+ gr_stylespec_set(spec, REGION_IS_ACTIVE(frame)
+ ? GR_ATTR(active)
+ : GR_ATTR(inactive));
+ gr_stylespec_set(spec, frame->quasiactive_count>0
+ ? GR_ATTR(quasiactive)
+ : GR_ATTR(not_quasiactive));
+}
+
+
/*}}}*/
+