Merge pull request #31 from Vulpovile/property-window

Property window fixes
This commit is contained in:
Vulpovile
2019-11-03 18:16:14 -08:00
committed by GitHub
7 changed files with 125 additions and 87 deletions

View File

@@ -27,6 +27,7 @@ DataModelInstance::DataModelInstance(void)
workspace->setParent(this); workspace->setParent(this);
level->setParent(this); level->setParent(this);
_loadedFileName="..//skooter.rbxm"; _loadedFileName="..//skooter.rbxm";
listicon = 1;
} }

View File

@@ -266,18 +266,10 @@
RelativePath=".\IEBrowser.cpp" RelativePath=".\IEBrowser.cpp"
> >
</File> </File>
<File
RelativePath=".\IEBrowser.h"
>
</File>
<File <File
RelativePath=".\IEDispatcher.cpp" RelativePath=".\IEDispatcher.cpp"
> >
</File> </File>
<File
RelativePath=".\LevelInstance.cpp"
>
</File>
<File <File
RelativePath="main.cpp" RelativePath="main.cpp"
> >
@@ -298,10 +290,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\PartInstance.cpp"
>
</File>
<File <File
RelativePath=".\propertyGrid.cpp" RelativePath=".\propertyGrid.cpp"
> >
@@ -310,10 +298,6 @@
RelativePath=".\PropertyWindow.cpp" RelativePath=".\PropertyWindow.cpp"
> >
</File> </File>
<File
RelativePath=".\PVInstance.cpp"
>
</File>
<File <File
RelativePath=".\WindowFunctions.cpp" RelativePath=".\WindowFunctions.cpp"
> >
@@ -337,6 +321,18 @@
RelativePath=".\Instance.cpp" RelativePath=".\Instance.cpp"
> >
</File> </File>
<File
RelativePath=".\LevelInstance.cpp"
>
</File>
<File
RelativePath=".\PartInstance.cpp"
>
</File>
<File
RelativePath=".\PVInstance.cpp"
>
</File>
<File <File
RelativePath=".\TextButtonInstance.cpp" RelativePath=".\TextButtonInstance.cpp"
> >
@@ -388,7 +384,7 @@
> >
</File> </File>
<File <File
RelativePath=".\GroupInstance.h" RelativePath=".\IEBrowser.h"
> >
</File> </File>
<File <File
@@ -399,10 +395,6 @@
RelativePath=".\LevelInstance.h" RelativePath=".\LevelInstance.h"
> >
</File> </File>
<File
RelativePath=".\PartInstance.h"
>
</File>
<File <File
RelativePath=".\propertyGrid.h" RelativePath=".\propertyGrid.h"
> >
@@ -411,10 +403,6 @@
RelativePath=".\PropertyWindow.h" RelativePath=".\PropertyWindow.h"
> >
</File> </File>
<File
RelativePath=".\PVInstance.h"
>
</File>
<File <File
RelativePath=".\rapidxml\rapidxml.hpp" RelativePath=".\rapidxml\rapidxml.hpp"
> >
@@ -454,6 +442,10 @@
RelativePath=".\DataModelInstance.h" RelativePath=".\DataModelInstance.h"
> >
</File> </File>
<File
RelativePath=".\GroupInstance.h"
>
</File>
<File <File
RelativePath=".\ImageButtonInstance.h" RelativePath=".\ImageButtonInstance.h"
> >
@@ -462,6 +454,14 @@
RelativePath=".\Instance.h" RelativePath=".\Instance.h"
> >
</File> </File>
<File
RelativePath=".\PartInstance.h"
>
</File>
<File
RelativePath=".\PVInstance.h"
>
</File>
<File <File
RelativePath=".\TextButtonInstance.h" RelativePath=".\TextButtonInstance.h"
> >

View File

@@ -18,6 +18,7 @@ Instance::Instance(const Instance &oinst)
name = oinst.name; name = oinst.name;
className = oinst.className; className = oinst.className;
canDelete = oinst.canDelete; canDelete = oinst.canDelete;
listicon = oinst.listicon;
//setParent(oinst.parent); //setParent(oinst.parent);
} }

View File

@@ -5,6 +5,7 @@
#include "PropertyWindow.h" #include "PropertyWindow.h"
#include "Globals.h" #include "Globals.h"
#include "strsafe.h" #include "strsafe.h"
/*typedef struct typPRGP { /*typedef struct typPRGP {
Instance* instance; // Declare member types Instance* instance; // Declare member types
Property &prop; Property &prop;
@@ -17,6 +18,49 @@ Instance * parent = NULL;
const int CX_BITMAP = 16; const int CX_BITMAP = 16;
const int CY_BITMAP = 16; const int CY_BITMAP = 16;
HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent)
{
HDC hdcMem, hdcMem2;
HBITMAP hbmMask;
BITMAP bm;
// Create monochrome (1 bit) mask bitmap.
GetObject(hbmColour, sizeof(BITMAP), &bm);
hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
// Get some HDCs that are compatible with the display driver
hdcMem = CreateCompatibleDC(0);
hdcMem2 = CreateCompatibleDC(0);
SelectObject(hdcMem, hbmColour);
SelectObject(hdcMem2, hbmMask);
// Set the background colour of the colour image to the colour
// you want to be transparent.
SetBkColor(hdcMem, crTransparent);
// Copy the bits from the colour image to the B+W mask... everything
// with the background colour ends up white while everythig else ends up
// black...Just what we wanted.
BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
// Take our new mask and use it to turn the transparent colour in our
// original colour image to black so the transparency effect will
// work right.
BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCINVERT);
// Clean up.
DeleteDC(hdcMem);
DeleteDC(hdcMem2);
return hbmMask;
}
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
TCHAR achTemp[256]; TCHAR achTemp[256];
@@ -50,7 +94,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
// Get the food icon from the item data. // Get the food icon from the item data.
HBITMAP hbmIcon = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1)); HBITMAP hbmIcon = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));
HBITMAP hbmMask = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1)); HBITMAP hbmMask = CreateBitmapMask(hbmIcon, RGB(255, 0, 220));
// The colors depend on whether the item is selected. // The colors depend on whether the item is selected.
clrForeground = SetTextColor(lpdis->hDC, clrForeground = SetTextColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ? GetSysColor(lpdis->itemState & ODS_SELECTED ?
@@ -66,7 +110,16 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
x = LOWORD(GetDialogBaseUnits()) / 4; x = LOWORD(GetDialogBaseUnits()) / 4;
// Get and display the text for the list item. // Get and display the text for the list item.
int mul = 0;
SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) achTemp); SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) achTemp);
if(lpdis->itemID >= 0)
{
mul = children[lpdis->itemID]->listicon;
}
//else mul = children[lpdis->itemID-1]->listicon;
//mul = children[lpdis->itemID]->listicon;
hr = StringCchLength(achTemp, 256, &cch); hr = StringCchLength(achTemp, 256, &cch);
if (FAILED(hr)) if (FAILED(hr))
@@ -89,11 +142,11 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SelectObject(hdc, hbmMask); SelectObject(hdc, hbmMask);
BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1, BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
CX_BITMAP, CY_BITMAP, hdc, 0, 0, SRCAND); CX_BITMAP, CY_BITMAP, hdc, mul*16, 0, SRCAND);
SelectObject(hdc, hbmIcon); SelectObject(hdc, hbmIcon);
BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1, BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
CX_BITMAP, CY_BITMAP, hdc, 0, 0, SRCPAINT); CX_BITMAP, CY_BITMAP, hdc, mul*16, 0, SRCPAINT);
DeleteDC(hdc); DeleteDC(hdc);
@@ -123,32 +176,8 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
CHAR ListItem[256]; CHAR ListItem[256];
SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem); SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem);
if(ItemIndex != 0) propWind->ClearProperties();
{ propWind->UpdateSelected(children.at(ItemIndex));
propWind->ClearProperties();
while(g_selectedInstances.size() != 0)
g_selectedInstances.erase(g_selectedInstances.begin());
if(parent != NULL)
{
std::cout << ItemIndex << std::endl;
if(ItemIndex == 1)
{
g_selectedInstances.push_back(parent);
propWind->SetProperties(parent);
}
else
{
g_selectedInstances.push_back(children.at(ItemIndex+2));
propWind->SetProperties(children.at(ItemIndex+2));
}
}
else
{
g_selectedInstances.push_back(children.at(ItemIndex-1));
propWind->SetProperties(children.at(ItemIndex-1));
}
}
} }
} }
break; break;
@@ -164,7 +193,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm; LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex); LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
selectedInstance->PropUpdate(item); selectedInstance->PropUpdate(item);
//propWind->SetProperties(selectedInstance); //propWind->UpdateSelected(selectedInstance);
} }
} }
break; break;
@@ -178,28 +207,35 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
void PropertyWindow::refreshExplorer() void PropertyWindow::refreshExplorer(Instance* selectedInstance)
{ {
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0); SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
parent = NULL; parent = NULL;
for (unsigned int i=0;i<g_selectedInstances.size();i++) { children.clear();
g_selectedInstances.clear();
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)g_selectedInstances[i]->name.c_str()); //for (unsigned int i=0;i<g_selectedInstances.size();i++) {
if(g_selectedInstances[i]->getParent() != NULL) children.push_back(selectedInstance);
{ SendMessage(_explorerComboBox, CB_ADDSTRING, 0, (LPARAM)selectedInstance->name.c_str());
std::string title = ".. ("; if(selectedInstance->getParent() != NULL)
title += g_selectedInstances[i]->getParent()->name; {
title += ")"; std::string title = ".. (";
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str()); title += selectedInstance->getParent()->name;
parent = g_selectedInstances[i]->getParent(); title += ")";
} SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str());
children = g_selectedInstances[i]->getChildren(); parent = selectedInstance->getParent();
for(size_t z = 0; z < children.size(); z++) children.push_back(selectedInstance->getParent());
{
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)children.at(z)->name.c_str());
}
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
} }
//children = g_selectedInstances[i]->getChildren();
std::vector<Instance*> selectedChildren = selectedInstance->getChildren();
for(size_t z = 0; z < selectedChildren.size(); z++)
{
children.push_back(selectedChildren.at(z));
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)selectedChildren.at(z)->name.c_str());
}
g_selectedInstances.push_back(selectedInstance);
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
//}
} }
bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) { bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) {
@@ -225,7 +261,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
NULL, NULL,
"COMBOBOX", "COMBOBOX",
"Combo", "Combo",
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS ,
0, 0,
0, 0,
0, 0,
@@ -283,7 +319,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this); SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this);
refreshExplorer(); //refreshExplorer();
_resize(); _resize();
return true; return true;
@@ -306,7 +342,7 @@ void PropertyWindow::_resize()
SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
} }
void PropertyWindow::SetProperties(Instance * instance) void PropertyWindow::UpdateSelected(Instance * instance)
{ {
PropGrid_ResetContent(_propGrid); PropGrid_ResetContent(_propGrid);
prop = instance->getProperties(); prop = instance->getProperties();
@@ -322,7 +358,7 @@ void PropertyWindow::SetProperties(Instance * instance)
PropGrid_ExpandAllCatalogs(_propGrid); PropGrid_ExpandAllCatalogs(_propGrid);
//SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); //SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
refreshExplorer(); refreshExplorer(instance);
_resize(); _resize();
} }

View File

@@ -4,10 +4,10 @@ class PropertyWindow {
public: public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance);
void SetProperties(Instance *); void UpdateSelected(Instance *);
void ClearProperties(); void ClearProperties();
void onResize(); void onResize();
void refreshExplorer(); void refreshExplorer(Instance* selectedInstance);
HWND _hwndProp; HWND _hwndProp;
private: private:
HWND _propGrid; HWND _propGrid;

View File

@@ -7,6 +7,7 @@ WorkspaceInstance::WorkspaceInstance(void)
name = "Workspace"; name = "Workspace";
className = "Workspace"; className = "Workspace";
canDelete = false; canDelete = false;
listicon = 8;
} }
WorkspaceInstance::~WorkspaceInstance(void) WorkspaceInstance::~WorkspaceInstance(void)

View File

@@ -276,7 +276,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
} }
g_selectedInstances = newinst; g_selectedInstances = newinst;
if(g_selectedInstances.size() > 0) if(g_selectedInstances.size() > 0)
usableApp->_propWindow->SetProperties(newinst.at(0)); usableApp->_propWindow->UpdateSelected(newinst.at(0));
} }
} }
} }
@@ -1380,11 +1380,11 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
} }
} }
if(!found) if(!found)
{while(g_selectedInstances.size() > 0) {
g_selectedInstances.erase(g_selectedInstances.begin()); g_selectedInstances.clear();
g_selectedInstances.push_back(test); g_selectedInstances.push_back(test);
} }
_propWindow->SetProperties(test); _propWindow->UpdateSelected(test);
//message = "Dragging = true."; //message = "Dragging = true.";
//messageTime = System::time(); //messageTime = System::time();
//dragging = true; //dragging = true;
@@ -1394,10 +1394,9 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
} }
if(!objFound) if(!objFound)
{ {
while(g_selectedInstances.size() > 0) g_selectedInstances.clear();
g_selectedInstances.erase(g_selectedInstances.begin());
g_selectedInstances.push_back(dataModel); g_selectedInstances.push_back(dataModel);
_propWindow->SetProperties(dataModel); _propWindow->UpdateSelected(dataModel);
} }
} }