#include "SunClientPrecompiledHeader.h" #ifdef _DEV_VER #ifdef _NA_006519_20130311_TEXTURE_VIEWER #include "uiTextureViewerTextureWindow/uitextureviewertexturewindow.h" #include "uiTextureViewerSearchWindow/uiTextureViewerSearchWindow.h" #include "uiTextureViewerMan/uiTextureViewerMan.h" #include "TextureListInfoParser.h" #include "TextureListInfoHandleManager.h" #include "InterfaceManager.h" #include "Mouse.h" uiTextureViewerTextureWindow::uiTextureViewerTextureWindow(InterfaceManager* ui_manager): uiBase(ui_manager), vscroll_control_(NULL), width_rate_(0.0f), height_rate_(0.0f), image_width_rate_(0.0f), image_height_rate_(0.0f), vscroll_pos_(0), hscroll_pos_(0), hscroll_bar_size_(0.0f), hscroll_bar_move_max_(0), hscroll_bar_pos_(0), Is_mouse_lbutton_down_(false), Is_mouse_over_(false), texture_scale(1.0f), Is_Lbutton_down(false), Is_rect_line_down_(false), before_hscroll_pos_(0), before_vscroll_pos_(0) { ui_texture_handle_ = INVALID_HANDLE_VALUE; ui_width_plus_scroll_button_ = INVALID_HANDLE_VALUE; ui_width_minus_scroll_button_ = INVALID_HANDLE_VALUE; ui_width_bar_back_ = INVALID_HANDLE_VALUE; ui_width_bar_progress_ = INVALID_HANDLE_VALUE; hscroll_bar_thumb_rect_.left = 0; hscroll_bar_thumb_rect_.top = 0; hscroll_bar_thumb_rect_.right = 0; hscroll_bar_thumb_rect_.bottom = 0; drag_rect_.left = 0; drag_rect_.top = 0; drag_rect_.right = 0; drag_rect_.bottom = 0; } //-----------------------------------------------------------------------------------------// uiTextureViewerTextureWindow::~uiTextureViewerTextureWindow(void) { this->Release(); } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::Init( CDrawBase* draw_base ) { RegisterControl(); SetMode(kCreateMode); uiBase::Init(draw_base); ui_texture_viewer_manager_ = static_cast(GetMan()); assert(ui_texture_viewer_manager_); vscroll_control_ = static_cast(GetControlWZ(GetControlID_byPosition(kControl_Scroll_V000))); assert(vscroll_control_); if (vscroll_control_) { vscroll_control_->ShowWindowWZ(WZ_SHOW); VScrollDialog::ResizeingVScrollControl(0, 0); } // hscroll ¹öưµé rect ÃʱâÈ­ ÀÌ°Ç ³ªÁß¿¡ µû·Î »©µÎÀÚ. hscroll_plus_button_rect_.left = 0.0f; hscroll_plus_button_rect_.top = 0.0f; hscroll_plus_button_rect_.right = 0.0f; hscroll_plus_button_rect_.bottom = 0.0f; hscroll_minus_button_rect_.left = 0.0f; hscroll_minus_button_rect_.top = 0.0f; hscroll_minus_button_rect_.right = 0.0f; hscroll_minus_button_rect_.bottom = 0.0f; texture_scale = 1.0f; } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::Release() { // ¸®¼Ò½º °ü¸® ºÎºÐÀ» º¼ Çʿ䰡 ÀÖ´Ù. if (ui_texture_handle_ != INVALID_HANDLE_VALUE) { g_pSunRenderer->x_pManagerTexture->DestroyTexture(ui_texture_handle_); ui_texture_handle_ = INVALID_HANDLE_VALUE; } ui_width_plus_scroll_button_ = INVALID_HANDLE_VALUE; ui_width_minus_scroll_button_ = INVALID_HANDLE_VALUE; ui_width_bar_back_ = INVALID_HANDLE_VALUE; ui_width_bar_progress_ = INVALID_HANDLE_VALUE; } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::OnUpdateSolarDialog() { CDialogWZ* dialog_ptr = GetDialogWZ(); assert(dialog_ptr); if(dialog_ptr == NULL) return; if (dialog_ptr) { KeyCheck(); // ¸¶¿ì½º È٠ó¸® RECT client_rect; GetDialogWZ()->GetClientRect(&client_rect); BYTE mouse_wheel_state = GetMouseWheelStatus(&client_rect); OnMouseWheelScroll(mouse_wheel_state); // °¡·Î ½ºÅ©·Ñ º¸Á¤ if (hscroll_pos_ > hscroll_bar_move_max_) { hscroll_pos_ = hscroll_bar_move_max_; hscroll_bar_pos_ = hscroll_bar_move_max_; } int scroll_min = 0; int scroll_max = 0; int current_scroll_pos = vscroll_control_->GetScrollPosWZ(); vscroll_control_->GetScrollRangeWZ(&scroll_min, &scroll_max); if (vscroll_pos_ > scroll_max) { vscroll_pos_ = scroll_max; current_scroll_pos = scroll_max; vscroll_control_->SetScrollPosWZ(current_scroll_pos); } } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::OnRenderSolarDialog() { if (ui_texture_handle_ != INVALID_HANDLE_VALUE) { RECT rcDialog = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); RECT rc = {rcDialog.left, rcDialog.top, rcDialog.right, rcDialog.bottom}; TextureRender(rc); ScrollMinusButtonRender(rc); ScrollPlusButtonRender(rc); BackgroundScrollRender(rc); HScrollRender(rc); GridRender(rc); DragRectRender(rc); TextureInfoPrint(); } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::MessageProc( SI_MESSAGE* message ) { if (IsLock()) return; switch (message->eResultMsg) { case RT_MSG_LBUTTONCLICK: { OnLButtonClick(message); Is_rect_line_down_ = false; } break; case RT_MSG_LBUTTONDCLICK: { OnDoubleLButtonClick(message); } break; case RT_MSG_MOUSEOVER: { Is_mouse_over_ = true; } break; case RT_MSG_EDIT_KEYDOWN: { } default: { SolarDialog::MessageProc(message); VScrollDialog::MessageProc(message); Is_mouse_over_ = false; } break; } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::MouseOver_MsgProc( SI_MESSAGE* message ) { } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::OnShowWindow( BOOL is_show ) { if (is_show) { } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::Process( DWORD tick_count ) { } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::Render( const RECT& DestRect ) { } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::RegisterControl(void) { RegisterControlPosition(StrToWzID("B004"), kControl_Button_B004); RegisterControlPosition(StrToWzID("V000"), kControl_Scroll_V000); RegisterControlPosition(StrToWzID("P000"), kControl_Picture_P000); RegisterControlPosition(StrToWzID("P001"), kControl_Picture_P001); RegisterControlPosition(StrToWzID("S000"), kControl_Text_S000); } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnLButtonClick( SI_MESSAGE* message ) { bool result = true; switch (GetControlPosition_byID(message->dwCtrlID)) { case kControl_Button_B004: // ´Ý±â { ShowInterface(FALSE); } break; case kControl_Scroll_V000: // ½ºÅ©·Ñ { } break; default: { } break; } plus_button_click_check(); minus_button_click_check(); return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnRButtonClick( SI_MESSAGE* message ) { bool result = true; return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnMouseOver( SI_MESSAGE* message ) { bool result = true; return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnDoubleLButtonClick( SI_MESSAGE* message ) { bool result = true; return result; } void uiTextureViewerTextureWindow::SetMode( BYTE mode ) { CCtrlStaticWZ* static_constrol_ptr = NULL; switch (mode) { case kCreateMode: { // ´ÙÀ̾ó·Î±× Á¦¸ñ static_constrol_ptr = static_cast(GetControlWZ_byPosition(kControl_Text_S000)); if (static_constrol_ptr) { char* temp = "ÅØ½ºÃÄ"; static_constrol_ptr->SetTextWZA(temp); } } break; } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::change_texture( TCHAR* full_path ) { if (ui_texture_handle_) { g_pSunRenderer->x_pManagerTexture->DestroyTexture(ui_texture_handle_); ui_texture_handle_ = INVALID_HANDLE_VALUE; if (ui_texture_handle_ == INVALID_HANDLE_VALUE) { ui_texture_handle_ = g_pSunRenderer->x_pManagerTexture->LoadTexture(full_path, TLS_ORIGINAL_SIZE | TLS_NO_MIPMAP | TLS_NO_MULTITHREAD); St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); RECT DestRect = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); if (TexInfo) { width_rate_ = (float(DestRect.right - DestRect.left)) / ((float)TexInfo->m_nImageWidth); height_rate_ = (float(DestRect.bottom - DestRect.top)) / ((float)TexInfo->m_nImageHeight); if (width_rate_ > 1.0f) width_rate_ = 1.0f; if (height_rate_ > 1.0f) height_rate_ = 1.0f; image_width_rate_ = TexInfo->m_nImageWidth * (width_rate_ - 1.0f); image_height_rate_ = TexInfo->m_nImageHeight * (height_rate_ - 1.0f); if (height_rate_ < 1.0f) { int height_max = (TexInfo->m_nImageHeight) - (DestRect.bottom - DestRect.top); VScrollDialog::ResizeingVScrollControl(/*½ºÅ©·Ñ max*/ height_max, /*pos*/0 ); } else VScrollDialog::ResizeingVScrollControl(/*½ºÅ©·Ñ max*/ 0, /*pos*/0 ); vscroll_pos_ = 0; vscroll_control_->SetScrollPosWZ(vscroll_pos_); hscroll_pos_ = 0; hscroll_bar_move_max_ = 0; hscroll_bar_pos_ = 0; hscroll_bar_size_ = 0; texture_scale = 1.0f; drag_rect_.left = 0; drag_rect_.top = 0; drag_rect_.right = 0; drag_rect_.bottom = 0; before_hscroll_pos_ = 0; before_vscroll_pos_ = 0; } } } } //-----------------------------------------------------------------------------------------// CCtrlVScrollWZ* uiTextureViewerTextureWindow::vscroll_control() { return GetVScrollControlWZ(GetControlID_byPosition(kControl_Scroll_V000)); } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::GetScrollArea( RECT& area ) { if (IsOverControl(GetControlWZ_byPosition(kControl_Picture_P001)) == true) { area = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); return true; } return false; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnVScrollUp( SI_MESSAGE* message ) { bool result = true; if (VScrollDialog::OnVScrollThumb(message) == true) { WzID scroll_control_id = GetControlID_byPosition(kControl_Scroll_V000); CCtrlVScrollWZ* scroll_control = static_cast (GetControlWZ(scroll_control_id)); if (scroll_control != NULL) { int scroll_min = 0; int scroll_max = 0; int current_scroll_pos = scroll_control->GetScrollPosWZ(); --current_scroll_pos; current_scroll_pos = max(0, current_scroll_pos); scroll_control->SetScrollPosWZ(current_scroll_pos); vscroll_pos_ = current_scroll_pos; } } return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnVScrollDown( SI_MESSAGE* message ) { bool result = true; WzID scroll_control_id = GetControlID_byPosition(kControl_Scroll_V000); CCtrlVScrollWZ* scroll_control = static_cast (GetControlWZ(scroll_control_id)); if (scroll_control != NULL) { int scroll_min = 0; int scroll_max = 0; int current_scroll_pos = scroll_control->GetScrollPosWZ(); scroll_control->GetScrollRangeWZ(&scroll_min, &scroll_max); ++current_scroll_pos; current_scroll_pos = min(scroll_max, current_scroll_pos); scroll_control->SetScrollPosWZ(current_scroll_pos); vscroll_pos_ = current_scroll_pos; } return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnVScrollThumb( SI_MESSAGE* message ) { bool result = true; WzID scroll_control_id = GetControlID_byPosition(kControl_Scroll_V000); CCtrlVScrollWZ* scroll_control = static_cast (GetControlWZ(scroll_control_id)); if (scroll_control != NULL) { int scroll_min = 0; int scroll_max = 0; int current_scroll_pos = scroll_control->GetScrollPosWZ(); scroll_control->GetScrollRangeWZ(&scroll_min, &scroll_max); current_scroll_pos = max(0, current_scroll_pos); current_scroll_pos = min(scroll_max, current_scroll_pos); vscroll_pos_ = current_scroll_pos; } return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::plus_button_click_check( void ) { bool result = false; GetDialogWZ()->static_mousecursor_pos; RECT rc; rc.left = (LONG)hscroll_plus_button_rect_.left; rc.top = (LONG)hscroll_plus_button_rect_.top; rc.right = (LONG)hscroll_plus_button_rect_.right; rc.bottom = (LONG)hscroll_plus_button_rect_.bottom; POINT pt = Mouse::Instance()->GetMousePoint(); if (PtInRect(&rc, pt)) { result = true; ++hscroll_pos_; ++hscroll_bar_pos_; if (hscroll_bar_pos_ > hscroll_bar_move_max_) { hscroll_bar_pos_ = hscroll_bar_move_max_; hscroll_pos_ = hscroll_bar_move_max_; } return result; } return result; } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::minus_button_click_check( void ) { bool result = false; GetDialogWZ()->static_mousecursor_pos; RECT rc; rc.left = (LONG)hscroll_minus_button_rect_.left; rc.top = (LONG)hscroll_minus_button_rect_.top; rc.right = (LONG)hscroll_minus_button_rect_.right; rc.bottom = (LONG)hscroll_minus_button_rect_.bottom; POINT pt = Mouse::Instance()->GetMousePoint(); if (PtInRect(&rc, pt)) { result = true; --hscroll_pos_; --hscroll_bar_pos_; if (hscroll_bar_pos_ < 0) { hscroll_bar_pos_ = 0; hscroll_pos_ = 0; } return result; } return result; } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::TextureInfoPrint( void ) { if (Is_mouse_over_) { POINT pt = Mouse::Instance()->GetMousePoint(); HDC dcHandle = GetDC(g_hWndMain); COLORREF color = GetPixel(dcHandle, pt.x, pt.y); BYTE r = GetRValue(color); BYTE g = GetGValue(color); BYTE b = GetBValue(color); // ´ÙÀ̾ó·Î±× Á¦¸ñ CCtrlStaticWZ* static_constrol_ptr = static_cast (GetControlWZ_byPosition(kControl_Text_S000)); if (static_constrol_ptr) { POINT pt = Mouse::Instance()->GetMousePoint(); RECT client_rect = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); char* temp = "ÅØ½ºÃÄ"; if (PtInRect(&client_rect, pt)) { pt.x -= client_rect.left - hscroll_pos_; pt.y -= client_rect.top - vscroll_pos_; pt.x = LONG((float)pt.x / texture_scale); pt.y = LONG((float)pt.y / texture_scale); if (ui_texture_handle_ == INVALID_HANDLE_VALUE) { sprintf(rgb_text_, "%s\tR : %d\tG : %d\tB : %d\tX : %d\tY : %d", temp, r, g, b, pt.x, pt.y); } else { St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); if (ui_texture_handle_) { if(TexInfo) { sprintf(rgb_text_, "%s(%d,%d)\tR : %d\tG : %d\tB : %d\tX : %d\tY : %d", temp, TexInfo->m_nImageWidth, TexInfo->m_nImageHeight, r, g, b, pt.x, pt.y); } } } } else { if (ui_texture_handle_ == INVALID_HANDLE_VALUE) { sprintf(rgb_text_, "%s", temp); } else { if(ui_texture_handle_) { St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); if(TexInfo) { sprintf(rgb_text_, "%s(%d, %d)\t", temp, TexInfo->m_nImageWidth, TexInfo->m_nImageHeight); } } } } static_constrol_ptr->SetTextWZA(rgb_text_); } } else { // ´ÙÀ̾ó·Î±× Á¦¸ñ CCtrlStaticWZ* static_constrol_ptr = static_cast(GetControlWZ_byPosition(kControl_Text_S000)); if (static_constrol_ptr) { TCHAR* temp = "ÅØ½ºÃÄ"; static_constrol_ptr->SetTextWZA(temp); } } } //-----------------------------------------------------------------------------------------// bool uiTextureViewerTextureWindow::OnMouseWheelScroll( BYTE mouse_wheel_state ) { if (mouse_wheel_state == MOUSE_WHEEL_UP) { texture_scale += 0.1f; if (texture_scale > 1.5f) { texture_scale = 1.5f; } } else if (mouse_wheel_state == MOUSE_WHEEL_DOWN) { texture_scale -= 0.1f; if (texture_scale < 1.0f) texture_scale = 1.0f; } adjust_vscroll(); adjust_hscroll(); return true; } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::adjust_vscroll( void ) { St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); RECT DestRect = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); if (TexInfo) { width_rate_ = (float(DestRect.right - DestRect.left)) / (((float)TexInfo->m_nImageWidth) * texture_scale); height_rate_ = (float(DestRect.bottom - DestRect.top)) / ((float)TexInfo->m_nImageHeight * texture_scale); if(width_rate_ > 1.0f) width_rate_ = 1.0f; if(height_rate_ > 1.0f) height_rate_ = 1.0f; image_width_rate_ = (TexInfo->m_nImageWidth * texture_scale) * (width_rate_ - 1.0f); image_height_rate_ = (TexInfo->m_nImageHeight * texture_scale) * (height_rate_ - 1.0f); if (height_rate_ < 1.0f) { int height_max = int(((float)TexInfo->m_nImageHeight * (float)texture_scale)) - (DestRect.bottom - DestRect.top); VScrollDialog::ResizeingVScrollControl(/*½ºÅ©·Ñ max*/ height_max, /*pos*/0 ); } else VScrollDialog::ResizeingVScrollControl(/*½ºÅ©·Ñ max*/ 0, /*pos*/0 ); } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::adjust_hscroll( void ) { } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::KeyCheck( void ) { // °¡·Î ½ºÅ©·Ñ Thumb¸¦ À§ÇÑ if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) { POINT pt = Mouse::Instance()->GetMousePoint(); if (PtInRect(&hscroll_bar_thumb_rect_, pt)) { if(Is_mouse_lbutton_down_ != true) { Is_mouse_lbutton_down_ = true; first_point = pt; } else { Is_mouse_lbutton_down_ = false; pt.x = pt.x - first_point.x; pt.y = pt.y - first_point.y; hscroll_bar_pos_ += pt.x; hscroll_pos_ += pt.x; if (hscroll_bar_pos_ < 0) { hscroll_bar_pos_ = 0; hscroll_pos_ = 0; } if (hscroll_bar_pos_ > hscroll_bar_move_max_) { hscroll_bar_pos_ = hscroll_bar_move_max_; hscroll_pos_ = hscroll_bar_move_max_; } first_point.x = 0; first_point.y = 0; } } // ¸¶¿ì½º·Î À̹ÌÁö µå·¡±× Çϱâ À§ÇØ RECT rcDialog = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); if (PtInRect(&rcDialog, pt)) { if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { if (texture_scale <= 1.0f) { if (Is_rect_line_down_ != true) { Is_rect_line_down_ = true; first_rect_drag_point_ = pt; drag_rect_.left = static_cast (pt.x); drag_rect_.top = static_cast (pt.y); drag_rect_.right = static_cast (pt.x); drag_rect_.bottom = static_cast (pt.y); } else { drag_rect_.right = static_cast (pt.x); drag_rect_.bottom = static_cast (pt.y); first_rect_drag_point_.x = 0; first_rect_drag_point_.y = 0; } } // ±×¸®°í ÀÖ´Â »óȲ ÀÏ ¶§´Â ½ºÅ©·ÑÀÌ µÇÁö ¾Êµµ·Ï return ÇÑ´Ù. return; } if (Is_Lbutton_down != true) { Is_Lbutton_down = true; first_drag_point_ = pt; } else { Is_Lbutton_down = false; pt.x = pt.x - first_drag_point_.x; pt.y = pt.y - first_drag_point_.y; hscroll_bar_pos_ -= pt.x; hscroll_pos_ -= pt.x; int scroll_min = 0; int scroll_max = 0; int current_scroll_pos = vscroll_control_->GetScrollPosWZ(); current_scroll_pos -= pt.y; vscroll_pos_ -= pt.y; vscroll_control_->GetScrollRangeWZ(&scroll_min, &scroll_max); if (vscroll_pos_ > scroll_max) { vscroll_pos_ = scroll_max; current_scroll_pos = scroll_max; vscroll_control_->SetScrollPosWZ(current_scroll_pos); } else if (vscroll_pos_ < scroll_min) { vscroll_pos_ = scroll_min; current_scroll_pos = scroll_min; vscroll_control_->SetScrollPosWZ(current_scroll_pos); } else { vscroll_control_->SetScrollPosWZ(current_scroll_pos); } if (hscroll_bar_pos_ < 0) { hscroll_bar_pos_ = 0; hscroll_pos_ = 0; } else if (hscroll_bar_pos_ > hscroll_bar_move_max_) { hscroll_bar_pos_ = hscroll_bar_move_max_; hscroll_pos_ = hscroll_bar_move_max_; } first_drag_point_.x = 0; first_drag_point_.y = 0; } } } else { Is_mouse_lbutton_down_ = false; first_point.x = 0; first_point.y = 0; first_drag_point_.x = 0; first_drag_point_.y = 0; Is_Lbutton_down = false; first_rect_drag_point_.x = 0; first_rect_drag_point_.y = 0; Is_rect_line_down_ = false; } if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) { drag_rect_.left = 0; drag_rect_.top = 0; drag_rect_.right = 0; drag_rect_.bottom = 0; } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::TextureRender( const RECT& DestRect ) { // ÅØ½ºÃÄ Ãâ·Â if (ui_texture_handle_ != INVALID_HANDLE_VALUE) { St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); if (TexInfo) { // ºñÀ²À» °è»êÇØ¼­ Àû¿ë width_rate_ = (static_cast (DestRect.right - DestRect.left)) / (((static_cast (TexInfo->m_nImageWidth)) * texture_scale)); height_rate_ = (static_cast (DestRect.bottom - DestRect.top)) / (((static_cast (TexInfo->m_nImageHeight)) * texture_scale)); if (width_rate_ > 1.0f) width_rate_ = 1.0f; if (height_rate_ > 1.0f) height_rate_ = 1.0f; image_width_rate_ = (TexInfo->m_nImageWidth * texture_scale) * (width_rate_ - 1.0f); image_height_rate_ = (TexInfo->m_nImageHeight * texture_scale) * (height_rate_ - 1.0f); float origin_image_width_rate = (static_cast (TexInfo->m_nImageWidth)) * (width_rate_ - 1.0f); float origin_image_height_rate = (static_cast (TexInfo->m_nImageHeight)) * (height_rate_ - 1.0f); float result_Image_width = TexInfo->m_nImageWidth + origin_image_width_rate; float result_Image_height = TexInfo->m_nImageHeight + origin_image_height_rate; g_pSunRenderer->RenderTexture(ui_texture_handle_, static_cast (DestRect.left), static_cast (DestRect.top), static_cast (((static_cast (TexInfo->m_nImageWidth)) * texture_scale) + image_width_rate_), static_cast (((static_cast (TexInfo->m_nImageHeight)) * texture_scale) + image_height_rate_), static_cast (hscroll_pos_ / texture_scale), static_cast (vscroll_pos_ / texture_scale), static_cast (result_Image_width), static_cast (result_Image_height), NULL); } } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::ScrollMinusButtonRender( const RECT& DestRect ) { BASE_TextureListInfo* tex_minus_info = NULL; ui_width_minus_scroll_button_ = TextureListInfoHandleManager::Instance() ->GetTexture(10003, tex_minus_info); // ¸¶À̳ʽº ½ºÅ©·Ñ ¹öư »Ñ¸®±â if (ui_width_minus_scroll_button_ != INVALID_HANDLE_VALUE && tex_minus_info != NULL) { g_pSunRenderer->RenderTexture(ui_width_minus_scroll_button_, static_cast (DestRect.left + 3), static_cast (DestRect.bottom + 3), static_cast (tex_minus_info->tex_size.right), static_cast (tex_minus_info->tex_size.bottom), static_cast (tex_minus_info->tex_size.left), static_cast (tex_minus_info->tex_size.top), static_cast (tex_minus_info->tex_size.right), static_cast (tex_minus_info->tex_size.bottom)); hscroll_minus_button_rect_.left = static_cast (DestRect.left + 3); hscroll_minus_button_rect_.top = static_cast (DestRect.bottom + 3); hscroll_minus_button_rect_.right = static_cast (DestRect.left + 3) + static_cast (tex_minus_info->tex_size.right); hscroll_minus_button_rect_.bottom = static_cast (DestRect.bottom + 3) + static_cast (tex_minus_info->tex_size.bottom); } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::ScrollPlusButtonRender( const RECT& DestRect ) { BASE_TextureListInfo* tex_plus_info = NULL; ui_width_plus_scroll_button_ = TextureListInfoHandleManager::Instance() ->GetTexture(10002, tex_plus_info); // Ç÷¯½º ½ºÅ©·Ñ ¹öư »Ñ¸®±â if (ui_width_plus_scroll_button_ != INVALID_HANDLE_VALUE && tex_plus_info != NULL) { g_pSunRenderer->RenderTexture(ui_width_plus_scroll_button_, static_cast (DestRect.right - 3), static_cast (DestRect.bottom + 3), static_cast (tex_plus_info->tex_size.right), static_cast (tex_plus_info->tex_size.bottom), static_cast (tex_plus_info->tex_size.left), static_cast (tex_plus_info->tex_size.top), static_cast (tex_plus_info->tex_size.right), static_cast (tex_plus_info->tex_size.bottom)); hscroll_plus_button_rect_.left = float(DestRect.right - 3); hscroll_plus_button_rect_.top = float(DestRect.bottom + 3); hscroll_plus_button_rect_.right = float(DestRect.right - 3) + float(tex_plus_info->tex_size.right); hscroll_plus_button_rect_.bottom = float(DestRect.bottom + 3) + float(tex_plus_info->tex_size.bottom); } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::BackgroundScrollRender( const RECT& DestRect ) { BASE_TextureListInfo* tex_width_bar_back_info = NULL; ui_width_bar_back_ = TextureListInfoHandleManager::Instance() ->GetTexture(10022, tex_width_bar_back_info); BASE_TextureListInfo* tex_plus_info = NULL; ui_width_plus_scroll_button_ = TextureListInfoHandleManager::Instance() ->GetTexture(10002, tex_plus_info); BASE_TextureListInfo* tex_minus_info = NULL; ui_width_minus_scroll_button_ = TextureListInfoHandleManager::Instance() ->GetTexture(10003, tex_minus_info); // µÚ¿¡ ½ºÅ©·Ñ ±âº» ¹è°æ »Ñ¸®±â if (ui_width_bar_back_ != INVALID_HANDLE_VALUE && tex_plus_info != NULL && tex_minus_info != NULL && tex_width_bar_back_info != NULL) { g_pSunRenderer->RenderTexture(ui_width_bar_back_, static_cast (DestRect.left + tex_minus_info->tex_size.right), static_cast (DestRect.bottom + 3), static_cast (DestRect.right - DestRect.left - tex_plus_info->tex_size.right - 3), static_cast (tex_plus_info->tex_size.bottom), static_cast (tex_width_bar_back_info->tex_size.left + 3), static_cast (tex_width_bar_back_info->tex_size.top), static_cast (283), static_cast (tex_width_bar_back_info->tex_size.bottom)); hscroll_bar_background_size_.left = 0.0f; hscroll_bar_background_size_.top = 0.0f; hscroll_bar_background_size_.right = static_cast ((DestRect.right - DestRect.left - tex_plus_info->tex_size.right - 3)); hscroll_bar_background_size_.bottom = static_cast (tex_plus_info->tex_size.bottom); RECT DestRect = GetControlWZ_byPosition(kControl_Picture_P001)->GetSizeRect(); // ½ºÅ©·Ñ »Ñ¸®±â Àü¿¡ ºñÀ² °è»ê if (width_rate_ < 1.0f) { St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); int width_max = static_cast (((float)TexInfo->m_nImageWidth * (float)texture_scale) - (DestRect.right - DestRect.left)); hscroll_bar_move_max_ = width_max; width_max = static_cast ((hscroll_bar_background_size_.right - hscroll_bar_background_size_.left) - width_max); hscroll_bar_size_ = static_cast (width_max); } else hscroll_bar_move_max_ = 0; } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::HScrollRender( const RECT& DestRect ) { BASE_TextureListInfo* tex_width_bar_progress_info = NULL; ui_width_bar_progress_ = TextureListInfoHandleManager::Instance() ->GetTexture(10024, tex_width_bar_progress_info); BASE_TextureListInfo* tex_plus_info = NULL; ui_width_plus_scroll_button_ = TextureListInfoHandleManager::Instance() ->GetTexture(10002, tex_plus_info); // ½ºÅ©·Ñ »Ñ¸®±â if (ui_width_bar_progress_ != INVALID_HANDLE_VALUE && tex_plus_info != NULL && tex_width_bar_progress_info != NULL) { g_pSunRenderer->RenderTexture(ui_width_bar_progress_, static_cast (DestRect.left + tex_plus_info->tex_size.right + 2.0f + hscroll_bar_pos_), static_cast (DestRect.bottom + 6.0f), static_cast (hscroll_bar_size_), static_cast (tex_plus_info->tex_size.bottom - 6.0f), static_cast (tex_width_bar_progress_info->tex_size.left), static_cast (tex_width_bar_progress_info->tex_size.top), static_cast (tex_width_bar_progress_info->tex_size.right), static_cast (tex_width_bar_progress_info->tex_size.bottom)); // Thumb Ãæµ¹ 󸮸¦ À§Çؼ­ ÀúÀå ÇØ µÐ´Ù. hscroll_bar_thumb_rect_.left = static_cast(DestRect.left + tex_plus_info->tex_size.right + 2.0f + hscroll_bar_pos_); hscroll_bar_thumb_rect_.top = static_cast(DestRect.bottom + 6.0f); hscroll_bar_thumb_rect_.right = static_cast(hscroll_bar_thumb_rect_.left + hscroll_bar_size_); hscroll_bar_thumb_rect_.bottom = static_cast(hscroll_bar_thumb_rect_.top + tex_plus_info->tex_size.bottom - 6.0f); } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::GridRender( const RECT& DestRect ) { uiTextureViewerMan* manager = static_cast (GetMan()); uiBase* search_window = (manager->GetTextureViewerWindow(UI_TEXTURE_VIEWER_SEARCH_WINDOW)); if(((uiTextureViewerSearchWindow*) (search_window))->get_Is_grid_mode() == false) { return; } float interval = 32.0f * texture_scale; St_TextureContainer* TexInfo = g_pSunRenderer->x_pManagerTexture->GetTextureInfo(ui_texture_handle_); //assert(TexInfo); if(!TexInfo) return; // ·ºÆ®¸¦ ´Ù½Ã Á¤ÀÇ ÇØ ÁÜÀ¸·Î¼­ ÇØ°á ÇØ ÁÙ ¼ö ÀÖÀ» °Í °°´Ù. int width_line_num = static_cast((TexInfo->m_nHeight) * texture_scale) / static_cast(interval); FRECT DestFRect = { static_cast(DestRect.left) - hscroll_pos_, static_cast(DestRect.top) - vscroll_pos_, (static_cast(DestRect.left) - hscroll_pos_) + (static_cast(TexInfo->m_nWidth) * texture_scale), (static_cast(DestRect.top) - vscroll_pos_) + (static_cast(TexInfo->m_nHeight) * texture_scale)}; /* |--------------| |--------------| |______________| */ FRECT widthRect = {DestFRect.left, DestFRect.top, DestFRect.right, DestFRect.bottom }; if (DestFRect.left < DestRect.left) widthRect.left = static_cast (DestRect.left); if (DestFRect.right > DestRect.right) widthRect.right = static_cast (DestRect.right); for (int i = 0; i <= width_line_num; ++i) { if ((DestFRect.top) + (i * interval) >= DestRect.top && (DestFRect.top) + (i * interval) <= DestRect.bottom) { g_pSunRenderer->Render2DLine(static_cast (widthRect.left), static_cast (widthRect.top) + (i * interval), static_cast (widthRect.right), static_cast (widthRect.top) + (i * interval), WzColor_RGBA(255, 0, 0, 255)); } } int height_line_num = static_cast ((TexInfo->m_nWidth) * texture_scale) / static_cast (interval); FRECT heightRect = { DestFRect.left, DestFRect.top, DestFRect.right, DestFRect.bottom }; if (DestFRect.top < DestRect.top) heightRect.top = static_cast (DestRect.top); if (DestFRect.bottom > DestRect.bottom) heightRect.bottom = static_cast (DestRect.bottom); for (int j = 0; j <= height_line_num; ++j) { if ((DestFRect.left) + (j * interval) <= DestRect.right && (DestFRect.left) + (j * interval) >= DestRect.left) { g_pSunRenderer->Render2DLine(static_cast (heightRect.left) + (j * interval), static_cast (heightRect.top), static_cast (heightRect.left) + (j * interval), static_cast (heightRect.bottom), WzColor_RGBA(255, 0, 0, 255)); } } } //-----------------------------------------------------------------------------------------// void uiTextureViewerTextureWindow::DragRectRender( const RECT& DestRect ) { if(hscroll_pos_ != before_hscroll_pos_) { int differ = static_cast ((hscroll_pos_ / texture_scale) - (before_hscroll_pos_ / texture_scale)); drag_rect_.left -= (differ / texture_scale); drag_rect_.right -= (differ / texture_scale); before_hscroll_pos_ = hscroll_pos_; } if(vscroll_pos_ != before_vscroll_pos_) { int differ = vscroll_pos_ - before_vscroll_pos_; drag_rect_.top -= (differ / texture_scale); drag_rect_.bottom -= (differ / texture_scale); before_vscroll_pos_ = vscroll_pos_; } // ¸¶¿ì½º µå·¡±× rect Render FRECT render_drag_rect = drag_rect_; float dist_left = render_drag_rect.left - DestRect.left; float dist_top = render_drag_rect.top - DestRect.top; float dist_right = render_drag_rect.right - DestRect.left; float dist_bottom = render_drag_rect.bottom - DestRect.top; render_drag_rect.left = DestRect.left + (dist_left * texture_scale); render_drag_rect.top = DestRect.top + (dist_top * texture_scale); render_drag_rect.right = DestRect.left + (dist_right * texture_scale); render_drag_rect.bottom = DestRect.top + (dist_bottom * texture_scale); if (drag_rect_.left > static_cast (DestRect.left) && drag_rect_.top > 0.0f) { FRECT resultRect = { render_drag_rect.left, render_drag_rect.top, render_drag_rect.right, render_drag_rect.bottom }; if (render_drag_rect.top >= DestRect.top && render_drag_rect.top <= DestRect.bottom) { if (resultRect.right > DestRect.right) resultRect.right = static_cast (DestRect.right); if (resultRect.left < DestRect.left) resultRect.left = static_cast (DestRect.left); g_pSunRenderer->Render2DLine(resultRect.left, resultRect.top, resultRect.right, resultRect.top, WzColor_RGBA(255, 255, 255, 255)); } if ( render_drag_rect.right <= DestRect.right && render_drag_rect.right >= DestRect.left) { if (render_drag_rect.bottom > DestRect.bottom) resultRect.bottom = static_cast (DestRect.bottom); if(render_drag_rect.top < DestRect.top) resultRect.top = static_cast (DestRect.top); g_pSunRenderer->Render2DLine(resultRect.right, resultRect.top, resultRect.right, resultRect.bottom, WzColor_RGBA(255, 255, 255, 255)); } if( render_drag_rect.bottom <= DestRect.bottom && render_drag_rect.bottom >= DestRect.top) { if (render_drag_rect.right > DestRect.right) resultRect.right = static_cast (DestRect.right); if (render_drag_rect.left < DestRect.left) resultRect.left = static_cast (DestRect.left); g_pSunRenderer->Render2DLine(resultRect.left, resultRect.bottom, resultRect.right, resultRect.bottom, WzColor_RGBA(255, 255, 255, 255)); } if (render_drag_rect.left >= DestRect.left && render_drag_rect.left <= DestRect.right) { if (render_drag_rect.top < DestRect.top) resultRect.top = static_cast (DestRect.top); if(render_drag_rect.bottom > DestRect.bottom) resultRect.bottom = static_cast (DestRect.bottom); g_pSunRenderer->Render2DLine(resultRect.left, resultRect.bottom, resultRect.left, resultRect.top, WzColor_RGBA(255, 255, 255, 255)); } } } //-----------------------------------------------------------------------------------------// #endif #endif