From a4de5b27c2ce9aca1516b13ad9c70a51f9bd06ff Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Thu, 14 May 2020 21:03:57 -0400 Subject: Resizing implemented, but there are some little artifacts and nasty library bugs that need fixing. --- ag_render.f90 | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 10 deletions(-) (limited to 'ag_render.f90') diff --git a/ag_render.f90 b/ag_render.f90 index be21112..888a83c 100644 --- a/ag_render.f90 +++ b/ag_render.f90 @@ -41,6 +41,7 @@ implicit none integer, parameter::ag_render_event_back = 3 integer, parameter::ag_render_event_go = 4 integer, parameter::ag_render_event_scroll = 5 + integer, parameter::ag_render_event_resize = 6 type :: link integer, dimension(4)::location @@ -165,13 +166,22 @@ contains end subroutine scrolled_callback + subroutine resize_callback() + use appgraphics, only: stopidle + implicit none + + ag_render_event = ag_render_event_resize + call stopidle() + + end subroutine resize_callback + subroutine draw_address_bar(self) use appgraphics implicit none type(appgraphics_renderer)::self - integer::x, address_width + integer::x, address_width, label_x self%address_bar_height = 24 @@ -181,8 +191,7 @@ contains call setcolor(BLACK) call settextstyle(WINDOWS_FONT, HORIZ_DIR, 12) - call bar(0, 0, getmaxx(), self%address_bar_height) - + ! Draw the buttons first x = getmaxx()/4 - 40 if(self%back_button_id == 0) then self%back_button_id = createbutton(x, 2, 40, 20, "Back", back_button_callback) @@ -191,7 +200,7 @@ contains end if x = x + 50 - call outtextxy(x, 5, "Address:") + label_x = x x = x + textwidth("Address:") + 5 address_width = getmaxx()/2 - textwidth("Address:") - 5 @@ -208,6 +217,11 @@ contains call setbuttonposition(self%go_button_id, x, 2, 40, 20) end if + call setviewport(0, 0, getmaxx(), self%address_bar_height, .true.) + call clearviewport() + call outtextxy(label_x, 5, "Address:") + call resetviewport() + end subroutine draw_address_bar subroutine draw_status_bar(self, text) @@ -226,7 +240,7 @@ contains call setcolor(BLACK) call settextstyle(WINDOWS_FONT, HORIZ_DIR, 12) - call bar(0, getmaxy()-self%status_bar_height, getmaxx(), getmaxy()) + call bar(0, getmaxy()-self%status_bar_height, getmaxx()+1, getmaxy()+1) call outtextxy(self%left_border+2, getmaxy()-self%status_bar_height+2, trim(text)) end subroutine draw_status_bar @@ -240,10 +254,10 @@ contains integer::h self%scroll_bar_width = 15 - h = getmaxy()-self%address_bar_height-self%status_bar_height + h = getmaxy()-self%address_bar_height-self%status_bar_height - 1 if(self%scroll_id == 0) then self%scroll_id = createscrollbar(getmaxx()-self%scroll_bar_width, & - self%address_bar_height, & + self%address_bar_height+1, & self%scroll_bar_width, & h, & SCROLL_VERTICAL, & @@ -253,13 +267,25 @@ contains else call setscrollbarposition(self%scroll_id, & getmaxx()-self%scroll_bar_width, & - self%address_bar_height, & + self%address_bar_height+1, & self%scroll_bar_width, & h) end if end subroutine draw_scroll_bar + function compute_max_width(self) + use appgraphics, only: getmaxx + implicit none + + type(appgraphics_renderer)::self + integer::compute_max_width + + compute_max_width = getmaxx() - self%left_border - & + self%right_border - self%scroll_bar_width + + end function compute_max_width + subroutine ag_initialize(self) use appgraphics implicit none @@ -272,6 +298,10 @@ contains call setwindowclosecallback(window_closing_callback) call registermousehandler(MOUSE_LB_UP, mouse_button_callback) + call enableresize(resize_callback) + + call setbkcolor(LIGHTGRAY) + call clearviewport() self%address_id = 0 self%go_button_id = 0 @@ -286,7 +316,7 @@ contains self%text_color = BLACK self%link_color = BLUE - self%max_width = getmaxx() + self%max_width = compute_max_width(self) self%font_size = default_font_size self%default_font = SERIF_FONT self%line_spacing = 2 @@ -613,7 +643,8 @@ contains function ag_action(self, text) use render, only: render_action_none, render_action_layout, & - render_action_goto, render_action_quit + render_action_goto, render_action_quit, & + idle_status implicit none class(appgraphics_renderer)::self @@ -625,6 +656,11 @@ contains ! For scrolling integer::doclength + ! Resize can be laggy, so ensure it actually was finalized + if(self%max_width /= compute_max_width(self)) then + ag_render_event = ag_render_event_resize + end if + if(ag_render_event == ag_render_event_none) then call startidle(10000) end if @@ -655,6 +691,20 @@ contains doclength = self%y - self%initial_y self%y = (doclength * scroll_position) / (-100) ag_action = render_action_layout + + case(ag_render_event_resize) + + ! Effectively have to redraw everything + call draw_address_bar(self) + call draw_status_bar(self, idle_status) + call draw_scroll_bar(self) + call setscrollposition(self%scroll_id, 0) + + ! Need to recompute the max width for the layout engine + self%max_width = compute_max_width(self) + self%y = 0 + + ag_action = render_action_layout end select -- cgit v1.2.3