Return unique_ptr from ui_add_gadget_scrollbar
This commit is contained in:
parent
3b4fbd0bd5
commit
1d363bbd5d
|
@ -191,11 +191,11 @@ struct UI_GADGET_LISTBOX : UI_GADGET
|
|||
int current_item;
|
||||
int selected_item;
|
||||
int old_current_item;
|
||||
fix64 last_scrolled;
|
||||
int dragging;
|
||||
int textheight;
|
||||
UI_GADGET_SCROLLBAR * scrollbar;
|
||||
int moved;
|
||||
std::unique_ptr<UI_GADGET_SCROLLBAR> scrollbar;
|
||||
fix64 last_scrolled;
|
||||
};
|
||||
|
||||
enum dialog_flags
|
||||
|
@ -305,7 +305,7 @@ extern void ui_mega_process();
|
|||
|
||||
extern void ui_get_button_size( const char * text, int * width, int * height );
|
||||
|
||||
extern UI_GADGET_SCROLLBAR * ui_add_gadget_scrollbar( UI_DIALOG * dlg, short x, short y, short w, short h, int start, int stop, int position, int window_size );
|
||||
std::unique_ptr<UI_GADGET_SCROLLBAR> ui_add_gadget_scrollbar(UI_DIALOG * dlg, short x, short y, short w, short h, int start, int stop, int position, int window_size);
|
||||
window_event_result ui_scrollbar_do( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar, const d_event &event );
|
||||
extern void ui_draw_scrollbar( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar );
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ void ui_gadget_delete_all( UI_DIALOG * dlg )
|
|||
delete static_cast<UI_GADGET_LISTBOX *>(tmp);
|
||||
break;
|
||||
case UI_GADGET_SCROLLBAR::s_kind:
|
||||
delete static_cast<UI_GADGET_SCROLLBAR *>(tmp);
|
||||
break;
|
||||
case UI_GADGET_RADIO::s_kind:
|
||||
case UI_GADGET_CHECKBOX::s_kind:
|
||||
case UI_GADGET_INPUTBOX::s_kind:
|
||||
|
|
|
@ -186,7 +186,7 @@ window_event_result ui_listbox_do( UI_DIALOG *dlg, UI_GADGET_LISTBOX * listbox,c
|
|||
listbox->old_first_item = listbox->first_item;
|
||||
|
||||
|
||||
if (GADGET_PRESSED(listbox->scrollbar))
|
||||
if (GADGET_PRESSED(listbox->scrollbar.get()))
|
||||
{
|
||||
listbox->moved = 1;
|
||||
|
||||
|
@ -396,7 +396,7 @@ void ui_listbox_change(UI_DIALOG *, UI_GADGET_LISTBOX *listbox, short numitems,
|
|||
listbox->current_item = listbox->old_current_item = 0;
|
||||
listbox->moved = 0;
|
||||
|
||||
scrollbar = listbox->scrollbar;
|
||||
scrollbar = listbox->scrollbar.get();
|
||||
|
||||
start=0;
|
||||
stop= numitems - listbox->num_items_displayed;
|
||||
|
|
|
@ -50,7 +50,7 @@ void ui_draw_scrollbar( UI_DIALOG *dlg, UI_GADGET_SCROLLBAR * scrollbar )
|
|||
ui_draw_box_out(0, scrollbar->fake_position, scrollbar->width-1, scrollbar->fake_position+scrollbar->fake_size-1 );
|
||||
}
|
||||
|
||||
UI_GADGET_SCROLLBAR * ui_add_gadget_scrollbar( UI_DIALOG * dlg, short x, short y, short w, short h, int start, int stop, int position, int window_size )
|
||||
std::unique_ptr<UI_GADGET_SCROLLBAR> ui_add_gadget_scrollbar(UI_DIALOG * dlg, short x, short y, short w, short h, int start, int stop, int position, int window_size)
|
||||
{
|
||||
int tw, th, taw;
|
||||
|
||||
|
@ -65,13 +65,13 @@ UI_GADGET_SCROLLBAR * ui_add_gadget_scrollbar( UI_DIALOG * dlg, short x, short y
|
|||
|
||||
if (stop < start ) stop = start;
|
||||
|
||||
auto scrollbar = ui_gadget_add<UI_GADGET_SCROLLBAR>( dlg, x, y+w, x+w-1, y+h-w-1 );
|
||||
std::unique_ptr<UI_GADGET_SCROLLBAR> scrollbar{ui_gadget_add<UI_GADGET_SCROLLBAR>(dlg, x, y+w, x+w-1, y+h-w-1)};
|
||||
|
||||
scrollbar->up_button = ui_add_gadget_button( dlg, x, y, w, w, up, NULL );
|
||||
scrollbar->up_button->parent = scrollbar;
|
||||
scrollbar->up_button->parent = scrollbar.get();
|
||||
|
||||
scrollbar->down_button =ui_add_gadget_button( dlg, x, y+h-w, w, w, down, NULL );
|
||||
scrollbar->down_button->parent = scrollbar;
|
||||
scrollbar->down_button->parent = scrollbar.get();
|
||||
|
||||
scrollbar->horz = 0;
|
||||
scrollbar->width = scrollbar->x2-scrollbar->x1+1;
|
||||
|
|
Loading…
Reference in a new issue