-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a8ef34
commit 82cf02b
Showing
18 changed files
with
230 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include "../modelo/dominio.h" | ||
#include "../templates/helpers.h" | ||
#include "basicos_vista.h" | ||
#include "componentes/boton_con_texto.h" | ||
#include "componentes/botones.h" | ||
#include "datos_botones.h" | ||
#include <cassert> | ||
#include <vector> | ||
|
||
using std::vector; | ||
using TipoPizzaToBoton = std::map<dominio::TipoPizza, BotonConTexto>; | ||
|
||
/** | ||
* Crea y posiciona los botones asociados con la accion "encargar". | ||
* @param font: Fuente a utilizar para el texto del boton. | ||
* @param tp_disponibles: Tipos de pizza disponibles para encargar. | ||
* @return TipoPizzaToBoton: Un mapa que asocia cada TipoPizza con un | ||
* BotonConTexto. | ||
*/ | ||
TipoPizzaToBoton _crear_botones_encargar( | ||
const OptionalFont &font, // | ||
const dominio::TiposDePizza &tp_disponibles // | ||
) { | ||
// Constantes para definir la posicion de cada boton | ||
const auto rect_panel = basicos_vista::obtener_rect_panel( // | ||
IndicePanel::PANEL_ENCARGAR | ||
); | ||
const sf::Vector2f pos_panel = rect_panel.getPosition(); | ||
const auto pos_inicial_relativa_al_panel = sf::Vector2f( | ||
medidas::MARGEN_IZQ_ETIQUETAS, medidas::FILA_CONTENIDO_PANEL | ||
); | ||
|
||
// Lambda para crear boton data | ||
const auto crear_boton_data = [](dominio::TipoPizza tp) { | ||
assert(has_key(tipo_pizza_to_string, tp)); | ||
const std::string pizza_str = tipo_pizza_to_string.at(tp); | ||
return BotonData{ | ||
pizza_str, // | ||
colores::botones_encargar::FONDO, // | ||
colores::botones_encargar::TEXTO // | ||
}; | ||
}; | ||
|
||
// Crea los botones | ||
TipoPizzaToBoton botones; | ||
vector<BotonConTexto *> ordenados; | ||
for (auto tp : tp_disponibles) { | ||
const BotonData boton_data = crear_boton_data(tp); | ||
botones.emplace(tp, BotonConTexto({boton_data, font})); | ||
botones.at(tp).establecer_contenedor(rect_panel); | ||
ordenados.push_back(&botones.at(tp)); | ||
} | ||
|
||
// Posiciona los botones | ||
const int dif_vertical = medidas::DIF_VERTICAL_BOTONES_ENCARGAR; | ||
colocar_botones_en_vertical( | ||
ordenados, pos_inicial_relativa_al_panel, dif_vertical | ||
); | ||
return botones; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.