Explorer fixed, and renamed SetProperties()

SetProperties() doesn't describe what it actually does.
Changed to:
UpdateSelected()
This commit is contained in:
MusicalProgrammer
2019-11-02 20:27:18 -04:00
parent bc8742b5f5
commit 55f59e46e0
3 changed files with 46 additions and 69 deletions

View File

@@ -112,19 +112,14 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
// Get and display the text for the list item. // Get and display the text for the list item.
int mul = 0; 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)
if(lpdis->itemID >= 0)
{ {
mul = selectedInstance->listicon; mul = children[lpdis->itemID]->listicon;
} }
else if(lpdis->itemID == 1 && parent != NULL) //else mul = children[lpdis->itemID-1]->listicon;
{
mul = parent->listicon; //mul = children[lpdis->itemID]->listicon;
}
else if(parent != NULL)
{
mul = children[lpdis->itemID-2]->listicon;
}
else mul = children[lpdis->itemID-1]->listicon;
hr = StringCchLength(achTemp, 256, &cch); hr = StringCchLength(achTemp, 256, &cch);
if (FAILED(hr)) if (FAILED(hr))
@@ -181,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->ClearProperties();
while(g_selectedInstances.size() != 0) propWind->UpdateSelected(children.at(ItemIndex));
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;
@@ -222,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;
@@ -236,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());
if(selectedInstance->getParent() != NULL)
{ {
std::string title = ".. ("; std::string title = ".. (";
title += g_selectedInstances[i]->getParent()->name; title += selectedInstance->getParent()->name;
title += ")"; title += ")";
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str()); SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str());
parent = g_selectedInstances[i]->getParent(); parent = selectedInstance->getParent();
children.push_back(selectedInstance->getParent());
} }
children = g_selectedInstances[i]->getChildren(); //children = g_selectedInstances[i]->getChildren();
for(size_t z = 0; z < children.size(); z++)
std::vector<Instance*> selectedChildren = selectedInstance->getChildren();
for(size_t z = 0; z < selectedChildren.size(); z++)
{ {
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)children.at(z)->name.c_str()); 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); 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) {
@@ -341,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;
@@ -364,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();
@@ -380,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

@@ -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);
} }
} }