void palette_manager::adjust_size() { scroll_top(); const SDL_Rect& rect = gui_.palette_area(); set_location(rect); palette_start_ = rect.y; bg_register(rect); active_palette().adjust_size(rect); set_dirty(); }
void palette_manager::handle_event(const SDL_Event& event) { gui::widget::handle_event(event); if (event.type == SDL_MOUSEMOTION) { // If the mouse is inside the palette, give it focus. if (sdl::point_in_rect(event.button.x, event.button.y, location())) { if (!focus(&event)) set_focus(true); } // If the mouse is outside, remove focus. else if (focus(&event)) set_focus(false); } if (!focus(&event)) { return; } const SDL_MouseButtonEvent &mouse_button_event = event.button; if (event.type == SDL_MOUSEWHEEL) { if (event.wheel.y > 0) { scroll_up(); } else if (event.wheel.y < 0) { scroll_down(); } if (event.wheel.x < 0) { active_palette().prev_group(); scroll_top(); } else if (event.wheel.x > 0) { active_palette().next_group(); scroll_top(); } } if (mouse_button_event.type == SDL_MOUSEBUTTONUP) { //set_dirty(true); // draw(true); // set_dirty(active_palette().mouse_click()); // gui_.invalidate_game_status(); } }
void palette_manager::set_group(size_t index) { active_palette().set_group(index); scroll_top(); }