X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcscrollbar.C;h=680341d0beebf0e990e1b74a5bf42c62670e9473;hb=b55798fc64eee00c6fab3b4763e791befb7275f9;hp=8bfbc735bede5f782df24b160a156965a92cdc13;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bcscrollbar.C b/cinelerra-5.1/guicast/bcscrollbar.C index 8bfbc735..680341d0 100644 --- a/cinelerra-5.1/guicast/bcscrollbar.C +++ b/cinelerra-5.1/guicast/bcscrollbar.C @@ -2,39 +2,34 @@ /* * CINELERRA * Copyright (C) 2011 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program 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 General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "bcpixmap.h" #include "bcresources.h" #include "bcscrollbar.h" #include "clip.h" -#include "colors.h" +#include "bccolors.h" #include "vframe.h" #include -BC_ScrollBar::BC_ScrollBar(int x, - int y, - int orientation, - int pixels, - int64_t length, - int64_t position, - int64_t handlelength, +BC_ScrollBar::BC_ScrollBar(int x, int y, int orientation, int pixels, + int64_t length, int64_t position, int64_t handlelength, VFrame **data) : BC_SubWindow(x, y, 0, 0, -1) { @@ -43,16 +38,15 @@ BC_ScrollBar::BC_ScrollBar(int x, this->handlelength = handlelength; this->selection_status = 0; this->highlight_status = 0; + this->stretch = orientation & SCROLL_STRETCH ? 1 : 0; + orientation &= ~SCROLL_STRETCH; this->orientation = orientation; this->pixels = pixels; - if(data) - this->data = data; - else - if(orientation == SCROLL_HORIZ) - this->data = BC_WindowBase::get_resources()->hscroll_data; - else - this->data = BC_WindowBase::get_resources()->vscroll_data; + if( !data ) data = orientation == SCROLL_HORIZ ? + BC_WindowBase::get_resources()->hscroll_data : + BC_WindowBase::get_resources()->vscroll_data ; + this->data = data; handle_pixel = 0; handle_pixels = 0; @@ -90,8 +84,6 @@ void BC_ScrollBar::set_images(VFrame **data) calculate_dimensions(w, h); } - - void BC_ScrollBar::calculate_dimensions(int &w, int &h) { switch(orientation) @@ -125,30 +117,18 @@ int BC_ScrollBar::get_span(int orientation) int BC_ScrollBar::get_span() { - switch(orientation) - { - case SCROLL_HORIZ: - return data[SCROLL_HANDLE_UP]->get_h(); - break; - - case SCROLL_VERT: - return data[SCROLL_HANDLE_UP]->get_w(); - break; + switch(orientation) { + case SCROLL_HORIZ: return data[SCROLL_HANDLE_UP]->get_h(); + case SCROLL_VERT: return data[SCROLL_HANDLE_UP]->get_w(); } return 0; } int BC_ScrollBar::get_arrow_pixels() { - switch(orientation) - { - case SCROLL_HORIZ: - return data[SCROLL_BACKARROW_UP]->get_w(); - break; - - case SCROLL_VERT: - return data[SCROLL_BACKARROW_UP]->get_h(); - break; + switch(orientation) { + case SCROLL_HORIZ: return data[SCROLL_BACKARROW_UP]->get_w(); + case SCROLL_VERT: return data[SCROLL_BACKARROW_UP]->get_h(); } return 0; } @@ -168,8 +148,8 @@ void BC_ScrollBar::draw(int flush) // Too small to draw anything if(get_w() < get_arrow_pixels() * 2 + 5) { - draw_3segmenth(0, - 0, + draw_3segmenth(0, + 0, get_w(), images[SCROLL_HANDLE_UP]); } @@ -268,8 +248,8 @@ void BC_ScrollBar::draw(int flush) // Too small to draw anything if(get_h() < get_arrow_pixels() * 2 + 5) { - draw_3segmentv(0, - 0, + draw_3segmentv(0, + 0, get_w(), images[SCROLL_HANDLE_UP]); } @@ -362,23 +342,23 @@ void BC_ScrollBar::draw(int flush) void BC_ScrollBar::get_handle_dimensions() { - int total_pixels = pixels - + int total_pixels = pixels - get_arrow_pixels() * 2; if(length > 0) { - handle_pixels = (int64_t)((double)handlelength / - length * - total_pixels + + handle_pixels = (int64_t)((double)handlelength / + length * + total_pixels + .5); if(handle_pixels < get_resources()->scroll_minhandle) handle_pixels = get_resources()->scroll_minhandle; - handle_pixel = (int64_t)((double)position / - length * - total_pixels + .5) + + handle_pixel = (int64_t)((double)position / + length * + total_pixels + .5) + get_arrow_pixels(); // Handle pixels is beyond minimum right position. Clamp it. @@ -408,8 +388,8 @@ void BC_ScrollBar::get_handle_dimensions() CLAMP(handle_pixel, get_arrow_pixels(), (int)(pixels - get_arrow_pixels())); CLAMP(handle_pixels, 0, total_pixels); -// printf("BC_ScrollBar::get_handle_dimensions %d %d %d\n", -// total_pixels, +// printf("BC_ScrollBar::get_handle_dimensions %d %d %d\n", +// total_pixels, // handle_pixel, // handle_pixels); } @@ -420,7 +400,7 @@ int BC_ScrollBar::cursor_enter_event() { if(!highlight_status) { - highlight_status = get_cursor_zone(top_level->cursor_x, + highlight_status = get_cursor_zone(top_level->cursor_x, top_level->cursor_y); draw(1); } @@ -445,7 +425,7 @@ int BC_ScrollBar::cursor_motion_event() { if(highlight_status && !selection_status) { - int new_highlight_status = + int new_highlight_status = get_cursor_zone(top_level->cursor_x, top_level->cursor_y); if(new_highlight_status != highlight_status) { @@ -458,14 +438,14 @@ int BC_ScrollBar::cursor_motion_event() { //printf("BC_ScrollBar::cursor_motion_event 1\n"); double total_pixels = pixels - get_arrow_pixels() * 2; - int64_t cursor_pixel = (orientation == SCROLL_HORIZ) ? - top_level->cursor_x : + int64_t cursor_pixel = (orientation == SCROLL_HORIZ) ? + top_level->cursor_x : top_level->cursor_y; - int64_t new_position = (int64_t)((double)(cursor_pixel - min_pixel) / + int64_t new_position = (int64_t)((double)(cursor_pixel - min_pixel) / total_pixels * length); //printf("BC_ScrollBar::cursor_motion_event 2\n"); - if(new_position > length - handlelength) + if(new_position > length - handlelength) new_position = length - handlelength; if(new_position < 0) new_position = 0; @@ -533,7 +513,7 @@ int BC_ScrollBar::button_press_event() int BC_ScrollBar::repeat_event(int64_t duration) { - if(duration == top_level->get_resources()->scroll_repeat && + if(duration == top_level->get_resources()->scroll_repeat && selection_status) { //printf("BC_ScrollBar::repeat_event %d %d\n", __LINE__, (int)repeat_count); @@ -664,6 +644,7 @@ int BC_ScrollBar::update_value(int64_t value) int BC_ScrollBar::update_length(int64_t length, int64_t position, int64_t handlelength, int flush) { + if( stretch ) length += handlelength/4; this->length = length; this->position = position; this->handlelength = handlelength;