From ad31584d71c4572edf9bb7f43f82239a9654d339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BD=80=29?= Date: Wed, 5 May 2021 08:56:38 +0900 Subject: [PATCH] ADD: sort order switching button --- gui/components/gui_button.cc | 46 ++++++++++++++++++++++++++++++++++++ gui/components/gui_button.h | 3 +++ 2 files changed, 49 insertions(+) diff --git a/gui/components/gui_button.cc b/gui/components/gui_button.cc index ef6961c7d0..2fc24fb8bc 100644 --- a/gui/components/gui_button.cc +++ b/gui/components/gui_button.cc @@ -125,6 +125,14 @@ void button_t::set_typ(enum type t) img = IMG_EMPTY; break; + case sortarrow: + { + const uint8 block_height = 2; + const uint8 bars_height = uint8((size.h-block_height-4)/4) * block_height*2 + block_height; + set_size( scr_size(max(D_BUTTON_HEIGHT, (gui_theme_t::gui_color_button_text_offset.w+4)*2 + 6/*arrow width(5)+margin(1)*/+block_height + (bars_height-2)/2), max(D_BUTTON_HEIGHT, LINESPACE)) ); + break; + } + default: break; } @@ -196,6 +204,13 @@ scr_size button_t::get_min_size() const return size; } + case sortarrow: + { + const uint8 block_height = 2; + const uint8 bars_height = uint8((size.h-block_height-4)/4) * block_height*2 + block_height; + return scr_size( max( D_BUTTON_HEIGHT, (gui_theme_t::gui_color_button_text_offset.w+4)*2 + 6/*arrow width(5)+margin(1)*/+block_height + (bars_height-2)/2 ), max(D_BUTTON_HEIGHT, LINESPACE) ); + } + default: return gui_component_t::get_min_size(); } @@ -381,6 +396,36 @@ void button_t::draw(scr_coord offset) } break; + case sortarrow: + { + display_img_stretch(gui_theme_t::button_tiles[0], area); + + const uint8 block_height = 2; + const uint8 bars_height = uint8((size.h-block_height-4)/4)*block_height*2 + block_height; + scr_rect area_drawing(area.x, area.y, 6/*arrow width(5)+margin(1)*/+block_height+(bars_height-2)/2, bars_height); + area_drawing.set_pos(gui_theme_t::gui_color_button_text_offset + area.get_pos() + scr_coord(4/*left margin*/,D_GET_CENTER_ALIGN_OFFSET(bars_height,size.h))); + + // draw an arrow + display_fillbox_wh_clip_rgb(area_drawing.x+2, area_drawing.y, 1, bars_height, SYSCOL_BUTTON_TEXT, false); + if (pressed) { + // desc + display_fillbox_wh_clip_rgb(area_drawing.x+1, area_drawing.y+1, 3, 1, SYSCOL_BUTTON_TEXT, false); + display_fillbox_wh_clip_rgb(area_drawing.x, area_drawing.y+2, 5, 1, SYSCOL_BUTTON_TEXT, false); + for (uint8 row=0; row*4