void bar_widget::handle_draw() const { int x_offset = x(); { color_save_context color_saver; // draw color under end caps. graphics::draw_rect(rect(x()+scale_, y()+scale_, left_cap_width_-2*scale_, height()-2*scale_), graphics::color(bar_color_)); graphics::draw_rect(rect(x()+left_cap_width_+total_bar_length_, y()+scale_, right_cap_width_-scale_, height()-2*scale_), graphics::color(drained_segments_ ? drained_bar_color_ : bar_color_)); // background for active segments. int anim_offset = animation_current_position_*scale_; graphics::draw_rect(rect(x()+left_cap_width_, y(), active_bar_length_+anim_offset, height()), graphics::color(bar_color_)); // background for drained segments. if(drained_segments_ || animating_) { graphics::draw_rect(rect(x()+active_bar_length_+left_cap_width_+anim_offset, y(), drained_bar_length_-anim_offset, height()), graphics::color(drained_bar_color_)); } draw_ticks(x()+left_cap_width_, segments_-drained_segments_+(drained_segments_?1:0), tick_mark_color_); draw_ticks(x()+left_cap_width_+active_bar_length_, drained_segments_, drained_tick_mark_color_); } // left cap if(left_cap_.area.w() == 0) { graphics::blit_texture(left_cap_.texture, x_offset, y(), left_cap_width_, height(), rotate_); } else { graphics::blit_texture(left_cap_.texture, x_offset, y(), left_cap_width_, height(), rotate_, GLfloat(left_cap_.area.x())/left_cap_.texture.width(), GLfloat(left_cap_.area.y())/left_cap_.texture.height(), GLfloat(left_cap_.area.x2())/left_cap_.texture.width(), GLfloat(left_cap_.area.y2())/left_cap_.texture.height()); } x_offset += left_cap_width_; // bar if(bar_.area.w() == 0) { graphics::blit_texture(bar_.texture, x_offset, y(), total_bar_length_, height(), rotate_); } else { graphics::blit_texture(bar_.texture, x_offset, y(), total_bar_length_, height(), rotate_, GLfloat(bar_.area.x())/bar_.texture.width(), GLfloat(bar_.area.y())/bar_.texture.height(), GLfloat(bar_.area.x2())/bar_.texture.width(), GLfloat(bar_.area.y2())/bar_.texture.height()); } x_offset += total_bar_length_; // right cap if(right_cap_.area.w() == 0) { graphics::blit_texture(left_cap_.texture, x_offset, y(), right_cap_width_, height(), rotate_); } else { graphics::blit_texture(right_cap_.texture, x_offset, y(), right_cap_width_, height(), rotate_, GLfloat(right_cap_.area.x())/right_cap_.texture.width(), GLfloat(right_cap_.area.y())/right_cap_.texture.height(), GLfloat(right_cap_.area.x2())/right_cap_.texture.width(), GLfloat(right_cap_.area.y2())/right_cap_.texture.height()); } }
int GraphicGUI::resize_event(int w, int h) { int difference = h - get_h(); int canvas_xdiff = get_w() - canvas->get_w(); int canvas_ydiff = get_h() - canvas->get_h(); canvas->reposition_window(canvas->get_x(), canvas->get_y(), w - canvas_xdiff, h - canvas_ydiff); freq_text->reposition_window(freq_text->get_x(), freq_text->get_y() + difference); value_text->reposition_window(value_text->get_x(), value_text->get_y() + difference); freq_title->reposition_window(freq_title->get_x(), freq_title->get_y() + difference); level_title->reposition_window(level_title->get_x(), level_title->get_y() + difference); size_title->reposition_window(size_title->get_x(), size_title->get_y() + difference); reset->reposition_window(reset->get_x(), reset->get_y() + difference); size->reposition_window(size->get_x(), size->get_y() + difference); draw_ticks(); update_canvas(); flash(); plugin->w = w; plugin->h = h; plugin->send_configure_change(); return 1; }
void GraphicGUI::create_objects() { int margin = plugin->get_theme()->widget_border; int x = get_text_width(SMALLFONT, "-00") + LINE_W4 + margin; int y = margin; int freq_h = get_text_height(SMALLFONT) + LINE_W4; add_subwindow(canvas = new GraphicCanvas(plugin, this, x, y, get_w() - x - margin, get_h() - // BC_Pot::calculate_h() - BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) - margin * 3 - y - freq_h)); y += canvas->get_h() + freq_h + margin; int x1 = x; int y1 = y; add_subwindow(freq_title = new BC_Title(x, y, "Frequency:")); x += freq_title->get_w() + margin; add_subwindow(freq_text = new FreqTextBox(plugin, this, x, y, 100)); x += freq_text->get_w() + margin; add_subwindow(level_title = new BC_Title(x, y, "Level:")); x += level_title->get_w() + margin; add_subwindow(value_text = new ValueTextBox(plugin, this, x, y, 100)); x += value_text->get_w() + margin; add_subwindow(reset = new GraphicReset(plugin, this, x, y)); x += reset->get_w() + margin; // x = x1; // y += value_text->get_h() + margin; add_subwindow(size_title = new BC_Title(x, y, "Window size:")); x += size_title->get_w() + margin; add_subwindow(size = new GraphicSize(this, plugin, x, y)); size->create_objects(); size->update(plugin->config.window_size); x += size->get_w() + margin; // add_subwindow(title = new BC_Title(x, y, "Wetness:")); // x += title->get_w() + margin; // add_subwindow(wetness = new GraphicWetness(this, plugin, // x, // y)); draw_ticks(); update_canvas(); show_window(); }
static void analog_update_proc(Layer *layer, GContext *ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); // Draw ticks behind draw_ticks(layer, ctx); // minute/hour hand graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_context_set_antialiased(ctx, true); gpath_rotate_to(minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_rotate_to(minute_fill, TRIG_MAX_ANGLE * t->tm_min / 60); gpath_rotate_to(hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6)); gpath_rotate_to(hour_fill, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6)); // Draw minute hand background graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 6); gpath_draw_outline(ctx, minute_arrow); // Draw minute hand foreground graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_width(ctx, 3); gpath_draw_outline(ctx, minute_arrow); gpath_draw_filled(ctx, minute_fill); // Draw hour hand background graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 6); gpath_draw_outline(ctx, hour_arrow); // Draw hour hand foreground graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_width(ctx, 3); gpath_draw_outline(ctx, hour_arrow); gpath_draw_filled(ctx, hour_fill); // Draw a black peg in the center graphics_context_set_antialiased(ctx, false); graphics_context_set_fill_color(ctx, GColorBlack); graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 1); gpath_draw_filled(ctx, peg_fill); }
static void do_movemag(int x, int y) { int xx, yy; mag_x = x; mag_y = y; if (mag_x == new_mag_x && mag_y == new_mag_y) globals.ev.flags &= ~EV_MAG_MOVE; compute_mag_pos(&xx, &yy); XMoveWindow(DISP, magnifier.win, xx, yy); scroll_window(&magnifier, (x + mane_base_x) * mane.shrinkfactor - (int)magnifier.width / 2, (y + mane_base_y) * mane.shrinkfactor - (int)magnifier.height / 2); draw_ticks(magnifier.width, magnifier.height, globals.gc.ruler); }
void magnifier_move(String params, XEvent *event) { int x, y; XSetWindowAttributes attr; #ifndef MOTIF Window throwaway; #endif const char *p = params; if (*p == '*') { int n = atoi(p + 1) - 1; if (n < 0 || n >= (int)get_magglass_items() || get_magglass_width(n) <= 0) { XdviBell(DISP, event->xany.window, 0); return; } magnifier.width = get_magglass_width(n); magnifier.height = get_magglass_height(n); } else { magnifier.width = magnifier.height = atoi(p); p = strchr(p, 'x'); if (p != NULL) { magnifier.height = atoi(p + 1); if (magnifier.height == 0) magnifier.width = 0; } if (magnifier.width == 0) { XdviBell(DISP, event->xany.window, 0); return; } } #ifndef MOTIF XTranslateCoordinates(DISP, event->xbutton.window, mane.win, 0, 0, &mag_conv_x, &mag_conv_y, &throwaway); #endif mag_x = event->xbutton.x + mag_conv_x; mag_y = event->xbutton.y + mag_conv_y; main_x = event->xbutton.x_root - mag_x; main_y = event->xbutton.y_root - mag_y; compute_mag_pos(&x, &y); magnifier.base_x = (mag_x + mane_base_x) * mane.shrinkfactor - magnifier.width / 2; magnifier.base_y = (mag_y + mane_base_y) * mane.shrinkfactor - magnifier.height / 2; attr.save_under = True; attr.border_pixel = resource.rule_pixel; #if COLOR attr.background_pixel = bg_current->pixel; #else attr.background_pixel = resource.back_Pixel; #endif attr.override_redirect = True; #ifdef GREY attr.colormap = G_colormap; #endif magnifier.win = XCreateWindow(DISP, RootWindowOfScreen(SCRN), x, y, magnifier.width, magnifier.height, MAGBORD, G_depth, InputOutput, G_visual, CWSaveUnder | CWBorderPixel | CWBackPixel | #ifdef GREY CWColormap | #endif CWOverrideRedirect, &attr); XSelectInput(DISP, magnifier.win, ExposureMask); XMapWindow(DISP, magnifier.win); /* * This call will draw the point rulers when the magnifier first pops up, * if the XDvi*delayRulers resource is false. Some users may prefer rulers * to remain invisible until the magnifier is moved, so the default is * true. Rulers can be suppressed entirely by setting the XDvi*tickLength * resource to zero or negative. */ if (!resource.delay_rulers) draw_ticks(magnifier.width, magnifier.height, globals.gc.ruler); globals.cursor.flags |= CURSOR_MAG; globals.ev.flags |= EV_CURSOR; magnifier_stat = 1; /* waiting for exposure */ mouse_motion = mag_motion; mouse_release = mag_release; }
static void ticks_update_proc(Layer *layer, GContext *ctx) { draw_ticks(ctx, center, tick_radius, 60, 5, 1); }
void Fl_Slider::draw() { // figure out the inner size of the box: Fl_Boxtype box = this->box(); int ix = 0, iy = 0, iw = w(), ih = h(); box->inset(ix,iy,iw,ih); // figure out where to draw the slider, leaving room for tick marks: int sx = ix, sy = iy, sw = iw, sh = ih; if (tick_size_ && (type()&TICK_BOTH)) { if (horizontal()) { sh -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sy += tick_size_/2; break; case TICK_ABOVE: sy += tick_size_; break; } } else { sw -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sx += tick_size_/2; break; case TICK_ABOVE: sx += tick_size_; break; } } } Fl_Flags flags = 0; if (!active_r()) { flags.set(FL_INACTIVE); } else { if (Fl::pushed() == this) flags.set(FL_VALUE); if (belowmouse()) flags.set(FL_HIGHLIGHT); } if(!(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT)) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // minimal-update the slider, if it indicates the background needs // to be drawn, draw that. We draw the slot if the current box type // has no border: if (draw(sx, sy, sw, sh, flags, iy==0)) { if(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // draw the focus indicator inside the box: if (focused()) { focus_box()->draw(ix+1, iy+1, iw-2, ih-2, label_color(), FL_INVISIBLE); } if (type() & TICK_BOTH) { if (horizontal()) { switch (type()&TICK_BOTH) { case TICK_ABOVE: ih = sy+sh/2-iy; break; case TICK_BELOW: ih += iy; iy = sy+sh/2+(iy?0:3); ih -= iy; break; } } else { switch (type()&TICK_BOTH) { case TICK_ABOVE: iw = sx+sw/2-ix; break; case TICK_BELOW: iw += ix; ix = sx+sw/2+(iy?0:3); iw -= ix; break; } } Fl_Color color = text_color(); if (!active_r()) color = fl_inactive(color); fl_color(color); draw_ticks(ix, iy, iw, ih, (slider_size_+1)/2); } fl_pop_clip(); } }