23 font_handle_(
FontLoader::GetIns()->GetFontHandle(
"font/Yu_Gothic_UI.dft"))
28 const int pos_x,
const int pos_y,
29 const unsigned int option,
const bool this_is_first_time)
65 button->SetPos(button->GetPosMiddleX() + diff_x,
66 button->GetPosMiddleY() + diff_y,
70 if (this_is_first_time)
83 button->SetVisible(visible);
99 button->ClickedAction(state);
105 const int cursor_x,
const int cursor_y)
const noexcept
112 return gui_left_pos_x_ < cursor_x && cursor_x < gui_left_pos_x_ + width_ &&
113 gui_top_pos_y_ < cursor_y && cursor_y < gui_top_pos_y_ + height_;
127 int cursor_dif_x,
int cursor_dif_y,
128 unsigned int mouse_key_bit)
130 if (!(mouse_key_bit & MOUSE_INPUT_LEFT))
142 const unsigned int base_color = GetColor(255, 255, 255);
143 const unsigned int frame_color = GetColor(30, 30, 30);
144 const unsigned int alpha = 200;
146 const int frame_width = 1;
148 SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha);
175 const unsigned int text_color = GetColor(10, 10, 10);
176 DrawFormatStringToHandle(
177 text_pos_x, text_pos_y, text_color,
font_handle_, str.c_str());
179 SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
int init_pos_y_
SetされたGUIの左上のY座標.
void SetPos(int pos_x, int pos_y, unsigned int option=kDxlibGuiAnchorLeftTop, bool this_is_first_time=false)
GUIの位置を設定する. Dxlibの画面の座標は左上を原点とし,右下に行くほど値が大きくなる. 横方向にx軸,縦方向にy軸をとる.
void DrawBackground(const std::string &str) const
bool visible_
GUIが表示されているかどうかのフラグ.
int gui_left_pos_x_
GUIの左端の位置.
static constexpr int kTitleBarHeight
タイトルバーの高さ.
int gui_top_pos_y_
GUIの上端の位置.
AbstractDxlibGui()=delete
void SetVisible(bool visible) override
GUIの表示を行うかどうかを設定する.
void DraggedAction(int cursor_dif_x, int cursor_dif_y, unsigned int mouse_key_bit) override
ドラッグ中の処理を行う. カーソルは上にあるけど,ドラッグ中ではない場合でも呼び出される.
bool IsDraggable(int cursor_x, int cursor_y) const override
ドラッグ可能な位置にあるかを判定する.
constexpr bool IsVisible() const override
GUIの表示を行うかどうかを返す.
bool CursorOnGui(int cursor_x, int cursor_y) const noexcept override
GUIの上にカーソルがあるかどうかを返す.
int init_pos_x_
SetされたGUIの左上のX座標.
int font_handle_
フォントハンドル.
std::vector< std::unique_ptr< SimpleButton > > button_
ボタンのリスト.
void ClickedAction(const DxlibMouseState &state) override
GUIがクリックされたときに実行される関数. CursorOnGuiが true を返すときに呼び出される. 複数のGUIが重なっている場合は,優先度の高いものから順に呼び出される.
constexpr unsigned int kDxlibGuiAnchorTop
constexpr unsigned int kDxlibGuiAnchorMiddleX
constexpr unsigned int kDxlibGuiAnchorBottom
constexpr unsigned int kDxlibGuiAnchorMiddleXMiddleY
constexpr unsigned int kDxlibGuiAnchorLeft
constexpr unsigned int kDxlibGuiAnchorRight
constexpr unsigned int kDxlibGuiAnchorLeftTop
constexpr unsigned int kDxlibGuiAnchorMiddleY
int cursor_y
マウスカーソルのY座標.上端を0とし,下に正の値をとる.
int cursor_x
マウスカーソルのX座標.左端を0とし,右に正の値をとる.